Posted By

Taverneiro on 12/17/10


Tagged


Versions (?)

Start up rails with rspec, tests, etc


 / Published in: Bash
 

  1. rails new project_name -T
  2.  
  3. Gemfile:
  4. group :development do
  5. gem 'rspec-rails', '2.0.1'
  6. gem 'annotate-models', '1.0.4'
  7. end
  8.  
  9. group :test do
  10. gem 'rspec', '2.0.1'
  11. gem 'webrat', '0.7.1'
  12. gem 'spork', '0.8.4'
  13. gem 'factory_girl_rails', '1.0'
  14. end
  15.  
  16. rails generate rspec:install
  17. spork --bootstrap
  18.  
  19. spec/spec_helper.rb:
  20. require 'rubygems'
  21. require 'spork'
  22.  
  23. Spork.prefork do
  24. # Loading more in this block will cause your tests to run faster. However,
  25. # if you change any configuration or code from libraries loaded here, you'll
  26. # need to restart spork for it take effect.
  27. ENV["RAILS_ENV"] ||= 'test'
  28. unless defined?(Rails)
  29. require File.dirname(__FILE__) + "/../config/environment"
  30. end
  31. require 'rspec/rails'
  32.  
  33. # Requires supporting files with custom matchers and macros, etc,
  34. # in ./support/ and its subdirectories.
  35. Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
  36.  
  37. Rspec.configure do |config|
  38. # == Mock Framework
  39. #
  40. # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
  41. #
  42. # config.mock_with :mocha
  43. # config.mock_with :flexmock
  44. # config.mock_with :rr
  45. config.mock_with :rspec
  46.  
  47. config.fixture_path = "#{::Rails.root}/spec/fixtures"
  48.  
  49. # If you're not using ActiveRecord, or you'd prefer not to run each of your
  50. # examples within a transaction, comment the following line or assign false
  51. # instead of true.
  52. config.use_transactional_fixtures = true
  53.  
  54. ### Part of a Spork hack. See http://bit.ly/arY19y
  55. # Emulate initializer set_clear_dependencies_hook in
  56. # railties/lib/rails/application/bootstrap.rb
  57. ActiveSupport::Dependencies.clear
  58. end
  59. end
  60.  
  61. Spork.each_run do
  62. end
  63.  
  64. config/application.rb:
  65. ### Part of a Spork hack. See http://bit.ly/arY19y
  66. if Rails.env.test?
  67. initializer :after => :initialize_dependency_mechanism do
  68. # Work around initializer in railties/lib/rails/application/bootstrap.rb
  69. ActiveSupport::Dependencies.mechanism = :load
  70. end
  71. end
  72.  
  73. .rspec:
  74. --colour
  75. --drb

Report this snippet  

You need to login to post a comment.