capybara-screenshot 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  RSpec.configure do |config|
2
2
  # use the before hook to add an after hook that runs last
3
3
  config.before(:type => :request) do
4
- Capybara::Screenshot::RSpecCache.add_after(example.example_group) do
4
+ Capybara::Screenshot::RSpec.add_after(example.example_group) do
5
5
  if Capybara::Screenshot.autosave_on_failure && example.exception
6
6
  filename_prefix = Capybara::Screenshot.filename_prefix_for(:rspec, example)
7
7
 
@@ -17,14 +17,27 @@ end
17
17
  # keep a record of which example groups we've added an after hook to and add if one does not exist
18
18
  module Capybara
19
19
  module Screenshot
20
- class RSpecCache
20
+ class RSpec
21
21
  @@example_groups = []
22
22
  def self.add_after(example_group, &block)
23
- unless @@example_groups.include?(example_group)
23
+ unless (@@example_groups & self_and_parents(example_group)).count > 0
24
24
  example_group.after :each, &block
25
25
  @@example_groups << example_group
26
26
  end
27
27
  end
28
+
29
+ private
30
+ # Return an array of current ExampleGroup and all parent ExampleGroups other than Core which has no metadata
31
+ def self.self_and_parents(example_group, children = [])
32
+ parent_is_core = example_group.superclass.metadata.nil? rescue true # don't ever raise an error if RSpec API changes in the future, lets rather do multiple screen shots as a side effect
33
+ if parent_is_core
34
+ children << example_group
35
+ children
36
+ else
37
+ children << example_group
38
+ self_and_parents(example_group.superclass, children)
39
+ end
40
+ end
28
41
  end
29
42
  end
30
43
  end
@@ -1,5 +1,5 @@
1
1
  module Capybara
2
2
  module Screenshot
3
- VERSION = "0.2.3"
3
+ VERSION = "0.2.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capybara-screenshot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -100,7 +100,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
100
100
  version: '0'
101
101
  segments:
102
102
  - 0
103
- hash: 2034660228649349470
103
+ hash: -2394325955606346377
104
104
  required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  version: '0'
110
110
  segments:
111
111
  - 0
112
- hash: 2034660228649349470
112
+ hash: -2394325955606346377
113
113
  requirements: []
114
114
  rubyforge_project: capybara-screenshot
115
115
  rubygems_version: 1.8.24