spec/unit/request_signature_spec.rb in webmock-1.20.3 vs spec/unit/request_signature_spec.rb in webmock-1.20.4
- old
+ new
@@ -3,75 +3,76 @@
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")
+ expect(WebMock::Util::URI).to receive(:normalize_uri).and_return("www.example.kom")
signature = WebMock::RequestSignature.new(:get, "www.example.com")
- signature.uri.should == "www.example.kom"
+ expect(signature.uri).to eq("www.example.kom")
end
it "should have assigned uri without normalization if uri is URI" do
- WebMock::Util::URI.should_not_receive(:normalize_uri)
+ expect(WebMock::Util::URI).not_to receive(:normalize_uri)
uri = Addressable::URI.parse("www.example.com")
signature = WebMock::RequestSignature.new(:get, uri)
- signature.uri.should == uri
+ expect(signature.uri).to eq(uri)
end
it "should have assigned normalized headers" do
- WebMock::Util::Headers.should_receive(:normalize_headers).with('A' => 'a').and_return('B' => 'b')
- WebMock::RequestSignature.new(:get, "www.example.com", :headers => {'A' => 'a'}).headers.should == {'B' => 'b'}
+ expect(WebMock::Util::Headers).to receive(:normalize_headers).with('A' => 'a').and_return('B' => 'b')
+ expect(WebMock::RequestSignature.new(:get, "www.example.com", :headers => {'A' => 'a'}).headers).to eq({'B' => 'b'})
end
it "should have assigned body" do
- WebMock::RequestSignature.new(:get, "www.example.com", :body => "abc").body.should == "abc"
+ expect(WebMock::RequestSignature.new(:get, "www.example.com", :body => "abc").body).to eq("abc")
end
it "should symbolize the method" do
- WebMock::RequestSignature.new('get', "www.example.com", :body => "abc").method.should == :get
+ expect(WebMock::RequestSignature.new('get', "www.example.com", :body => "abc").method).to eq(:get)
end
end
it "should report string describing itself" do
- WebMock::RequestSignature.new(:get, "www.example.com",
- :body => "abc", :headers => {'A' => 'a', 'B' => 'b'}).to_s.should ==
+ expect(WebMock::RequestSignature.new(:get, "www.example.com",
+ :body => "abc", :headers => {'A' => 'a', 'B' => 'b'}).to_s).to eq(
"GET http://www.example.com/ with body 'abc' with headers {'A'=>'a', 'B'=>'b'}"
+ )
end
describe "hash" do
it "should report same hash for two signatures with the same values" do
signature1 = WebMock::RequestSignature.new(:get, "www.example.com",
:body => "abc", :headers => {'A' => 'a', 'B' => 'b'})
signature2 = WebMock::RequestSignature.new(:get, "www.example.com",
:body => "abc", :headers => {'A' => 'a', 'B' => 'b'})
- signature1.hash.should == signature2.hash
+ expect(signature1.hash).to eq(signature2.hash)
end
it "should report different hash for two signatures with different method" do
signature1 = WebMock::RequestSignature.new(:get, "www.example.com")
signature2 = WebMock::RequestSignature.new(:put, "www.example.com")
- signature1.hash.should_not == signature2.hash
+ expect(signature1.hash).not_to eq(signature2.hash)
end
it "should report different hash for two signatures with different uri" do
signature1 = WebMock::RequestSignature.new(:get, "www.example.com")
signature2 = WebMock::RequestSignature.new(:get, "www.example.org")
- signature1.hash.should_not == signature2.hash
+ expect(signature1.hash).not_to eq(signature2.hash)
end
it "should report different hash for two signatures with different body" do
signature1 = WebMock::RequestSignature.new(:get, "www.example.com", :body => "abc")
signature2 = WebMock::RequestSignature.new(:get, "www.example.com", :body => "def")
- signature1.hash.should_not == signature2.hash
+ expect(signature1.hash).not_to eq(signature2.hash)
end
it "should report different hash for two signatures with different headers" do
signature1 = WebMock::RequestSignature.new(:get, "www.example.com",
:headers => {'A' => 'a'})
signature2 = WebMock::RequestSignature.new(:get, "www.example.com",
:headers => {'A' => 'A'})
- signature1.hash.should_not == signature2.hash
+ expect(signature1.hash).not_to eq(signature2.hash)
end
end
[:==, :eql?].each do |method|
@@ -80,36 +81,36 @@
signature1 = WebMock::RequestSignature.new(:get, "www.example.com",
:body => "abc", :headers => {'A' => 'a', 'B' => 'b'})
signature2 = WebMock::RequestSignature.new(:get, "www.example.com",
:body => "abc", :headers => {'A' => 'a', 'B' => 'b'})
- signature1.send(method, signature2).should be_true
+ expect(signature1.send(method, signature2)).to be_truthy
end
it "should be false for two signatures with different method" do
signature1 = WebMock::RequestSignature.new(:get, "www.example.com")
signature2 = WebMock::RequestSignature.new(:put, "www.example.com")
- signature1.send(method, signature2).should be_false
+ expect(signature1.send(method, signature2)).to be_falsey
end
it "should be false for two signatures with different uri" do
signature1 = WebMock::RequestSignature.new(:get, "www.example.com")
signature2 = WebMock::RequestSignature.new(:get, "www.example.org")
- signature1.send(method, signature2).should be_false
+ expect(signature1.send(method, signature2)).to be_falsey
end
it "should be false for two signatures with different body" do
signature1 = WebMock::RequestSignature.new(:get, "www.example.com", :body => "abc")
signature2 = WebMock::RequestSignature.new(:get, "www.example.com", :body => "def")
- signature1.send(method, signature2).should be_false
+ expect(signature1.send(method, signature2)).to be_falsey
end
it "should be false for two signatures with different headers" do
signature1 = WebMock::RequestSignature.new(:get, "www.example.com",
:headers => {'A' => 'a'})
signature2 = WebMock::RequestSignature.new(:get, "www.example.com",
:headers => {'A' => 'A'})
- signature1.send(method, signature2).should be_false
+ expect(signature1.send(method, signature2)).to be_falsey
end
end
end
end