puffing-billy 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c210f975286ead0f70c852cbeaa2a5bd5f22dc88
4
- data.tar.gz: 7f408efe6f4ce17a9e53fc5b0a3f963b15425e2d
3
+ metadata.gz: 11f63ec36c7471c6290b07e64f35879c9b4efd7e
4
+ data.tar.gz: d309c50f0918f9893ddb9da69beb034bf3b26133
5
5
  SHA512:
6
- metadata.gz: 9dfaca86a69fac9cb4938eb68c4298c482d7ae02155b93ef23a9d0b51e4891d9944a38f2002a833843a9f778c3f62d526278955d9b69b3bd26e70f56ce20d083
7
- data.tar.gz: b17c5ea015846c53fa4434dbd0735417e111f52ea1fd0c02921cf899a595d68bbe208a60ad10f20aa7c96c483484742e3a10694d28c496421c79d66274521b29
6
+ metadata.gz: 24b195fd2c7711efa8f9846b7cf97b2e55ddfab4ae181483645bcecaf78bd5c112e5d886d4ed51ba2de2e6fdfd1876a21eb52360efe323fe953515ce89643612
7
+ data.tar.gz: c88c7270b7921f76bc72eba910f2e8a6062cf0db17c8506d5389127ac18bb9677878fc6a3a2225bc195bdd5ea60d58f1b0db159e44320a5f6520373561d62e4b
@@ -1,3 +1,8 @@
1
+ v0.9.2, 2017-01-18
2
+ ------------------
3
+ * Ensure that files are closed after being opened [#175](https://github.com/oesmith/puffing-billy/pull/175)
4
+ * Fix floating scopes [#177](https://github.com/oesmith/puffing-billy/pull/177)
5
+
1
6
  v0.9.1, 2016-07-28
2
7
  ------------------
3
8
  * Rescue LoadErrors during driver registration [#170](https://github.com/oesmith/puffing-billy/pull/170)
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- puffing-billy (0.9.1)
5
- addressable
4
+ puffing-billy (0.9.2)
5
+ addressable (~> 2.4.0)
6
6
  em-http-request (~> 1.1.0)
7
7
  em-synchrony
8
8
  eventmachine (~> 1.0.4)
@@ -28,7 +28,7 @@ GEM
28
28
  ffi (~> 1.0, >= 1.0.11)
29
29
  cliver (0.3.2)
30
30
  coderay (1.1.0)
31
- cookiejar (0.3.0)
31
+ cookiejar (0.3.3)
32
32
  cucumber (2.0.2)
33
33
  builder (>= 2.1.2)
34
34
  cucumber-core (~> 1.2.0)
@@ -40,15 +40,15 @@ GEM
40
40
  gherkin (~> 2.12.0)
41
41
  daemons (1.2.3)
42
42
  diff-lcs (1.2.5)
43
- em-http-request (1.1.3)
43
+ em-http-request (1.1.5)
44
44
  addressable (>= 2.3.4)
45
- cookiejar (<= 0.3.0)
45
+ cookiejar (!= 0.3.1)
46
46
  em-socksify (>= 0.3)
47
47
  eventmachine (>= 1.0.3)
48
48
  http_parser.rb (>= 0.6.0)
49
49
  em-socksify (0.3.1)
50
50
  eventmachine (>= 1.0.0.beta.4)
51
- em-synchrony (1.0.5)
51
+ em-synchrony (1.0.6)
52
52
  eventmachine (>= 1.0.0.beta.1)
53
53
  eventmachine (1.0.8)
54
54
  eventmachine_httpserver (0.2.1)
data/README.md CHANGED
@@ -408,6 +408,21 @@ RSpec.configure do |config|
408
408
  end
409
409
  ```
410
410
 
411
+ ## Separate Cache Directory for Each Test (in Cucumber)
412
+
413
+ 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 use a Before tag like so:
414
+
415
+ ```rb
416
+ Before('@javascript') do |scenario, block|
417
+ Billy.configure do |c|
418
+ feature_name = scenario.feature.name.underscore
419
+ scenario_name = scenario.name.underscore
420
+ c.cache_path = "features/support/fixtures/req_cache/#{feature_name}/#{scenario_name}/"
421
+ Dir.mkdir_p(Billy.config.cache_path) unless File.exist?(Billy.config.cache_path)
422
+ end
423
+ end
424
+ ```
425
+
411
426
  ## Stub requests recording
412
427
 
413
428
  If you want to record requests to stubbed URIs, set the following configuration option:
@@ -478,7 +493,6 @@ end
478
493
 
479
494
  Note that this approach may cause unexpected behavior if your backend sends the Referer HTTP header (which is unlikely).
480
495
 
481
-
482
496
  ## Resources
483
497
 
484
498
  * [Bring Ruby VCR to Javascript testing with Capybara and puffing-billy](http://architects.dzone.com/articles/bring-ruby-vcr-javascript)
@@ -30,15 +30,15 @@ module Billy
30
30
  end
31
31
 
32
32
  def fetch_from_persistence(key)
33
- @cache[key] = YAML.load(File.open(cache_file(key))) if persisted?(key)
33
+ @cache[key] = YAML.load_file(cache_file(key)) if persisted?(key)
34
34
  rescue ArgumentError => e
35
35
  Billy.log :error, "Could not parse YAML: #{e.message}"
36
36
  nil
37
37
  end
38
38
 
39
- def store(method, url, request_headers, body, response_headers, status, content)
39
+ def store(key, _scope, method, url, request_headers, body, response_headers, status, content)
40
40
  cached = {
41
- scope: scope,
41
+ scope: _scope,
42
42
  url: format_url(url),
43
43
  body: body,
44
44
  status: status,
@@ -49,7 +49,6 @@ module Billy
49
49
 
50
50
  cached.merge!(request_headers: request_headers) if Billy.config.cache_request_headers
51
51
 
52
- key = key(method, url, body)
53
52
  @cache[key] = cached
54
53
 
55
54
  if Billy.config.persist_cache
@@ -21,6 +21,9 @@ module Billy
21
21
  port: Billy.config.proxied_request_port }} )
22
22
  end
23
23
 
24
+ cache_scope = Billy::Cache.instance.scope
25
+ cache_key = Billy::Cache.instance.key(method.downcase, url, body)
26
+
24
27
  req = EventMachine::HttpRequest.new(url, opts)
25
28
  req = req.send(method.downcase, build_request_options(url, headers, body))
26
29
 
@@ -40,7 +43,17 @@ module Billy
40
43
  end
41
44
 
42
45
  if cacheable?(url, response[:headers], response[:status])
43
- Billy::Cache.instance.store(method.downcase, url, headers, body, response[:headers], response[:status], response[:content])
46
+ Billy::Cache.instance.store(
47
+ cache_key,
48
+ cache_scope,
49
+ method.downcase,
50
+ url,
51
+ headers,
52
+ body,
53
+ response[:headers],
54
+ response[:status],
55
+ response[:content]
56
+ )
44
57
  end
45
58
 
46
59
  Billy.log(:info, "puffing-billy: PROXY #{method} succeeded for '#{url}'")
@@ -1,3 +1,3 @@
1
1
  module Billy
2
- VERSION = '0.9.1'
2
+ VERSION = '0.9.2'
3
3
  end
@@ -67,7 +67,7 @@ namespace :cache do
67
67
  end
68
68
 
69
69
  def load_cache_file(filename)
70
- YAML.load(File.open(filename))
70
+ YAML.load_file(filename)
71
71
  rescue ArgumentError => e
72
72
  puts "Could not parse YAML: #{e.message}"
73
73
  end
@@ -28,7 +28,8 @@ Gem::Specification.new do |gem|
28
28
  gem.add_development_dependency 'pry'
29
29
  gem.add_development_dependency 'cucumber'
30
30
  gem.add_development_dependency 'watir-webdriver'
31
- gem.add_runtime_dependency 'addressable'
31
+ # addressable 2.5.0 drops support for ruby 1.9.3
32
+ gem.add_runtime_dependency 'addressable', '~> 2.4.0'
32
33
  gem.add_runtime_dependency 'eventmachine', '~> 1.0.4'
33
34
  gem.add_runtime_dependency 'em-synchrony'
34
35
  gem.add_runtime_dependency 'em-http-request', '~> 1.1.0'
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.9.1
4
+ version: 0.9.2
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-07-29 00:00:00.000000000 Z
11
+ date: 2017-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -196,16 +196,16 @@ dependencies:
196
196
  name: addressable
197
197
  requirement: !ruby/object:Gem::Requirement
198
198
  requirements:
199
- - - ">="
199
+ - - "~>"
200
200
  - !ruby/object:Gem::Version
201
- version: '0'
201
+ version: 2.4.0
202
202
  type: :runtime
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
- - - ">="
206
+ - - "~>"
207
207
  - !ruby/object:Gem::Version
208
- version: '0'
208
+ version: 2.4.0
209
209
  - !ruby/object:Gem::Dependency
210
210
  name: eventmachine
211
211
  requirement: !ruby/object:Gem::Requirement
@@ -386,7 +386,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
386
386
  version: '0'
387
387
  requirements: []
388
388
  rubyforge_project:
389
- rubygems_version: 2.5.1
389
+ rubygems_version: 2.4.8
390
390
  signing_key:
391
391
  specification_version: 4
392
392
  summary: Easy request stubs for browser tests.
@@ -411,3 +411,4 @@ test_files:
411
411
  - spec/lib/proxy_spec.rb
412
412
  - spec/spec_helper.rb
413
413
  - spec/support/test_server.rb
414
+ has_rdoc: