[rspec-users] Cucumber rake/webrat issue.
Ben Mabey
ben at benmabey.com
Mon May 18 15:08:11 EDT 2009
Matthew Van Horn wrote:
> I'm probably missing something really obvious, but I just upgraded
> cucumber, rspec/rails, and webrat on a project, and for some reason,
> cucumber is not seeing any of the webrat steps (or bmabey's email
> steps) when running from rake. It seems ok when running using the cucumb
Did you read the History on how to upgrade? If not see if it helps..
here is the pertinent info:
** IMPORTANT UPGRADE NOTES FOR RAILS USERS **
Running Cucumber features in the same Ruby interpreter as Rake doesn't
seem to work,
so you have to explicitly tell the task to fork (like it was doing by
default in prior
versions). In lib/tasks/cucumber.rake:
Cucumber::Rake::Task.new(:features) do |t|
t.fork = true # Explicitly fork
t.cucumber_opts = %w{--format pretty}
end
(If you run script/generate cucumber this will be done for you).
Alternatively you can omit forking and run features like this:
RAILS_ENV=test rake features
However, setting the RAILS_ENV is easy to forget, so I don't recommend
relying on this.
-Ben
>
> The versions are (most recent of the following):
> bmabey-email_spec (0.1.3)
> cucumber (0.3.5, 0.3.2, 0.3.0)
> rspec (1.2.6, 1.2.4)
> rspec-rails (1.2.6, 1.2.4)
> webrat (0.4.4)
>
> My env.rb looks like this:
>
> # Sets up the Rails environment for Cucumber
> ENV["RAILS_ENV"] ||= "test"
> require File.expand_path(File.dirname(__FILE__) +
> '/../../config/environment')
> require 'cucumber/rails/world'
> require 'email_spec/cucumber'
>
> require 'cucumber/formatter/unicode' # Comment out this line if you
> don't want Cucumber Unicode support
> Cucumber::Rails.use_transactional_fixtures
> Cucumber::Rails.bypass_rescue # Comment out this line if you want
> Rails own error handling
> # (e.g. rescue_action_in_public /
> rescue_responses / rescue_from)
>
> require 'webrat'
>
> Webrat.configure do |config|
> config.mode = :rails
> end
>
> require 'cucumber/rails/rspec'
> require 'webrat/core/matchers'
>
>
> Lib tasks cucumber.rake looks like:
> $LOAD_PATH.unshift(RAILS_ROOT + '/vendor/plugins/cucumber/lib') if
> File.directory?(RAILS_ROOT + '/vendor/plugins/cucumber/lib')
>
> begin
> require 'cucumber/rake/task'
>
> Cucumber::Rake::Task.new(:features) do |t|
> t.fork = true
> t.cucumber_opts = %w{--format pretty}
> end
> task :features => 'db:test:prepare'
> rescue LoadError
> desc 'Cucumber rake task not available'
> task :features do
> abort 'Cucumber rake task is not available. Be sure to install
> cucumber as a gem or plugin'
> end
> end
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
More information about the rspec-users
mailing list