capybara-screenshot 0.3.8 → 0.3.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,4 @@ language: ruby
2
2
  script: "bundle exec rspec"
3
3
  rvm:
4
4
  - 1.9.3
5
- - jruby-18mode # JRuby in 1.8 mode
6
- - jruby-19mode # JRuby in 1.9 mode
7
- - 1.8.7
5
+ - jruby-19mode # JRuby in 1.9 mode
data/README.md CHANGED
@@ -2,11 +2,14 @@ capybara-screenshot gem
2
2
  =======================
3
3
 
4
4
  [![Build Status](https://travis-ci.org/mattheworiordan/capybara-screenshot.png)](https://travis-ci.org/mattheworiordan/capybara-screenshot)
5
+ [![Code Climate](https://d3s6mut3hikguw.cloudfront.net/github/mattheworiordan/capybara-screenshot.png)](https://codeclimate.com/github/mattheworiordan/capybara-screenshot)
5
6
 
6
7
  Using this gem, whenever a [Capybara](https://github.com/jnicklas/capybara) test in [Cucumber](http://cukes.info/), [Rspec](https://www.relishapp.com/rspec) or Minitest fails, the HTML for the failed page and a screenshot (when using [capybara-webkit](https://github.com/thoughtbot/capybara-webkit), [Selenium](http://seleniumhq.org/) or [poltergeist](https://github.com/jonleighton/poltergeist)) is saved into $APPLICATION_ROOT/tmp/capybara.
7
8
 
8
9
  This is a huge help when trying to diagnose a problem in your failing steps as you can view the source code and potentially how the page looked at the time of the failure.
9
10
 
11
+ _Please note that Ruby 1.9 is required to use this Gem. For Ruby 1.8 support, please see the [capybara-screenshot Ruby 1.8 branch](https://github.com/mattheworiordan/capybara-screenshot/tree/ruby-1.8-support)_
12
+
10
13
  Installation
11
14
  -----
12
15
 
@@ -18,19 +18,24 @@ module Capybara
18
18
  end
19
19
 
20
20
  def save_html
21
- if Capybara::VERSION.match(/^\d+/)[0] == '1'
22
- capybara.save_page(page.body, "#{html_path}")
23
- else
24
- capybara.save_page("#{html_path}")
21
+ clear_save_and_open_page_path do
22
+ if Capybara::VERSION.match(/^\d+/)[0] == '1'
23
+ capybara.save_page(page.body, "#{html_path}")
24
+ else
25
+ capybara.save_page("#{html_path}")
26
+ end
25
27
  end
26
28
  warn "Saved file #{html_path}"
27
29
  end
28
30
 
29
31
  def save_screenshot
30
- Capybara::Screenshot.registered_drivers.fetch(capybara.current_driver) { |driver_name|
31
- warn "capybara-screenshot could not detect a screenshot driver for '#{capybara.current_driver}'. Saving with default with unknown results."
32
- Capybara::Screenshot.registered_drivers[:default]
33
- }.call(page.driver, screenshot_path)
32
+ clear_save_and_open_page_path do
33
+ Capybara.save_and_open_page_path = nil
34
+ Capybara::Screenshot.registered_drivers.fetch(capybara.current_driver) { |driver_name|
35
+ warn "capybara-screenshot could not detect a screenshot driver for '#{capybara.current_driver}'. Saving with default with unknown results."
36
+ Capybara::Screenshot.registered_drivers[:default]
37
+ }.call(page.driver, screenshot_path)
38
+ end
34
39
  end
35
40
 
36
41
  def html_path
@@ -41,6 +46,15 @@ module Capybara
41
46
  File.join(Capybara::Screenshot.capybara_root, "#{file_base_name}.png")
42
47
  end
43
48
 
49
+ # If Capybara.save_and_open_page_path is set then
50
+ # the html_path or screenshot_path will be appended to this path
51
+ # instead of replacing it
52
+ def clear_save_and_open_page_path
53
+ old_path = Capybara.save_and_open_page_path
54
+ Capybara.save_and_open_page_path = nil
55
+ yield
56
+ Capybara.save_and_open_page_path = old_path
57
+ end
44
58
  end
45
59
  end
46
60
  end
@@ -1,5 +1,5 @@
1
1
  module Capybara
2
2
  module Screenshot
3
- VERSION = "0.3.8"
3
+ VERSION = "0.3.10"
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.3.8
4
+ version: 0.3.10
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: 2013-06-25 00:00:00.000000000 Z
12
+ date: 2013-07-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capybara
@@ -107,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
107
  version: '0'
108
108
  segments:
109
109
  - 0
110
- hash: 3507128222500016468
110
+ hash: -2459750308362478257
111
111
  required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  none: false
113
113
  requirements:
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  version: '0'
117
117
  segments:
118
118
  - 0
119
- hash: 3507128222500016468
119
+ hash: -2459750308362478257
120
120
  requirements: []
121
121
  rubyforge_project: capybara-screenshot
122
122
  rubygems_version: 1.8.24