Permalink
Browse files

checkpoint1

  • Loading branch information...
cheezy committed Nov 19, 2010
0 parents commit 73eb796e1db0dbba19dffb7406517ad3014315b5
Showing with 95 additions and 0 deletions.
  1. +12 −0 Rakefile
  2. +2 −0 cucumber.yml
  3. +12 −0 features/Rakefile
  4. +2 −0 features/cucumber.yml
  5. +20 −0 features/support/browser.rb
  6. +2 −0 features/support/env.rb
  7. +13 −0 features/support/hooks.rb
  8. +32 −0 features/support/screenshot.rb
@@ -0,0 +1,12 @@
+$:.unshift(File.dirname(__FILE__) + '/../../lib')
+require 'cucumber/rake/task'
+
+Cucumber::Rake::Task.new do |t|
+ t.cucumber_opts = %w{--format pretty}
+end
+
+Cucumber::Rake::Task.new(:cucumber_screenshot) do |t|
+ t.cucumber_opts = %w{--format html --out report.html}
+end
+
+task :default => :cucumber
@@ -0,0 +1,2 @@
+default: --format html --out report.html --format pretty --no-source
+focus: --format html --out report.html --format pretty --no-source --tag @FOCUS
@@ -0,0 +1,12 @@
+$:.unshift(File.dirname(__FILE__) + '/../../lib')
+require 'cucumber/rake/task'
+
+Cucumber::Rake::Task.new do |t|
+ t.cucumber_opts = %w{--format pretty}
+end
+
+Cucumber::Rake::Task.new(:cucumber_screenshot) do |t|
+ t.cucumber_opts = %w{--format html --out report.html}
+end
+
+task :default => :cucumber
@@ -0,0 +1,2 @@
+default: --format html --out report.html --format pretty --no-source
+focus: --format html --out report.html --format pretty --no-source --tag @FOCUS
@@ -0,0 +1,20 @@
+if ENV['FIREWATIR']
+ require 'firewatir'
+ Browser = FireWatir::Firefox
+else
+ case RUBY_PLATFORM
+ when /darwin/
+ require 'safariwatir'
+ Browser = Watir::Safari
+ when /win32|mingw/
+ require 'watir'
+ Browser = Watir::IE
+ when /java/
+ require 'celerity'
+ Browser = Celerity::Browser
+ else
+ raise "This platform is not supported (#{PLATFORM})"
+ end
+end
+
+
@@ -0,0 +1,2 @@
+require 'spec/expectations'
+
@@ -0,0 +1,13 @@
+
+Before do
+ @browser = Browser.new
+end
+
+After do
+ @browser.close
+end
+
+
+After do | scenario|
+ embed_screenshot("screehshot=#{Time.new.to_i}") if scenario.failed?
+end
@@ -0,0 +1,32 @@
+
+module Screenshots
+
+ if Cucumber::OS_X
+ def embed_screenshot(id)
+ `screencapture -t png #{id}.png`
+ embed("#{id}.png", "image/png")
+ end
+ elsif Cucumber::WINDOWS
+ require 'watir/screen_capture'
+ require 'win32/clipboard'
+
+ include Watir::ScreenCapture
+ include Win32
+
+ def embed_screenshot(id)
+ keybd_event = API.new("keybd_event", 'IILL', 'V', 'user32')
+ keybd_event.call(VK_SNAPSHOT,0,0,0)
+ File.open("#{id}.bmp", 'wb'){ |fh|
+ fh.write Win32::Clipboard.data(Clipboard::DIB)
+ }
+ end
+ else
+ # Other platforms...
+ def embed_screenshot(id)
+ STDERR.puts "Sorry - no screenshots on your platform yet."
+ end
+ end
+end
+World(Screenshots)
+
+

0 comments on commit 73eb796

Please sign in to comment.