puffing-billy 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +2 -1
- data/README.md +13 -5
- data/lib/billy/rspec.rb +33 -28
- data/lib/billy/version.rb +1 -1
- data/puffing-billy.gemspec +2 -1
- data/spec/spec_helper.rb +0 -2
- metadata +29 -13
data/Gemfile.lock
CHANGED
@@ -2,10 +2,12 @@ PATH
|
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
4
|
puffing-billy (0.1.1)
|
5
|
+
capybara
|
5
6
|
em-http-request
|
6
7
|
eventmachine
|
7
8
|
eventmachine_httpserver
|
8
9
|
http_parser.rb
|
10
|
+
rspec
|
9
11
|
yajl-ruby
|
10
12
|
|
11
13
|
GEM
|
@@ -85,7 +87,6 @@ PLATFORMS
|
|
85
87
|
ruby
|
86
88
|
|
87
89
|
DEPENDENCIES
|
88
|
-
capybara
|
89
90
|
capybara-webkit
|
90
91
|
faraday
|
91
92
|
poltergeist
|
data/README.md
CHANGED
@@ -1,15 +1,23 @@
|
|
1
1
|
# Puffing Billy
|
2
2
|
|
3
|
-
A
|
4
|
-
|
3
|
+
A rewriting web proxy for testing interactions between your browser and
|
4
|
+
external sites. Works with ruby + rspec.
|
5
|
+
|
6
|
+
Puffing Billy is like [webmock](https://github.com/bblimke/webmock), but for
|
7
|
+
your browser.
|
5
8
|
|
6
9
|
![](http://upload.wikimedia.org/wikipedia/commons/0/01/Puffing_Billy_1862.jpg)
|
7
10
|
|
8
11
|
## Overview
|
9
12
|
|
10
13
|
Billy spawns an EventMachine-based proxy server, which it uses to intercept
|
11
|
-
requests sent by your browser. It has a simple
|
12
|
-
|
14
|
+
requests sent by your browser. It has a simple API for configuring which
|
15
|
+
requests need stubbing and what they should return.
|
16
|
+
|
17
|
+
Billy lets you test against known, repeatable data. It also allows you to
|
18
|
+
test for failure cases. Does your twitter (or facebook/google/etc)
|
19
|
+
integration degrade gracefully when the API starts returning 500s? Well now
|
20
|
+
you can test it!
|
13
21
|
|
14
22
|
```ruby
|
15
23
|
it 'should stub google' do
|
@@ -19,7 +27,6 @@ it 'should stub google' do
|
|
19
27
|
end
|
20
28
|
```
|
21
29
|
|
22
|
-
|
23
30
|
## Installation
|
24
31
|
|
25
32
|
Add this line to your application's Gemfile:
|
@@ -104,3 +111,4 @@ to see how Billy's default drivers are configured.
|
|
104
111
|
1. Integration for test frameworks other than rspec.
|
105
112
|
2. Caching (for super awesome improved test performance).
|
106
113
|
3. Show errors from the EventMachine reactor loop in the test output.
|
114
|
+
|
data/lib/billy/rspec.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'rspec'
|
2
|
+
require 'capybara/rspec'
|
2
3
|
require 'billy'
|
3
4
|
|
4
5
|
$billy_proxy = Billy::Proxy.new
|
@@ -24,37 +25,41 @@ RSpec.configure do |config|
|
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
options = {
|
32
|
-
phantomjs_options: [
|
33
|
-
'--ignore-ssl-errors=yes',
|
34
|
-
"--proxy=#{Billy.proxy.host}:#{Billy.proxy.port}"
|
35
|
-
]
|
36
|
-
}
|
37
|
-
Capybara::Poltergeist::Driver.new(app, options)
|
38
|
-
end
|
28
|
+
['capybara/poltergeist', 'capybara/webkit', 'selenium/webdriver'].each do |d|
|
29
|
+
begin
|
30
|
+
require d
|
31
|
+
rescue LoadError
|
39
32
|
end
|
33
|
+
end
|
40
34
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
35
|
+
if defined?(Capybara::Poltergeist)
|
36
|
+
Capybara.register_driver :poltergeist_billy do |app|
|
37
|
+
options = {
|
38
|
+
phantomjs_options: [
|
39
|
+
'--ignore-ssl-errors=yes',
|
40
|
+
"--proxy=#{Billy.proxy.host}:#{Billy.proxy.port}"
|
41
|
+
]
|
42
|
+
}
|
43
|
+
Capybara::Poltergeist::Driver.new(app, options)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
if defined?(Capybara::Driver::Webkit)
|
48
|
+
Capybara.register_driver :webkit_billy do |app|
|
49
|
+
driver = Capybara::Driver::Webkit.new(app)
|
50
|
+
driver.browser.set_proxy(:host => Billy.proxy.host,
|
51
|
+
:port => Billy.proxy.port)
|
52
|
+
driver.browser.ignore_ssl_errors
|
53
|
+
driver
|
49
54
|
end
|
55
|
+
end
|
50
56
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
57
|
+
if defined?(Selenium::WebDriver)
|
58
|
+
Capybara.register_driver :selenium_billy do |app|
|
59
|
+
profile = Selenium::WebDriver::Firefox::Profile.new
|
60
|
+
profile.proxy = Selenium::WebDriver::Proxy.new(
|
61
|
+
:http => "#{Billy.proxy.host}:#{Billy.proxy.port}",
|
62
|
+
:ssl => "#{Billy.proxy.host}:#{Billy.proxy.port}")
|
63
|
+
Capybara::Selenium::Driver.new(app, :profile => profile)
|
59
64
|
end
|
60
65
|
end
|
data/lib/billy/version.rb
CHANGED
data/puffing-billy.gemspec
CHANGED
@@ -18,7 +18,6 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.add_development_dependency "rspec"
|
19
19
|
gem.add_development_dependency "thin"
|
20
20
|
gem.add_development_dependency "faraday"
|
21
|
-
gem.add_development_dependency "capybara"
|
22
21
|
gem.add_development_dependency "poltergeist"
|
23
22
|
gem.add_development_dependency "selenium-webdriver"
|
24
23
|
gem.add_development_dependency "capybara-webkit"
|
@@ -28,4 +27,6 @@ Gem::Specification.new do |gem|
|
|
28
27
|
gem.add_runtime_dependency "eventmachine_httpserver"
|
29
28
|
gem.add_runtime_dependency "http_parser.rb"
|
30
29
|
gem.add_runtime_dependency "yajl-ruby"
|
30
|
+
gem.add_runtime_dependency "rspec"
|
31
|
+
gem.add_runtime_dependency "capybara"
|
31
32
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puffing-billy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -60,7 +60,7 @@ dependencies:
|
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
63
|
+
name: poltergeist
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
65
65
|
none: false
|
66
66
|
requirements:
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
|
-
name:
|
79
|
+
name: selenium-webdriver
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
81
81
|
none: false
|
82
82
|
requirements:
|
@@ -92,7 +92,7 @@ dependencies:
|
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
|
-
name:
|
95
|
+
name: capybara-webkit
|
96
96
|
requirement: !ruby/object:Gem::Requirement
|
97
97
|
none: false
|
98
98
|
requirements:
|
@@ -108,7 +108,7 @@ dependencies:
|
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
110
|
- !ruby/object:Gem::Dependency
|
111
|
-
name:
|
111
|
+
name: rack
|
112
112
|
requirement: !ruby/object:Gem::Requirement
|
113
113
|
none: false
|
114
114
|
requirements:
|
@@ -124,14 +124,14 @@ dependencies:
|
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
|
-
name:
|
127
|
+
name: eventmachine
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
129
129
|
none: false
|
130
130
|
requirements:
|
131
131
|
- - ! '>='
|
132
132
|
- !ruby/object:Gem::Version
|
133
133
|
version: '0'
|
134
|
-
type: :
|
134
|
+
type: :runtime
|
135
135
|
prerelease: false
|
136
136
|
version_requirements: !ruby/object:Gem::Requirement
|
137
137
|
none: false
|
@@ -140,7 +140,7 @@ dependencies:
|
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: '0'
|
142
142
|
- !ruby/object:Gem::Dependency
|
143
|
-
name:
|
143
|
+
name: em-http-request
|
144
144
|
requirement: !ruby/object:Gem::Requirement
|
145
145
|
none: false
|
146
146
|
requirements:
|
@@ -156,7 +156,7 @@ dependencies:
|
|
156
156
|
- !ruby/object:Gem::Version
|
157
157
|
version: '0'
|
158
158
|
- !ruby/object:Gem::Dependency
|
159
|
-
name:
|
159
|
+
name: eventmachine_httpserver
|
160
160
|
requirement: !ruby/object:Gem::Requirement
|
161
161
|
none: false
|
162
162
|
requirements:
|
@@ -172,7 +172,7 @@ dependencies:
|
|
172
172
|
- !ruby/object:Gem::Version
|
173
173
|
version: '0'
|
174
174
|
- !ruby/object:Gem::Dependency
|
175
|
-
name:
|
175
|
+
name: http_parser.rb
|
176
176
|
requirement: !ruby/object:Gem::Requirement
|
177
177
|
none: false
|
178
178
|
requirements:
|
@@ -188,7 +188,7 @@ dependencies:
|
|
188
188
|
- !ruby/object:Gem::Version
|
189
189
|
version: '0'
|
190
190
|
- !ruby/object:Gem::Dependency
|
191
|
-
name:
|
191
|
+
name: yajl-ruby
|
192
192
|
requirement: !ruby/object:Gem::Requirement
|
193
193
|
none: false
|
194
194
|
requirements:
|
@@ -204,7 +204,23 @@ dependencies:
|
|
204
204
|
- !ruby/object:Gem::Version
|
205
205
|
version: '0'
|
206
206
|
- !ruby/object:Gem::Dependency
|
207
|
-
name:
|
207
|
+
name: rspec
|
208
|
+
requirement: !ruby/object:Gem::Requirement
|
209
|
+
none: false
|
210
|
+
requirements:
|
211
|
+
- - ! '>='
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
version: '0'
|
214
|
+
type: :runtime
|
215
|
+
prerelease: false
|
216
|
+
version_requirements: !ruby/object:Gem::Requirement
|
217
|
+
none: false
|
218
|
+
requirements:
|
219
|
+
- - ! '>='
|
220
|
+
- !ruby/object:Gem::Version
|
221
|
+
version: '0'
|
222
|
+
- !ruby/object:Gem::Dependency
|
223
|
+
name: capybara
|
208
224
|
requirement: !ruby/object:Gem::Requirement
|
209
225
|
none: false
|
210
226
|
requirements:
|