Skip to content
Browse files

Set up test environment.

  • Loading branch information...
1 parent b0f29a5 commit c4bde5f9ce12bbb5feeb9adb6684de3f478bc00f @tristandunn committed Feb 11, 2012
Showing with 224 additions and 51 deletions.
  1. +9 −31 Gemfile
  2. +78 −20 Gemfile.lock
  3. +8 −0 config/cucumber.yml
  4. +30 −0 features/support/env.rb
  5. +65 −0 lib/tasks/cucumber.rake
  6. +10 −0 script/cucumber
  7. +24 −0 spec/spec_helper.rb
View
40 Gemfile
@@ -2,36 +2,14 @@ source 'https://rubygems.org'
gem 'rails', '3.2.1'
-# Bundle edge Rails instead:
-# gem 'rails', :git => 'git://github.com/rails/rails.git'
-
-
-
-# Gems used only for assets and not required
-# in production environments by default.
-group :assets do
- gem 'sass-rails', '~> 3.2.3'
- gem 'coffee-rails', '~> 3.2.1'
-
- # See https://github.com/sstephenson/execjs#readme for more supported runtimes
- # gem 'therubyracer'
-
- gem 'uglifier', '>= 1.0.3'
+group :development do
+ gem 'rspec-rails', '2.8.1'
end
-
-
-# To use ActiveModel has_secure_password
-# gem 'bcrypt-ruby', '~> 3.0.0'
-
-# To use Jbuilder templates for JSON
-# gem 'jbuilder'
-
-# Use unicorn as the web server
-# gem 'unicorn'
-
-# Deploy with Capistrano
-# gem 'capistrano'
-
-# To use debugger
-# gem 'ruby-debug19', :require => 'ruby-debug'
+group :test do
+ gem 'bourne', '1.0'
+ gem 'cucumber-rails', '1.2.1', require: false
+ gem 'pusher-fake', git: 'git://github.com/tristandunn/pusher-fake.git'
+ gem 'rspec-rails', '2.8.1'
+ gem 'shoulda-matchers', '1.0.0'
+end
View
98 Gemfile.lock
@@ -1,3 +1,13 @@
+GIT
+ remote: git://github.com/tristandunn/pusher-fake.git
+ revision: d9309262dba2f5b6ca57ac6842d6fae908198a06
+ specs:
+ pusher-fake (0.1.0)
+ em-websocket (= 0.3.6)
+ ruby-hmac (= 0.4.0)
+ thin (= 1.3.1)
+ yajl-ruby (= 1.1.0)
+
GEM
remote: https://rubygems.org/
specs:
@@ -28,18 +38,40 @@ GEM
activesupport (3.2.1)
i18n (~> 0.6)
multi_json (~> 1.0)
+ addressable (2.2.6)
arel (3.0.0)
+ bourne (1.0)
+ mocha (= 0.9.8)
builder (3.0.0)
- coffee-rails (3.2.2)
- coffee-script (>= 2.2.0)
- railties (~> 3.2.0)
- coffee-script (2.2.0)
- coffee-script-source
- execjs
- coffee-script-source (1.2.0)
+ capybara (1.1.2)
+ mime-types (>= 1.16)
+ nokogiri (>= 1.3.3)
+ rack (>= 1.0.0)
+ rack-test (>= 0.5.4)
+ selenium-webdriver (~> 2.0)
+ xpath (~> 0.1.4)
+ childprocess (0.3.1)
+ ffi (~> 1.0.6)
+ cucumber (1.1.4)
+ builder (>= 2.1.2)
+ diff-lcs (>= 1.1.2)
+ gherkin (~> 2.7.1)
+ json (>= 1.4.6)
+ term-ansicolor (>= 1.0.6)
+ cucumber-rails (1.2.1)
+ capybara (>= 1.1.2)
+ cucumber (>= 1.1.3)
+ nokogiri (>= 1.5.0)
+ daemons (1.1.8)
+ diff-lcs (1.1.3)
+ em-websocket (0.3.6)
+ addressable (>= 2.1.1)
+ eventmachine (>= 0.12.9)
erubis (2.7.0)
- execjs (1.3.0)
- multi_json (~> 1.0)
+ eventmachine (0.12.10)
+ ffi (1.0.11)
+ gherkin (2.7.7)
+ json (>= 1.4.6)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.1)
@@ -49,7 +81,10 @@ GEM
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.17.2)
+ mocha (0.9.8)
+ rake
multi_json (1.0.4)
+ nokogiri (1.5.0)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.1)
@@ -76,30 +111,53 @@ GEM
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
- sass (3.1.15)
- sass-rails (3.2.4)
- railties (~> 3.2.0)
- sass (>= 3.1.10)
- tilt (~> 1.3)
+ rspec (2.8.0)
+ rspec-core (~> 2.8.0)
+ rspec-expectations (~> 2.8.0)
+ rspec-mocks (~> 2.8.0)
+ rspec-core (2.8.0)
+ rspec-expectations (2.8.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.8.0)
+ rspec-rails (2.8.1)
+ actionpack (>= 3.0)
+ activesupport (>= 3.0)
+ railties (>= 3.0)
+ rspec (~> 2.8.0)
+ ruby-hmac (0.4.0)
+ rubyzip (0.9.6.1)
+ selenium-webdriver (2.19.0)
+ childprocess (>= 0.2.5)
+ ffi (~> 1.0.9)
+ multi_json (~> 1.0.4)
+ rubyzip
+ shoulda-matchers (1.0.0)
sprockets (2.1.2)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
+ term-ansicolor (1.0.7)
+ thin (1.3.1)
+ daemons (>= 1.0.9)
+ eventmachine (>= 0.12.6)
+ rack (>= 1.0.0)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.31)
- uglifier (1.2.3)
- execjs (>= 0.3.0)
- multi_json (>= 1.0.2)
+ xpath (0.1.4)
+ nokogiri (~> 1.3)
+ yajl-ruby (1.1.0)
PLATFORMS
ruby
DEPENDENCIES
- coffee-rails (~> 3.2.1)
+ bourne (= 1.0)
+ cucumber-rails (= 1.2.1)
+ pusher-fake!
rails (= 3.2.1)
- sass-rails (~> 3.2.3)
- uglifier (>= 1.0.3)
+ rspec-rails (= 2.8.1)
+ shoulda-matchers (= 1.0.0)
View
8 config/cucumber.yml
@@ -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
30 features/support/env.rb
@@ -0,0 +1,30 @@
+# 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 XPath selectors rather than Webrat's default of CSS3. In
+# order to ease the transition to Capybara we set the default here. If you'd
+# prefer to use XPath just remove this line and adjust any selectors in your
+# steps to use the XPath syntax.
+Capybara.default_selector = :css
+
+# 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
View
65 lib/tasks/cucumber.rake
@@ -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 => 'db: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 => 'db: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 => 'db: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 ActiveRecord, append a no-op task that we can depend upon.
+ task 'db: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
10 script/cucumber
@@ -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
24 spec/spec_helper.rb
@@ -0,0 +1,24 @@
+# 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'
+require 'rspec/autorun'
+
+# Requires supporting ruby files with custom matchers and macros, etc,
+# in spec/support/ and its subdirectories.
+Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
+
+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
+
+ # If true, the base class of anonymous controllers will be inferred
+ # automatically. This will be the default behavior in future versions of
+ # rspec-rails.
+ config.infer_base_class_for_anonymous_controllers = false
+end

0 comments on commit c4bde5f

Please sign in to comment.
Something went wrong with that request. Please try again.