Permalink
Browse files

added rspec, cucumber and spork

  • Loading branch information...
1 parent acc47da commit b35e4b0069f2526dc40af40faff13c532e61edcc @drapergeek committed Apr 9, 2012
Showing with 137 additions and 84 deletions.
  1. +5 −0 Gemfile
  2. +20 −0 Gemfile.lock
  3. +51 −53 features/support/env.rb
  4. +5 −0 features/testing.feature
  5. +56 −31 spec/spec_helper.rb
View
5 Gemfile
@@ -18,4 +18,9 @@ group :development, :test do
gem 'rspec-rails'
gem 'cucumber-rails', :require => false
gem 'factory_girl_rails'
+ gem 'spork', '~> 1.0rc'
+ gem 'mocha'
+ gem 'pry'
+ gem 'database_cleaner'
+ gem 'launchy'
end
View
20 Gemfile.lock
@@ -28,6 +28,7 @@ GEM
activesupport (3.2.3)
i18n (~> 0.6)
multi_json (~> 1.0)
+ addressable (2.2.7)
archive-tar-minitar (0.5.2)
arel (3.0.2)
builder (3.0.0)
@@ -40,6 +41,7 @@ GEM
xpath (~> 0.1.4)
childprocess (0.3.1)
ffi (~> 1.0.6)
+ coderay (1.0.5)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
@@ -58,6 +60,7 @@ GEM
capybara (>= 1.1.2)
cucumber (>= 1.1.8)
nokogiri (>= 1.5.0)
+ database_cleaner (0.7.2)
diff-lcs (1.1.3)
erubis (2.7.0)
execjs (1.3.0)
@@ -77,16 +80,26 @@ GEM
railties (>= 3.2.0, < 5.0)
thor (~> 0.14)
json (1.6.6)
+ launchy (2.1.0)
+ addressable (~> 2.2.6)
linecache19 (0.5.12)
ruby_core_source (>= 0.1.4)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
+ metaclass (0.0.1)
+ method_source (0.7.1)
mime-types (1.18)
+ mocha (0.10.5)
+ metaclass (~> 0.0.1)
multi_json (1.2.0)
nokogiri (1.5.2)
polyglot (0.3.3)
+ pry (0.9.8.4)
+ coderay (~> 1.0.5)
+ method_source (~> 0.7.1)
+ slop (>= 2.4.4, < 3)
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
@@ -146,6 +159,8 @@ GEM
ffi (~> 1.0)
multi_json (~> 1.0)
rubyzip
+ slop (2.4.4)
+ spork (1.0.0rc2)
sprockets (2.1.2)
hike (~> 1.2)
rack (~> 1.0)
@@ -170,11 +185,16 @@ PLATFORMS
DEPENDENCIES
coffee-rails (~> 3.2.1)
cucumber-rails
+ database_cleaner
factory_girl_rails
jquery-rails
+ launchy
+ mocha
+ pry
rails (= 3.2.3)
rspec-rails
ruby-debug19
sass-rails (~> 3.2.3)
+ spork (~> 1.0rc)
sqlite3
uglifier (>= 1.0.3)
View
104 features/support/env.rb
@@ -1,59 +1,57 @@
-# 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
-
-# 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."
+require 'spork'
+
+Spork.prefork do
+ # Loading more in this block will cause your tests to run faster. However,
+ # if you change any configuration or code from libraries loaded here, you'll
+ # need to restart spork for it take effect.
+
+ require 'cucumber/rails'
+
+ Capybara.default_selector = :css
+
+ ActionController::Base.allow_rescue = false
+
+ 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
+
+ Cucumber::Rails::Database.javascript_strategy = :truncation
+
+end
+
+Spork.each_run do
+ # This code will be run each time you run your specs.
+
end
-# You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.
-# See the DatabaseCleaner documentation for details. Example:
+# --- Instructions ---
+# Sort the contents of this file into a Spork.prefork and a Spork.each_run
+# block.
#
-# Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
-# # { :except => [:widgets] } may not do what you expect here
-# # as tCucumber::Rails::Database.javascript_strategy overrides
-# # this setting.
-# DatabaseCleaner.strategy = :truncation
-# end
+# The Spork.prefork block is run only once when the spork server is started.
+# You typically want to place most of your (slow) initializer code in here, in
+# particular, require'ing any 3rd-party gems that you don't normally modify
+# during development.
#
-# Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
-# DatabaseCleaner.strategy = :transaction
-# end
+# The Spork.each_run block is run each time you run your specs. In case you
+# need to load files that tend to change during development, require them here.
+# With Rails, your application modules are loaded automatically, so sometimes
+# this block can remain empty.
#
-
-# 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
+# Note: You can modify files loaded *from* the Spork.each_run block without
+# restarting the spork server. However, this file itself will not be reloaded,
+# so if you change any of the code inside the each_run block, you still need to
+# restart the server. In general, if you have non-trivial code in this file,
+# it's advisable to move it into a separate file so you can easily edit it
+# without restarting spork. (For example, with RSpec, you could move
+# non-trivial code into a file spec/support/my_helper.rb, making sure that the
+# spec/support/* files are require'd from inside the each_run block.)
+#
+# Any code that is left outside the two blocks will be run during preforking
+# *and* during each_run -- that's probably not what you want.
+#
+# These instructions should self-destruct in 10 seconds. If they don't, feel
+# free to delete them.
View
5 features/testing.feature
@@ -0,0 +1,5 @@
+Feature: Making sure cucumber runs
+
+ Scenario:
+ When I visit the homepage
+ Then I should see rails
View
87 spec/spec_helper.rb
@@ -1,32 +1,57 @@
-# 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
-
- # 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.
- config.use_transactional_fixtures = true
-
- # 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
+require 'rubygems'
+require 'spork'
+Spork.prefork do
+ 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|
+ config.mock_with :mocha
+ config.use_transactional_fixtures = true
+ config.infer_base_class_for_anonymous_controllers = false
+ end
+
+end
+
+Spork.each_run do
+ # This code will be run each time you run your specs.
+
end
+
+# --- Instructions ---
+# Sort the contents of this file into a Spork.prefork and a Spork.each_run
+# block.
+#
+# The Spork.prefork block is run only once when the spork server is started.
+# You typically want to place most of your (slow) initializer code in here, in
+# particular, require'ing any 3rd-party gems that you don't normally modify
+# during development.
+#
+# The Spork.each_run block is run each time you run your specs. In case you
+# need to load files that tend to change during development, require them here.
+# With Rails, your application modules are loaded automatically, so sometimes
+# this block can remain empty.
+#
+# Note: You can modify files loaded *from* the Spork.each_run block without
+# restarting the spork server. However, this file itself will not be reloaded,
+# so if you change any of the code inside the each_run block, you still need to
+# restart the server. In general, if you have non-trivial code in this file,
+# it's advisable to move it into a separate file so you can easily edit it
+# without restarting spork. (For example, with RSpec, you could move
+# non-trivial code into a file spec/support/my_helper.rb, making sure that the
+# spec/support/* files are require'd from inside the each_run block.)
+#
+# Any code that is left outside the two blocks will be run during preforking
+# *and* during each_run -- that's probably not what you want.
+#
+# These instructions should self-destruct in 10 seconds. If they don't, feel
+# free to delete them.
+
+
+
+

0 comments on commit b35e4b0

Please sign in to comment.