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.
@@ -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
@@ -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
- unless Capybara.current_path.blank?
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
@@ -3,7 +3,7 @@ require 'capybara-screenshot/saver'
3
3
  module Capybara
4
4
  module Screenshot
5
5
  class RSpec
6
- def self.screen_shot_and_save_page(body)
6
+ def self.screen_shot_and_save_page
7
7
  Capybara::Screenshot::Saver.screen_shot_and_save_page Capybara, Capybara.body
8
8
  end
9
9
  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
- require 'capybara/util/save_and_open_page'
6
- path = "/#{Time.now.strftime('%Y-%m-%d-%H-%M-%S')}"
7
- capybara.save_page body, "#{path}.html"
8
- if capybara.page.driver.respond_to?(:render)
9
- path = if defined?(Rails)
10
- Rails.root.join "#{capybara.save_and_open_page_path}#{path}.png"
11
- else
12
- # Sinatra support, untested
13
- File.join settings.root "#{capybara.save_and_open_page_path}#{path}.png"
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
@@ -1,5 +1,5 @@
1
1
  module Capybara
2
2
  module Screenshot
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
@@ -4,7 +4,7 @@ module Capybara
4
4
  module Screenshot
5
5
  module World
6
6
  def screen_shot_and_save_page
7
- Capybara::Screenshot::Saver.screen_shot_and_save_page Capybara, body
7
+ Capybara::Screenshot::Saver.screen_shot_and_save_page Capybara, Capybara.body
8
8
  end
9
9
  end
10
10
  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: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
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