Blog

Showing posts with label cucumber. Show all posts
Showing posts with label cucumber. Show all posts

Saturday, March 5, 2011

Trigger Cucumber Features from Vim

I use rstakeout to automatically run my Cucumber features when a feature changes (yes I probably should be using watchr). I use the following command:

rstakeout "rake cucumber:wip" "features/**/*"

But sometimes I want to run the features manually. However, I don't want to leave my editor to do this. A mapping in Vim to trigger the run saves the day:

map <Leader>c :call system("touch features/support/env.rb")<CR>

Saturday, February 5, 2011

Cucumber Rails: undefined local variable or method `node'

I've been stung by this a couple of times so it's time to add it to my blog. This exception is raised when Cucumber follows a link using the click_link Capybara method. An example of the error:

When I follow "Add brand"                      # features/step_definitions/web_steps.rb:33
      undefined local variable or method `node' for # (NameError)
      ./features/step_definitions/web_steps.rb:35:in `block (2 levels) in '
      ./features/step_definitions/web_steps.rb:14:in `with_scope'
      ./features/step_definitions/web_steps.rb:34:in `/^(?:|I )follow "([^"]*)"(?: within "([^"]*)")?$/'
      features/manage_brand.feature:14:in `When I follow "Add brand"'

This has been report in the following places:

The solution is to either remove the following line from env.rb:

require 'cucumber/capybara-javascript-emulation'

or better yet, simply bundle the Gem from the 'master' branch. Add this to your Gemfile:

group :development, :test do
  gem 'cucumber-rails', :git => 'git://github.com/aslakhellesoy/cucumber-rails.git'
  # other gems...
end

Important Note: You must regenerate your env.rb using rails g cucumber:install otherwise you will receive the following error:

no such file to load -- cucumber/rails/active_record (LoadError)

Sunday, January 16, 2011

Minitest raising error for Cucumber generate command in Rails 3/Ruby 1.9.2

I mistaken included the "shoulda" gem in the "development" group. When generating cucumber with the following options I receive the following error:

rails g cucumber:install --capybara --rspec --spork
/Volumes/Data/Users/nicholas/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/minitest/unit.rb:566:in `block in process_args': invalid option: --capybara (OptionParser::InvalidOption)
 from /Volumes/Data/Users/nicholas/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/minitest/unit.rb:545:in `new'
 from /Volumes/Data/Users/nicholas/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/minitest/unit.rb:545:in `process_args'
 from /Volumes/Data/Users/nicholas/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/minitest/unit.rb:576:in `run'
 from /Volumes/Data/Users/nicholas/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/minitest/unit.rb:492:in `block in autorun'

Excluding "shoulda" from the "development" group (i.e. just in test) resolved the error.

References

Google Groups

Friday, January 14, 2011

Radiant, Cucumber and Globalize2 Extension

After installing the Globalize2 extension and creating Cucumber features for a dependent extension, I needed to remove the dataset class method to get features running since the models no longer matched the dataset factories:

# /Library/Ruby/Gems/1.8/gems/radiant-0.9.1/features/support/dataset.rb
require 'dataset'

Cucumber::Rails::World.class_eval do
  include Dataset
  datasets_directory "#{RADIANT_ROOT}/spec/datasets"
  self.datasets_database_dump_path = "#{Rails.root}/tmp/dataset"
 #dataset :users, :config, :pages, :layouts, :pages_with_layouts, :snippets, :users_and_pages, :file_not_found, :markup_pages
end

Please note this blog is no longer maintained. Please visit CivilCode Inc - Custom Software Development.