Permalink
Browse files

RSpec, guard and factory girl now works correctly

  • Loading branch information...
1 parent 6b0f84b commit cc08548202bd824a34a064ba4eba11f78d4fcd84 jipiboily committed Jan 14, 2012
Showing with 107 additions and 9 deletions.
  1. +1 −0 .rspec
  2. +48 −1 Gemfile.lock
  3. +19 −0 Guardfile
  4. +3 −1 lib/monologue/engine.rb
  5. +3 −0 monologue.gemspec
  6. +33 −7 spec/spec_helper.rb
View
1 .rspec
@@ -0,0 +1 @@
+--colour
View
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- monologue (0.0.1)
+ monologue (0.0.1.alpha)
rails (~> 3.1.3)
GEM
@@ -37,7 +37,28 @@ GEM
multi_json (~> 1.0)
arel (2.2.1)
builder (3.0.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.0)
+ ffi (~> 1.0.6)
+ diff-lcs (1.1.3)
erubis (2.7.0)
+ factory_girl (2.3.2)
+ activesupport
+ factory_girl_rails (1.4.0)
+ factory_girl (~> 2.3.0)
+ railties (>= 3.0.0)
+ ffi (1.0.11)
+ guard (0.10.0)
+ ffi (>= 0.5.0)
+ thor (~> 0.14.6)
+ guard-rspec (0.6.0)
+ guard (>= 0.10.0)
hike (1.2.1)
i18n (0.6.0)
jquery-rails (1.0.19)
@@ -50,6 +71,7 @@ GEM
treetop (~> 1.4.8)
mime-types (1.17.2)
multi_json (1.0.4)
+ nokogiri (1.5.0)
polyglot (0.3.3)
rack (1.3.6)
rack-cache (1.1)
@@ -78,6 +100,25 @@ GEM
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
+ 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)
+ rubyzip (0.9.5)
+ selenium-webdriver (2.16.0)
+ childprocess (>= 0.2.5)
+ ffi (~> 1.0.9)
+ multi_json (~> 1.0.4)
+ rubyzip
sprockets (2.0.3)
hike (~> 1.2)
rack (~> 1.0)
@@ -89,11 +130,17 @@ GEM
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.31)
+ xpath (0.1.4)
+ nokogiri (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
+ capybara
+ factory_girl_rails (~> 1.4.0)
+ guard-rspec
jquery-rails
monologue!
+ rspec-rails (~> 2.8)
sqlite3
View
@@ -0,0 +1,19 @@
+# A sample Guardfile
+# More info at https://github.com/guard/guard#readme
+
+guard 'rspec', :version => 2 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{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
+ watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_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('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" }
+end
+
View
@@ -2,7 +2,9 @@ module Monologue
class Engine < Rails::Engine
isolate_namespace Monologue
+ config.generators.test_framework :rspec, :view_specs => false, :fixture => false
+ config.generators.stylesheets false
+ config.generators.fixture_replacement :factory_girl
config.generators.integration_tool :rspec
- config.generators.test_framework :rspec
end
end
View
@@ -18,7 +18,10 @@ Gem::Specification.new do |s|
s.add_dependency "rails", "~> 3.1.3"
# s.add_dependency "jquery-rails"
s.add_development_dependency "rspec-rails", "~> 2.8"
+ s.add_development_dependency 'factory_girl_rails', '~> 1.4.0'
s.add_development_dependency "capybara"
+ s.add_development_dependency "guard-rspec"
+
s.add_development_dependency "sqlite3"
end
View
@@ -1,14 +1,40 @@
-# Configure Rails Environment
-ENV["RAILS_ENV"] = "test"
-
-require File.expand_path("../dummy/config/environment.rb", __FILE__)
+# This file is copied to spec/ when you run 'rails generate rspec:install'
+ENV["RAILS_ENV"] ||= 'test'
+require File.expand_path("../dummy/config/environment", __FILE__)
require 'rspec/rails'
+require 'capybara/rspec'
+require 'rspec/autorun'
+require "factory_girl_rails"
+
+ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
+
+# Requires supporting ruby files with custom matchers and macros, etc,
+# in spec/support/ and its subdirectories.
+Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each {|f| require f }
+Dir[File.join(ENGINE_RAILS_ROOT, "spec/factories/**/*.rb")].each {|f| require f}
-Rails.backtrace_cleaner.remove_silencers!
-# Load support files
-Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
+Rails.backtrace_cleaner.remove_silencers!
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
end

0 comments on commit cc08548

Please sign in to comment.