Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed tests so they pass in Rails 4 and updated gemspec. #247

Merged
merged 6 commits into from
Apr 2, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,18 @@ appraise "capybara_1_1" do
gem 'bson_ext'
gem 'mongoid'
end

appraise "rails_4_0" do
gem "rails", "~> 4.0.0.beta1"
gem "railties", "~> 4.0.0.beta1"
gem "capybara", "~> 2.0.2"
gem 'turn'
gem 'rspec-rails'
gem 'sass-rails', "~> 4.0.0.beta1"
gem 'coffee-rails', "~> 4.0.0.beta1"
gem 'uglifier'
gem 'jquery-rails'
gem 'sqlite3'
gem 'bson_ext'
gem 'mongoid'
end
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source "https://rubygems.org"
# Test dependencies for Rails in the default test task, as test-generated
# apps do not run bundler for speed reasons. Kept here so they can be
# excluded from Appraisal-generated gemfiles.
gem 'rails', '~> 3.2.12'
gem 'rails'
gem 'turn'
gem 'rspec-rails'
gem 'sass-rails'
Expand Down
4 changes: 2 additions & 2 deletions cucumber-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency('cucumber', '>= 1.2.0')
s.add_runtime_dependency('nokogiri', '>= 1.5.0')
s.add_runtime_dependency('capybara', '>= 1.1.2')
s.add_runtime_dependency('rails', '~> 3.0')
s.add_runtime_dependency('rails', '>= 3.0.0')

# Main development dependencies
s.add_development_dependency('rake', '>= 0.9.2.2')
Expand All @@ -22,7 +22,7 @@ Gem::Specification.new do |s|
s.add_development_dependency('rspec', '~> 2.10.0')
s.add_development_dependency('ammeter', '>= 0.2.5')
s.add_development_dependency('factory_girl', '>= 3.2.0')
s.add_development_dependency('database_cleaner', '>= 0.7.2')
s.add_development_dependency('database_cleaner', '>= 1.0.0.RC1')
s.add_development_dependency('appraisal', '~> 0.5.1')

# For Documentation:
Expand Down
6 changes: 3 additions & 3 deletions features/allow_rescue.feature
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Feature: Allow Cucumber to rescue exceptions

Background: A controller that raises an exception
Given I have created a new Rails 3 app "rails-3-app" and installed cucumber-rails
Given I have created a new Rails app "rails-app" and installed cucumber-rails
And I write to "app/controllers/posts_controller.rb" with:
"""
class PostsController < ApplicationController
Expand All @@ -12,11 +12,11 @@ Feature: Allow Cucumber to rescue exceptions
"""
And I write to "config/routes.rb" with:
"""
Rails3App::Application.routes.draw do
RailsApp::Application.routes.draw do
resources :posts
end
"""

Scenario: Allow rescue
Given I write to "features/posts.feature" with:
"""
Expand Down
4 changes: 2 additions & 2 deletions features/capybara_javascript_drivers.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Feature: Capybara Javascript Drivers

Background: A simple calendar app
Given I have created a new Rails 3 app and installed cucumber-rails
Given I have created a new Rails app and installed cucumber-rails
And I successfully run `bundle exec rails g scaffold appointment name:string when:datetime`
And I write to "features/step_definitions/date_time_steps.rb" with:
"""
Expand All @@ -18,7 +18,7 @@ Feature: Capybara Javascript Drivers
select_datetime(datetime, :from => selector)
end
"""

Scenario: Use a particular driver
Given I write to "features/create_appointment.feature" with:
"""
Expand Down
5 changes: 3 additions & 2 deletions features/choose_javascript_database_strategy.feature
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ Feature: Choose javascript database strategy
has been reported by some Oracle users.

Background:
Given I have created a new Rails 3 app and installed cucumber-rails
Given I have created a new Rails app and installed cucumber-rails
And I have a "Widget" ActiveRecord model object

Scenario: Set the strategy to truncation and run a javascript scenario.
Given I append to "features/env.rb" with:
"""
Expand Down Expand Up @@ -110,6 +110,7 @@ Feature: Choose javascript database strategy
2 scenarios (2 passed)
5 steps (5 passed)
"""

Scenario: Set the strategy to truncation with an except option and run a javascript scenario.
Given I append to "features/env.rb" with:
"""
Expand Down
2 changes: 1 addition & 1 deletion features/database_cleaner.feature
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Feature: DatabaseCleaner

Scenario: Create records in background
Given I have created a new Rails 3 app and installed cucumber-rails
Given I have created a new Rails app and installed cucumber-rails
And I write to "features/widgets.feature" with:
"""
Feature: Create widgets
Expand Down
2 changes: 1 addition & 1 deletion features/disable_automatic_database_cleaning.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Feature: Disable automatic database cleaning
control the invocation of database_cleaner explicitly.

Scenario: Disabling automatic cleaning
Given I have created a new Rails 3 app and installed cucumber-rails
Given I have created a new Rails app and installed cucumber-rails
And I append to "features/env.rb" with:
"""
Cucumber::Rails::Database.autorun_database_cleaner = false
Expand Down
4 changes: 2 additions & 2 deletions features/emulate_javascript.feature
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Feature: Emulate Javascript

Scenario: See a widget
Given I have created a new Rails 3 app and installed cucumber-rails
Given I have created a new Rails app and installed cucumber-rails
And I successfully run `rails generate scaffold widget name:string`
And I write to "features/f.feature" with:
"""
Expand Down Expand Up @@ -35,7 +35,7 @@ Feature: Emulate Javascript
"""

Scenario: Pass on the CSRF token
Given I have created a new Rails 3 app and installed cucumber-rails
Given I have created a new Rails app and installed cucumber-rails
And I successfully run `rails generate scaffold widget name:string`
And I successfully run `sed -i -e 's/forgery_protection *= false/forgery_protection = true/' config/environments/test.rb`
And I successfully run `rails generate controller session establish`
Expand Down
19 changes: 18 additions & 1 deletion features/fixing_bundler_pre.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,25 @@ Feature: Fixing Bundler Pre

@bundler-pre
Scenario: Install Cucumber-Rails with bundler prerelease
Given I have created a new Rails 3 app and installed cucumber-rails, accidentally outside of the test group in my Gemfile
Given I have created a new Rails app and installed cucumber-rails, accidentally outside of the test group in my Gemfile
And I successfully run `rake db:migrate`
And I write to "app/controllers/home_controller.rb" with:
"""
class HomeController < ActionController::Base
def index
end
end
"""
And I write to "config/routes.rb" with:
"""
TestApp::Application.routes.draw do
root to: 'home#index'
end
"""
And I write to "app/views/home/index.html.erb" with:
"""
h1 Test App
"""
And I write to "features/tests.feature" with:
"""
Feature: Tests
Expand Down
6 changes: 3 additions & 3 deletions features/install_cucumber_rails.feature
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Feature: Rails 3
Feature: Rails
In order to take over the world
Cucumber-Rails should work on major versions
of Rails 3 and Ruby, with Capybara, Spork and DatabaseCleaner
of Rails and Ruby, with Capybara, Spork and DatabaseCleaner

Scenario: Install Cucumber-Rails
Given I have created a new Rails 3 app and installed cucumber-rails
Given I have created a new Rails app and installed cucumber-rails
Then the following files should exist:
| config/cucumber.yml |
| script/cucumber |
Expand Down
25 changes: 21 additions & 4 deletions features/mongoid.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ Feature: Mongoid
"""
gem "cucumber-rails", :group => :test, :path => '../../..'
gem "capybara", :group => :test
gem "database_cleaner", :group => :test
gem "mongoid", :group => :test
gem "database_cleaner", ">= 1.0.0.RC1", :group => :test
gem "mongoid", git: "git://github.com/mongoid/mongoid.git", :group => :test
gem "bson_ext", :group => :test

"""
And I successfully run `bundle install`
And I successfully run `bundle exec rails generate cucumber:install --skip-database`
And I successfully run `bundle exec rails generate mongoid:config`
And I write to "features/tests.feature" with:
Expand All @@ -23,6 +24,23 @@ Feature: Mongoid
Scenario: Tests
When I go to the home page
"""
And I write to "app/controllers/home_controller.rb" with:
"""
class HomeController < ActionController::Base
def index
end
end
"""
And I write to "config/routes.rb" with:
"""
CukeApp::Application.routes.draw do
root to: 'home#index'
end
"""
And I write to "app/views/home/index.html.erb" with:
"""
h1 Test App
"""
And I write to "features/step_definitions/web_steps.rb" with:
"""
When /^I go to the home page$/ do
Expand All @@ -32,8 +50,7 @@ Feature: Mongoid
And I overwrite "features/support/env.rb" with:
"""
require 'cucumber/rails'
DatabaseCleaner.orm = 'mongoid'
DatabaseCleaner.strategy = :truncation
DatabaseCleaner[:mongoid].strategy = :truncation
"""
And I run `bundle exec rake cucumber`
Then it should pass with:
Expand Down
11 changes: 4 additions & 7 deletions features/multiple_databases.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Feature: Multiple Databases
As an engineer
I want to specify explicit strategies for each

Background: A Rails 3 app utilizing multiple database repositories exists
Given I have created a new Rails 3 app and installed cucumber-rails
Background: A Rails app utilizing multiple database repositories exists
Given I have created a new Rails app and installed cucumber-rails
And I append to "config/database.yml" with:
"""

Expand All @@ -15,9 +15,7 @@ Feature: Multiple Databases
And I write to "app/models/bear.rb" with:
"""
class Bear < ActiveRecord::Base
establish_connection "ursidae"

attr_accessible :name
establish_connection :ursidae
end
"""
And a directory named "db/migrate"
Expand All @@ -40,7 +38,7 @@ Feature: Multiple Databases
"""
require 'cucumber/rails'
DatabaseCleaner.strategy = :transaction
DatabaseCleaner[:active_record, {:connection => "ursidae"}].strategy = :truncation
DatabaseCleaner[:active_record, {:connection => :ursidae }].strategy = :truncation
"""
And I write to "features/create_bear.feature" with:
"""
Expand All @@ -58,7 +56,6 @@ Feature: Multiple Databases
Bear.transaction { Bear.find_by_name("yogi").lock! }
end
"""

Scenario: Default transactional strategy is not attempted on second database
When I run `bundle exec rake cucumber FEATURE=features/create_bear.feature`
Then it should pass with:
Expand Down
3 changes: 1 addition & 2 deletions features/no_database.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ Feature: No Database
Allow Cucumber to work with a Rails app without a database

Scenario: No ActiveRecord and DatabaseCleaner
Given I have created a new Rails 3 app with no database and installed cucumber-rails
Given I have created a new Rails app with no database and installed cucumber-rails
# Turn off ActiveRecord
And I write to "config/application.rb" with:
"""
require File.expand_path('../boot', __FILE__)

require 'action_controller/railtie'
require 'action_mailer/railtie'
require 'active_resource/railtie'
require 'rails/test_unit/railtie'

Bundler.require(:default, Rails.env) if defined?(Bundler)
Expand Down
2 changes: 1 addition & 1 deletion features/rerun_profile.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Feature: Rerun profile
I want to rerun only failing features

Scenario: Rerun
Given I have created a new Rails 3 app and installed cucumber-rails
Given I have created a new Rails app and installed cucumber-rails
And a file named "rerun.txt" with:
"""
features/rerun_test.feature:2
Expand Down
4 changes: 2 additions & 2 deletions features/rest_api.feature
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Feature: REST API

Scenario: Compare JSON
Given I have created a new Rails 3 app "rails-3-app" and installed cucumber-rails
Given I have created a new Rails app "rails-app" and installed cucumber-rails
And I write to "app/controllers/posts_controller.rb" with:
"""
class PostsController < ApplicationController
Expand All @@ -12,7 +12,7 @@ Feature: REST API
"""
And I write to "config/routes.rb" with:
"""
Rails3App::Application.routes.draw do
RailsApp::Application.routes.draw do
resources :posts
end
"""
Expand Down
3 changes: 1 addition & 2 deletions features/routing.feature
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Feature: Routing

Scenario: Visit undefined route
Given I have created a new Rails 3 app with no database and installed cucumber-rails
And I remove the file "public/index.html"
Given I have created a new Rails app with no database and installed cucumber-rails
And I write to "features/tests.feature" with:
"""
Feature: Tests
Expand Down
11 changes: 6 additions & 5 deletions features/step_definitions/cucumber_rails_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ def install_cucumber_rails(*options)
end
gem "capybara", :group => :test
gem "rspec-rails", :group => :test
gem "database_cleaner", :group => :test unless options.include?(:no_database_cleaner)
gem "database_cleaner", { git: "git://github.com/davebrace/database_cleaner.git", :group => :test } unless options.include?(:no_database_cleaner)
gem 'factory_girl', :group => :test unless options.include?(:no_factory_girl)
run_simple 'bundle install'
run_simple 'bundle exec rails generate cucumber:install'
end

Expand All @@ -37,28 +38,28 @@ def fixture(path)
end
World(CucumberRailsHelper)

Given /^I have created a new Rails 3 app and installed cucumber\-rails, accidentally outside of the test group in my Gemfile$/ do
Given /^I have created a new Rails app and installed cucumber\-rails, accidentally outside of the test group in my Gemfile$/ do
rails_new
install_cucumber_rails :not_in_test_group
create_web_steps
prepare_aruba_report
end

Given /^I have created a new Rails 3 app "([^"]*)" and installed cucumber\-rails$/ do |app_name|
Given /^I have created a new Rails app "([^"]*)" and installed cucumber\-rails$/ do |app_name|
rails_new :name => app_name
install_cucumber_rails
create_web_steps
prepare_aruba_report
end

Given /^I have created a new Rails 3 app and installed cucumber\-rails$/ do
Given /^I have created a new Rails app and installed cucumber\-rails$/ do
rails_new
install_cucumber_rails
create_web_steps
prepare_aruba_report
end

Given /^I have created a new Rails 3 app with no database and installed cucumber-rails$/ do
Given /^I have created a new Rails app with no database and installed cucumber-rails$/ do
rails_new :args => '--skip-active-record'
install_cucumber_rails :no_database_cleaner, :no_factory_girl
overwrite_file('features/support/env.rb', "require 'cucumber/rails'\n")
Expand Down
2 changes: 2 additions & 0 deletions gemfiles/rails_3_0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

source "https://rubygems.org"

gem "sass-rails"
gem "coffee-rails"
gem "rails", "~> 3.0.20"
gem "capybara", "~> 2.0.2"
gem "turn"
Expand Down
18 changes: 18 additions & 0 deletions gemfiles/rails_4_0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", "~> 4.0.0.beta1"
gem "railties", "~> 4.0.0.beta1"
gem "capybara", "~> 2.0.2"
gem "turn"
gem "rspec-rails"
gem "sass-rails", "~> 4.0.0.beta1"
gem "coffee-rails", "~> 4.0.0.beta1"
gem "uglifier"
gem "jquery-rails"
gem "sqlite3"
gem "bson_ext"
gem "mongoid"

gemspec :path=>"../"