webmock-rspec-helper 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.travis.yml +1 -2
- data/README.md +4 -0
- data/lib/webmock-rspec-helper.rb +4 -1
- data/lib/webmock-rspec-helper/version.rb +1 -1
- data/spec/webmock-rspec-helper_spec.rb +8 -1
- data/webmock-rspec-helper.gemspec +1 -1
- metadata +3 -5
- data/lib/webmock/rspec/helper.rb +0 -9
- data/lib/webmock/rspec/helper/version.rb +0 -7
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YTYxMjlhOWZlYjY5ZjU0ODgwYTM1YTFmMDBiMmJjODhkYmNiNGZmYw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZWUxZGNhMzc5MjRlNWU0YzdkNWMyMGNmODFjNmUzZDU3ODc0MzcyMg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NTlhZDczY2ZjODhiMWU1Y2EwMWIzZDI5YmYxYzI4OTc4NDk3MDRjYjA0OWRh
|
10
|
+
MmJmY2I5NmRkYjI0N2M1YTU1ZTM2YzA5NzAyOTcyYzQ1ZTA1ZjllYWM3YzM4
|
11
|
+
OTJmMWU2MGQzOTc4ZmNhYTAxYmIxZjRjZTEwYWZjYzRjY2Y3YTU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Zjc0YTc3Y2E5ZDk4NTE2MWUwZDJmOTU3N2JmNDAyZTFlYzIzNzMxMTcwYzVi
|
14
|
+
MTYyMzkzODc1NDAzNzcyMTMyODFlZWUyYWZmZGRjYzZiYjFjYjE3MzBiYmQ5
|
15
|
+
MThkNDkxZGRkZThjODZhODIyZWRjYjY1YmExNDBiNzA4MGNhYjY=
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -36,6 +36,10 @@ Will stub requests to Google to return the contents of GET_google.json. Requests
|
|
36
36
|
|
37
37
|
Will stub requests to Google to return the contents of GET_google.401.json. Requests will return a 401 status code.
|
38
38
|
|
39
|
+
Any options that need to go into `with` can be given as the return value of a block passed into `webmock`:
|
40
|
+
|
41
|
+
`webmock(:get, %r[:google.com] => 'GET_google.json') { Hash[query: { test: '123' }] }`
|
42
|
+
|
39
43
|
## Contributing
|
40
44
|
|
41
45
|
1. Fork it ( https://github.com/[my-github-username]/webmock-rspec-helper/fork )
|
data/lib/webmock-rspec-helper.rb
CHANGED
@@ -9,7 +9,10 @@ module WebMock
|
|
9
9
|
mocks.each do |regex, filename|
|
10
10
|
status = filename[/\.(\d+)\./, 1] || 200
|
11
11
|
body = File.read Rails.root.join('spec', 'support', 'stubs', filename)
|
12
|
-
|
12
|
+
|
13
|
+
stub = WebMock.stub_request(method, regex)
|
14
|
+
stub.with(yield) if block_given?
|
15
|
+
stub.to_return status: status.to_i, body: body
|
13
16
|
end
|
14
17
|
end
|
15
18
|
|
@@ -27,9 +27,16 @@ describe '#webmock' do
|
|
27
27
|
expect(response.status).to eq 999
|
28
28
|
expect(response.body['google']).to eq true
|
29
29
|
end
|
30
|
+
|
31
|
+
it 'accepts a block that returns the with options' do
|
32
|
+
webmock(:get, %r[google.com] => 'GET_google.json') { Hash[query: { test: '123' }] }
|
33
|
+
expect { GET('http://google.com') }.to raise_error(WebMock::NetConnectNotAllowedError) rescue nil
|
34
|
+
response = GET('http://google.com?test=123')
|
35
|
+
expect(response.status).to eq 200
|
36
|
+
end
|
30
37
|
end
|
31
38
|
|
32
39
|
def GET(url)
|
33
|
-
response = Net::HTTP.get_response URI.parse(
|
40
|
+
response = Net::HTTP.get_response URI.parse(url)
|
34
41
|
OpenStruct.new status: response.code.to_i, body: JSON.parse(response.body)
|
35
42
|
end
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ['logan.serman@metova.com']
|
11
11
|
spec.summary = 'Easily define WebMock stubs that point to JSON files'
|
12
12
|
spec.description = spec.summary
|
13
|
-
spec.homepage = ''
|
13
|
+
spec.homepage = 'https://github.com/lserman/webmock-rspec-helper'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webmock-rspec-helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Logan Serman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -96,13 +96,11 @@ files:
|
|
96
96
|
- helper.rb
|
97
97
|
- lib/webmock-rspec-helper.rb
|
98
98
|
- lib/webmock-rspec-helper/version.rb
|
99
|
-
- lib/webmock/rspec/helper.rb
|
100
|
-
- lib/webmock/rspec/helper/version.rb
|
101
99
|
- spec/support/stubs/GET_google.999.json
|
102
100
|
- spec/support/stubs/GET_google.json
|
103
101
|
- spec/webmock-rspec-helper_spec.rb
|
104
102
|
- webmock-rspec-helper.gemspec
|
105
|
-
homepage:
|
103
|
+
homepage: https://github.com/lserman/webmock-rspec-helper
|
106
104
|
licenses:
|
107
105
|
- MIT
|
108
106
|
metadata: {}
|
data/lib/webmock/rspec/helper.rb
DELETED