Skip to content

Commit 1477390

Browse files
committed
chore: update RSpec to 3.13
and update specs syntax (mocks and be_true/be_false)
1 parent 8c36ead commit 1477390

8 files changed

Lines changed: 81 additions & 76 deletions

File tree

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ source 'http://rubygems.org'
33
gemspec
44

55
group :development, :test do
6-
gem 'rspec', '~> 2.10'
6+
gem 'rspec'
77
gem 'forgery'
88
gem 'rake'
99
end

Gemfile.lock

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,23 @@ GEM
99
remote: http://rubygems.org/
1010
specs:
1111
base64 (0.3.0)
12-
diff-lcs (1.1.3)
12+
diff-lcs (1.6.2)
1313
forgery (0.5.0)
1414
rake (12.3.3)
1515
rexml (3.2.5)
16-
rspec (2.10.0)
17-
rspec-core (~> 2.10.0)
18-
rspec-expectations (~> 2.10.0)
19-
rspec-mocks (~> 2.10.0)
20-
rspec-core (2.10.0)
21-
rspec-expectations (2.10.0)
22-
diff-lcs (~> 1.1.3)
23-
rspec-mocks (2.10.0)
16+
rspec (3.13.1)
17+
rspec-core (~> 3.13.0)
18+
rspec-expectations (~> 3.13.0)
19+
rspec-mocks (~> 3.13.0)
20+
rspec-core (3.13.5)
21+
rspec-support (~> 3.13.0)
22+
rspec-expectations (3.13.5)
23+
diff-lcs (>= 1.2.0, < 2.0)
24+
rspec-support (~> 3.13.0)
25+
rspec-mocks (3.13.5)
26+
diff-lcs (>= 1.2.0, < 2.0)
27+
rspec-support (~> 3.13.0)
28+
rspec-support (3.13.5)
2429
xml-simple (1.1.9)
2530
rexml
2631

@@ -31,7 +36,7 @@ DEPENDENCIES
3136
bigbluebutton-api-ruby!
3237
forgery
3338
rake
34-
rspec (~> 2.10)
39+
rspec
3540

3641
BUNDLED WITH
3742
2.6.9

features/step_definitions/check_status_steps.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
When /^the method isMeetingRunning informs that the meeting is running$/ do
22
@req.response = @api.is_meeting_running?(@req.id)
3-
@req.response.should be_true
3+
@req.response.should be true
44
end
55

66
When /^the method isMeetingRunning informs that the meeting is not running$/i do
77
@req.response = @api.is_meeting_running?(@req.id)
8-
@req.response.should be_false
8+
@req.response.should be false
99
end
1010

1111
When /^calling the method get_meetings$/ do
@@ -29,8 +29,8 @@
2929
found[:attendeePW].should be_a(String)
3030
found[:attendeePW].should_not be_empty
3131
found[:moderatorPW].should == @req.mod_pass
32-
found[:hasBeenForciblyEnded].should be_false
33-
found[:running].should be_false
32+
found[:hasBeenForciblyEnded].should be false
33+
found[:running].should be false
3434
if @api.version >= "0.8"
3535
found[:meetingName].should == @req.id
3636
found[:createTime].should be_a(Numeric)
@@ -40,8 +40,8 @@
4040
When /^it shows all the information of the meeting that was created$/ do
4141
@req.response = @api.get_meeting_info(@req.id, @req.mod_pass)
4242
@req.response[:meetingID].should == @req.id
43-
@req.response[:running].should be_false
44-
@req.response[:hasBeenForciblyEnded].should be_false
43+
@req.response[:running].should be false
44+
@req.response[:hasBeenForciblyEnded].should be false
4545
@req.response[:startTime].should be_nil
4646
@req.response[:endTime].should be_nil
4747
@req.response[:participantCount].should == 0
@@ -70,7 +70,7 @@
7070

7171
@req.opts.has_key?(:record) ?
7272
(@req.response[:recording].should == @req.opts[:record]) :
73-
(@req.response[:recording].should be_false)
73+
(@req.response[:recording].should be false)
7474
@req.opts.has_key?(:maxParticipants) ?
7575
(@req.response[:maxUsers].should == @req.opts[:maxParticipants]) :
7676
(@req.response[:maxUsers].should == 20)
@@ -98,9 +98,9 @@
9898
@req.response = @api.get_meeting_info(@req.id, @req.mod_pass)
9999
participants = count.to_i
100100

101-
@req.response[:running].should be_true
101+
@req.response[:running].should be true
102102
@req.response[:moderatorCount].should > 0
103-
@req.response[:hasBeenForciblyEnded].should be_false
103+
@req.response[:hasBeenForciblyEnded].should be false
104104
@req.response[:participantCount].should == participants
105105
@req.response[:attendees].size.should == 2
106106

features/step_definitions/common_steps.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@
5757
end
5858

5959
When /^the response is successful$/ do
60-
@req.response[:returncode].should be_true
60+
@req.response[:returncode].should be true
6161
end
6262

6363
When /^the response is successful with no messages$/ do
64-
@req.response[:returncode].should be_true
64+
@req.response[:returncode].should be true
6565
@req.response[:messageKey].should == ""
6666
@req.response[:message].should == ""
6767
end
@@ -83,9 +83,9 @@
8383
end
8484

8585
When /^the response to the create method is successful and well formatted$/ do
86-
@req.response[:returncode].should be_true
86+
@req.response[:returncode].should be true
8787
@req.response[:meetingID].should == @req.id
88-
@req.response[:hasBeenForciblyEnded].should be_false
88+
@req.response[:hasBeenForciblyEnded].should be false
8989
@req.response[:messageKey].should == ""
9090
@req.response[:message].should == ""
9191

@@ -111,12 +111,12 @@
111111
end
112112

113113
When /^the response to the end method is successful and well formatted$/ do
114-
@req.response[:returncode].should be_true
114+
@req.response[:returncode].should be true
115115
@req.response[:messageKey].should == "sentEndMeetingRequest"
116116
@req.response[:message].should_not be_empty
117117
end
118118

119119
When /^the response to the get_recordings method is successful and well formatted$/ do
120-
@req.response[:returncode].should be_true
120+
@req.response[:returncode].should be true
121121
@req.response[:recordings].should == []
122122
end

features/step_definitions/end_meetings_steps.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@
2424
end
2525

2626
When /^the flag hasBeenForciblyEnded should be set$/ do
27-
@req.response[:hasBeenForciblyEnded].should be_true
27+
@req.response[:hasBeenForciblyEnded].should be true
2828
end
2929

3030
When /^the information returned by get_meeting_info is correct$/ do
3131
# check only what is different in a meeting that WAS ENDED
3232
# the rest is checked in other scenarios
3333

3434
@req.response = @api.get_meeting_info(@req.id, @req.mod_pass)
35-
@req.response[:running].should be_false
36-
@req.response[:hasBeenForciblyEnded].should be_true
35+
@req.response[:running].should be false
36+
@req.response[:hasBeenForciblyEnded].should be true
3737
@req.response[:participantCount].should == 0
3838
@req.response[:moderatorCount].should == 0
3939
@req.response[:attendees].should == []

features/step_definitions/recordings_steps.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
When /^the meeting is set to be recorded$/ do
1313
@req.response = @api.get_meeting_info(@req.id, @req.mod_pass)
14-
@req.response[:returncode].should be_true
15-
@req.response[:recording].should be_true
14+
@req.response[:returncode].should be true
15+
@req.response[:recording].should be true
1616
end
1717

1818
When /^the user creates a meeting without the record flag$/ do
@@ -28,8 +28,8 @@
2828

2929
When /^the meeting is not set to be recorded$/i do
3030
@req.response = @api.get_meeting_info(@req.id, @req.mod_pass)
31-
@req.response[:returncode].should be_true
32-
@req.response[:recording].should be_false
31+
@req.response[:returncode].should be true
32+
@req.response[:recording].should be false
3333
end
3434

3535
When /^the user calls the get_recordings method$/ do

spec/bigbluebutton_api_spec.rb

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,9 @@
302302
before {
303303
api.should_receive(:send_api_request).with(:getMeetings, {}).
304304
and_return(flattened_response)
305-
formatter_mock = mock(BigBlueButton::BigBlueButtonFormatter)
306-
formatter_mock.should_receive(:flatten_objects).with(:meetings, :meeting)
307-
BigBlueButton::BigBlueButtonFormatter.should_receive(:new).and_return(formatter_mock)
305+
formatter_double = double(BigBlueButton::BigBlueButtonFormatter)
306+
formatter_double.should_receive(:flatten_objects).with(:meetings, :meeting)
307+
BigBlueButton::BigBlueButtonFormatter.should_receive(:new).and_return(formatter_double)
308308
BigBlueButton::BigBlueButtonFormatter.should_receive(:format_meeting).with(meeting_hash1)
309309
BigBlueButton::BigBlueButtonFormatter.should_receive(:format_meeting).with(meeting_hash2)
310310
}
@@ -381,27 +381,27 @@
381381
describe "#last_http_response" do
382382
# we test this through a #test_connection call
383383

384-
let(:request_mock) { mock }
384+
let(:request_double) { double }
385385
before {
386386
api.should_receive(:get_url)
387387
# this return value will be stored in @http_response
388-
api.should_receive(:send_request).and_return(request_mock)
388+
api.should_receive(:send_request).and_return(request_double)
389389
# to return fast from #send_api_request
390-
request_mock.should_receive(:body).and_return("")
390+
request_double.should_receive(:body).and_return("")
391391
api.test_connection
392392
}
393-
it { api.last_http_response.should == request_mock }
393+
it { api.last_http_response.should == request_double }
394394
end
395395

396396
describe "#last_xml_response" do
397397
# we test this through a #test_connection call
398398

399-
let(:request_mock) { mock }
399+
let(:request_double) { double }
400400
let(:expected_xml) { "<response><returncode>SUCCESS</returncode></response>" }
401401
before {
402402
api.should_receive(:get_url)
403-
api.should_receive(:send_request).and_return(request_mock)
404-
request_mock.should_receive(:body).at_least(1).and_return(expected_xml)
403+
api.should_receive(:send_request).and_return(request_double)
404+
request_double.should_receive(:body).at_least(1).and_return(expected_xml)
405405
api.test_connection
406406
}
407407
it { api.last_xml_response.should == expected_xml }
@@ -503,22 +503,22 @@
503503
let(:data) { "any data" }
504504
let(:url) { "http://test-server:8080?param1=value1&checksum=12345" }
505505
let(:make_request) { api.send_api_request(method, params, data) }
506-
let(:response_mock) { mock() } # mock of what send_request() would return
506+
let(:response_double) { double() } # mock of what send_request() would return
507507

508508
before { api.should_receive(:get_url).with(method, params).and_return([url, nil]) }
509509

510510
context "returns an empty hash if the response body is empty" do
511511
before do
512-
api.should_receive(:send_request).with(url, data).and_return(response_mock)
513-
response_mock.should_receive(:body).and_return("")
512+
api.should_receive(:send_request).with(url, data).and_return(response_double)
513+
response_double.should_receive(:body).and_return("")
514514
end
515515
it { make_request.should == { } }
516516
end
517517

518518
context "hashfies and validates the response body" do
519519
before do
520-
api.should_receive(:send_request).with(url, data).and_return(response_mock)
521-
response_mock.should_receive(:body).twice.and_return("response-body")
520+
api.should_receive(:send_request).with(url, data).and_return(response_double)
521+
response_double.should_receive(:body).twice.and_return("response-body")
522522
end
523523

524524
context "checking if it has a :response key" do
@@ -536,15 +536,15 @@
536536
let(:response) { { :returncode => "SUCCESS" } }
537537
let(:formatted_response) { { :returncode => true, :messageKey => "", :message => "" } }
538538
before do
539-
api.should_receive(:send_request).with(url, data).and_return(response_mock)
540-
response_mock.should_receive(:body).twice.and_return("response-body")
539+
api.should_receive(:send_request).with(url, data).and_return(response_double)
540+
response_double.should_receive(:body).twice.and_return("response-body")
541541
BigBlueButton::BigBlueButtonHash.should_receive(:from_xml).with("response-body").and_return(response)
542542

543543
# here starts the validation
544544
# doesn't test the resulting format, only that the formatter was called
545-
formatter_mock = mock(BigBlueButton::BigBlueButtonFormatter)
546-
BigBlueButton::BigBlueButtonFormatter.should_receive(:new).with(response).and_return(formatter_mock)
547-
formatter_mock.should_receive(:default_formatting).and_return(formatted_response)
545+
formatter_double = double(BigBlueButton::BigBlueButtonFormatter)
546+
BigBlueButton::BigBlueButtonFormatter.should_receive(:new).with(response).and_return(formatter_double)
547+
formatter_double.should_receive(:default_formatting).and_return(formatted_response)
548548
end
549549
it { make_request }
550550
end
@@ -553,13 +553,13 @@
553553
let(:response) { { :returncode => true } }
554554
let(:formatted_response) { { } }
555555
before do
556-
api.should_receive(:send_request).with(url, data).and_return(response_mock)
557-
response_mock.should_receive(:body).twice.and_return("response-body")
556+
api.should_receive(:send_request).with(url, data).and_return(response_double)
557+
response_double.should_receive(:body).twice.and_return("response-body")
558558
BigBlueButton::BigBlueButtonHash.should_receive(:from_xml).with("response-body").and_return(response)
559559

560-
formatter_mock = mock(BigBlueButton::BigBlueButtonFormatter)
561-
BigBlueButton::BigBlueButtonFormatter.should_receive(:new).with(response).and_return(formatter_mock)
562-
formatter_mock.should_receive(:default_formatting).and_return(formatted_response)
560+
formatter_double = double(BigBlueButton::BigBlueButtonFormatter)
561+
BigBlueButton::BigBlueButtonFormatter.should_receive(:new).with(response).and_return(formatter_double)
562+
formatter_double.should_receive(:default_formatting).and_return(formatted_response)
563563
end
564564
it { expect { make_request }.to raise_error(BigBlueButton::BigBlueButtonException) }
565565
end
@@ -571,25 +571,25 @@
571571
let(:res) { Net::HTTPResponse.new(1.0, '200', 'OK') }
572572

573573
before do
574-
@http_mock = mock(Net::HTTP)
575-
@http_mock.should_receive(:"open_timeout=").with(api.timeout)
576-
@http_mock.should_receive(:"read_timeout=").with(api.timeout)
577-
Net::HTTP.should_receive(:new).with("test-server", 8080).and_return(@http_mock)
574+
@http_double = double(Net::HTTP)
575+
@http_double.should_receive(:"open_timeout=").with(api.timeout)
576+
@http_double.should_receive(:"read_timeout=").with(api.timeout)
577+
Net::HTTP.should_receive(:new).with("test-server", 8080).and_return(@http_double)
578578
res.stub(:body) { "ok" }
579579
end
580580

581581
context "standard case" do
582-
before { @http_mock.should_receive(:get).with("/res?param1=value1&checksum=12345", {}).and_return(res) }
582+
before { @http_double.should_receive(:get).with("/res?param1=value1&checksum=12345", {}).and_return(res) }
583583
it { api.send(:send_request, url).should == res }
584584
end
585585

586586
context "handles a TimeoutError" do
587-
before { @http_mock.should_receive(:get) { raise TimeoutError } }
587+
before { @http_double.should_receive(:get) { raise TimeoutError } }
588588
it { expect { api.send(:send_request, url) }.to raise_error(BigBlueButton::BigBlueButtonException) }
589589
end
590590

591591
context "handles general Exceptions" do
592-
before { @http_mock.should_receive(:get) { raise Exception } }
592+
before { @http_double.should_receive(:get) { raise Exception } }
593593
it { expect { api.send(:send_request, url) }.to raise_error(BigBlueButton::BigBlueButtonException) }
594594
end
595595

@@ -598,7 +598,7 @@
598598
before {
599599
path = "/res?param1=value1&checksum=12345"
600600
opts = { 'Content-Type' => 'application/xml' }
601-
@http_mock.should_receive(:post).with(path, data, opts).and_return(res)
601+
@http_double.should_receive(:post).with(path, data, opts).and_return(res)
602602
}
603603
it {
604604
api.send(:send_request, url, data).should == res
@@ -607,7 +607,7 @@
607607

608608
context "get with headers" do
609609
let(:headers_hash) { { :anything => "anything" } }
610-
before { @http_mock.should_receive(:get).with("/res?param1=value1&checksum=12345", headers_hash).and_return(res) }
610+
before { @http_double.should_receive(:get).with("/res?param1=value1&checksum=12345", headers_hash).and_return(res) }
611611
it {
612612
api.request_headers = headers_hash
613613
api.send(:send_request, url).should == res
@@ -620,7 +620,7 @@
620620
before {
621621
path = "/res?param1=value1&checksum=12345"
622622
opts = { 'Content-Type' => 'application/xml', :anything => "anything" }
623-
@http_mock.should_receive(:post).with(path, data, opts).and_return(res)
623+
@http_double.should_receive(:post).with(path, data, opts).and_return(res)
624624
}
625625
it {
626626
api.request_headers = headers_hash
@@ -685,11 +685,11 @@
685685
context "formats the response" do
686686
before {
687687
api.should_receive(:send_api_request).with(:getRecordings, anything).and_return(flattened_response)
688-
formatter_mock = mock(BigBlueButton::BigBlueButtonFormatter)
689-
formatter_mock.should_receive(:flatten_objects).with(:recordings, :recording)
688+
formatter_double = double(BigBlueButton::BigBlueButtonFormatter)
689+
formatter_double.should_receive(:flatten_objects).with(:recordings, :recording)
690690
BigBlueButton::BigBlueButtonFormatter.should_receive(:format_recording).with(recording1)
691691
BigBlueButton::BigBlueButtonFormatter.should_receive(:format_recording).with(recording2)
692-
BigBlueButton::BigBlueButtonFormatter.should_receive(:new).and_return(formatter_mock)
692+
BigBlueButton::BigBlueButtonFormatter.should_receive(:new).and_return(formatter_double)
693693
}
694694
it { api.get_recordings }
695695
end

0 commit comments

Comments
 (0)