capybara-screenshot 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +6 -0
- data/lib/capybara-screenshot.rb +8 -3
- data/lib/capybara-screenshot/minitest.rb +13 -0
- data/lib/capybara-screenshot/rspec.rb +1 -1
- data/lib/capybara-screenshot/saver.rb +12 -10
- data/lib/capybara-screenshot/version.rb +1 -1
- data/lib/capybara-screenshot/world.rb +1 -1
- metadata +4 -3
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
16 November 2011
|
2
2
|
----------------
|
3
3
|
|
4
|
+
Added support for Minitest using teardown hooks
|
5
|
+
|
6
|
+
|
7
|
+
16 November 2011
|
8
|
+
----------------
|
9
|
+
|
4
10
|
Added support for RSpec by adding a RSpec configuration after hook and checking if Capybara is being used.
|
5
11
|
|
6
12
|
15 November 2011
|
data/lib/capybara-screenshot.rb
CHANGED
@@ -22,9 +22,14 @@ if defined?(RSpec)
|
|
22
22
|
require 'capybara-screenshot/rspec'
|
23
23
|
RSpec.configure do |config|
|
24
24
|
config.after do
|
25
|
-
|
26
|
-
Capybara::Screenshot::RSpec.screen_shot_and_save_page(Capybara.body)
|
27
|
-
end
|
25
|
+
Capybara::Screenshot::RSpec.screen_shot_and_save_page
|
28
26
|
end
|
29
27
|
end
|
28
|
+
end
|
29
|
+
|
30
|
+
begin
|
31
|
+
require 'minitest/unit'
|
32
|
+
require 'capybara-screenshot/minitest'
|
33
|
+
rescue
|
34
|
+
# mini test not available
|
30
35
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'capybara-screenshot/saver'
|
2
|
+
|
3
|
+
if defined?(ActionDispatch::IntegrationTest)
|
4
|
+
ActionDispatch::IntegrationTest.add_teardown_hook do |context|
|
5
|
+
# by adding the argument context, MiniTest passes the context of the test
|
6
|
+
# which has an instance variable @passed indicating success / failure
|
7
|
+
context.instance_eval do
|
8
|
+
if @passed.blank?
|
9
|
+
Capybara::Screenshot::Saver.screen_shot_and_save_page Capybara, Capybara.body
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -2,17 +2,19 @@ module Capybara
|
|
2
2
|
module Screenshot
|
3
3
|
class Saver
|
4
4
|
def self.screen_shot_and_save_page(capybara, body)
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
Rails
|
11
|
-
|
12
|
-
|
13
|
-
|
5
|
+
unless capybara.current_path.blank?
|
6
|
+
require 'capybara/util/save_and_open_page'
|
7
|
+
path = "/#{Time.now.strftime('%Y-%m-%d-%H-%M-%S')}"
|
8
|
+
capybara.save_page body, "#{path}.html"
|
9
|
+
if capybara.page.driver.respond_to?(:render)
|
10
|
+
path = if defined?(Rails)
|
11
|
+
Rails.root.join "#{capybara.save_and_open_page_path}#{path}.png"
|
12
|
+
else
|
13
|
+
# Sinatra support, untested
|
14
|
+
File.join settings.root "#{capybara.save_and_open_page_path}#{path}.png"
|
15
|
+
end
|
16
|
+
capybara.page.driver.render path
|
14
17
|
end
|
15
|
-
capybara.page.driver.render path
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capybara-screenshot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matthew O'Riordan
|
@@ -81,6 +81,7 @@ files:
|
|
81
81
|
- Rakefile
|
82
82
|
- capybara-screenshot.gemspec
|
83
83
|
- lib/capybara-screenshot.rb
|
84
|
+
- lib/capybara-screenshot/minitest.rb
|
84
85
|
- lib/capybara-screenshot/rspec.rb
|
85
86
|
- lib/capybara-screenshot/saver.rb
|
86
87
|
- lib/capybara-screenshot/version.rb
|