- Setup cucumber with rails
- Define basic features
- To test ajax response
The version for gems that are used to create the documents are,
- cucumber (1.2.0)
- cucumber-rails (1.3.0)
Setup
Cucumber-rails gem makes it easier to install cucumber in rails, but I faced some issues which I would like to document. The following is from the cucumber-rails document,
group :test do gem 'cucumber-rails', :require => false # database_cleaner is not required, but highly recommended gem 'database_cleaner' gem 'cucumber-rails-training-wheels' gem 'capybara' gem 'rspec-expectations' gem 'fabrication' #for test fixture creation endThen run,
bundle install rails generate cucumber:install
This will generate the necessary file for cucumber.
I am working on a sample cucumber project that can facilitate newbies to get started with cucumber and get to know the best practices. Any contribution is very welcome.
create config/cucumber.yml create script/cucumber chmod script/cucumber create features/step_definitions create features/support create features/support/env.rb exist lib/tasks create lib/tasks/cucumber.rakeIf you are using mongo, then it should give you a warning that you can not use 'transaction' strategy for mongo. Then you can change that to 'truncation' in your 'features/support/env.rb' file. Change the env.rb as following,
DatabaseCleaner.strategy = :truncationNow it is time to write some features to test. cucumber-rails-training-wheels gem help you with generators, so that you can generate features quickly. To generate use the command as follows,
rails generate cucumber_rails_training_wheels:feature post title:string body:text number:integer published:booleanWith this plug-in you can generate cucumber feature when you are using scaffold generator. For details please see the reference.
I am working on a sample cucumber project that can facilitate newbies to get started with cucumber and get to know the best practices. Any contribution is very welcome.
Global fixture setup and tear down
If you have some global data that is needed to be loaded for every test then you can use cucumber hooks. You can create the fixtures that you always need, for an example users for login or initialize admin global settings.Reference
- A sample working cucumber implementation
- github.com/cucumber/cucumber-rails
- github.com/cucumber/cucumber-rails-training-wheels
- watir.com/2011/01/22/simple-cucumber-watir-page-object-pattern-framework
- jitu-blog.blogspot.com/2011/12/jbehave-web-and-page-object-pattern.html
- github.com/cucumber/cucumber/wiki/Hooks
1 comment:
The content is good for newbies. It would have been even more better if there was some more content.
Post a Comment