Permalink
Browse files

change to work with the latest capybara-webkit

  • Loading branch information...
1 parent 632fbe0 commit 7c2c21ac0cfa4cea1df9c67a252e82bdab87f044 @eitoball eitoball committed Dec 9, 2012
Showing with 27 additions and 5 deletions.
  1. +5 −1 lib/capybara-screenshot.rb
  2. +22 −4 spec/capybara-screenshot/saver_spec.rb
@@ -82,7 +82,11 @@ def self.register_filename_prefix_formatter(test_type, &block)
end
register_driver(:webkit) do |driver, path|
- driver.render(path)
+ if driver.respond_to?(:save_screenshot)
+ driver.save_screenshot(path)
+ else
+ driver.render(path)
+ end
end
register_driver(:webkit_debug) do |driver, path|
@@ -138,10 +138,28 @@
capybara_mock.stub(:current_driver).and_return(:webkit)
end
- it 'should save driver render' do
- driver_mock.should_receive(:render).with(screenshot_path)
+ context 'has render method' do
+ before do
+ driver_mock.stub(:respond_to?).with(:'save_screenshot').and_return(false)
+ end
- saver.save
+ it 'should save driver render' do
+ driver_mock.should_receive(:render).with(screenshot_path)
+
+ saver.save
+ end
+ end
+
+ context 'has save_screenshot method' do
+ before do
+ driver_mock.stub(:respond_to?).with(:'save_screenshot').and_return(true)
+ end
+
+ it 'should save driver render' do
+ driver_mock.should_receive(:save_screenshot).with(screenshot_path)
+
+ saver.save
+ end
end
end
@@ -176,4 +194,4 @@
saver.save
end
end
-end
+end

0 comments on commit 7c2c21a

Please sign in to comment.