puffing-billy 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +5 -2
- data/README.md +58 -15
- data/lib/billy.rb +0 -49
- data/lib/billy/browsers/capybara.rb +64 -0
- data/lib/billy/browsers/watir.rb +44 -0
- data/lib/billy/capybara/cucumber.rb +5 -0
- data/lib/billy/capybara/rspec.rb +5 -0
- data/lib/billy/cucumber.rb +3 -18
- data/lib/billy/handlers/proxy_handler.rb +3 -3
- data/lib/billy/init/cucumber.rb +15 -0
- data/lib/billy/init/rspec.rb +15 -0
- data/lib/billy/proxy_connection.rb +14 -1
- data/lib/billy/rspec.rb +3 -19
- data/lib/billy/version.rb +1 -1
- data/lib/billy/watir/cucumber.rb +2 -0
- data/lib/billy/watir/rspec.rb +2 -0
- data/puffing-billy.gemspec +1 -0
- data/spec/lib/billy/proxy_connection_spec.rb +20 -0
- data/spec/lib/billy/watir/watir_spec.rb +18 -0
- data/spec/lib/proxy_spec.rb +14 -1
- data/spec/spec_helper.rb +8 -1
- metadata +28 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9df069d25b0352ca1208074cf35c1b8abec1ba03
|
4
|
+
data.tar.gz: 1768ffd02817406f80450fcfa92153f56144e2f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 421ec2e524b8cd62ffd2ade27c9119c6b06c7c9217f18c594ac0d1ff51530fb34b7a56d73a07e6b7e8060e89ecb7ec07003b47ae3de75f42b3b63eb9ef7ad04a
|
7
|
+
data.tar.gz: 4397dafabee3b83d326f398a27a0767c5318f1f956d8031214db7a8b366a49e63343ca6d16c1b713c1bc5416d7e3ca5b94f3c047ee4290097f1ef2a850d3b960
|
data/.travis.yml
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
language: ruby
|
2
2
|
before_install:
|
3
3
|
- gem install bundler
|
4
|
+
- mkdir travis-phantomjs
|
5
|
+
- wget https://s3.amazonaws.com/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2 -O $PWD/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2
|
6
|
+
- tar -xvf $PWD/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2 -C $PWD/travis-phantomjs
|
7
|
+
- export PATH=$PWD/travis-phantomjs:$PATH
|
8
|
+
- phantomjs --version
|
4
9
|
rvm:
|
5
10
|
- 1.9.3
|
6
11
|
- 2.0.0
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
v0.9.0, 2016-07-23
|
2
|
+
------------------
|
3
|
+
* Add Watir web driver support [#158](https://github.com/oesmith/puffing-billy/pull/158)
|
4
|
+
* Fix response headers by anticipating EventMachine::HttpResponse behavior [#162](https://github.com/oesmith/puffing-billy/pull/162)
|
5
|
+
* Support using a Regexp in path_blacklist [#163](https://github.com/oesmith/puffing-billy/pull/163)
|
6
|
+
|
1
7
|
v0.8.0, 2016-06-02
|
2
8
|
------------------
|
3
9
|
* Add optional after_cache_handles_request callback for manipulating cached responses [#149](https://github.com/oesmith/puffing-billy/pull/149)
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
puffing-billy (0.
|
4
|
+
puffing-billy (0.9.0)
|
5
5
|
addressable
|
6
6
|
em-http-request (~> 1.1.0)
|
7
7
|
em-synchrony
|
@@ -126,6 +126,8 @@ GEM
|
|
126
126
|
eventmachine (~> 1.0)
|
127
127
|
rack (~> 1.0)
|
128
128
|
thor (0.19.1)
|
129
|
+
watir-webdriver (0.9.1)
|
130
|
+
selenium-webdriver (>= 2.46.2)
|
129
131
|
websocket (1.2.2)
|
130
132
|
websocket-driver (0.6.2)
|
131
133
|
websocket-extensions (>= 0.1.0)
|
@@ -150,6 +152,7 @@ DEPENDENCIES
|
|
150
152
|
rspec
|
151
153
|
selenium-webdriver
|
152
154
|
thin
|
155
|
+
watir-webdriver
|
153
156
|
|
154
157
|
BUNDLED WITH
|
155
|
-
1.
|
158
|
+
1.12.4
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Puffing Billy
|
1
|
+
# Puffing Billy [![Gem Version](https://badge.fury.io/rb/puffing-billy.svg)](https://badge.fury.io/rb/puffing-billy) [![Build Status](https://travis-ci.org/oesmith/puffing-billy.svg?branch=master)](https://travis-ci.org/oesmith/puffing-billy)
|
2
2
|
|
3
3
|
A rewriting web proxy for testing interactions between your browser and
|
4
4
|
external sites. Works with ruby + rspec.
|
@@ -46,10 +46,12 @@ Or install it yourself as:
|
|
46
46
|
|
47
47
|
## RSpec Usage
|
48
48
|
|
49
|
+
### Setup for Capybara
|
50
|
+
|
49
51
|
In your `rails_helper.rb`:
|
50
52
|
|
51
53
|
```ruby
|
52
|
-
require 'billy/rspec'
|
54
|
+
require 'billy/capybara/rspec'
|
53
55
|
|
54
56
|
# select a driver for your chosen browser environment
|
55
57
|
Capybara.javascript_driver = :selenium_billy # Uses Firefox
|
@@ -58,11 +60,24 @@ Capybara.javascript_driver = :selenium_billy # Uses Firefox
|
|
58
60
|
# Capybara.javascript_driver = :poltergeist_billy
|
59
61
|
```
|
60
62
|
|
61
|
-
|
62
|
-
|
63
|
+
> __Note__: `:poltergeist_billy` doesn't support proxying any localhosts, so you must use
|
64
|
+
`:webkit_billy` for headless specs when using puffing-billy for other local rack apps.
|
63
65
|
See [this phantomjs issue](https://github.com/ariya/phantomjs/issues/11342) for any updates.
|
64
66
|
|
65
|
-
|
67
|
+
### Setup for Watir
|
68
|
+
|
69
|
+
In your `rails_helper.rb`:
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
require 'billy/watir/rspec'
|
73
|
+
|
74
|
+
# select a driver for your chosen browser environment
|
75
|
+
@browser = Billy::Browsers::Watir.new :firefox
|
76
|
+
# @browser = Billy::Browsers::Watir.new = :chrome
|
77
|
+
# @browser = Billy::Browsers::Watir.new = :phantomjs
|
78
|
+
```
|
79
|
+
|
80
|
+
### In your tests (Capybara/Watir)
|
66
81
|
|
67
82
|
```ruby
|
68
83
|
# Stub and return text, json, jsonp (or anything else)
|
@@ -115,16 +130,6 @@ proxied to the remote server.
|
|
115
130
|
|
116
131
|
## Cucumber Usage
|
117
132
|
|
118
|
-
In your `features/support/env.rb`:
|
119
|
-
|
120
|
-
```ruby
|
121
|
-
require 'billy/cucumber'
|
122
|
-
|
123
|
-
After do
|
124
|
-
Capybara.use_default_driver
|
125
|
-
end
|
126
|
-
```
|
127
|
-
|
128
133
|
An example feature:
|
129
134
|
|
130
135
|
```
|
@@ -135,6 +140,18 @@ Feature: Stubbing via billy
|
|
135
140
|
And a stub for google
|
136
141
|
```
|
137
142
|
|
143
|
+
### Capybara
|
144
|
+
|
145
|
+
In your `features/support/env.rb`:
|
146
|
+
|
147
|
+
```ruby
|
148
|
+
require 'billy/capybara/cucumber'
|
149
|
+
|
150
|
+
After do
|
151
|
+
Capybara.use_default_driver
|
152
|
+
end
|
153
|
+
```
|
154
|
+
|
138
155
|
And in steps:
|
139
156
|
|
140
157
|
```ruby
|
@@ -154,6 +171,32 @@ It's good practice to reset the driver after each scenario, so having an
|
|
154
171
|
stubs are reset after each step, so any usage of a stub should be in the
|
155
172
|
same step that it was created in.
|
156
173
|
|
174
|
+
### Watir
|
175
|
+
|
176
|
+
In your `features/support/env.rb`:
|
177
|
+
|
178
|
+
```ruby
|
179
|
+
require 'billy/watir/cucumber'
|
180
|
+
|
181
|
+
After do
|
182
|
+
@browser.close
|
183
|
+
end
|
184
|
+
```
|
185
|
+
|
186
|
+
And in steps:
|
187
|
+
|
188
|
+
```ruby
|
189
|
+
Before('@billy') do
|
190
|
+
@browser = Billy::Browsers::Watir.new :firefox
|
191
|
+
end
|
192
|
+
|
193
|
+
And /^a stub for google$/ do
|
194
|
+
proxy.stub('http://www.google.com/').and_return(:text => "I'm not Google!")
|
195
|
+
@browser.goto 'http://www.google.com/'
|
196
|
+
expect(@browser.text).to eq("I'm not Google!")
|
197
|
+
end
|
198
|
+
```
|
199
|
+
|
157
200
|
## Minitest Usage
|
158
201
|
|
159
202
|
Please see [this link](https://gist.github.com/sauy7/1b081266dd453a1b737b) for
|
data/lib/billy.rb
CHANGED
@@ -19,53 +19,4 @@ module Billy
|
|
19
19
|
proxy
|
20
20
|
)
|
21
21
|
end
|
22
|
-
|
23
|
-
def self.register_drivers
|
24
|
-
['capybara/poltergeist', 'capybara/webkit', 'selenium/webdriver'].each do |d|
|
25
|
-
begin
|
26
|
-
require d
|
27
|
-
rescue LoadError
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
if defined?(Capybara::Poltergeist)
|
32
|
-
Capybara.register_driver :poltergeist_billy do |app|
|
33
|
-
options = {
|
34
|
-
phantomjs_options: [
|
35
|
-
'--ignore-ssl-errors=yes',
|
36
|
-
"--proxy=#{Billy.proxy.host}:#{Billy.proxy.port}"
|
37
|
-
]
|
38
|
-
}
|
39
|
-
Capybara::Poltergeist::Driver.new(app, options)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
if defined?(Capybara::Webkit::Driver)
|
44
|
-
Capybara.register_driver :webkit_billy do |app|
|
45
|
-
options = {
|
46
|
-
ignore_ssl_errors: true,
|
47
|
-
proxy: {host: Billy.proxy.host, port: Billy.proxy.port}
|
48
|
-
}
|
49
|
-
Capybara::Webkit::Driver.new(app, Capybara::Webkit::Configuration.to_hash.merge(options))
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
if defined?(Selenium::WebDriver)
|
54
|
-
Capybara.register_driver :selenium_billy do |app|
|
55
|
-
profile = Selenium::WebDriver::Firefox::Profile.new
|
56
|
-
profile.assume_untrusted_certificate_issuer = false
|
57
|
-
profile.proxy = Selenium::WebDriver::Proxy.new(
|
58
|
-
http: "#{Billy.proxy.host}:#{Billy.proxy.port}",
|
59
|
-
ssl: "#{Billy.proxy.host}:#{Billy.proxy.port}")
|
60
|
-
Capybara::Selenium::Driver.new(app, profile: profile)
|
61
|
-
end
|
62
|
-
|
63
|
-
Capybara.register_driver :selenium_chrome_billy do |app|
|
64
|
-
Capybara::Selenium::Driver.new(
|
65
|
-
app, browser: :chrome,
|
66
|
-
switches: ["--proxy-server=#{Billy.proxy.host}:#{Billy.proxy.port}"]
|
67
|
-
)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
22
|
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'billy'
|
2
|
+
|
3
|
+
module Billy
|
4
|
+
module Browsers
|
5
|
+
class Capybara
|
6
|
+
|
7
|
+
DRIVERS = {
|
8
|
+
poltergeist: 'capybara/poltergeist',
|
9
|
+
webkit: 'capybara/webkit',
|
10
|
+
selenium: 'selenium/webdriver'
|
11
|
+
}
|
12
|
+
|
13
|
+
def self.register_drivers
|
14
|
+
DRIVERS.each do |name, driver|
|
15
|
+
require driver rescue next
|
16
|
+
send("register_#{name}_driver")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def self.register_poltergeist_driver
|
23
|
+
::Capybara.register_driver :poltergeist_billy do |app|
|
24
|
+
options = {
|
25
|
+
phantomjs_options: [
|
26
|
+
'--ignore-ssl-errors=yes',
|
27
|
+
"--proxy=#{Billy.proxy.host}:#{Billy.proxy.port}"
|
28
|
+
]
|
29
|
+
}
|
30
|
+
::Capybara::Poltergeist::Driver.new(app, options)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.register_webkit_driver
|
35
|
+
::Capybara.register_driver :webkit_billy do |app|
|
36
|
+
options = {
|
37
|
+
ignore_ssl_errors: true,
|
38
|
+
proxy: {host: Billy.proxy.host, port: Billy.proxy.port}
|
39
|
+
}
|
40
|
+
::Capybara::Webkit::Driver.new(app, ::Capybara::Webkit::Configuration.to_hash.merge(options))
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.register_selenium_driver
|
45
|
+
::Capybara.register_driver :selenium_billy do |app|
|
46
|
+
profile = Selenium::WebDriver::Firefox::Profile.new
|
47
|
+
profile.assume_untrusted_certificate_issuer = false
|
48
|
+
profile.proxy = Selenium::WebDriver::Proxy.new(
|
49
|
+
http: "#{Billy.proxy.host}:#{Billy.proxy.port}",
|
50
|
+
ssl: "#{Billy.proxy.host}:#{Billy.proxy.port}")
|
51
|
+
::Capybara::Selenium::Driver.new(app, profile: profile)
|
52
|
+
end
|
53
|
+
|
54
|
+
::Capybara.register_driver :selenium_chrome_billy do |app|
|
55
|
+
::Capybara::Selenium::Driver.new(
|
56
|
+
app, browser: :chrome,
|
57
|
+
switches: ["--proxy-server=#{Billy.proxy.host}:#{Billy.proxy.port}"]
|
58
|
+
)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'billy'
|
2
|
+
require 'watir-webdriver'
|
3
|
+
|
4
|
+
module Billy
|
5
|
+
module Browsers
|
6
|
+
class Watir < ::Watir::Browser
|
7
|
+
|
8
|
+
def initialize(name, args = {})
|
9
|
+
args = case name
|
10
|
+
when :chrome then configure_chrome(args)
|
11
|
+
when :phantomjs then configure_phantomjs(args)
|
12
|
+
when :firefox then configure_firefox(args)
|
13
|
+
else
|
14
|
+
raise NameError, "Invalid browser driver specified. (Expected: :chrome, :phantomjs, :firefox)"
|
15
|
+
end
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def configure_chrome(args)
|
22
|
+
args[:switches] ||= []
|
23
|
+
args[:switches] += %W[--proxy-server=#{Billy.proxy.host}:#{Billy.proxy.port}]
|
24
|
+
args
|
25
|
+
end
|
26
|
+
|
27
|
+
def configure_phantomjs(args)
|
28
|
+
args[:args] ||= []
|
29
|
+
args[:args] += %W[--proxy=#{Billy.proxy.host}:#{Billy.proxy.port}]
|
30
|
+
args
|
31
|
+
end
|
32
|
+
|
33
|
+
def configure_firefox(args)
|
34
|
+
args[:profile] ||= Selenium::WebDriver::Firefox::Profile.new
|
35
|
+
args[:profile].proxy = Selenium::WebDriver::Proxy.new(
|
36
|
+
http: "#{Billy.proxy.host}:#{Billy.proxy.port}",
|
37
|
+
ssl: "#{Billy.proxy.host}:#{Billy.proxy.port}"
|
38
|
+
)
|
39
|
+
args
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/billy/cucumber.rb
CHANGED
@@ -1,19 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'capybara/cucumber'
|
3
|
-
require 'billy'
|
1
|
+
# Deprecated
|
2
|
+
require 'billy/capybara/cucumber'
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
module Billy
|
8
|
-
module CucumberHelper
|
9
|
-
def proxy
|
10
|
-
Billy.proxy
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
World(Billy::CucumberHelper)
|
16
|
-
|
17
|
-
After('@billy') do
|
18
|
-
proxy.reset
|
19
|
-
end
|
4
|
+
warn "[DEPRECATION] `require 'billy/cucumber'` is deprecated. Please use `require 'billy/capybara/cucumber'` instead."
|
@@ -73,9 +73,9 @@ module Billy
|
|
73
73
|
response = {
|
74
74
|
status: req.response_header.status,
|
75
75
|
headers: req.response_header.raw,
|
76
|
-
content: req.response.force_encoding('BINARY')
|
76
|
+
content: req.response.force_encoding('BINARY')
|
77
|
+
}
|
77
78
|
response[:headers].merge!('Connection' => 'close')
|
78
|
-
response[:headers].delete('Transfer-Encoding')
|
79
79
|
response
|
80
80
|
end
|
81
81
|
|
@@ -111,7 +111,7 @@ module Billy
|
|
111
111
|
end
|
112
112
|
|
113
113
|
def blacklisted_path?(path)
|
114
|
-
!Billy.config.path_blacklist.index { |bl| path.include?(bl) }.nil?
|
114
|
+
!Billy.config.path_blacklist.index { |bl| bl.is_a?(Regexp) ? path =~ bl : path.include?(bl) }.nil?
|
115
115
|
end
|
116
116
|
|
117
117
|
def successful_status?(status)
|
@@ -74,12 +74,25 @@ module Billy
|
|
74
74
|
|
75
75
|
private
|
76
76
|
|
77
|
+
def prepare_response_headers_for_evma_httpserver(headers)
|
78
|
+
# Remove the headers below because they will be added later by evma_httpserver (EventMachine::DelegatedHttpResponse).
|
79
|
+
# See https://github.com/eventmachine/evma_httpserver/blob/master/lib/evma_httpserver/response.rb
|
80
|
+
headers_to_remove = [
|
81
|
+
'transfer-encoding',
|
82
|
+
'content-length',
|
83
|
+
'content-encoding'
|
84
|
+
]
|
85
|
+
|
86
|
+
headers.delete_if {|key, value| headers_to_remove.include?(key.downcase) }
|
87
|
+
end
|
88
|
+
|
77
89
|
def send_response(response)
|
78
90
|
res = EM::DelegatedHttpResponse.new(self)
|
79
91
|
res.status = response[:status]
|
80
|
-
res.headers = response[:headers]
|
92
|
+
res.headers = prepare_response_headers_for_evma_httpserver(response[:headers])
|
81
93
|
res.content = response[:content]
|
82
94
|
res.send_response
|
83
95
|
end
|
96
|
+
|
84
97
|
end
|
85
98
|
end
|
data/lib/billy/rspec.rb
CHANGED
@@ -1,20 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'billy'
|
1
|
+
# Deprecated
|
2
|
+
require 'billy/capybara/rspec'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
module Billy
|
7
|
-
module RspecHelper
|
8
|
-
def proxy
|
9
|
-
Billy.proxy
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
RSpec.configure do |config|
|
15
|
-
config.include(Billy::RspecHelper)
|
16
|
-
|
17
|
-
config.after(:each) do
|
18
|
-
proxy.reset
|
19
|
-
end
|
20
|
-
end
|
4
|
+
warn "[DEPRECATION] `require 'billy/rspec'` is deprecated. Please use `require 'billy/capybara/rspec'` instead."
|
data/lib/billy/version.rb
CHANGED
data/puffing-billy.gemspec
CHANGED
@@ -27,6 +27,7 @@ Gem::Specification.new do |gem|
|
|
27
27
|
gem.add_development_dependency 'rb-inotify'
|
28
28
|
gem.add_development_dependency 'pry'
|
29
29
|
gem.add_development_dependency 'cucumber'
|
30
|
+
gem.add_development_dependency 'watir-webdriver'
|
30
31
|
gem.add_runtime_dependency 'addressable'
|
31
32
|
gem.add_runtime_dependency 'eventmachine', '~> 1.0.4'
|
32
33
|
gem.add_runtime_dependency 'em-synchrony'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Billy::ProxyConnection do
|
4
|
+
context '#prepare_response_headers_for_evma_httpserver' do
|
5
|
+
let(:subject) { Billy::ProxyConnection.new('') }
|
6
|
+
|
7
|
+
it 'should remove duplicated headers fields' do
|
8
|
+
provided_headers = {
|
9
|
+
'transfer-encoding' => '',
|
10
|
+
'content-length' => '',
|
11
|
+
'content-encoding' => '',
|
12
|
+
'key' => 'value'
|
13
|
+
}
|
14
|
+
expected_headers = { 'key' => 'value' }
|
15
|
+
headers = subject.send(:prepare_response_headers_for_evma_httpserver, provided_headers)
|
16
|
+
|
17
|
+
expect(headers).to eql expected_headers
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Watir-specific tests', type: :feature, js: true do
|
4
|
+
before do
|
5
|
+
proxy.stub('http://www.example.com/get').and_return(
|
6
|
+
text: 'Success!'
|
7
|
+
)
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should raise a NameError if an invalid browser driver is specified' do
|
11
|
+
expect{Billy::Browsers::Watir.new :invalid}.to raise_error(NameError)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should respond to a stubbed GET request' do
|
15
|
+
@browser.goto 'http://www.example.com/get'
|
16
|
+
expect(@browser.text).to eq 'Success!'
|
17
|
+
end
|
18
|
+
end
|
data/spec/lib/proxy_spec.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'billy'
|
3
2
|
require 'resolv'
|
4
3
|
|
5
4
|
shared_examples_for 'a proxy server' do
|
@@ -135,6 +134,20 @@ shared_examples_for 'a cache' do
|
|
135
134
|
it 'should be cached' do
|
136
135
|
assert_cached_url('/api')
|
137
136
|
end
|
137
|
+
|
138
|
+
context 'path_blacklist includes regex' do
|
139
|
+
before do
|
140
|
+
Billy.config.path_blacklist = [/widgets$/]
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'should not cache a non-match' do
|
144
|
+
assert_noncached_url('/widgets/5/edit')
|
145
|
+
end
|
146
|
+
|
147
|
+
it 'should cache a match' do
|
148
|
+
assert_cached_url('/widgets')
|
149
|
+
end
|
150
|
+
end
|
138
151
|
end
|
139
152
|
|
140
153
|
context 'cache persistence' do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
Dir[File.expand_path('../support/**/*.rb', __FILE__)].each { |f| require f }
|
2
2
|
|
3
3
|
require 'pry'
|
4
|
-
require 'billy/rspec'
|
4
|
+
require 'billy/capybara/rspec'
|
5
|
+
require 'billy/watir/rspec'
|
5
6
|
require 'rack'
|
6
7
|
require 'logger'
|
7
8
|
|
9
|
+
browser = Billy::Browsers::Watir.new :phantomjs
|
8
10
|
Capybara.app = Rack::Directory.new(File.expand_path('../../examples', __FILE__))
|
9
11
|
Capybara.javascript_driver = :poltergeist_billy
|
10
12
|
|
@@ -20,6 +22,7 @@ RSpec.configure do |config|
|
|
20
22
|
|
21
23
|
config.before :all do
|
22
24
|
start_test_servers
|
25
|
+
@browser = browser
|
23
26
|
end
|
24
27
|
|
25
28
|
config.before :each do
|
@@ -29,4 +32,8 @@ RSpec.configure do |config|
|
|
29
32
|
config.after :each do
|
30
33
|
Billy.config.reset
|
31
34
|
end
|
35
|
+
|
36
|
+
config.after :suite do
|
37
|
+
browser.close
|
38
|
+
end
|
32
39
|
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: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Olly Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -178,6 +178,20 @@ dependencies:
|
|
178
178
|
- - ">="
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: watir-webdriver
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
181
195
|
- !ruby/object:Gem::Dependency
|
182
196
|
name: addressable
|
183
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -303,7 +317,11 @@ files:
|
|
303
317
|
- examples/preflight_request.html
|
304
318
|
- examples/tumblr_api.html
|
305
319
|
- lib/billy.rb
|
320
|
+
- lib/billy/browsers/capybara.rb
|
321
|
+
- lib/billy/browsers/watir.rb
|
306
322
|
- lib/billy/cache.rb
|
323
|
+
- lib/billy/capybara/cucumber.rb
|
324
|
+
- lib/billy/capybara/rspec.rb
|
307
325
|
- lib/billy/config.rb
|
308
326
|
- lib/billy/cucumber.rb
|
309
327
|
- lib/billy/handlers/cache_handler.rb
|
@@ -311,6 +329,8 @@ files:
|
|
311
329
|
- lib/billy/handlers/proxy_handler.rb
|
312
330
|
- lib/billy/handlers/request_handler.rb
|
313
331
|
- lib/billy/handlers/stub_handler.rb
|
332
|
+
- lib/billy/init/cucumber.rb
|
333
|
+
- lib/billy/init/rspec.rb
|
314
334
|
- lib/billy/json_utils.rb
|
315
335
|
- lib/billy/mitm.crt
|
316
336
|
- lib/billy/mitm.key
|
@@ -320,6 +340,8 @@ files:
|
|
320
340
|
- lib/billy/railtie.rb
|
321
341
|
- lib/billy/rspec.rb
|
322
342
|
- lib/billy/version.rb
|
343
|
+
- lib/billy/watir/cucumber.rb
|
344
|
+
- lib/billy/watir/rspec.rb
|
323
345
|
- lib/puffing-billy.rb
|
324
346
|
- lib/puffing-billy/rspec.rb
|
325
347
|
- lib/tasks/billy.rake
|
@@ -338,8 +360,10 @@ files:
|
|
338
360
|
- spec/lib/billy/handlers/proxy_handler_spec.rb
|
339
361
|
- spec/lib/billy/handlers/request_handler_spec.rb
|
340
362
|
- spec/lib/billy/handlers/stub_handler_spec.rb
|
363
|
+
- spec/lib/billy/proxy_connection_spec.rb
|
341
364
|
- spec/lib/billy/proxy_request_stub_spec.rb
|
342
365
|
- spec/lib/billy/resource_utils_spec.rb
|
366
|
+
- spec/lib/billy/watir/watir_spec.rb
|
343
367
|
- spec/lib/proxy_spec.rb
|
344
368
|
- spec/spec_helper.rb
|
345
369
|
- spec/support/test_server.rb
|
@@ -380,8 +404,10 @@ test_files:
|
|
380
404
|
- spec/lib/billy/handlers/proxy_handler_spec.rb
|
381
405
|
- spec/lib/billy/handlers/request_handler_spec.rb
|
382
406
|
- spec/lib/billy/handlers/stub_handler_spec.rb
|
407
|
+
- spec/lib/billy/proxy_connection_spec.rb
|
383
408
|
- spec/lib/billy/proxy_request_stub_spec.rb
|
384
409
|
- spec/lib/billy/resource_utils_spec.rb
|
410
|
+
- spec/lib/billy/watir/watir_spec.rb
|
385
411
|
- spec/lib/proxy_spec.rb
|
386
412
|
- spec/spec_helper.rb
|
387
413
|
- spec/support/test_server.rb
|