Commits

Josh Hubbard  committed d331947

Installed guard and spork to speed up rspec testing.

  • Participants
  • Parent commits 149cc99

Comments (0)

Files changed (6)

 --colour
+--drb
    gem 'webrat', '0.7.1'
    gem 'factory_girl_rails', '1.0'
    gem 'ladle'
+   gem 'spork', '0.9.0'
+   gem 'guard-spork', '0.3.2'
 end
 
 

File Gemfile.lock

     archive-tar-minitar (0.5.2)
     arel (2.0.10)
     builder (2.1.2)
+    coderay (1.0.9)
     columnize (0.3.4)
     diff-lcs (1.1.3)
     erubis (2.6.6)
       addressable (~> 2.2.4)
       multipart-post (~> 1.1.0)
       rack (>= 1.1.0, < 2)
+    formatador (0.2.4)
     gravatar_image_tag (1.0.0.pre2)
+    guard (1.7.0)
+      formatador (>= 0.2.4)
+      listen (>= 0.6.0)
+      lumberjack (>= 1.0.2)
+      pry (>= 0.9.10)
+      thor (>= 0.14.6)
+    guard-spork (0.3.2)
+      guard (>= 0.8.4)
+      spork (>= 0.8.4)
     htmlentities (4.3.1)
     i18n (0.5.0)
     json (1.7.6)
       open4 (~> 1.0.0)
     linecache19 (0.5.12)
       ruby_core_source (>= 0.1.4)
+    listen (0.7.3)
+    lumberjack (1.0.3)
     mail (2.2.19)
       activesupport (>= 2.3.6)
       i18n (>= 0.4.0)
       mime-types (~> 1.16)
       treetop (~> 1.4.8)
+    method_source (0.8.1)
     mime-types (1.19)
     multi_json (1.0.3)
     multi_xml (0.2.2)
       oa-openid (= 0.2.6)
     open4 (1.0.1)
     polyglot (0.3.3)
+    pry (0.9.12)
+      coderay (~> 1.0.5)
+      method_source (~> 0.8)
+      slop (~> 3.4)
     pyu-ruby-sasl (0.0.3.3)
     rack (1.2.7)
     rack-mount (0.6.14)
     ruby_core_source (0.1.5)
       archive-tar-minitar (>= 0.5.2)
     rubyntlm (0.1.1)
+    slop (3.4.4)
+    spork (0.9.0)
     sqlite3 (1.3.3)
     thor (0.14.6)
     treetop (1.4.12)
   annotate (= 2.4.0)
   factory_girl_rails (= 1.0)
   gravatar_image_tag (= 1.0.0.pre2)
+  guard-spork (= 0.3.2)
   htmlentities
   ladle
   mysql2 (< 0.3)
   rspec (= 2.6.0)
   rspec-rails (= 2.6.1)
   ruby-debug19
+  spork (= 0.9.0)
   sqlite3 (= 1.3.3)
   uuidtools
   webrat (= 0.7.1)
+# A sample Guardfile
+# More info at https://github.com/guard/guard#readme
+
+guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do
+  watch(%r{^spec/.+_spec\.rb$})
+  watch(%r{^lib/(.+)\.rb$})     { |m| "spec/lib/#{m[1]}_spec.rb" }
+  watch('spec/spec_helper.rb')  { "spec" }
+
+  # Rails example
+  watch(%r{^spec/.+_spec\.rb$})
+  watch(%r{^app/(.+)\.rb$})                           { |m| "spec/#{m[1]}_spec.rb" }
+  watch(%r{^app/(.*)(\.erb|\.haml)$})                 { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
+  watch(%r{^lib/(.+)\.rb$})                           { |m| "spec/lib/#{m[1]}_spec.rb" }
+  watch(%r{^app/controllers/(.+)_(controller)\.rb$})  { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
+  watch(%r{^spec/support/(.+)\.rb$})                  { "spec" }
+  watch('spec/spec_helper.rb')                        { "spec" }
+  watch('config/routes.rb')                           { "spec/routing" }
+  watch('app/controllers/application_controller.rb')  { "spec/controllers" }
+  # Capybara request specs
+  watch(%r{^app/views/(.+)/.*\.(erb|haml)$})          { |m| "spec/requests/#{m[1]}_spec.rb" }
+
+  watch(%r{^app/controllers/(.+)_(controller)\.rb$}) do |m|
+    ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb",
+     (m[1][/_pages/] ? "spec/requests/#{m[1]}_spec.rb" :
+       "spec/requests/#{m[1].singularize}_pages_spec.rb")]
+  end
+  watch(%r{^app/views/(.+)/}) do |m|
+    "spec/requests/#{m[1].singularize}_pages_spec.rb"
+  end
+end

File spec/requests/users_spec.rb

+require 'spec_helper'
+
+describe "Users" do
+  describe "GET /users" do
+    it "works! (now write some real specs)" do
+      # Run the generator again with the --webrat flag if you want to use webrat methods/matchers
+      get users_path
+      response.should be_redirect
+    end
+  end
+end

File spec/spec_helper.rb

+require 'rubygems'
+require 'spork'
+#uncomment the following line to use spork with the debugger
+#require 'spork/ext/ruby-debug'
+
+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.
+  ENV["RAILS_ENV"] ||= 'test'
+  require File.expand_path("../../config/environment", __FILE__)
+  require 'rspec/rails'
+  require 'rspec/autorun'
+
+  Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
+end
+
+Spork.each_run do
+  # This code will be run each time you run your specs.
+  DmpTool::Application.reload_routes!
+  Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
+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.
+
+
+
+
 # This file is copied to spec/ when you run 'rails generate rspec:install'
 ENV["RAILS_ENV"] ||= 'test'
 require File.expand_path("../../config/environment", __FILE__)