Skip to content

Commit

Permalink
Use bundler to manage dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
timcharper committed Jul 9, 2010
1 parent f6dfcac commit 9e70852
Show file tree
Hide file tree
Showing 15 changed files with 319 additions and 79 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ pkg
tmp/
*.project
ext/Rakefile
.bundle
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source :gemcutter
gem 'cucumber', '0.7.3'
gem 'gherkin', '1.0.27'
gem 'rspec', '1.3.0'
gem 'rake'
gem 'ruby-debug'
53 changes: 53 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
dependencies:
ruby-debug:
group:
- :default
version: ">= 0"
rake:
group:
- :default
version: ">= 0"
rspec:
group:
- :default
version: = 1.3.0
gherkin:
group:
- :default
version: = 1.0.27
cucumber:
group:
- :default
version: = 0.7.3
specs:
- rake:
version: 0.8.7
- builder:
version: 2.1.2
- columnize:
version: 0.3.1
- diff-lcs:
version: 1.1.2
- trollop:
version: 1.16.2
- gherkin:
version: 1.0.27
- json_pure:
version: 1.4.3
- term-ansicolor:
version: 1.0.5
- cucumber:
version: 0.7.3
- linecache:
version: "0.43"
- rspec:
version: 1.3.0
- ruby-debug-base:
version: 0.10.3
- ruby-debug:
version: 0.10.3
hash: c24e72c551f001f4324870a5572c500748ab2ee2
sources:
- Rubygems:
uri: http://gemcutter.org
26 changes: 26 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,32 @@ Use this as a guideline when "Sporking" your features/support/env.rb file

http://gist.github.com/123370

== Running the Spork test suite

If you wish to hack on spork, you will want to run the automated test suite to make sure your changes don't break anything. Spork uses bundler to manage and install dependencies. To start:

bundle install

Then, to run the specs:

bundle exec spec spec/

(or, alternatively...)

bundle exec rake

=== running features ===

Basically, like this:

bundle exec cucumber features

If you wish to test with another Gemfile:

GEMFILE=rails2.3 bundle exec cucumber features

Where rails2.3 is one of support/gemfiles/* (rails2.3 is the default)

== Some potential issues and ways to overcome them:

See http://wiki.github.com/timcharper/spork/troubleshooting
Expand Down
119 changes: 66 additions & 53 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
require 'rubygems'
require 'bundler'
Bundler.setup
require 'rake'

require 'spec/rake/spectask'
Expand Down Expand Up @@ -34,58 +36,69 @@ Rake::RDocTask.new do |rdoc|
rdoc.rdoc_files.include('lib/**/*.rb')
end

desc "Test all supported versions of rails"
task :test_rails do
FAIL_MSG = "!! FAIL !!"
OK_MSG = "OK"
UNSUPPORTED_MSG = "Unsupported"
rails_gems = `gem list rails`.grep(/^rails\b/).first
versions = rails_gems.scan(/\((.+)\)/).flatten.first.split(", ")
versions_2_x_gems = versions.grep(/^2/)
results = {}
versions_2_x_gems.each do |version|
if version < '2.0.5'
puts "-----------------------------------------------------"
puts "Rails #{version} is not officially supported by Spork"
puts "Why? http://www.nabble.com/rspec-rails-fails-to-find-a-controller-name-td23223425.html"
puts "-----------------------------------------------------"
results[version] = UNSUPPORTED_MSG
next
end


puts "Testing version #{version}"
pid = Kernel.fork do
test_files = %w[features/rspec_rails_integration.feature features/rails_delayed_loading_workarounds.feature]

unless version < '2.1'
# pending a fix, the following error happens with rails 2.0:
# /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.3.11/lib/cucumber/rails/world.rb:41:in `use_transactional_fixtures': undefined method `configuration' for Rails:Module (NoMethodError)
test_files << "features/cucumber_rails_integration.feature "
end
exec("env RAILS_VERSION=#{version} cucumber #{test_files * ' '}; echo $? > result")
end
Process.waitpid(pid)
result = File.read('result').chomp
FileUtils.rm('result')
if result=='0'
results[version] = OK_MSG
else
results[version] = FAIL_MSG
end
end

puts "Results:"
File.open("TESTED_RAILS_VERSIONS.txt", 'wb') do |f|
results.keys.sort.each do |version|
s = "#{version}:\t#{results[version]}"
f.puts(s)
puts(s)
end
end
if results.values.any? { |r| r == FAIL_MSG }
exit 1
else
exit 0

desc "Install gem bundles used for tests"
task :install_bundles do
load File.expand_path("features/support/bundler_helpers.rb", File.dirname(__FILE__))
Dir["features/gemfiles/*"].each do |gemfile_dir|
BundlerHelpers.install_bundle(gemfile_dir)
puts "done."
end
end

# PENDING: Get this to work with gem bundler
# desc "Test all supported versions of rails"
# task :test_rails do
# FAIL_MSG = "!! FAIL !!"
# OK_MSG = "OK"
# UNSUPPORTED_MSG = "Unsupported"
# rails_gems = `gem list rails`.grep(/^rails\b/).first
# versions = rails_gems.scan(/\((.+)\)/).flatten.first.split(", ")
# versions_2_x_gems = versions.grep(/^2/)
# results = {}
# versions_2_x_gems.each do |version|
# if version < '2.0.5'
# puts "-----------------------------------------------------"
# puts "Rails #{version} is not officially supported by Spork"
# puts "Why? http://www.nabble.com/rspec-rails-fails-to-find-a-controller-name-td23223425.html"
# puts "-----------------------------------------------------"
# results[version] = UNSUPPORTED_MSG
# next
# end
#
#
# puts "Testing version #{version}"
# pid = Kernel.fork do
# test_files = %w[features/rspec_rails_integration.feature features/rails_delayed_loading_workarounds.feature]
#
# unless version < '2.1'
# # pending a fix, the following error happens with rails 2.0:
# # /opt/local/lib/ruby/gems/1.8/gems/cucumber-0.3.11/lib/cucumber/rails/world.rb:41:in `use_transactional_fixtures': undefined method `configuration' for Rails:Module (NoMethodError)
# test_files << "features/cucumber_rails_integration.feature "
# end
# exec("env RAILS_VERSION=#{version} cucumber #{test_files * ' '}; echo $? > result")
# end
# Process.waitpid(pid)
# result = File.read('result').chomp
# FileUtils.rm('result')
# if result=='0'
# results[version] = OK_MSG
# else
# results[version] = FAIL_MSG
# end
# end
#
# puts "Results:"
# File.open("TESTED_RAILS_VERSIONS.txt", 'wb') do |f|
# results.keys.sort.each do |version|
# s = "#{version}:\t#{results[version]}"
# f.puts(s)
# puts(s)
# end
# end
# if results.values.any? { |r| r == FAIL_MSG }
# exit 1
# else
# exit 0
# end
# end
1 change: 1 addition & 0 deletions bin/cucumber
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bundle exec cucumber "$@"
7 changes: 0 additions & 7 deletions features/cucumber_rails_integration.feature
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,6 @@ Feature: Cucumber integration with rails
Scenario: did it work again?
Then it should work
"""
And a file named "features/cucumber_rails_fr.feature" with:
"""
# language: fr
Fonction: French
Scénario: ca marche?
Alors ca marche
"""
And a file named "features/support/cucumber_rails_helper.rb" with:
"""
$loaded_stuff << 'features/support/cucumber_rails_helper.rb'
Expand Down
10 changes: 10 additions & 0 deletions features/gemfiles/rails2.3/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
source :gemcutter
gem 'sqlite3-ruby', '1.2.5'
gem 'cucumber', '0.7.3'
gem 'cucumber-rails'
gem 'gherkin', '1.0.27'
gem 'rspec', '1.3.0'
gem 'rspec-rails', '>= 1.3.2'
gem 'rails', '2.3.8'
gem 'ruby-debug', '>= 0.10.3'
gem 'spork', :path => File.expand_path("../../..", File.dirname(__FILE__))
95 changes: 95 additions & 0 deletions features/gemfiles/rails2.3/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---
dependencies:
spork:
group:
- :default
version: ">= 0"
ruby-debug:
group:
- :default
version: ">= 0.10.3"
rails:
group:
- :default
version: = 2.3.8
sqlite3-ruby:
group:
- :default
version: = 1.2.5
rspec:
group:
- :default
version: = 1.3.0
rspec-rails:
group:
- :default
version: ">= 1.3.2"
cucumber-rails:
group:
- :default
version: ">= 0"
gherkin:
group:
- :default
version: = 1.0.27
cucumber:
group:
- :default
version: = 0.7.3
specs:
- rake:
version: 0.8.7
- activesupport:
version: 2.3.8
- rack:
version: 1.1.0
- actionpack:
version: 2.3.8
- actionmailer:
version: 2.3.8
- activerecord:
version: 2.3.8
- activeresource:
version: 2.3.8
- builder:
version: 2.1.2
- columnize:
version: 0.3.1
- diff-lcs:
version: 1.1.2
- trollop:
version: 1.16.2
- gherkin:
version: 1.0.27
- json_pure:
version: 1.4.3
- term-ansicolor:
version: 1.0.5
- cucumber:
version: 0.7.3
- cucumber-rails:
version: 0.3.1
- linecache:
version: "0.43"
- rails:
version: 2.3.8
- rspec:
version: 1.3.0
- rspec-rails:
version: 1.3.2
- ruby-debug-base:
version: 0.10.3
- ruby-debug:
version: 0.10.3
- spork:
version: 0.8.4
source: 0
- sqlite3-ruby:
version: 1.2.5
hash: 3f1d7d04cfed88de4d337e2b5fb51639bc0a05f2
sources:
- Path:
path: !ruby/object:Pathname
path: /Users/timcharper/projects/spork
- Rubygems:
uri: http://gemcutter.org
1 change: 0 additions & 1 deletion features/rspec_rails_integration.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Feature: Rails Integration
Providing default hooks and behaviors

Background: Rails App with RSpec and Spork

Given I am in a fresh rails project named "test_rails_project"
And a file named "spec/spec_helper.rb" with:
"""
Expand Down
8 changes: 6 additions & 2 deletions features/steps/rails_steps.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
Given /^I am in a fresh rails project named "(.+)"$/ do |folder_name|
@current_dir = SporkWorld::SANDBOX_DIR
version_argument = ENV['RAILS_VERSION'] ? "_#{ENV['RAILS_VERSION']}_" : nil
# version_argument = ENV['RAILS_VERSION'] ? "_#{ENV['RAILS_VERSION']}_" : nil
# run("#{SporkWorld::RUBY_BINARY} #{%x{which rails}.chomp} #{folder_name}")
run([SporkWorld::RUBY_BINARY, '-I', Cucumber::LIBDIR, %x{which rails}.chomp, version_argument, folder_name].compact * " ")
run(["rails", folder_name].compact * " ")
if last_exit_status != 0
puts "Couldn't generate project. Output:\nSTDERR:\n-------\n#{last_stderr}\n------\n\nSTDOUT:\n-------\n#{last_stdout}\n\n"
last_exit_status.should == 0
end
@current_dir = File.join(File.join(SporkWorld::SANDBOX_DIR, folder_name))
end

Expand Down
Loading

0 comments on commit 9e70852

Please sign in to comment.