Remove Cucumber tests

This commit is contained in:
Elliot Winkler 2014-10-26 18:54:55 -06:00
parent 3fb4cdb3b7
commit c432a8c899
29 changed files with 1 additions and 591 deletions

View File

@ -6,7 +6,6 @@ gem 'appraisal', '~> 1.0'
gem 'aruba'
gem 'bourne', '~> 1.3'
gem 'bundler', '~> 1.1'
gem 'cucumber', '~> 1.1'
gem 'pry'
gem 'rails', '~> 3.0'
gem 'rake', '>= 0.9.2'

View File

@ -153,7 +153,6 @@ DEPENDENCIES
aruba
bourne (~> 1.3)
bundler (~> 1.1)
cucumber (~> 1.1)
jdbc-sqlite3
jruby-openssl
pry

View File

@ -1,7 +1,6 @@
require 'bundler/setup'
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'cucumber/rake/task'
require 'appraisal'
require 'erb'
require_relative 'lib/shoulda/matchers/version'
@ -22,23 +21,10 @@ RSpec::Core::RakeTask.new('spec:acceptance') do |t|
t.verbose = false
end
Cucumber::Rake::Task.new do |t|
options = []
options << '--format' << (ENV['CUCUMBER_FORMAT'] || 'progress')
if Bundler.definition.dependencies.none? { |dependency| dependency.name == 'spring' }
options << '--profile' << 'without_spring'
end
t.fork = false
t.cucumber_opts = options
end
task :default do
if ENV['BUNDLE_GEMFILE'] =~ /gemfiles/
sh 'rake spec:unit'
Rake::Task['cucumber'].invoke
sh 'rake spec:acceptance'
else
Rake::Task['appraise'].invoke
end

View File

@ -1,15 +0,0 @@
Feature: integration with ActiveModel
Scenario: create a new project using matchers
When I generate a new ActiveModel application
And I configure the application to use "shoulda-matchers" from this project
And I write to "load_dependencies.rb" with:
"""
require 'active_model'
require 'shoulda-matchers'
puts ActiveModel::VERSION::STRING
puts "Loaded all dependencies without errors"
"""
When I successfully run `bundle exec ruby load_dependencies.rb`
Then the output should contain "Loaded all dependencies without errors"

View File

@ -1,47 +0,0 @@
Feature: Independent matchers
Background:
When I generate a new Ruby application
Scenario: A Ruby application that uses Minitest and the delegate_method matcher
When I add Minitest to the project
And I write to "lib/post_office.rb" with:
"""
class PostOffice
end
"""
And I write to "lib/courier.rb" with:
"""
require "forwardable"
class Courier
extend Forwardable
def_delegators :post_office, :deliver
attr_reader :post_office
def initialize(post_office)
@post_office = post_office
end
end
"""
And I write a Minitest test to "test/courier_test.rb" with:
"""
require "test_helper"
require "courier"
require "post_office"
class CourierTest < {{MINITEST_TEST_CASE_CLASS}}
subject { Courier.new(post_office) }
should delegate_method(:deliver).to(:post_office)
def post_office
PostOffice.new
end
end
"""
And I set the "TESTOPTS" environment variable to "-v"
And I successfully run `bundle exec ruby -I lib -I test test/courier_test.rb`
Then the output should indicate that 1 test was run
And the output should contain "Courier should delegate #deliver to #post_office object"

View File

@ -1,160 +0,0 @@
Feature: integrate with Rails
Background:
When I generate a new rails application
And I write to "db/migrate/1_create_users.rb" with:
"""
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.string :name
end
end
end
"""
When I successfully run `bundle exec rake db:migrate db:test:prepare --trace`
And I write to "app/models/user.rb" with:
"""
class User < ActiveRecord::Base
validates_presence_of :name
end
"""
When I write to "app/controllers/examples_controller.rb" with:
"""
class ExamplesController < ApplicationController
def show
@example = 'hello'
render :nothing => true
end
end
"""
When I configure a wildcard route
Scenario: generate a rails application and use matchers in Test::Unit
When I configure the application to use shoulda-context
And I configure the application to use "shoulda-matchers" from this project
And I write to "test/unit/user_test.rb" with:
"""
require 'test_helper'
class UserTest < ActiveSupport::TestCase
should validate_presence_of(:name)
end
"""
When I write to "test/functional/examples_controller_test.rb" with:
"""
require 'test_helper'
class ExamplesControllerTest < ActionController::TestCase
def setup
get :show
end
should respond_with(:success)
end
"""
When I set the "TESTOPTS" environment variable to "-v"
When I successfully run `bundle exec rake test --trace`
Then the output should indicate that 1 unit and 1 functional test were run
And the output should contain "User should require name to be set"
And the output should contain "should respond with 200"
Scenario: generate a rails application and use matchers in Rspec
When I configure the application to use rspec-rails
And I configure the application to use "shoulda-matchers" from this project
And I run the rspec generator
And I write to "spec/models/user_spec.rb" with:
"""
require 'spec_helper'
if RSpec::Core::Version::STRING.to_i >= 3
require 'rails_helper'
end
describe User do
it { should validate_presence_of(:name) }
end
"""
When I write to "spec/controllers/examples_controller_spec.rb" with:
"""
require 'spec_helper'
if RSpec::Core::Version::STRING.to_i >= 3
require 'rails_helper'
end
describe ExamplesController, "show" do
before { get :show }
it { should respond_with(:success) }
end
"""
When I successfully run `bundle exec rake spec SPEC_OPTS=-fd --trace`
Then the output should contain "2 examples, 0 failures"
And the output should contain "should require name to be set"
And the output should contain "should respond with 200"
@spring
Scenario: A Rails application that uses RSpec, requires shoulda-matchers manually, and uses Spring to run tests
When I configure the application to use Spring
When I configure the application to use "spring-commands-rspec"
When I configure the application to use rspec-rails
And I configure the application to use "shoulda-matchers" from this project, disabling auto-require
And I run the rspec generator
And I require shoulda-matchers following rspec-rails
And I write to "spec/models/user_spec.rb" with:
"""
require 'spec_helper'
if RSpec::Core::Version::STRING.to_i >= 3
require 'rails_helper'
end
describe User do
it { should validate_presence_of(:name) }
end
"""
When I write to "spec/controllers/examples_controller_spec.rb" with:
"""
require 'spec_helper'
if RSpec::Core::Version::STRING.to_i >= 3
require 'rails_helper'
end
describe ExamplesController, "show" do
before { get :show }
it { should respond_with(:success) }
it { should_not render_template('foo') }
end
"""
When I run `bundle exec spring stop`
When I successfully run `bundle exec spring rspec spec -fd`
Then the output should contain "3 examples, 0 failures"
And the output should contain "should require name to be set"
And the output should contain "should respond with 200"
Scenario: generate a Rails application that mixes Rspec and Test::Unit
When I configure the application to use rspec-rails in test and development
And I configure the application to use "shoulda-matchers" from this project in test and development
And I run the rspec generator
And I write to "spec/models/user_spec.rb" with:
"""
require 'spec_helper'
if RSpec::Core::Version::STRING.to_i == 3
require 'rails_helper'
end
describe User do
it { should validate_presence_of(:name) }
end
"""
When I write to "test/functional/examples_controller_test.rb" with:
"""
require 'test_helper'
class ExamplesControllerTest < ActionController::TestCase
test 'responds successfully' do
get :show
assert respond_with(:success)
end
end
"""
When I successfully run `bundle exec rake spec test:functionals SPEC_OPTS=-fd --trace`
Then the output should contain "1 example, 0 failures"
Then the output should indicate that 1 test was run

View File

@ -1,21 +0,0 @@
When 'I generate a new ActiveModel application' do
steps %{
When I run `mkdir #{APP_NAME}`
And I cd to "#{APP_NAME}"
And I run `bundle init`
}
# Figure out the ActiveModel version to use by reusing the Rails version from
# the Appraise gemfile.
if match = File.read(ENV['BUNDLE_GEMFILE']).match(/^gem "rails", "(.*)"/)
append_to_gemfile %(gem 'activemodel', '#{ match[1] }')
else
puts "Couldn't determine which ActiveModel version to load; using latest"
append_to_gemfile %(gem 'activemodel')
end
steps %{
And I set the "BUNDLE_GEMFILE" environment variable to "Gemfile"
And I install gems
}
end

View File

@ -1,84 +0,0 @@
When 'I generate a new rails application' do
steps %{
When I run `bundle exec rails new #{APP_NAME} --skip-bundle`
And I cd to "#{APP_NAME}"
And I comment out the gem "turn" from the Gemfile
And I comment out the gem "coffee-rails" from the Gemfile
And I comment out the gem "uglifier" from the Gemfile
And I reset Bundler environment variables
And I set the "BUNDLE_GEMFILE" environment variable to "Gemfile"
And I install gems
}
if RUBY_VERSION >= '1.9.3'
append_to_gemfile %(gem 'rake', '~> 0.9')
step %(I successfully run `bundle update rake`)
end
end
When 'I configure the application to use Spring' do
if rails_lt_4?
append_to_gemfile "gem 'spring'"
steps %{And I install gems}
end
end
When /^I configure the application to use "([^\"]+)" from this project in test and development$/ do |name|
append_to_gemfile <<-GEMFILE
group :test, :development do
gem '#{name}', path: '#{PROJECT_ROOT}'
end
GEMFILE
steps %{And I install gems}
end
When 'I run the rspec generator' do
steps %{
When I successfully run `rails generate rspec:install`
}
end
When 'I configure the application to use rspec-rails' do
append_to_gemfile <<-GEMFILE
gem 'rspec-rails', '#{rspec_rails_version}'
GEMFILE
steps %{And I install gems}
end
When 'I configure the application to use rspec-rails in test and development' do
append_to_gemfile <<-GEMFILE
group :test, :development do
gem 'rspec-rails', '#{rspec_rails_version}'
end
GEMFILE
steps %{And I install gems}
end
When 'I require shoulda-matchers following rspec-rails' do
insert_line_after test_helper_path,
"require 'rspec/rails'",
"require 'shoulda/matchers'"
end
When /^I set the "([^"]*)" environment variable to "([^"]*)"$/ do |key, value|
ENV[key] = value
end
When 'I configure a wildcard route' do
steps %{
When I write to "config/routes.rb" with:
"""
Rails.application.routes.draw do
get ':controller(/:action(/:id(.:format)))'
end
"""
}
end
When 'I append gems from Appraisal Gemfile' do
File.read(ENV['BUNDLE_GEMFILE']).split("\n").each do |line|
if line =~ /^gem "(?!rails|appraisal)/
append_to_gemfile line.strip
end
end
end

View File

@ -1,108 +0,0 @@
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 write a Minitest test to "([^"]+)" with:/ do |path, contents|
contents.sub!('{{MINITEST_TEST_CASE_CLASS}}', minitest_test_case_class)
write_file(path, contents)
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}
end
When /^I configure the application to use "([^\"]+)" from this project, disabling auto-require$/ do |name|
append_to_gemfile "gem '#{name}', path: '#{PROJECT_ROOT}', require: false"
steps %{And I install gems}
end
When 'I configure the application to use shoulda-context' do
append_to_gemfile %q(gem 'shoulda-context', '~> 1.2.0')
append_to_gemfile %q(gem 'pry')
steps %{And I install gems}
end
When 'I reset Bundler environment variables' do
BUNDLE_ENV_VARS.each do |key|
ENV[key] = nil
end
end
When /^I comment out the gem "([^"]*)" from the Gemfile$/ do |gemname|
comment_out_gem_in_gemfile(gemname)
end
When /^I install gems$/ do
steps %{When I run `bundle install --local`}
end
Then /^the output should indicate that (\d+) tests? (?:was|were) run/ do |number|
# Rails 4 has slightly different output than Rails 3 due to
# Test::Unit::TestCase -> MiniTest
if rails_lt_4?
steps %{Then the output should contain "#{number} tests, #{number} assertions, 0 failures, 0 errors"}
else
steps %{Then the output should match /#{number} (tests|runs), #{number} assertions, 0 failures, 0 errors, 0 skips/}
end
end
Then /^the output should indicate that (\d+) unit and (\d+) functional tests? were run/ do |n1, n2|
n1 = n1.to_i
n2 = n2.to_i
total = n1.to_i + n2.to_i
# Rails 3 runs separate test suites in separate processes, but Rails 4 does
# not, so that's why we have to check for different things here
if rails_lt_4?
steps %{Then the output should match /#{n1} tests, #{n1} assertions, 0 failures, 0 errors.+#{n2} tests, #{n2} assertions, 0 failures, 0 errors/}
else
steps %{Then the output should match /#{total} (tests|runs), #{total} assertions, 0 failures, 0 errors, 0 skips/}
end
end

View File

@ -1,19 +0,0 @@
require 'aruba/cucumber'
require 'pry'
PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')).freeze
APP_NAME = 'testapp'.freeze
BUNDLE_ENV_VARS = %w(RUBYOPT BUNDLE_PATH BUNDLE_BIN_PATH BUNDLE_GEMFILE)
ORIGINAL_BUNDLE_VARS = Hash[ENV.select{ |key,value| BUNDLE_ENV_VARS.include?(key) }]
Before do
@aruba_timeout_seconds = 60 * 2
ENV['BUNDLE_GEMFILE'] = File.join(Dir.pwd, ENV['BUNDLE_GEMFILE']) unless ENV['BUNDLE_GEMFILE'].start_with?(Dir.pwd)
end
After do
ORIGINAL_BUNDLE_VARS.each_pair do |key, value|
ENV[key] = value
end
end

View File

@ -1,36 +0,0 @@
module RubyHelpers
def append_to(path, contents)
in_current_dir do
File.open(path, 'a') do |file|
file.puts
file.puts contents
end
end
end
def append_to_gemfile(contents)
append_to('Gemfile', contents)
end
def comment_out_gem_in_gemfile(gemname)
in_current_dir do
gemfile = File.read('Gemfile')
gemfile.sub!(/^(\s*)(gem\s*['"]#{gemname})/, "\\1# \\2")
File.open('Gemfile', 'w'){ |file| file.write(gemfile) }
end
end
def insert_line_after(file_path, line, line_to_insert)
line += "\n"
line_to_insert += "\n"
in_current_dir do
contents = File.read(file_path)
index = contents.index(line) + line.length
contents.insert(index, line_to_insert)
File.open(file_path, 'w') { |f| f.write(contents) }
end
end
end
World(RubyHelpers)

View File

@ -1,21 +0,0 @@
module MinitestHelpers
def minitest_test_case_class
if minitest_gte_5?
'Minitest::Test'
else
'MiniTest::Unit::TestCase'
end
end
def minitest_gte_5?
if minitest_version
Gem::Requirement.new('>= 5').satisfied_by?(minitest_version)
end
end
def minitest_version
Bundler.definition.specs['minitest'][0].version
end
end
World(MinitestHelpers)

View File

@ -1,47 +0,0 @@
module RailsHelpers
RAILS_VERSION_IN_GEMFILE_PATH_REGEX = %r{/([^/]+?)(?:_.+)?\.gemfile$}
def rails_version_match
ORIGINAL_BUNDLE_VARS['BUNDLE_GEMFILE'].
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 ||=
if rails_version_string
Gem::Version.new(rails_version_string)
end
end
def rails_lt_4?
if rails_version
Gem::Requirement.new('< 4').satisfied_by?(rails_version)
end
end
def rspec_rails_version
Bundler.definition.specs['rspec-rails'][0].version
end
def rspec_rails_gte_3?
if rspec_rails_version
Gem::Requirement.new('>= 3').satisfied_by?(rspec_rails_version)
end
end
def test_helper_path
if rspec_rails_gte_3?
'spec/rails_helper.rb'
else
'spec/spec_helper.rb'
end
end
end
World(RailsHelpers)

View File

@ -6,7 +6,6 @@ gem "appraisal", "~> 1.0"
gem "aruba"
gem "bourne", "~> 1.3"
gem "bundler", "~> 1.1"
gem "cucumber", "~> 1.1"
gem "pry"
gem "rails", "~> 3.0.17"
gem "rake", ">= 0.9.2"

View File

@ -159,7 +159,6 @@ DEPENDENCIES
aruba
bourne (~> 1.3)
bundler (~> 1.1)
cucumber (~> 1.1)
jdbc-sqlite3
jruby-openssl
minitest (~> 4.0)

View File

@ -6,7 +6,6 @@ gem "appraisal", "~> 1.0"
gem "aruba"
gem "bourne", "~> 1.3"
gem "bundler", "~> 1.1"
gem "cucumber", "~> 1.1"
gem "pry"
gem "rails", "~> 3.1.8"
gem "rake", ">= 0.9.2"

View File

@ -194,7 +194,6 @@ DEPENDENCIES
bourne (~> 1.3)
bundler (~> 1.1)
coffee-rails (~> 3.1.1)
cucumber (~> 1.1)
jdbc-sqlite3
jquery-rails
jruby-openssl

View File

@ -6,7 +6,6 @@ gem "appraisal", "~> 1.0"
gem "aruba"
gem "bourne", "~> 1.3"
gem "bundler", "~> 1.1"
gem "cucumber", "~> 1.1"
gem "pry"
gem "rails", "~> 3.1.8"
gem "rake", ">= 0.9.2"

View File

@ -194,7 +194,6 @@ DEPENDENCIES
bourne (~> 1.3)
bundler (~> 1.1)
coffee-rails (~> 3.1.1)
cucumber (~> 1.1)
jdbc-sqlite3
jquery-rails
jruby-openssl

View File

@ -6,7 +6,6 @@ gem "appraisal", "~> 1.0"
gem "aruba"
gem "bourne", "~> 1.3"
gem "bundler", "~> 1.1"
gem "cucumber", "~> 1.1"
gem "pry"
gem "rails", "~> 3.2.13"
gem "rake", ">= 0.9.2"

View File

@ -193,7 +193,6 @@ DEPENDENCIES
bourne (~> 1.3)
bundler (~> 1.1)
coffee-rails (~> 3.2.1)
cucumber (~> 1.1)
jdbc-sqlite3
jquery-rails
jruby-openssl

View File

@ -6,7 +6,6 @@ gem "appraisal", "~> 1.0"
gem "aruba"
gem "bourne", "~> 1.3"
gem "bundler", "~> 1.1"
gem "cucumber", "~> 1.1"
gem "pry"
gem "rails", "~> 3.2.13"
gem "rake", ">= 0.9.2"

View File

@ -190,7 +190,6 @@ DEPENDENCIES
bourne (~> 1.3)
bundler (~> 1.1)
coffee-rails (~> 3.2.1)
cucumber (~> 1.1)
jdbc-sqlite3
jquery-rails
jruby-openssl

View File

@ -6,7 +6,6 @@ gem "appraisal", "~> 1.0"
gem "aruba"
gem "bourne", "~> 1.3"
gem "bundler", "~> 1.1"
gem "cucumber", "~> 1.1"
gem "pry"
gem "rails", "4.0.0"
gem "rake", ">= 0.9.2"

View File

@ -202,7 +202,6 @@ DEPENDENCIES
bourne (~> 1.3)
bundler (~> 1.1)
coffee-rails (~> 4.0.0)
cucumber (~> 1.1)
jbuilder (~> 1.2)
jdbc-sqlite3
jquery-rails

View File

@ -6,7 +6,6 @@ gem "appraisal", "~> 1.0"
gem "aruba"
gem "bourne", "~> 1.3"
gem "bundler", "~> 1.1"
gem "cucumber", "~> 1.1"
gem "pry"
gem "rails", "4.0.1"
gem "rake", ">= 0.9.2"

View File

@ -200,7 +200,6 @@ DEPENDENCIES
bourne (~> 1.3)
bundler (~> 1.1)
coffee-rails (~> 4.0.0)
cucumber (~> 1.1)
jbuilder (~> 1.2)
jdbc-sqlite3
jquery-rails

View File

@ -6,7 +6,6 @@ gem "appraisal", "~> 1.0"
gem "aruba"
gem "bourne", "~> 1.3"
gem "bundler", "~> 1.1"
gem "cucumber", "~> 1.1"
gem "pry"
gem "rails", "~> 4.1.0"
gem "rake", ">= 0.9.2"

View File

@ -204,7 +204,6 @@ DEPENDENCIES
bourne (~> 1.3)
bundler (~> 1.1)
coffee-rails (~> 4.0.0)
cucumber (~> 1.1)
jbuilder (~> 2.0)
jdbc-sqlite3
jquery-rails