Skip to content

Commit ff50808

Browse files
Update tests to use Logger instead of debugger
1 parent b4a82d8 commit ff50808

File tree

3 files changed

+22
-21
lines changed

3 files changed

+22
-21
lines changed

spec/bigbluebutton_api_0.81_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
let(:url) { "http://server.com" }
88
let(:secret) { "1234567890abcdefghijkl" }
99
let(:version) { "0.81" }
10-
let(:debug) { false }
11-
let(:api) { BigBlueButton::BigBlueButtonApi.new(url, secret, version, debug) }
10+
let(:api) { BigBlueButton::BigBlueButtonApi.new(url, secret, version) }
1211

1312
describe "#get_default_config_xml" do
1413
let(:response) { "<response><returncode>1</returncode></response>" }

spec/bigbluebutton_api_0.9_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
let(:url) { "http://server.com" }
88
let(:secret) { "1234567890abcdefghijkl" }
99
let(:version) { "0.9" }
10-
let(:debug) { false }
11-
let(:api) { BigBlueButton::BigBlueButtonApi.new(url, secret, version, debug) }
10+
let(:api) { BigBlueButton::BigBlueButtonApi.new(url, secret, version) }
1211

1312
describe "#create_meeting" do
1413
context "accepts the new parameters" do

spec/bigbluebutton_api_spec.rb

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@
99
# default variables and API object for all tests
1010
let(:url) { "http://server.com" }
1111
let(:secret) { "1234567890abcdefghijkl" }
12-
let(:debug) { false }
13-
let(:api) { BigBlueButton::BigBlueButtonApi.new(url, secret, version, debug) }
12+
let(:logger) { Logger.new(STDOUT) }
13+
let(:api) { BigBlueButton::BigBlueButtonApi.new(url, secret, version, logger) }
14+
before { logger.level = Logger::INFO }
1415

1516
describe "#initialize" do
1617
context "standard initialization" do
17-
subject { BigBlueButton::BigBlueButtonApi.new(url, secret, version, debug) }
18+
subject { BigBlueButton::BigBlueButtonApi.new(url, secret, version, logger) }
1819
it { subject.url.should == url }
1920
it { subject.secret.should == secret }
2021
it { subject.version.should == version }
21-
it { subject.debug.should == debug }
22+
it { subject.logger.should == logger }
2223
it { subject.timeout.should == 10 }
2324
it { subject.supported_versions.should include("0.8") }
2425
it { subject.supported_versions.should include("0.81") }
@@ -350,14 +351,14 @@
350351
end
351352

352353
describe "#==" do
353-
let(:api2) { BigBlueButton::BigBlueButtonApi.new(url, secret, version, debug) }
354+
let(:api2) { BigBlueButton::BigBlueButtonApi.new(url, secret, version, logger) }
354355

355356
context "compares attributes" do
356357
it { api.should == api2 }
357358
end
358359

359-
context "differs #debug" do
360-
before { api2.debug = !api.debug }
360+
context "differs #logger" do
361+
before { api2.logger = !api.logger }
361362
it { api.should_not == api2 }
362363
end
363364

@@ -559,17 +560,19 @@
559560
describe "#send_request" do
560561
let(:url) { "http://test-server:8080/res?param1=value1&checksum=12345" }
561562
let(:url_parsed) { URI.parse(url) }
563+
let(:res) { Net::HTTPResponse.new(1.0, '200', 'OK') }
562564

563565
before do
564566
@http_mock = mock(Net::HTTP)
565567
@http_mock.should_receive(:"open_timeout=").with(api.timeout)
566568
@http_mock.should_receive(:"read_timeout=").with(api.timeout)
567569
Net::HTTP.should_receive(:new).with("test-server", 8080).and_return(@http_mock)
570+
res.stub(:body) { "ok" }
568571
end
569572

570573
context "standard case" do
571-
before { @http_mock.should_receive(:get).with("/res?param1=value1&checksum=12345", {}).and_return("ok") }
572-
it { api.send(:send_request, url).should == "ok" }
574+
before { @http_mock.should_receive(:get).with("/res?param1=value1&checksum=12345", {}).and_return(res) }
575+
it { api.send(:send_request, url).should == res }
573576
end
574577

575578
context "handles a TimeoutError" do
@@ -586,20 +589,20 @@
586589
let(:data) { "any data" }
587590
before {
588591
path = "/res?param1=value1&checksum=12345"
589-
opts = { 'Content-Type' => 'application/x-www-form-urlencoded' }
590-
@http_mock.should_receive(:post).with(path, data, opts).and_return("ok")
592+
opts = { 'Content-Type' => 'application/xml' }
593+
@http_mock.should_receive(:post).with(path, data, opts).and_return(res)
591594
}
592595
it {
593-
api.send(:send_request, url, data).should == "ok"
596+
api.send(:send_request, url, data).should == res
594597
}
595598
end
596599

597600
context "get with headers" do
598601
let(:headers_hash) { { :anything => "anything" } }
599-
before { @http_mock.should_receive(:get).with("/res?param1=value1&checksum=12345", headers_hash).and_return("ok") }
602+
before { @http_mock.should_receive(:get).with("/res?param1=value1&checksum=12345", headers_hash).and_return(res) }
600603
it {
601604
api.request_headers = headers_hash
602-
api.send(:send_request, url).should == "ok"
605+
api.send(:send_request, url).should == res
603606
}
604607
end
605608

@@ -608,12 +611,12 @@
608611
let(:data) { "any data" }
609612
before {
610613
path = "/res?param1=value1&checksum=12345"
611-
opts = { 'Content-Type' => 'application/x-www-form-urlencoded', :anything => "anything" }
612-
@http_mock.should_receive(:post).with(path, data, opts).and_return("ok")
614+
opts = { 'Content-Type' => 'application/xml', :anything => "anything" }
615+
@http_mock.should_receive(:post).with(path, data, opts).and_return(res)
613616
}
614617
it {
615618
api.request_headers = headers_hash
616-
api.send(:send_request, url, data).should == "ok"
619+
api.send(:send_request, url, data).should == res
617620
}
618621
end
619622
end

0 commit comments

Comments
 (0)