Skip to content
Permalink
Browse files

setting up the testing suite

  • Loading branch information...
johncorderox committed Mar 31, 2019
1 parent 80f2a14 commit 0a98f7dcabe54c20706979e0774a834a888c5f94
Showing with 414 additions and 2 deletions.
  1. +1 βˆ’0 .rspec
  2. +6 βˆ’1 Gemfile
  3. +70 βˆ’0 Gemfile.lock
  4. +9 βˆ’0 config/cucumber.yml
  5. +4 βˆ’1 config/database.yml
  6. 0 features/step_definitions/.gitkeep
  7. +58 βˆ’0 features/support/env.rb
  8. +76 βˆ’0 lib/tasks/cucumber.rake
  9. +10 βˆ’0 script/cucumber
  10. +84 βˆ’0 spec/rails_helper.rb
  11. +96 βˆ’0 spec/spec_helper.rb
1 .rspec
@@ -0,0 +1 @@
--require spec_helper
@@ -49,6 +49,10 @@ group :development, :test do
gem 'shutup'
gem 'kaminari', '< 1.0.0'
gem 'rails_db', '2.0.4'
gem 'rspec-rails', '~> 3.5'
gem 'cucumber-rails', require: false
gem 'shoulda-matchers', git: 'https://github.com/thoughtbot/shoulda-matchers.git', branch: 'rails-5'
gem 'factory_bot_rails'
end

group :development do
@@ -61,7 +65,8 @@ group :development do
end

group :test do
# Adds support for Capybara system testing and selenium driver
gem 'rails-controller-testing'
gem 'database_cleaner'
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
# Easy installation and use of chromedriver to run system tests with Chrome
@@ -1,3 +1,11 @@
GIT
remote: https://github.com/thoughtbot/shoulda-matchers.git
revision: 4b160bd19ecca7f97d7ac22dccd5fde9b0da5a9f
branch: rails-5
specs:
shoulda-matchers (3.1.2)
activesupport (>= 4.2.0)

GEM
remote: https://rubygems.org/
specs:
@@ -47,6 +55,7 @@ GEM
archive-zip (0.12.0)
io-like (~> 0.3.0)
arel (9.0.0)
backports (3.12.0)
bcrypt (3.1.12)
bindex (0.5.0)
bootsnap (1.4.1)
@@ -77,15 +86,45 @@ GEM
coffee-script-source (1.12.2)
concurrent-ruby (1.1.5)
crass (1.0.4)
cucumber (3.1.2)
builder (>= 2.1.2)
cucumber-core (~> 3.2.0)
cucumber-expressions (~> 6.0.1)
cucumber-wire (~> 0.0.1)
diff-lcs (~> 1.3)
gherkin (~> 5.1.0)
multi_json (>= 1.7.5, < 2.0)
multi_test (>= 0.1.2)
cucumber-core (3.2.1)
backports (>= 3.8.0)
cucumber-tag_expressions (~> 1.1.0)
gherkin (~> 5.0)
cucumber-expressions (6.0.1)
cucumber-rails (1.6.0)
capybara (>= 1.1.2, < 4)
cucumber (>= 3.0.2, < 4)
mime-types (>= 1.17, < 4)
nokogiri (~> 1.8)
railties (>= 4, < 6)
cucumber-tag_expressions (1.1.1)
cucumber-wire (0.0.1)
database_cleaner (1.7.0)
devise (4.6.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0, < 6.0)
responders
warden (~> 1.2.3)
diff-lcs (1.3)
erubi (1.8.0)
execjs (2.7.0)
factory_bot (5.0.2)
activesupport (>= 4.2.0)
factory_bot_rails (5.0.1)
factory_bot (~> 5.0.0)
railties (>= 4.2.0)
ffi (1.10.0)
gherkin (5.1.0)
globalid (0.4.2)
activesupport (>= 4.2.0)
hirb (0.7.3)
@@ -114,12 +153,16 @@ GEM
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (0.9.2)
mime-types (3.2.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2018.0812)
mimemagic (0.3.3)
mini_mime (1.0.1)
mini_portile2 (2.4.0)
minitest (5.11.3)
msgpack (1.2.9)
multi_json (1.13.1)
multi_test (0.1.2)
nio4r (2.3.1)
nokogiri (1.10.1)
mini_portile2 (~> 2.4.0)
@@ -143,6 +186,10 @@ GEM
bundler (>= 1.3.0)
railties (= 5.2.2.1)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.4)
actionpack (>= 5.0.1.x)
actionview (>= 5.0.1.x)
activesupport (>= 5.0.1.x)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
@@ -179,6 +226,23 @@ GEM
responders (2.4.1)
actionpack (>= 4.2.0, < 6.0)
railties (>= 4.2.0, < 6.0)
rspec-core (3.8.0)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-rails (3.8.2)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-support (~> 3.8.0)
rspec-support (3.8.0)
ruby_dep (1.5.0)
rubyzip (1.2.2)
sass (3.7.3)
@@ -246,7 +310,10 @@ DEPENDENCIES
capybara (>= 2.15)
chromedriver-helper
coffee-rails (~> 4.2)
cucumber-rails
database_cleaner
devise
factory_bot_rails
hirb
jbuilder (~> 2.5)
jquery-rails
@@ -255,10 +322,13 @@ DEPENDENCIES
pg (>= 0.18, < 2.0)
puma (~> 3.11)
rails (~> 5.2.2, >= 5.2.2.1)
rails-controller-testing
rails_12factor
rails_db (= 2.0.4)
rspec-rails (~> 3.5)
sass-rails (~> 5.0)
selenium-webdriver
shoulda-matchers!
shutup
spring
spring-watcher-listen (~> 2.0.0)
@@ -0,0 +1,9 @@
<%
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
rerun = rerun.strip.gsub /\s/, ' '
rerun_opts = rerun.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags 'not @wip'"
%>
default: <%= std_opts %> features
wip: --tags @wip:3 --wip features
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags 'not @wip'
@@ -55,7 +55,7 @@ development:
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
test: &test
<<: *default
database: Carte_test

@@ -83,3 +83,6 @@ production:
database: Carte_production
username: Carte
password: <%= ENV['CARTE_DATABASE_PASSWORD'] %>

cucumber:
<<: *test
No changes.
@@ -0,0 +1,58 @@
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
# It is recommended to regenerate this file in the future when you upgrade to a
# newer version of cucumber-rails. Consider adding your own code to a new file
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
# files.

require 'cucumber/rails'

# Capybara defaults to CSS3 selectors rather than XPath.
# If you'd prefer to use XPath, just uncomment this line and adjust any
# selectors in your step definitions to use the XPath syntax.
# Capybara.default_selector = :xpath

# By default, any exception happening in your Rails application will bubble up
# to Cucumber so that your scenario will fail. This is a different from how
# your application behaves in the production environment, where an error page will
# be rendered instead.
#
# Sometimes we want to override this default behaviour and allow Rails to rescue
# exceptions and display an error page (just like when the app is running in production).
# Typical scenarios where you want to do this is when you test your error pages.
# There are two ways to allow Rails to rescue exceptions:
#
# 1) Tag your scenario (or feature) with @allow-rescue
#
# 2) Set the value below to true. Beware that doing this globally is not
# recommended as it will mask a lot of errors for you!
#
ActionController::Base.allow_rescue = false

# Remove/comment out the lines below if your app doesn't have a database.
# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
begin
DatabaseCleaner.strategy = :transaction
rescue NameError
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
end

# You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.
# See the DatabaseCleaner documentation for details. Example:
#
# Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
# # { except: [:widgets] } may not do what you expect here
# # as Cucumber::Rails::Database.javascript_strategy overrides
# # this setting.
# DatabaseCleaner.strategy = :truncation
# end
#
# Before('not @no-txn', 'not @selenium', 'not @culerity', 'not @celerity', 'not @javascript') do
# DatabaseCleaner.strategy = :transaction
# end
#

# Possible values are :truncation and :transaction
# The :transaction strategy is faster, but might give you threading problems.
# See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature
Cucumber::Rails::Database.javascript_strategy = :truncation

@@ -0,0 +1,76 @@
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
# It is recommended to regenerate this file in the future when you upgrade to a
# newer version of cucumber-rails. Consider adding your own code to a new file
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
# files.


unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks

vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?

begin
require 'cucumber/rake/task'

namespace :cucumber do
Cucumber::Rake::Task.new({ok: 'test:prepare'}, 'Run features that should pass') do |t|
t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
t.fork = true # You may get faster startup if you set this to false
t.profile = 'default'
end

Cucumber::Rake::Task.new({wip: 'test:prepare'}, 'Run features that are being worked on') do |t|
t.binary = vendored_cucumber_bin
t.fork = true # You may get faster startup if you set this to false
t.profile = 'wip'
end

Cucumber::Rake::Task.new({rerun: 'test:prepare'}, 'Record failing features and run only them if any exist') do |t|
t.binary = vendored_cucumber_bin
t.fork = true # You may get faster startup if you set this to false
t.profile = 'rerun'
end

desc 'Run all features'
task all: [:ok, :wip]

task :statsetup do
require 'rails/code_statistics'
::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features')
::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features')
end

task :annotations_setup do
Rails.application.configure do
if config.respond_to?(:annotations)
config.annotations.directories << 'features'
config.annotations.register_extensions('feature') { |tag| /#\s*(#{tag}):?\s*(.*)$/ }
end
end
end
end
desc 'Alias for cucumber:ok'
task cucumber: 'cucumber:ok'

task default: :cucumber

task features: :cucumber do
STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
end

# In case we don't have the generic Rails test:prepare hook, append a no-op task that we can depend upon.
task 'test:prepare' do
end

task stats: 'cucumber:statsetup'

task notes: 'cucumber:annotations_setup'
rescue LoadError
desc 'cucumber rake task not available (cucumber not installed)'
task :cucumber do
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
end
end

end
@@ -0,0 +1,10 @@
#!/usr/bin/env ruby

vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
if vendored_cucumber_bin
load File.expand_path(vendored_cucumber_bin)
else
require 'rubygems' unless ENV['NO_RUBYGEMS']
require 'cucumber'
load Cucumber::BINARY
end

0 comments on commit 0a98f7d

Please sign in to comment.
You can’t perform that action at this time.