puffing-billy 2.3.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +98 -97
- data/lib/billy/version.rb +1 -1
- data/puffing-billy.gemspec +1 -1
- data/spec/lib/proxy_spec.rb +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88b7f294336c78d57a65c5145d0d8b55a2d1bbdf0c52742b1b57b73a90e8f0dd
|
4
|
+
data.tar.gz: f7ec6e75042f4260026478db19026f03a3c145579496f97aa76fce3eaa726cd5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a094a3f80d81392fcd400b64bd70490f2fafc207ec925c23ab00a9c3184890dc113a5423609cf867c96a1416232c651710507526dfb94a4e7d13f7bd800c90e
|
7
|
+
data.tar.gz: 8a7d6b8a64c48d40200b9f15196bf4a2ef5be6736f9a4bad0780c731d56905e7f4eead8d640161a1cc999a4b339b0e51697f79a06e533af602a35d782ba24a9a
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
v2.3.1, 2020-03-19
|
2
|
+
-------------------
|
3
|
+
* Update min 'faraday' gem version required [#285](https://github.com/oesmith/puffing-billy/pull/285)
|
4
|
+
|
1
5
|
v2.3.0, 2019-12-26
|
2
6
|
-------------------
|
3
7
|
* Add `cache_whitelist` config option [#279](https://github.com/oesmith/puffing-billy/pull/279)
|
data/README.md
CHANGED
@@ -14,9 +14,9 @@ Billy spawns an EventMachine-based proxy server, which it uses to intercept
|
|
14
14
|
requests sent by your browser. It has a simple API for configuring which
|
15
15
|
requests need stubbing and what they should return.
|
16
16
|
|
17
|
-
Billy lets you test against known, repeatable data.
|
17
|
+
Billy lets you test against known, repeatable data. It also allows you to
|
18
18
|
test for failure cases. Does your twitter (or facebook/google/etc)
|
19
|
-
integration degrade gracefully when the API starts returning 500s?
|
19
|
+
integration degrade gracefully when the API starts returning 500s? Well now
|
20
20
|
you can test it!
|
21
21
|
|
22
22
|
```ruby
|
@@ -32,21 +32,25 @@ You can also record HTTP interactions and replay them later. See
|
|
32
32
|
|
33
33
|
## Installation
|
34
34
|
|
35
|
-
Add this line to your application's Gemfile
|
35
|
+
Add this line to your application's `Gemfile`:
|
36
36
|
|
37
|
-
|
37
|
+
```ruby
|
38
|
+
gem 'puffing-billy', group: :test
|
39
|
+
```
|
38
40
|
|
39
41
|
And then execute:
|
40
42
|
|
41
|
-
|
43
|
+
```sh
|
44
|
+
$ bundle
|
45
|
+
```
|
42
46
|
|
43
47
|
Or install it yourself as:
|
44
48
|
|
45
|
-
|
46
|
-
|
47
|
-
|
49
|
+
```sh
|
50
|
+
$ gem install puffing-billy
|
51
|
+
```
|
48
52
|
|
49
|
-
|
53
|
+
## Setup for Capybara
|
50
54
|
|
51
55
|
In your `rails_helper.rb`:
|
52
56
|
|
@@ -68,7 +72,7 @@ Capybara.javascript_driver = :selenium_billy # Uses Firefox
|
|
68
72
|
headless specs when using puffing-billy for other local rack apps.
|
69
73
|
See [this phantomjs issue](https://github.com/ariya/phantomjs/issues/11342) for any updates.
|
70
74
|
|
71
|
-
|
75
|
+
## Setup for Watir
|
72
76
|
|
73
77
|
In your `rails_helper.rb`:
|
74
78
|
|
@@ -81,7 +85,82 @@ require 'billy/watir/rspec'
|
|
81
85
|
# @browser = Billy::Browsers::Watir.new = :phantomjs
|
82
86
|
```
|
83
87
|
|
84
|
-
|
88
|
+
## Setup for Cucumber
|
89
|
+
|
90
|
+
An example feature:
|
91
|
+
|
92
|
+
```
|
93
|
+
Feature: Stubbing via billy
|
94
|
+
|
95
|
+
@javascript @billy
|
96
|
+
Scenario: Test billy
|
97
|
+
And a stub for google
|
98
|
+
```
|
99
|
+
|
100
|
+
### Setup for Cucumber + Capybara
|
101
|
+
|
102
|
+
In your `features/support/env.rb`:
|
103
|
+
|
104
|
+
```ruby
|
105
|
+
require 'billy/capybara/cucumber'
|
106
|
+
|
107
|
+
After do
|
108
|
+
Capybara.use_default_driver
|
109
|
+
end
|
110
|
+
```
|
111
|
+
|
112
|
+
And in steps:
|
113
|
+
|
114
|
+
```ruby
|
115
|
+
Before('@billy') do
|
116
|
+
Capybara.current_driver = :poltergeist_billy
|
117
|
+
end
|
118
|
+
|
119
|
+
And /^a stub for google$/ do
|
120
|
+
proxy.stub('http://www.google.com/').and_return(text: "I'm not Google!")
|
121
|
+
visit 'http://www.google.com/'
|
122
|
+
expect(page).to have_content("I'm not Google!")
|
123
|
+
end
|
124
|
+
```
|
125
|
+
|
126
|
+
It's good practice to reset the driver after each scenario, so having an
|
127
|
+
`@billy` tag switches the drivers on for a given scenario. Also note that
|
128
|
+
stubs are reset after each step, so any usage of a stub should be in the
|
129
|
+
same step that it was created in.
|
130
|
+
|
131
|
+
### Setup for Cucumber + Watir
|
132
|
+
|
133
|
+
In your `features/support/env.rb`:
|
134
|
+
|
135
|
+
```ruby
|
136
|
+
require 'billy/watir/cucumber'
|
137
|
+
|
138
|
+
After do
|
139
|
+
@browser.close
|
140
|
+
end
|
141
|
+
```
|
142
|
+
|
143
|
+
And in steps:
|
144
|
+
|
145
|
+
```ruby
|
146
|
+
Before('@billy') do
|
147
|
+
@browser = Billy::Browsers::Watir.new :firefox
|
148
|
+
end
|
149
|
+
|
150
|
+
And /^a stub for google$/ do
|
151
|
+
proxy.stub('http://www.google.com/').and_return(text: "I'm not Google!")
|
152
|
+
@browser.goto 'http://www.google.com/'
|
153
|
+
expect(@browser.text).to eq("I'm not Google!")
|
154
|
+
end
|
155
|
+
```
|
156
|
+
|
157
|
+
## Minitest Usage
|
158
|
+
|
159
|
+
Please see [this link](https://gist.github.com/sauy7/1b081266dd453a1b737b) for
|
160
|
+
details and report back to [Issue #49](https://github.com/oesmith/puffing-billy/issues/49)
|
161
|
+
if you get it fully working.
|
162
|
+
|
163
|
+
## Examples
|
85
164
|
|
86
165
|
```ruby
|
87
166
|
# Stub and return text, json, jsonp (or anything else)
|
@@ -161,81 +240,6 @@ proxy.unstub example_stub
|
|
161
240
|
proxy.reset
|
162
241
|
```
|
163
242
|
|
164
|
-
## Cucumber Usage
|
165
|
-
|
166
|
-
An example feature:
|
167
|
-
|
168
|
-
```
|
169
|
-
Feature: Stubbing via billy
|
170
|
-
|
171
|
-
@javascript @billy
|
172
|
-
Scenario: Test billy
|
173
|
-
And a stub for google
|
174
|
-
```
|
175
|
-
|
176
|
-
### Capybara
|
177
|
-
|
178
|
-
In your `features/support/env.rb`:
|
179
|
-
|
180
|
-
```ruby
|
181
|
-
require 'billy/capybara/cucumber'
|
182
|
-
|
183
|
-
After do
|
184
|
-
Capybara.use_default_driver
|
185
|
-
end
|
186
|
-
```
|
187
|
-
|
188
|
-
And in steps:
|
189
|
-
|
190
|
-
```ruby
|
191
|
-
Before('@billy') do
|
192
|
-
Capybara.current_driver = :poltergeist_billy
|
193
|
-
end
|
194
|
-
|
195
|
-
And /^a stub for google$/ do
|
196
|
-
proxy.stub('http://www.google.com/').and_return(text: "I'm not Google!")
|
197
|
-
visit 'http://www.google.com/'
|
198
|
-
expect(page).to have_content("I'm not Google!")
|
199
|
-
end
|
200
|
-
```
|
201
|
-
|
202
|
-
It's good practice to reset the driver after each scenario, so having an
|
203
|
-
`@billy` tag switches the drivers on for a given scenario. Also note that
|
204
|
-
stubs are reset after each step, so any usage of a stub should be in the
|
205
|
-
same step that it was created in.
|
206
|
-
|
207
|
-
### Watir
|
208
|
-
|
209
|
-
In your `features/support/env.rb`:
|
210
|
-
|
211
|
-
```ruby
|
212
|
-
require 'billy/watir/cucumber'
|
213
|
-
|
214
|
-
After do
|
215
|
-
@browser.close
|
216
|
-
end
|
217
|
-
```
|
218
|
-
|
219
|
-
And in steps:
|
220
|
-
|
221
|
-
```ruby
|
222
|
-
Before('@billy') do
|
223
|
-
@browser = Billy::Browsers::Watir.new :firefox
|
224
|
-
end
|
225
|
-
|
226
|
-
And /^a stub for google$/ do
|
227
|
-
proxy.stub('http://www.google.com/').and_return(text: "I'm not Google!")
|
228
|
-
@browser.goto 'http://www.google.com/'
|
229
|
-
expect(@browser.text).to eq("I'm not Google!")
|
230
|
-
end
|
231
|
-
```
|
232
|
-
|
233
|
-
## Minitest Usage
|
234
|
-
|
235
|
-
Please see [this link](https://gist.github.com/sauy7/1b081266dd453a1b737b) for
|
236
|
-
details and report back to [Issue #49](https://github.com/oesmith/puffing-billy/issues/49)
|
237
|
-
if you get it fully working.
|
238
|
-
|
239
243
|
## Caching
|
240
244
|
|
241
245
|
Requests routed through the external proxy are cached.
|
@@ -539,7 +543,8 @@ end
|
|
539
543
|
If you want the cache for each test to be independent, i.e. have it's own directory where the cache files are stored, you can do so.
|
540
544
|
|
541
545
|
### in Cucumber
|
542
|
-
|
546
|
+
|
547
|
+
use a `Before` tag:
|
543
548
|
```rb
|
544
549
|
Before('@javascript') do |scenario, block|
|
545
550
|
Billy.configure do |c|
|
@@ -552,7 +557,9 @@ end
|
|
552
557
|
```
|
553
558
|
|
554
559
|
### in Rspec
|
555
|
-
|
560
|
+
|
561
|
+
use a `before(:each)` block:
|
562
|
+
|
556
563
|
```rb
|
557
564
|
RSpec.configure do |config|
|
558
565
|
base_cache_path = Billy.config.cache_path
|
@@ -573,7 +580,6 @@ RSpec.configure do |config|
|
|
573
580
|
end
|
574
581
|
```
|
575
582
|
|
576
|
-
|
577
583
|
## Stub requests recording
|
578
584
|
|
579
585
|
If you want to record requests to stubbed URIs, set the following configuration option:
|
@@ -617,6 +623,7 @@ and tell it to ignore SSL certificate warnings. See
|
|
617
623
|
to see how Billy's default drivers are configured.
|
618
624
|
|
619
625
|
## Working with VCR and Webmock
|
626
|
+
|
620
627
|
If you use VCR and Webmock elsewhere in your specs, you may need to disable them
|
621
628
|
for your specs utilizing Puffing Billy. To do so, you can configure your `rails_helper.rb`
|
622
629
|
as shown below:
|
@@ -646,7 +653,7 @@ Note that this approach may cause unexpected behavior if your backend sends the
|
|
646
653
|
|
647
654
|
### Raising errors from stubs
|
648
655
|
|
649
|
-
By default
|
656
|
+
By default Puffing Billy suppresses errors from stub-blocks.
|
650
657
|
To make it raise errors instead, add this test initializers:
|
651
658
|
|
652
659
|
```ruby
|
@@ -739,12 +746,6 @@ custom on-after hook.
|
|
739
746
|
* [Integration Testing Stripe.js With Mocked Network Requests](http://dev.contractual.ly/testing-stripe-js-with-mocked-network/)
|
740
747
|
* [Clean-up unused cache files periodically with this config](https://github.com/oesmith/puffing-billy/pull/26#issuecomment-29905030)
|
741
748
|
|
742
|
-
## FAQ
|
743
|
-
|
744
|
-
1. Why name it after a train?
|
745
|
-
|
746
|
-
Trains are *cool*.
|
747
|
-
|
748
749
|
## Contributing
|
749
750
|
|
750
751
|
1. Fork it
|
@@ -755,5 +756,5 @@ custom on-after hook.
|
|
755
756
|
|
756
757
|
## TODO
|
757
758
|
|
758
|
-
1. Integration for test frameworks other than
|
759
|
+
1. Integration for test frameworks other than RSpec.
|
759
760
|
2. Show errors from the EventMachine reactor loop in the test output.
|
data/lib/billy/version.rb
CHANGED
data/puffing-billy.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
|
18
18
|
gem.add_development_dependency 'rspec'
|
19
19
|
gem.add_development_dependency 'thin'
|
20
|
-
gem.add_development_dependency 'faraday'
|
20
|
+
gem.add_development_dependency 'faraday', '>= 0.9.0'
|
21
21
|
gem.add_development_dependency 'apparition'
|
22
22
|
gem.add_development_dependency 'capybara'
|
23
23
|
gem.add_development_dependency 'selenium-webdriver'
|
data/spec/lib/proxy_spec.rb
CHANGED
@@ -255,7 +255,7 @@ shared_examples_for 'a cache' do
|
|
255
255
|
|
256
256
|
it 'should raise error when disabled' do
|
257
257
|
# TODO: Suppress stderr output: https://gist.github.com/adamstegman/926858
|
258
|
-
expect { http.get('/foo') }.to raise_error(Faraday::
|
258
|
+
expect { http.get('/foo') }.to raise_error(Faraday::ConnectionFailed, 'end of file reached')
|
259
259
|
end
|
260
260
|
end
|
261
261
|
|
@@ -284,7 +284,7 @@ shared_examples_for 'a cache' do
|
|
284
284
|
end
|
285
285
|
|
286
286
|
it 'should raise error for non-successful responses when :error' do
|
287
|
-
expect { http_error.get('/foo') }.to raise_error(Faraday::
|
287
|
+
expect { http_error.get('/foo') }.to raise_error(Faraday::ConnectionFailed)
|
288
288
|
end
|
289
289
|
end
|
290
290
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puffing-billy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Olly Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 0.9.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 0.9.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: apparition
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|