/ Published in: Bash
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
rails new project_name -T Gemfile: group :development do gem 'rspec-rails', '2.0.1' gem 'annotate-models', '1.0.4' end group :test do gem 'rspec', '2.0.1' gem 'webrat', '0.7.1' gem 'spork', '0.8.4' gem 'factory_girl_rails', '1.0' end rails generate rspec:install spork --bootstrap spec/spec_helper.rb: require 'rubygems' 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. ENV["RAILS_ENV"] ||= 'test' unless defined?(Rails) require File.dirname(__FILE__) + "/../config/environment" end require 'rspec/rails' # Requires supporting files with custom matchers and macros, etc, # in ./support/ and its subdirectories. Dir["#{File.dirname(__FILE__)}/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 config.mock_with :rspec 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, comment the following line or assign false # instead of true. config.use_transactional_fixtures = true ### Part of a Spork hack. See http://bit.ly/arY19y # Emulate initializer set_clear_dependencies_hook in # railties/lib/rails/application/bootstrap.rb ActiveSupport::Dependencies.clear end end Spork.each_run do end config/application.rb: ### Part of a Spork hack. See http://bit.ly/arY19y if Rails.env.test? initializer :after => :initialize_dependency_mechanism do # Work around initializer in railties/lib/rails/application/bootstrap.rb ActiveSupport::Dependencies.mechanism = :load end end .rspec: --colour --drb