Permalink
Browse files

Added explicit WebMock scope to all constants in WebMock specs and re…

…moved global include WebMock in spec_helper.
  • Loading branch information...
1 parent 7d2f07a commit 4cdf18c91c1ee0d028a0a32b22c994324c3e5c02 @bblimke committed Oct 10, 2010
View
@@ -21,7 +21,7 @@
describe "Curb features" do
before(:each) do
WebMock.disable_net_connect!
- RequestRegistry.instance.reset_webmock
+ WebMock::RequestRegistry.instance.reset_webmock
end
describe "callbacks" do
@@ -1,9 +1,9 @@
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
-describe RequestExecutionVerifier do
+describe WebMock::RequestExecutionVerifier do
before(:each) do
- @verifier = RequestExecutionVerifier.new
- @request_pattern = mock(RequestPattern, :to_s => "www.example.com")
+ @verifier = WebMock::RequestExecutionVerifier.new
+ @request_pattern = mock(WebMock::RequestPattern, :to_s => "www.example.com")
@verifier.request_pattern = @request_pattern
end
@@ -42,14 +42,14 @@
describe "matches?" do
it "should succeed if request was executed expected number of times" do
- RequestRegistry.instance.
+ WebMock::RequestRegistry.instance.
should_receive(:times_executed).with(@request_pattern).and_return(10)
@verifier.expected_times_executed = 10
@verifier.matches?.should be_true
end
it "should fail if request was not executed expected number of times" do
- RequestRegistry.instance.
+ WebMock::RequestRegistry.instance.
should_receive(:times_executed).with(@request_pattern).and_return(10)
@verifier.expected_times_executed = 5
@verifier.matches?.should be_false
@@ -60,26 +60,26 @@
describe "does_not_match?" do
it "should fail if request executed expected number of times" do
- RequestRegistry.instance.
+ WebMock::RequestRegistry.instance.
should_receive(:times_executed).with(@request_pattern).and_return(10)
@verifier.expected_times_executed = 10
@verifier.does_not_match?.should be_false
end
it "should succeed if request was not executed at all and expected number of times was not set" do
- RequestRegistry.instance.
+ WebMock::RequestRegistry.instance.
should_receive(:times_executed).with(@request_pattern).and_return(0)
@verifier.does_not_match?.should be_true
end
it "should fail if request was executed and expected number of times was not set" do
- RequestRegistry.instance.
+ WebMock::RequestRegistry.instance.
should_receive(:times_executed).with(@request_pattern).and_return(1)
@verifier.does_not_match?.should be_false
end
it "should succeed if request was not executed expected number of times" do
- RequestRegistry.instance.
+ WebMock::RequestRegistry.instance.
should_receive(:times_executed).with(@request_pattern).and_return(10)
@verifier.expected_times_executed = 5
@verifier.does_not_match?.should be_true

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -1,47 +1,47 @@
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
-describe RequestRegistry do
+describe WebMock::RequestRegistry do
before(:each) do
- RequestRegistry.instance.reset_webmock
- @request_pattern = RequestPattern.new(:get, "www.example.com")
- @request_signature = RequestSignature.new(:get, "www.example.com")
- @request_stub = RequestStub.new(:get, "www.example.com")
+ WebMock::RequestRegistry.instance.reset_webmock
+ @request_pattern = WebMock::RequestPattern.new(:get, "www.example.com")
+ @request_signature = WebMock::RequestSignature.new(:get, "www.example.com")
+ @request_stub = WebMock::RequestStub.new(:get, "www.example.com")
end
describe "reset_webmock" do
before(:each) do
- RequestRegistry.instance.register_request_stub(@request_stub)
- RequestRegistry.instance.requested_signatures.put(@request_signature)
+ WebMock::RequestRegistry.instance.register_request_stub(@request_stub)
+ WebMock::RequestRegistry.instance.requested_signatures.put(@request_signature)
end
it "should clean request stubs" do
- RequestRegistry.instance.registered_request?(@request_signature).should == @request_stub
- RequestRegistry.instance.reset_webmock
- RequestRegistry.instance.registered_request?(@request_signature).should == nil
+ WebMock::RequestRegistry.instance.registered_request?(@request_signature).should == @request_stub
+ WebMock::RequestRegistry.instance.reset_webmock
+ WebMock::RequestRegistry.instance.registered_request?(@request_signature).should == nil
end
it "should clean list of executed requests" do
- RequestRegistry.instance.times_executed(@request_pattern).should == 1
- RequestRegistry.instance.reset_webmock
- RequestRegistry.instance.times_executed(@request_pattern).should == 0
+ WebMock::RequestRegistry.instance.times_executed(@request_pattern).should == 1
+ WebMock::RequestRegistry.instance.reset_webmock
+ WebMock::RequestRegistry.instance.times_executed(@request_pattern).should == 0
end
end
describe "registering and reporting registered requests" do
it "should return registered stub" do
- RequestRegistry.instance.register_request_stub(@request_stub).should == @request_stub
+ WebMock::RequestRegistry.instance.register_request_stub(@request_stub).should == @request_stub
end
it "should report if request stub is not registered" do
- RequestRegistry.instance.registered_request?(@request_signature).should == nil
+ WebMock::RequestRegistry.instance.registered_request?(@request_signature).should == nil
end
it "should register and report registered stib" do
- RequestRegistry.instance.register_request_stub(@request_stub)
- RequestRegistry.instance.registered_request?(@request_signature).should == @request_stub
+ WebMock::RequestRegistry.instance.register_request_stub(@request_stub)
+ WebMock::RequestRegistry.instance.registered_request?(@request_signature).should == @request_stub
end
@@ -51,40 +51,42 @@
it "should report registered evaluated response for request pattern" do
@request_stub.to_return(:body => "abc")
- RequestRegistry.instance.register_request_stub(@request_stub)
- RequestRegistry.instance.response_for_request(@request_signature).should == Response.new(:body => "abc")
+ WebMock::RequestRegistry.instance.register_request_stub(@request_stub)
+ WebMock::RequestRegistry.instance.response_for_request(@request_signature).
+ should == WebMock::Response.new(:body => "abc")
end
it "should report evaluated response" do
@request_stub.to_return {|request| {:body => request.method.to_s} }
- RequestRegistry.instance.register_request_stub(@request_stub)
- response1 = RequestRegistry.instance.response_for_request(@request_signature)
- response1.should == Response.new(:body => "get")
+ WebMock::RequestRegistry.instance.register_request_stub(@request_stub)
+ response1 = WebMock::RequestRegistry.instance.response_for_request(@request_signature)
+ response1.should == WebMock::Response.new(:body => "get")
end
it "should report clone of theresponse" do
@request_stub.to_return {|request| {:body => request.method.to_s} }
- RequestRegistry.instance.register_request_stub(@request_stub)
- response1 = RequestRegistry.instance.response_for_request(@request_signature)
- response2 = RequestRegistry.instance.response_for_request(@request_signature)
+ WebMock::RequestRegistry.instance.register_request_stub(@request_stub)
+ response1 = WebMock::RequestRegistry.instance.response_for_request(@request_signature)
+ response2 = WebMock::RequestRegistry.instance.response_for_request(@request_signature)
response1.should_not be(response2)
end
it "should report nothing if no response for request is registered" do
- RequestRegistry.instance.response_for_request(@request_signature).should == nil
+ WebMock::RequestRegistry.instance.response_for_request(@request_signature).should == nil
end
it "should always return last registered matching response" do
- @request_stub1 = RequestStub.new(:get, "www.example.com")
+ @request_stub1 = WebMock::RequestStub.new(:get, "www.example.com")
@request_stub1.to_return(:body => "abc")
- @request_stub2 = RequestStub.new(:get, "www.example.com")
+ @request_stub2 = WebMock::RequestStub.new(:get, "www.example.com")
@request_stub2.to_return(:body => "def")
- @request_stub3 = RequestStub.new(:get, "www.example.org")
+ @request_stub3 = WebMock::RequestStub.new(:get, "www.example.org")
@request_stub3.to_return(:body => "ghj")
- RequestRegistry.instance.register_request_stub(@request_stub1)
- RequestRegistry.instance.register_request_stub(@request_stub2)
- RequestRegistry.instance.register_request_stub(@request_stub3)
- RequestRegistry.instance.response_for_request(@request_signature).should == Response.new(:body => "def")
+ WebMock::RequestRegistry.instance.register_request_stub(@request_stub1)
+ WebMock::RequestRegistry.instance.register_request_stub(@request_stub2)
+ WebMock::RequestRegistry.instance.register_request_stub(@request_stub3)
+ WebMock::RequestRegistry.instance.response_for_request(@request_signature).
+ should == WebMock::Response.new(:body => "def")
end
end
@@ -98,24 +100,24 @@ def times_executed(request_pattern)
end
before(:each) do
- @request_stub1 = RequestStub.new(:get, "www.example.com")
- @request_stub2 = RequestStub.new(:get, "www.example.net")
- @request_stub3 = RequestStub.new(:get, "www.example.org")
- RequestRegistry.instance.requested_signatures.put(RequestSignature.new(:get, "www.example.com"))
- RequestRegistry.instance.requested_signatures.put(RequestSignature.new(:get, "www.example.com"))
- RequestRegistry.instance.requested_signatures.put(RequestSignature.new(:get, "www.example.org"))
+ @request_stub1 = WebMock::RequestStub.new(:get, "www.example.com")
+ @request_stub2 = WebMock::RequestStub.new(:get, "www.example.net")
+ @request_stub3 = WebMock::RequestStub.new(:get, "www.example.org")
+ WebMock::RequestRegistry.instance.requested_signatures.put(WebMock::RequestSignature.new(:get, "www.example.com"))
+ WebMock::RequestRegistry.instance.requested_signatures.put(WebMock::RequestSignature.new(:get, "www.example.com"))
+ WebMock::RequestRegistry.instance.requested_signatures.put(WebMock::RequestSignature.new(:get, "www.example.org"))
end
it "should report 0 if no request matching pattern was requested" do
- RequestRegistry.instance.times_executed(RequestPattern.new(:get, "www.example.net")).should == 0
+ WebMock::RequestRegistry.instance.times_executed(WebMock::RequestPattern.new(:get, "www.example.net")).should == 0
end
it "should report number of times matching pattern was requested" do
- RequestRegistry.instance.times_executed(RequestPattern.new(:get, "www.example.com")).should == 2
+ WebMock::RequestRegistry.instance.times_executed(WebMock::RequestPattern.new(:get, "www.example.com")).should == 2
end
it "should report number of times all matching pattern were requested" do
- RequestRegistry.instance.times_executed(RequestPattern.new(:get, /.*example.*/)).should == 3
+ WebMock::RequestRegistry.instance.times_executed(WebMock::RequestPattern.new(:get, /.*example.*/)).should == 3
end
@@ -1,35 +1,35 @@
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
-describe RequestSignature do
+describe WebMock::RequestSignature do
describe "initialization" do
it "should have assigned normalized uri" do
WebMock::Util::URI.should_receive(:normalize_uri).and_return("www.example.kom")
- signature = RequestSignature.new(:get, "www.example.com")
+ signature = WebMock::RequestSignature.new(:get, "www.example.com")
signature.uri.should == "www.example.kom"
end
it "should have assigned uri without normalization if uri is URI" do
WebMock::Util::URI.should_not_receive(:normalize_uri)
uri = Addressable::URI.parse("www.example.com")
- signature = RequestSignature.new(:get, uri)
+ signature = WebMock::RequestSignature.new(:get, uri)
signature.uri.should == uri
end
it "should have assigned normalized headers" do
WebMock::Util::Headers.should_receive(:normalize_headers).with('A' => 'a').and_return('B' => 'b')
- RequestSignature.new(:get, "www.example.com", :headers => {'A' => 'a'}).headers.should == {'B' => 'b'}
+ WebMock::RequestSignature.new(:get, "www.example.com", :headers => {'A' => 'a'}).headers.should == {'B' => 'b'}
end
it "should have assigned body" do
- RequestSignature.new(:get, "www.example.com", :body => "abc").body.should == "abc"
+ WebMock::RequestSignature.new(:get, "www.example.com", :body => "abc").body.should == "abc"
end
end
it "should report string describing itself" do
- RequestSignature.new(:get, "www.example.com",
+ WebMock::RequestSignature.new(:get, "www.example.com",
:body => "abc", :headers => {'A' => 'a', 'B' => 'b'}).to_s.should ==
"GET http://www.example.com/ with body 'abc' with headers {'A'=>'a', 'B'=>'b'}"
end
View
@@ -1,9 +1,9 @@
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
-describe RequestStub do
+describe WebMock::RequestStub do
before(:each) do
- @request_stub = RequestStub.new(:get, "www.example.com")
+ @request_stub = WebMock::RequestStub.new(:get, "www.example.com")
end
it "should have request pattern with method and uri" do
@@ -18,18 +18,18 @@
it "should assign body to request pattern" do
@request_stub.with(:body => "abc")
- @request_stub.request_pattern.to_s.should == RequestPattern.new(:get, "www.example.com", :body => "abc").to_s
+ @request_stub.request_pattern.to_s.should == WebMock::RequestPattern.new(:get, "www.example.com", :body => "abc").to_s
end
it "should assign normalized headers to request pattern" do
@request_stub.with(:headers => {'A' => 'a'})
@request_stub.request_pattern.to_s.should ==
- RequestPattern.new(:get, "www.example.com", :headers => {'A' => 'a'}).to_s
+ WebMock::RequestPattern.new(:get, "www.example.com", :headers => {'A' => 'a'}).to_s
end
it "should assign given block to request profile" do
@request_stub.with { |req| req.body == "abc" }
- @request_stub.request_pattern.matches?(RequestSignature.new(:get, "www.example.com", :body => "abc")).should be_true
+ @request_stub.request_pattern.matches?(WebMock::RequestSignature.new(:get, "www.example.com", :body => "abc")).should be_true
end
end
Oops, something went wrong.

0 comments on commit 4cdf18c

Please sign in to comment.