Skip to content

Commit

Permalink
Capybara extensions automagically loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
nando committed Apr 16, 2010
1 parent 66297fa commit c20518f
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -16,7 +16,7 @@ unless ARGV.any? {|a| a =~ /^gems/}
build_tasks = [:lib, :rails_generators, :en_US, :es_ES, :capybara_en_US, :capybara_es_ES]
build_tasks.each do |lang|
Cucumber::Rake::Task.new(lang) do |t|
t.cucumber_opts = "--profile #{lang} --format pretty"
t.cucumber_opts = "--profile #{lang} --format progress"
end
end

Expand Down
5 changes: 3 additions & 2 deletions cucumber.yml
Expand Up @@ -3,5 +3,6 @@ es_ES: --require features/support/env.rb --require features/step_definitions/es_
en_US: --require features/support/env.rb --require features/step_definitions/en_US.rb features/en_US/
rails_generators: -r features/support/rails_generators_env.rb -r features/step_definitions/rails_generators_steps.rb features/rails_generators/

capybara_es_ES: --require features/support/capybara/env.rb --require features/step_definitions/es_ES.rb features/es_ES/
capybara_en_US: --require features/support/capybara/env.rb --require features/step_definitions/en_US.rb features/en_US/
capybara_es_ES: --require features/support/capybara_env.rb --require features/step_definitions/es_ES.rb features/es_ES/
capybara_en_US: --require features/support/capybara_env.rb --require features/step_definitions/en_US.rb features/en_US/
bad_env: --require features/support/bad_env.rb --require features/step_definitions/es_ES.rb features/es_ES/
24 changes: 24 additions & 0 deletions features/support/bad_env.rb
@@ -0,0 +1,24 @@
# Sets up the Rails environment for Cucumber
ENV["RAILS_ENV"] ||= "cucumber"
require File.expand_path(File.dirname(__FILE__) + '/app/config/environment')

require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
require 'cucumber/rails/world'
require 'cucumber/rails/rspec'
require 'cucumber/rails/active_record'
require 'cucumber/web/tableish'


# Whether or not to allow Rails to rescue errors and render them on
# an error page. Default is false, which will cause an error to be
# raised.
#
# If you leave this to false, you can turn on Rails rescuing on a
# per-scenario basis, simply tagging it with @allow-rescue
ActionController::Base.allow_rescue = false

# Whether or not to run each scenario within a database transaction.
#
# If you leave this to true, you can turn off traqnsactions on a
# per-scenario basis, simply tagging it with @no-txn
Cucumber::Rails::World.use_transactional_fixtures = true
6 changes: 2 additions & 4 deletions features/support/capybara_env.rb
@@ -1,6 +1,6 @@
# Sets up the Rails environment for Cucumber
ENV["RAILS_ENV"] ||= "cucumber"
require File.expand_path(File.dirname(__FILE__) + '/../app/config/environment')
require File.expand_path(File.dirname(__FILE__) + '/app/config/environment')

require 'ruby-debug'

Expand All @@ -20,8 +20,6 @@
# steps to use the XPath syntax.
Capybara.default_selector = :css

require File.expand_path(File.dirname(__FILE__) + '/capextensions')

# Whether or not to allow Rails to rescue errors and render them on
# an error page. Default is false, which will cause an error to be
# raised.
Expand All @@ -44,4 +42,4 @@
DatabaseCleaner.strategy = :truncation
rescue LoadError => ignore_if_database_cleaner_not_present
end
end
end
8 changes: 8 additions & 0 deletions lib/mundo_pepino.rb
Expand Up @@ -11,6 +11,14 @@

require 'string-mapper'

if defined?(Capybara)
require 'mundo_pepino/capybara/extensions'
else
unless defined?(Webrat)
raise "MundoPepino depends on Capybara or Webrat. Please load any of them and try again. Thanks!"
end
end

World(MundoPepino)

module MundoPepino
Expand Down

0 comments on commit c20518f

Please sign in to comment.