Add Cucumber setup for testing standalone Ruby applications

This commit is contained in:
Elliot Winkler 2014-09-12 16:39:00 -06:00
parent 0de39be965
commit de7e550f7e
13 changed files with 107 additions and 7 deletions

View File

@ -42,6 +42,7 @@ rails_4 = proc do
gem 'rspec-rails', '~> 3.0.1'
# Test suite makes heavy use of attr_accessible
gem 'protected_attributes'
gem 'minitest-reporters'
end
#---
@ -56,11 +57,13 @@ if Gem::Requirement.new('< 2').satisfied_by?(ruby_version)
appraise '3.1-1.9.2' do
instance_eval(&rails_3_1)
gem 'turn', '0.8.2'
gem 'minitest', '~> 4.0'
end
else
appraise '3.1' do
instance_eval(&rails_3_1)
gem 'turn', '~> 0.8.3'
gem 'minitest', '~> 4.0'
end
end
end

View File

@ -1,8 +1,54 @@
When 'I generate a new Ruby application' do
steps %{
When I run `mkdir #{APP_NAME}`
And I cd to "#{APP_NAME}"
And I run `bundle init`
And I set the "BUNDLE_GEMFILE" environment variable to "Gemfile"
When I configure the application to use "shoulda-matchers" from this project
}
end
When 'I add Minitest to the project' do
steps %{
When I configure the application to use shoulda-context
When I configure the application to use "minitest-reporters"
}
step 'I write to "test/test_helper.rb" with:', <<-EOT
require "minitest/autorun"
require "minitest/reporters"
require "shoulda/context"
require "shoulda/matchers"
Minitest::Reporters.use!(Minitest::Reporters::SpecReporter.new)
EOT
end
When 'I add Test::Unit to the project' do
steps %{
When I configure the application to use shoulda-context
When I configure the application to use "test-unit"
When I configure the application to use "turn" v0.9.0
}
step 'I write to "test/test_helper.rb" with:', <<-EOT
require "test/unit"
require "turn/autorun"
require "shoulda/context"
require "shoulda/matchers"
EOT
end
When /^I configure the application to use "([^\"]+)"$/ do |name|
append_to_gemfile "gem '#{name}'"
steps %{And I install gems}
end
When /^I configure the application to use "([^\"]+)" v(.+)$/ do |name, version|
append_to_gemfile "gem '#{name}', '#{version}'"
steps %{And I install gems}
end
When /^I configure the application to use "([^\"]+)" from this project$/ do |name|
append_to_gemfile "gem '#{name}', path: '#{PROJECT_ROOT}'"
steps %{And I install gems}

View File

@ -1,18 +1,28 @@
module RailsHelpers
RAILS_VERSION_IN_GEMFILE_PATH_REGEX = %r{/([^/]+?)(?:_.+)?\.gemfile$}
def rails_version_string
def rails_version_match
ORIGINAL_BUNDLE_VARS['BUNDLE_GEMFILE'].
match(RAILS_VERSION_IN_GEMFILE_PATH_REGEX).
captures[0]
match(RAILS_VERSION_IN_GEMFILE_PATH_REGEX)
end
def rails_version_string
if rails_version_match
rails_version_match.captures[0]
end
end
def rails_version
@_rails_version ||= Gem::Version.new(rails_version_string)
@_rails_version ||=
if rails_version_string
Gem::Version.new(rails_version_string)
end
end
def rails_lt_4?
Gem::Requirement.new('< 4').satisfied_by?(rails_version)
if rails_version
Gem::Requirement.new('< 4').satisfied_by?(rails_version)
end
end
def rspec_rails_version
@ -20,7 +30,9 @@ module RailsHelpers
end
def rspec_rails_gte_3?
Gem::Requirement.new('>= 3').satisfied_by?(rspec_rails_version)
if rspec_rails_version
Gem::Requirement.new('>= 3').satisfied_by?(rspec_rails_version)
end
end
def test_helper_path

View File

@ -29,5 +29,6 @@ gem "coffee-rails", "~> 3.1.1"
gem "uglifier", ">= 1.0.3"
gem "rspec-rails", "2.99.0"
gem "turn", "~> 0.8.3"
gem "minitest", "~> 4.0"
gemspec :path=>".././"

View File

@ -84,6 +84,7 @@ GEM
metaclass (0.0.1)
method_source (0.8.2)
mime-types (1.21)
minitest (4.7.5)
mocha (0.13.3)
metaclass (~> 0.0.1)
multi_json (1.10.1)
@ -188,6 +189,7 @@ DEPENDENCIES
jdbc-sqlite3
jquery-rails
jruby-openssl
minitest (~> 4.0)
pry
pygments.rb
rails (~> 3.1.8)

View File

@ -29,5 +29,6 @@ gem "coffee-rails", "~> 3.1.1"
gem "uglifier", ">= 1.0.3"
gem "rspec-rails", "2.99.0"
gem "turn", "0.8.2"
gem "minitest", "~> 4.0"
gemspec :path=>".././"

View File

@ -84,6 +84,7 @@ GEM
metaclass (0.0.1)
method_source (0.8.2)
mime-types (1.25.1)
minitest (4.7.5)
mocha (0.14.0)
metaclass (~> 0.0.1)
multi_json (1.10.1)
@ -188,6 +189,7 @@ DEPENDENCIES
jdbc-sqlite3
jquery-rails
jruby-openssl
minitest (~> 4.0)
pry
pygments.rb
rails (~> 3.1.8)

View File

@ -30,6 +30,7 @@ gem "sdoc"
gem "activeresource", "4.0.0"
gem "rspec-rails", "~> 3.0.1"
gem "protected_attributes"
gem "minitest-reporters"
gem "rails", "4.0.0"
gem "jbuilder", "~> 1.2"
gem "sass-rails", "~> 4.0.0"

View File

@ -35,6 +35,7 @@ GEM
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
ansi (1.4.3)
appraisal (1.0.0.beta2)
bundler
rake
@ -70,6 +71,7 @@ GEM
ffi (1.9.3)
gherkin (2.12.2)
multi_json (~> 1.3)
hashie (3.3.1)
hike (1.2.3)
i18n (0.6.11)
jbuilder (1.5.3)
@ -86,12 +88,20 @@ GEM
method_source (0.8.2)
mime-types (1.25.1)
minitest (4.7.5)
minitest-reporters (0.14.24)
ansi
builder
minitest (>= 2.12, < 5.0)
powerbar
mocha (0.14.0)
metaclass (~> 0.0.1)
multi_json (1.10.1)
multi_test (0.1.1)
polyglot (0.3.5)
posix-spawn (0.3.8)
powerbar (1.0.11)
ansi (~> 1.4.0)
hashie (>= 1.1.0)
protected_attributes (1.0.3)
activemodel (>= 4.0.0, < 5.0)
pry (0.9.12.6)
@ -197,6 +207,7 @@ DEPENDENCIES
jdbc-sqlite3
jquery-rails
jruby-openssl
minitest-reporters
protected_attributes
pry
pygments.rb

View File

@ -29,6 +29,7 @@ gem "turbolinks"
gem "sdoc"
gem "activeresource", "4.0.0"
gem "protected_attributes"
gem "minitest-reporters"
gem "rails", "4.0.1"
gem "jbuilder", "~> 1.2"
gem "sass-rails", "~> 4.0.0"

View File

@ -35,6 +35,7 @@ GEM
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
ansi (1.4.3)
appraisal (1.0.0.beta2)
bundler
rake
@ -70,6 +71,7 @@ GEM
ffi (1.9.3)
gherkin (2.12.2)
multi_json (~> 1.3)
hashie (3.3.1)
hike (1.2.3)
i18n (0.6.11)
jbuilder (1.5.3)
@ -86,12 +88,20 @@ GEM
method_source (0.8.2)
mime-types (1.25.1)
minitest (4.7.5)
minitest-reporters (0.14.24)
ansi
builder
minitest (>= 2.12, < 5.0)
powerbar
mocha (0.14.0)
metaclass (~> 0.0.1)
multi_json (1.10.1)
multi_test (0.1.1)
polyglot (0.3.3)
posix-spawn (0.3.8)
powerbar (1.0.11)
ansi (~> 1.4.0)
hashie (>= 1.1.0)
protected_attributes (1.0.5)
activemodel (>= 4.0.1, < 5.0)
pry (0.9.12.6)
@ -195,6 +205,7 @@ DEPENDENCIES
jdbc-sqlite3
jquery-rails
jruby-openssl
minitest-reporters
protected_attributes
pry
pygments.rb

View File

@ -27,6 +27,7 @@ gem "jquery-rails"
gem "turbolinks"
gem "activeresource", "4.0.0"
gem "rspec-rails", "~> 3.0.1"
gem "minitest-reporters"
gem "rails", "~> 4.1.0"
gem "jbuilder", "~> 2.0"
gem "sass-rails", "~> 4.0.3"

View File

@ -37,6 +37,7 @@ GEM
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 1.1)
ansi (1.4.3)
appraisal (1.0.0.beta2)
bundler
rake
@ -87,7 +88,12 @@ GEM
metaclass (0.0.2)
method_source (0.8.2)
mime-types (1.25.1)
minitest (5.4.0)
minitest (5.4.2)
minitest-reporters (1.0.5)
ansi
builder
minitest (>= 5.0)
ruby-progressbar
mocha (0.14.0)
metaclass (~> 0.0.1)
multi_json (1.10.1)
@ -143,6 +149,7 @@ GEM
rspec-mocks (~> 3.0.0)
rspec-support (~> 3.0.0)
rspec-support (3.0.3)
ruby-progressbar (1.5.1)
sass (3.2.19)
sass-rails (4.0.3)
railties (>= 4.0.0, < 5.0)
@ -202,6 +209,7 @@ DEPENDENCIES
jdbc-sqlite3
jquery-rails
jruby-openssl
minitest-reporters
protected_attributes (~> 1.0.6)
pry
pygments.rb