Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/msassak/cucumber-rails
Browse files Browse the repository at this point in the history
  • Loading branch information
aslakhellesoy committed May 3, 2010
2 parents 1c7d2f6 + f824889 commit abbb759
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 4 deletions.
1 change: 1 addition & 0 deletions History.txt
@@ -1,6 +1,7 @@
== In Git

== New features
* Relegate rerun to its own profile and rake task (Mike Sassak)
* Added new Then /^(?:|I )should see JSON:$/ step definition to Capybara - useful for REST. (Aslak Hellesøy)
* The #tableish method now understands tables with colspan and rowspan
* Support RSpec 2 (Johan Kiviniemi, Aslak Hellesøy, Rolf Bjaanes)
Expand Down
4 changes: 2 additions & 2 deletions features/rails3.feature
Expand Up @@ -19,7 +19,7 @@ Feature: Rails 3
"""
And I cd to "rails-3-app"
And I symlink this repo to "vendor/plugins/cucumber-rails"
When I successfully run "rails generate cucumber:skeleton"
When I successfully run "rails generate cucumber:skeleton --capybara"
Then the following files should exist:
| config/cucumber.yml |
| script/cucumber |
Expand All @@ -41,7 +41,7 @@ Feature: Rails 3
And I successfully run "rails rails-3-app"
And I cd to "rails-3-app"
And I symlink this repo to "vendor/plugins/cucumber-rails"
And I successfully run "rails generate cucumber:skeleton"
And I successfully run "rails generate cucumber:skeleton --capybara"
And I successfully run "rails generate cucumber:feature post title:string body:text published:boolean"
And I successfully run "rails generate scaffold post title:string body:text published:boolean"
And I append to "Gemfile" with:
Expand Down
38 changes: 38 additions & 0 deletions features/rerun_profile.feature
@@ -0,0 +1,38 @@
Feature: Rerun profile
In order to concentrate on failing features
As a Rails developer working with Cucumber
I want to rerun only failing features

Scenario: Rerun
Given I have created a new Rails 2 app "rails-2-app" with cucumber-rails support
And a file named "rerun.txt" with:
"""
features/rerun_test.feature:2
"""
And a file named "features/rerun_test.feature" with:
"""
Feature: Rerun test
Scenario: failing before
Given fixed now
Scenario: always passing
Given passing
"""
And a file named "features/step_definitions/rerun_steps.rb" with:
"""
Given /fixed now/ do
puts "All fixed now"
end
Given /passing/ do
puts "I've always been passing"
end
"""
When I successfully run "rake cucumber:rerun"
Then it should pass with:
"""
1 scenario (1 passed)
1 step (1 passed)
"""
And the file "rerun.txt" should not contain "features/rerun_test.feature:2"

23 changes: 23 additions & 0 deletions features/step_definitions/cucumber_rails_steps.rb
Expand Up @@ -5,3 +5,26 @@
FileUtils.ln_s(source, target)
end
end

Given /^I have created a new Rails 2 app "([^\"]*)" with cucumber\-rails support$/ do |app_name|
steps %Q{
Given I am using rvm "1.8.7"
And I am using rvm gemset "cucumber-rails-2.3.5" with Gemfile:
"""
gem 'rails', '2.3.5'
gem 'sqlite3-ruby', '1.2.5'
gem 'capybara', '0.3.6'
gem 'webrat'
gem 'rspec-rails'
gem 'cucumber'
gem 'database_cleaner'
gem 'culerity'
gem 'celerity'
"""
And I successfully run "rails #{app_name}"
And I cd to "#{app_name}"
And I symlink this repo to "vendor/plugins/cucumber-rails"
And I successfully run "ruby script/generate cucumber --capybara"
And I successfully run "rake db:migrate"
}
end
5 changes: 3 additions & 2 deletions templates/skeleton/config/cucumber.yml.erb
@@ -1,7 +1,8 @@
<%%
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
rerun_opts = rerun.to_s.strip.empty? ? "--format progress features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
std_opts = "#{rerun_opts} --format rerun --out rerun.txt --strict --tags ~@wip"
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --tags ~@wip"
%>
default: <%= spork? ? '--drb ' : '' %><%%= std_opts %>
default: <%= spork? ? '--drb ' : '' %><%%= std_opts %> features
wip: <%= spork? ? '--drb ' : '' %>--tags @wip:3 --wip features
rerun: <%= spork? ? '--drb ' : '' %><%%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
6 changes: 6 additions & 0 deletions templates/skeleton/tasks/cucumber.rake.erb
Expand Up @@ -21,6 +21,12 @@ begin
t.profile = 'wip'
end

Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t|
t.binary = vendored_cucumber_bin
t.fork = true # You may get faster startup if you set this to false
t.profile = 'rerun'
end

desc 'Run all features'
task :all => [:ok, :wip]
end
Expand Down

0 comments on commit abbb759

Please sign in to comment.