Skip to content

Commit

Permalink
Merge pull request cucumber#171 from chaffeqa/bundler-pre-bug
Browse files Browse the repository at this point in the history
Bundler pre bug
  • Loading branch information
aslakhellesoy committed Sep 23, 2011
2 parents 1e65994 + 223db4d commit c23d391
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 19 deletions.
28 changes: 28 additions & 0 deletions features/fixing_bundler_pre.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Feature: Fixing Bundler Pre
In order to keep fix a problem with bundler and rails
As a user with cucumber-rails outside of test group in my Gemfile
I want run features without errors


Scenario: Install Cucumber-Rails with bundler prerelease
Given I am using bundler prerelease
And I have created a new Rails 3 app "rails-3-app" with cucumber-rails support and cucumber-rails is outside of test group
And I successfully run `rake db:migrate`
And I write to "features/tests.feature" with:
"""
Feature: Tests
Scenario: Tests
When I go to the home page
"""
And I run `bundle exec rake cucumber`
Then it should pass with:
"""
1 scenario (1 passed)
1 step (1 passed)
"""
And the output should contain "WARNING:"

Scenario: Teardown
Given I am using stable bundler


39 changes: 39 additions & 0 deletions features/step_definitions/cucumber_rails_steps.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,42 @@
Given /^I have created a new Rails 3 app "([^"]*)" with cucumber\-rails support and cucumber-rails is outside of test group$/ do |app_name|
steps %Q{
When I successfully run `rails new #{app_name}`
Then it should pass with:
"""
README
"""
And I cd to "#{app_name}"
And I append to "Gemfile" with:
"""
gem "cucumber-rails", :path => "../../.."
gem "capybara", :group => :test
gem "rspec-rails", :group => :test
gem "database_cleaner", :group => :test
gem 'factory_girl', :group => :test
"""
And I successfully run `bundle exec rails generate cucumber:install`
}
if(ENV['ARUBA_REPORT_DIR'])
@aruba_report_start = Time.new
sleep(1)
end
end

Given /^I am using bundler prerelease$/ do
steps %Q{
Given I successfully run `gem uninstall bundler`
And I successfully run `gem install bundler --pre`
}
end

Given /^I am using stable bundler$/ do
steps %Q{
Given I successfully run `gem uninstall bundler`
And I successfully run `gem install bundler`
}
end

Given /^I have created a new Rails 3 app "([^"]*)" with cucumber\-rails support$/ do |app_name|
steps %Q{
When I successfully run `rails new #{app_name}`
Expand Down
44 changes: 25 additions & 19 deletions lib/cucumber/rails.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
require 'rails'
require 'cucumber/rails/application'
ENV["RAILS_ENV"] ||= "test"
ENV["RAILS_ROOT"] ||= File.expand_path(File.dirname(caller.detect{|f| f =~ /\/env\.rb:/}) + '/../..')
require File.expand_path(ENV["RAILS_ROOT"] + '/config/environment')
require 'cucumber/rails/action_controller'
env_caller = File.dirname(caller.detect{|f| f =~ /\/env\.rb:/}) if caller.detect{|f| f =~ /\/env\.rb:/}
if env_caller
require 'rails'
require 'cucumber/rails/application'
ENV["RAILS_ENV"] ||= "test"
ENV["RAILS_ROOT"] ||= File.expand_path(env_caller + "/../..")
require File.expand_path(ENV["RAILS_ROOT"] + '/config/environment')
require 'cucumber/rails/action_controller'

if defined?(ActiveRecord::Base)
require 'rails/test_help'
else
require 'action_dispatch/testing/test_process'
require 'action_dispatch/testing/integration'
end
if defined?(ActiveRecord::Base)
require 'rails/test_help'
else
require 'action_dispatch/testing/test_process'
require 'action_dispatch/testing/integration'
end

if !Rails.application.config.cache_classes
warn "WARNING: You have set Rails' config.cache_classes to false (most likely in config/environments/cucumber.rb). This setting is known to cause problems with database transactions. Set config.cache_classes to true if you want to use transactions. For more information see https://rspec.lighthouseapp.com/projects/16211/tickets/165."
end
if !Rails.application.config.cache_classes
warn "WARNING: You have set Rails' config.cache_classes to false (most likely in config/environments/cucumber.rb). This setting is known to cause problems with database transactions. Set config.cache_classes to true if you want to use transactions. For more information see https://rspec.lighthouseapp.com/projects/16211/tickets/165."
end

require 'cucumber/rails/world'
require 'cucumber/rails/hooks'
require 'cucumber/rails/capybara'
require 'cucumber/rails/world'
require 'cucumber/rails/hooks'
require 'cucumber/rails/capybara'

require 'cucumber/web/tableish'
require 'cucumber/web/tableish'
else
warn "WARNING: Cucumber-rails required outside of env.rb. The rest of loading is being defered until env.rb is called.
To avoid this warning, move 'gem cucumber-rails' under only group :test in your Gemfile"
end

0 comments on commit c23d391

Please sign in to comment.