Module: Capybara::Screenshot
- Defined in:
- lib/capybara-screenshot.rb,
lib/capybara-screenshot/rspec.rb,
lib/capybara-screenshot/saver.rb,
lib/capybara-screenshot/version.rb,
lib/capybara-screenshot/testunit.rb,
lib/capybara-screenshot/rspec/base_reporter.rb,
lib/capybara-screenshot/rspec/text_reporter.rb,
lib/capybara-screenshot/rspec/html_link_reporter.rb,
lib/capybara-screenshot/rspec/html_embed_reporter.rb,
lib/capybara-screenshot/rspec/textmate_link_reporter.rb
Defined Under Namespace
Modules: MiniTestPlugin, RSpec, Spinach
Classes: Saver
Constant Summary
collapse
- VERSION =
"1.0.1"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.append_timestamp ⇒ Object
Returns the value of attribute append_timestamp.
7
8
9
|
# File 'lib/capybara-screenshot.rb', line 7
def append_timestamp
@append_timestamp
end
|
.autosave_on_failure ⇒ Object
Returns the value of attribute autosave_on_failure.
4
5
6
|
# File 'lib/capybara-screenshot.rb', line 4
def autosave_on_failure
@autosave_on_failure
end
|
Returns the value of attribute filename_prefix_formatters.
6
7
8
|
# File 'lib/capybara-screenshot.rb', line 6
def filename_prefix_formatters
@filename_prefix_formatters
end
|
.final_session_name ⇒ Object
74
75
76
|
# File 'lib/capybara-screenshot.rb', line 74
def self.final_session_name
@final_session_name || Capybara.session_name || :default
end
|
.registered_drivers ⇒ Object
Returns the value of attribute registered_drivers.
5
6
7
|
# File 'lib/capybara-screenshot.rb', line 5
def registered_drivers
@registered_drivers
end
|
.testunit_paths ⇒ Object
Returns the value of attribute testunit_paths.
5
6
7
|
# File 'lib/capybara-screenshot/testunit.rb', line 5
def testunit_paths
@testunit_paths
end
|
.webkit_options ⇒ Object
Returns the value of attribute webkit_options.
8
9
10
|
# File 'lib/capybara-screenshot.rb', line 8
def webkit_options
@webkit_options
end
|
Class Method Details
.append_screenshot_path=(value) ⇒ Object
18
19
20
21
22
|
# File 'lib/capybara-screenshot.rb', line 18
def self.append_screenshot_path=(value)
$stderr.puts "WARNING: Capybara::Screenshot.append_screenshot_path is deprecated. " +
"Please use Capybara::Screenshot::RSpec.add_link_to_screenshot_for_failed_examples instead."
RSpec.add_link_to_screenshot_for_failed_examples = value
end
|
.capybara_root ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/capybara-screenshot.rb', line 50
def self.capybara_root
return @capybara_root if defined?(@capybara_root)
capybara_tmp_path = Capybara.save_and_open_page_path || '.'
@capybara = if defined?(::Rails)
::Rails.root.join capybara_tmp_path
elsif defined?(Padrino)
Padrino.root capybara_tmp_path
elsif defined?(Sinatra)
File.join(Sinatra::Application.root, capybara_tmp_path)
else
capybara_tmp_path
end.to_s
end
|
.filename_prefix_for(test_type, test) ⇒ Object
44
45
46
47
48
|
# File 'lib/capybara-screenshot.rb', line 44
def self.filename_prefix_for(test_type, test)
filename_prefix_formatters.fetch(test_type) { |key|
filename_prefix_formatters[:default]
}.call(test)
end
|
.register_driver(driver, &block) ⇒ Object
66
67
68
|
# File 'lib/capybara-screenshot.rb', line 66
def self.register_driver(driver, &block)
self.registered_drivers[driver] = block
end
|
70
71
72
|
# File 'lib/capybara-screenshot.rb', line 70
def self.register_filename_prefix_formatter(test_type, &block)
self.filename_prefix_formatters[test_type] = block
end
|
.screenshot_and_open_image ⇒ Object
Also known as:
screen_shot_and_open_image
30
31
32
33
34
35
36
37
|
# File 'lib/capybara-screenshot.rb', line 30
def self.screenshot_and_open_image
require "launchy"
saver = Saver.new(Capybara, Capybara.page, false)
saver.save
Launchy.open saver.screenshot_path
{:html => nil, :image => saver.screenshot_path}
end
|
.screenshot_and_save_page ⇒ Object
Also known as:
screen_shot_and_save_page
24
25
26
27
28
|
# File 'lib/capybara-screenshot.rb', line 24
def self.screenshot_and_save_page
saver = Saver.new(Capybara, Capybara.page)
saver.save
{:html => saver.html_path, :image => saver.screenshot_path}
end
|