capybara-screenshot 1.0.9 → 1.0.10

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZmMwYzE2YmM3NGE1NGJjNjM5Y2ZiYjNhNGIwMjE3Y2VjM2JmNjVhMw==
4
+ NDM5NDRiYWIwNmRkY2JkMWFiMjRkNWUzYjE1YTUwZWY3NmE5MmY4NQ==
5
5
  data.tar.gz: !binary |-
6
- YWIzMjk0MjA5OGZmOTA3MjExYjI5MjhjMDhiZTAxZTUxZmQ5ZjRlNg==
6
+ OTMwNTdiZWE1ZGU5NjMyZDVjZjM0ZTQyZGJmMjJjNDY3Y2VjZTQ5ZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZWJkZGEyMTY5YmY5NTgzMDg2OGNlOWQ2Yjc3YmZlMjZhNTBkZDUzMmE0YjYw
10
- MjMwODZlMTUxNjYwOWIxNTRlOWZiYTZjYTk4ZjllYTM2MjIzN2E5Y2ZhMTkw
11
- NDc0ZDc0OGQ3MDc2ZTQ4NDlmOTNkOTc0MjFhNDQ3OWQ0ODc0ZTM=
9
+ ZDhmNDQ2YTA3MTkwZWNlM2JhZmI5MDdhZjA1ZTNlNWI2OTA1MDYxODVmNjVi
10
+ ZDJjZmI3YTZmZmEzMmZmYjRiODdlODljZDQ1NjM3YzQ2ZTIxMmU1YTJkNDhj
11
+ ODk1OGUxYWVlYjQwZDcyYWVmZmFmOWQxMTQ5MWYzYzZmY2ZmYjU=
12
12
  data.tar.gz: !binary |-
13
- OGQxNzQ2Nzk4N2Q5ZGIzMjVkMGRjOGM3OTM0ODc1YzFlOTcwMDA5YjBlMDM5
14
- NjE0MTljNGU1ZGUyMTdmMjEwMDViZmZiOGFhNmNkMDdjYWEzZjNkMzBkYmVl
15
- OTJjMWMzMzBjMjkxZWQ0Yjk5YTg4MjRkMjNhOTYyNzIxNWQ0MGI=
13
+ NTQ5ZjZjMjkxZTg3MmU1YzJiYzViN2M5OWNlMjU4NGM1ODhmODlkNGE2NTJi
14
+ OWFhN2VhNzYyMDJiY2FiYTgxYjhjZjE1NmYyNTU5NzA4NmViZTQwYzUwMmRh
15
+ ZGE3ZDNhYWU0OThlMDMxM2FjZmNiZGZhZjdkNzgyZTM4ZWFiOTc=
@@ -1,3 +1,9 @@
1
+ 29 June 2015 - 1.0.9 -> 1.0.10
2
+
3
+ * [Small fix to memoization](https://github.com/mattheworiordan/capybara-screenshot/pull/134) plus [mini refactor](https://github.com/mattheworiordan/capybara-screenshot/commit/1db950bc53c729b26b8881d058a8781d6e7611b8)
4
+
5
+ Thanks to [Systho](https://github.com/Systho)
6
+
1
7
  6 April 2015 - 1.0.8 -> 1.0.9
2
8
  -----------
3
9
 
@@ -52,11 +52,7 @@ module Capybara
52
52
  end
53
53
 
54
54
  def self.capybara_root
55
- return @capybara_root if defined?(@capybara_root)
56
- #If the path isn't set, default to the current directory
57
- capybara_tmp_path = Capybara.save_and_open_page_path || '.'
58
-
59
- @capybara = if defined?(::Rails)
55
+ @capybara_root ||= if defined?(::Rails)
60
56
  ::Rails.root.join capybara_tmp_path
61
57
  elsif defined?(Padrino)
62
58
  Padrino.root capybara_tmp_path
@@ -91,6 +87,13 @@ module Capybara
91
87
  def self.reset_prune_history
92
88
  @pruned_previous_screenshots = nil
93
89
  end
90
+
91
+ private
92
+
93
+ # If the path isn't set, default to the current directory
94
+ def self.capybara_tmp_path
95
+ Capybara.save_and_open_page_path || '.'
96
+ end
94
97
  end
95
98
  end
96
99
 
@@ -8,13 +8,13 @@ module Capybara
8
8
 
9
9
  @strategy_proc = case strategy
10
10
  when :keep_all
11
- -> { }
11
+ lambda { }
12
12
  when :keep_last_run
13
- -> { prune_with_last_run_strategy }
13
+ lambda { prune_with_last_run_strategy }
14
14
  when Hash
15
15
  raise ArgumentError, ":keep key is required" unless strategy[:keep]
16
16
  raise ArgumentError, ":keep value must be number greater than zero" unless strategy[:keep].to_i > 0
17
- -> { prune_with_numeric_strategy(strategy[:keep].to_i) }
17
+ lambda { prune_with_numeric_strategy(strategy[:keep].to_i) }
18
18
  else
19
19
  fail "Invalid prune strategy #{strategy}. `:keep_all`or `{ keep: 10 }` are valid examples."
20
20
  end
@@ -72,6 +72,7 @@ module Capybara
72
72
  old_path = Capybara.save_and_open_page_path
73
73
  Capybara.save_and_open_page_path = nil
74
74
  yield
75
+ ensure
75
76
  Capybara.save_and_open_page_path = old_path
76
77
  end
77
78
 
@@ -1,5 +1,5 @@
1
1
  module Capybara
2
2
  module Screenshot
3
- VERSION = '1.0.9'
3
+ VERSION = '1.0.10'
4
4
  end
5
5
  end
@@ -119,6 +119,20 @@ describe Capybara::Screenshot::Saver do
119
119
  expect(saver).to_not be_html_saved
120
120
  end
121
121
 
122
+ context 'when saving a screenshot fails' do
123
+ it 'still restores the original value of Capybara.save_and_open_page_path' do
124
+ Capybara.save_and_open_page_path = 'tmp/bananas'
125
+
126
+ expect(capybara_mock).to receive(:save_page).and_raise
127
+
128
+ expect {
129
+ saver.save
130
+ }.to raise_error
131
+
132
+ expect(Capybara.save_and_open_page_path).to eq('tmp/bananas')
133
+ end
134
+ end
135
+
122
136
  describe '#output_screenshot_path' do
123
137
  let(:saver) { Capybara::Screenshot::Saver.new(capybara_mock, page_mock) }
124
138
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capybara-screenshot
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.9
4
+ version: 1.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew O'Riordan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-05 00:00:00.000000000 Z
11
+ date: 2015-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara