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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NzFlOWQ2MWUyMGNlMjY1ZDliOTgyZGU2OTk4OGQwYWE2N2Y5Yzk1Yg==
4
+ YTYxMjlhOWZlYjY5ZjU0ODgwYTM1YTFmMDBiMmJjODhkYmNiNGZmYw==
5
5
  data.tar.gz: !binary |-
6
- YWM1YzEwNzE3NGI2MzljN2MwZWQ3YzRmMzdhMTdhMmY5YzBhZTc2MA==
6
+ ZWUxZGNhMzc5MjRlNWU0YzdkNWMyMGNmODFjNmUzZDU3ODc0MzcyMg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NjYyNjgzNmIwNzE5NGI5YzVmZjA3NWQ5YWE4Y2U0NDBlYzA0ZWJhMTc2NmZl
10
- YTNhZDQ5MmFlMmExMjAxMWEwYWM0NTlhNWQ5OTk3ODg3OTM5OTBkNGQ5NTA5
11
- MTVkY2QyMDY1MmZkZGJmM2MwMDRkZmNkN2ViY2I5NmU5M2M1NTU=
9
+ NTlhZDczY2ZjODhiMWU1Y2EwMWIzZDI5YmYxYzI4OTc4NDk3MDRjYjA0OWRh
10
+ MmJmY2I5NmRkYjI0N2M1YTU1ZTM2YzA5NzAyOTcyYzQ1ZTA1ZjllYWM3YzM4
11
+ OTJmMWU2MGQzOTc4ZmNhYTAxYmIxZjRjZTEwYWZjYzRjY2Y3YTU=
12
12
  data.tar.gz: !binary |-
13
- OGUyOTBlM2Y0NjY0Njc5OTE0YWY0YjgyMGUyNTQzMzA2ZWE1YTkyODBkNTY4
14
- NjA2NjBjNjEzODI5NmE1NmE1M2E5ZDE5ZWNlZTlkYjQ1OWMxMTE3M2I1OGU2
15
- ZDhkMmYwZmJkMGM1N2NjODc3MzJhNjY5MjEwZDQ4OTBhMWMzODI=
13
+ Zjc0YTc3Y2E5ZDk4NTE2MWUwZDJmOTU3N2JmNDAyZTFlYzIzNzMxMTcwYzVi
14
+ MTYyMzkzODc1NDAzNzcyMTMyODFlZWUyYWZmZGRjYzZiYjFjYjE3MzBiYmQ5
15
+ MThkNDkxZGRkZThjODZhODIyZWRjYjY1YmExNDBiNzA4MGNhYjY=
@@ -1,8 +1,7 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  rvm:
4
- - 2.0.0
5
- - 2.1.0
4
+ - 2.0.0
6
5
  deploy:
7
6
  provider: rubygems
8
7
  gem:
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 )
@@ -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
- WebMock.stub_request(method, regex).to_return status: status.to_i, body: body
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
 
@@ -1,7 +1,7 @@
1
1
  module WebMock
2
2
  module RSpec
3
3
  module Helper
4
- VERSION = '0.0.1'
4
+ VERSION = '0.0.3'
5
5
  end
6
6
  end
7
7
  end
@@ -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('http://google.com')
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.1
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-09 00:00:00.000000000 Z
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: {}
@@ -1,9 +0,0 @@
1
- require "webmock/rspec/helper/version"
2
-
3
- module Webmock
4
- module Rspec
5
- module Helper
6
- # Your code goes here...
7
- end
8
- end
9
- end
@@ -1,7 +0,0 @@
1
- module Webmock
2
- module Rspec
3
- module Helper
4
- VERSION = "0.0.1"
5
- end
6
- end
7
- end