Forum: RSpec Cucumber rake/webrat issue.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Matthew Van Horn (Guest)
on 2009-05-18 23:05
(Received via mailing list)
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
cucumber binary.

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
Aslak H. (Guest)
on 2009-05-18 23:18
(Received via mailing list)
Hi Matthew,

Please repost to the new list:
http://www.nabble.com/-Cucumber--ANN%3A-New-Google...
Ben M. (Guest)
on 2009-05-18 23:21
(Received via mailing list)
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
Matthew Van Horn (Guest)
on 2009-05-18 23:22
(Received via mailing list)
On May 18, 2009, at 2:49 PM, 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
> cucumber binary.
>

I just wanted to add to this one other issue:
When I run:
cucumber ./features
everything is run ok (all steps are found).

However, when I run:
cucumber ./features/projects/projects.feature
or
cucumber ./features/projects
then it has the same missing steps issue as I mentioned. This also
happens with the textmate bundle, which is why it is a PITA for me.

What am I missing here?
Matthew Van Horn (Guest)
on 2009-05-19 15:41
(Received via mailing list)
On May 18, 2009, at 3:08 PM, Ben M. wrote:

>
>   t.cucumber_opts = %w{--format pretty}
>
> -Ben

I posted this on the new list, but this is what I had, and it looks
correct to me. (I re-ran the generator.)
This topic is locked and can not be replied to.