Permalink
Browse files

Updated to Crystal > 0.15.0

  • Loading branch information...
1 parent f09470f commit 46fa261a6c0ad05dc0e3d5adbab46224c056f1d6 @asterite asterite committed Apr 12, 2016
Showing with 20 additions and 17 deletions.
  1. +1 −1 shard.yml
  2. +14 −14 spec/webmock_spec.cr
  3. +5 −2 src/webmock/stub.cr
View
@@ -1,5 +1,5 @@
name: webmock
-version: 0.6.0
+version: 0.7.0
authors:
- Ary Borenszweig <aborenszweig@manas.com.ar>
View
@@ -221,7 +221,7 @@ describe WebMock do
it "matches with query string in with" do
WebMock.wrap do
- WebMock.stub(:get, "http://www.example.com").with(query: {"a": 1, "b": 2})
+ WebMock.stub(:get, "http://www.example.com").with(query: {"a": "1", "b": "2"})
response = HTTP::Client.get "http://www.example.com?b=2&a=1"
response.body.should eq("")
@@ -233,16 +233,16 @@ describe WebMock do
begin
HTTP::Client.post("http://www.example.com/foo?a=1", body: "Hello!", headers: HTTP::Headers{"Foo": "Bar"})
rescue ex : WebMock::NetConnectNotAllowedError
- ex.message.strip.should eq(
+ ex.message.not_nil!.strip.should eq(
<<-MSG
-Real HTTP connections are disabled. Unregistered request: POST http://www.example.com with body "Hello!" with headers {"Foo" => "Bar", "Host" => "www.example.com", "Content-Length" => "6"}
+ Real HTTP connections are disabled. Unregistered request: POST http://www.example.com with body "Hello!" with headers {"Foo" => "Bar", "Host" => "www.example.com", "Content-Length" => "6"}
-You can stub this request with the following snippet:
+ You can stub this request with the following snippet:
-WebMock.stub(:post, "www.example.com/foo?a=1").
- with(body: "Hello!", headers: {"Foo" => "Bar"}).
- to_return(body: "")
-MSG
+ WebMock.stub(:post, "www.example.com/foo?a=1").
+ with(body: "Hello!", headers: {"Foo" => "Bar"}).
+ to_return(body: "")
+ MSG
)
end
end
@@ -253,15 +253,15 @@ MSG
begin
HTTP::Client.post("http://www.example.com/foo?a=1")
rescue ex : WebMock::NetConnectNotAllowedError
- ex.message.strip.should eq(
+ ex.message.not_nil!.strip.should eq(
<<-MSG
-Real HTTP connections are disabled. Unregistered request: POST http://www.example.com with headers {"Host" => "www.example.com", "Content-Length" => "0"}
+ Real HTTP connections are disabled. Unregistered request: POST http://www.example.com with headers {"Host" => "www.example.com", "Content-Length" => "0"}
-You can stub this request with the following snippet:
+ You can stub this request with the following snippet:
-WebMock.stub(:post, "www.example.com/foo?a=1").
- to_return(body: "")
-MSG
+ WebMock.stub(:post, "www.example.com/foo?a=1").
+ to_return(body: "")
+ MSG
)
end
end
View
@@ -1,5 +1,8 @@
class WebMock::Stub
- def initialize(@method, uri)
+ @uri : URI
+ @expected_headers : HTTP::Headers?
+
+ def initialize(@method : Symbol, uri)
@uri = parse_uri(uri)
# For to_return
@@ -8,7 +11,7 @@ class WebMock::Stub
@headers = HTTP::Headers{"Content-length": "0"}
end
- def with(query = nil, body = nil, headers = nil)
+ def with(query : Hash(String, String) = nil, body : String = nil, headers = nil)
@expected_query = query
@expected_body = body
@expected_headers = HTTP::Headers.new.merge!(headers) if headers

0 comments on commit 46fa261

Please sign in to comment.