Permalink
Browse files

Rspec and Cucumber setup

  • Loading branch information...
1 parent 86d2424 commit 9b1499b1fe0522328e417c8908fbc6d9604913fc @reconbot reconbot committed Mar 3, 2014
View
@@ -0,0 +1 @@
+--color
View
@@ -4,9 +4,19 @@ ruby "2.0.0"
gem 'rails', '4.0.3'
group :development do
+end
+
+group :development, :test do
gem "pry-rails"
gem "better_errors"
gem "binding_of_caller"
+ gem 'rspec-rails', '~> 3.0.0.beta'
+ gem 'factory_girl_rails'
+end
+
+group :test do
+ gem 'cucumber-rails', require: false
+ gem 'database_cleaner'
end
group :production do
@@ -23,5 +33,5 @@ gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
gem 'mongoid', git: 'https://github.com/mongoid/mongoid.git'
gem 'wicked'
-gem 'unicorn'
+gem 'unicorn', require: false
gem 'figaro'
View
@@ -45,6 +45,12 @@ GEM
bootstrap-sass (3.1.1.0)
sass (~> 3.2)
builder (3.1.4)
+ capybara (2.2.1)
+ mime-types (>= 1.16)
+ nokogiri (>= 1.3.3)
+ rack (>= 1.0.0)
+ rack-test (>= 0.5.4)
+ xpath (~> 2.0)
coderay (1.0.9)
coffee-rails (4.0.1)
coffee-script (>= 2.2.0)
@@ -53,14 +59,34 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.7.0)
+ cucumber (1.3.11)
+ builder (>= 2.1.2)
+ diff-lcs (>= 1.1.3)
+ gherkin (~> 2.12)
+ multi_json (>= 1.7.5, < 2.0)
+ multi_test (>= 0.0.2)
+ cucumber-rails (1.4.0)
+ capybara (>= 1.1.2)
+ cucumber (>= 1.2.0)
+ nokogiri (>= 1.5.0)
+ rails (>= 3.0.0)
+ database_cleaner (1.2.0)
debug_inspector (0.0.2)
+ diff-lcs (1.2.5)
erubis (2.7.0)
execjs (2.0.2)
+ factory_girl (4.4.0)
+ activesupport (>= 3.0.0)
+ factory_girl_rails (4.4.1)
+ factory_girl (~> 4.4.0)
+ railties (>= 3.0.0)
figaro (0.6.4)
bundler (~> 1.0)
rails (>= 3, < 5)
font-awesome-rails (3.2.1.2)
railties (>= 3.2, < 5.0)
+ gherkin (2.12.2)
+ multi_json (~> 1.3)
hike (1.2.3)
i18n (0.6.9)
jbuilder (1.4.2)
@@ -75,9 +101,13 @@ GEM
treetop (~> 1.4.8)
method_source (0.8.2)
mime-types (1.25.1)
+ mini_portile (0.5.2)
minitest (4.7.5)
moped (1.5.0)
multi_json (1.8.4)
+ multi_test (0.0.3)
+ nokogiri (1.6.1)
+ mini_portile (~> 0.5.0)
origin (1.1.0)
polyglot (0.3.4)
pry (0.9.12.4)
@@ -109,6 +139,26 @@ GEM
thor (>= 0.18.1, < 2.0)
raindrops (0.11.0)
rake (10.1.1)
+ rspec-collection_matchers (0.0.3)
+ rspec-expectations (>= 2.99.0.beta1)
+ rspec-core (3.0.0.beta2)
+ rspec-support (= 3.0.0.beta2)
+ rspec-expectations (3.0.0.beta2)
+ diff-lcs (>= 1.2.0, < 2.0)
+ rspec-support (= 3.0.0.beta2)
+ rspec-mocks (3.0.0.beta2)
+ rspec-support (= 3.0.0.beta2)
+ rspec-rails (3.0.0.beta2)
+ actionpack (>= 3.0)
+ activemodel (>= 3.0)
+ activesupport (>= 3.0)
+ railties (>= 3.0)
+ rspec-collection_matchers
+ rspec-core (= 3.0.0.beta2)
+ rspec-expectations (= 3.0.0.beta2)
+ rspec-mocks (= 3.0.0.beta2)
+ rspec-support (= 3.0.0.beta2)
+ rspec-support (3.0.0.beta2)
sass (3.2.14)
sass-rails (4.0.1)
railties (>= 4.0.0, < 5.0)
@@ -144,6 +194,8 @@ GEM
wicked (0.6.1)
activesupport (>= 3.0.7)
rails (>= 3.0.7)
+ xpath (2.0.0)
+ nokogiri (~> 1.3)
PLATFORMS
ruby
@@ -153,6 +205,9 @@ DEPENDENCIES
binding_of_caller
bootstrap-sass
coffee-rails
+ cucumber-rails
+ database_cleaner
+ factory_girl_rails
figaro
font-awesome-rails
jbuilder (~> 1.2)
@@ -161,6 +216,7 @@ DEPENDENCIES
pry-rails
rails (= 4.0.3)
rails_12factor
+ rspec-rails (~> 3.0.0.beta)
sass-rails
turbolinks
uglifier (>= 1.3.0)
View
@@ -0,0 +1,16 @@
+#!/usr/bin/env ruby
+#
+# This file was generated by Bundler.
+#
+# The application 'rspec' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require 'pathname'
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
+ Pathname.new(__FILE__).realpath)
+
+require 'rubygems'
+require 'bundler/setup'
+
+load Gem.bin_path('rspec-core', 'rspec')
@@ -30,5 +30,10 @@ class Application < Rails::Application
script.js
install_steps.css
basic.rb ]
+
+ config.generators do |g|
+ g.test_framework :rspec, :views => false, :fixture => true
+ g.fixture_replacement :factory_girl, :dir => 'spec/factories'
+ end
end
end
View
@@ -0,0 +1,8 @@
+<%
+rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
+rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
+std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
+%>
+default: <%= std_opts %> features
+wip: --tags @wip:3 --wip features
+rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
View
@@ -1,2 +1,2 @@
PORT=3000
-RACK_ENV=DEVELOPMENT
+RACK_ENV=development
@@ -0,0 +1,62 @@
+# 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
+ # Needed for postgresql
+ # DatabaseCleaner.strategy = :transaction
+
+ # Needed for Mongo
+ DatabaseCleaner.strategy = :truncation
+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('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@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,65 @@
+# 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
+ 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'
+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
View
@@ -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
View
@@ -0,0 +1,43 @@
+# This file is copied to spec/ when you run 'rails generate rspec:install'
+ENV["RAILS_ENV"] ||= 'test'
+require File.expand_path("../../config/environment", __FILE__)
+require 'rspec/rails'
+
+# Requires supporting ruby files with custom matchers and macros, etc, in
+# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
+# run as spec files by default. This means that files in spec/support that end
+# in _spec.rb will both be required and run as specs, causing the specs to be
+# run twice. It is recommended that you do not name files matching this glob to
+# end with _spec.rb. You can configure this pattern with with the --pattern
+# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
+Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
+
+# Checks for pending migrations before tests are run.
+# If you are not using ActiveRecord, you can remove this line.
+ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
+
+RSpec.configure do |config|
+ # ## Mock Framework
+ #
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
+ #
+ # config.mock_with :mocha
+ # config.mock_with :flexmock
+ # config.mock_with :rr
+
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
+ # config.fixture_path = "#{::Rails.root}/spec/fixtures"
+
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
+ # examples within a transaction, remove the following line or assign false
+ # instead of true.
+
+ # needed for postgresql only
+ # config.use_transactional_fixtures = true
+
+ # Run specs in random order to surface order dependencies. If you find an
+ # order dependency and want to debug it, you can fix the order by providing
+ # the seed, which is printed after each run.
+ # --seed 1234
+ config.order = "random"
+end
File renamed without changes.
No changes.
@@ -1,7 +0,0 @@
-require 'test_helper'
-
-class InstallStepsControllerTest < ActionController::TestCase
- # test "the truth" do
- # assert true
- # end
-end
@@ -1,9 +0,0 @@
-require 'test_helper'
-
-class WelcomeControllerTest < ActionController::TestCase
- test "should get index" do
- get :index
- assert_response :success
- end
-
-end
View
No changes.
View
No changes.
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class InstallStepsHelperTest < ActionView::TestCase
-end
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class WelcomeHelperTest < ActionView::TestCase
-end
No changes.
View
No changes.
Oops, something went wrong.

0 comments on commit 9b1499b

Please sign in to comment.