Skip to content

Instantly share code, notes, and snippets.

@tomtt
Created April 2, 2009 19:44
Show Gist options
  • Save tomtt/89387 to your computer and use it in GitHub Desktop.
Save tomtt/89387 to your computer and use it in GitHub Desktop.
# formatter:
module OptionsGetterSetter
attr_accessor :options
end
module Cucumber
module Formatter
class ScreenShots < Ast::Visitor
def initialize(step_mother, io, options)
super(step_mother)
@trac_numbers_generated = {}
@feature_statistics = {}
options[:screen_shots_directory] =
@screenshots_directory = File.expand_path(File.join(RAILS_ROOT,
'public',
'screenshots',
Time.now.to_s(:number)))
FileUtils.mkdir_p(@screenshots_directory)
World { |world| world.options = options }
end
def visit_features(features)
super
puts "Screenshots created in %s" % @screenshots_directory
end
end
end
end
World do |world|
world.extend OptionsGetterSetter
world
end
# Running it:
>: ./script/cucumber features/screenshot_test.feature -f Cucumber::Formatter::ScreenShots
./features/support/formatter_shared.rb:13: warning: already initialized constant STAGES
Error creating formatter: Cucumber::Formatter::ScreenShots
undefined method `World' for #<Cucumber::Formatter::ScreenShots:0x3811390> (NoMethodError)
./features/support/screenshots_formatter.rb:18:in `initialize'
/opt/local/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/cli/configuration.rb:208:in `new'
/opt/local/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/cli/configuration.rb:208:in `build_formatter_broadcaster'
/opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `map'
/opt/local/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/cli/configuration.rb:197:in `each'
/opt/local/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/cli/configuration.rb:197:in `map'
/opt/local/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/cli/configuration.rb:197:in `build_formatter_broadcaster'
/opt/local/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/cli/main.rb:39:in `execute!'
/opt/local/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/cli/main.rb:20:in `execute'
/opt/local/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/cucumber:6
/opt/local/bin/cucumber:19:in `load'
/opt/local/bin/cucumber:19
./script/cucumber:7:in `load'
./script/cucumber:7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment