在Gemfile中添加
group :development do
gem 'rspec-rails', '2.6.1'
end
group :test do
gem 'rspec-rails', '2.6.1'
end
bundle install
In order to get Rails to use RSpec in place of Test::Unit, we need to install the files needed by RSpec. This can be accomplished with rails generate
:
rails generate rspec:install
$ [sudo] gem install autotest -v 4.4.6
$ [sudo] gem install autotest-rails-pure -v 4.1.2
修改完下面这个bug就可以在工程目录中运行autotest进行自动测试了
changing line 226 from:
# hacky_discovery = Gem::Specification.any? { |s| s.name =~ /^rspec/ }
to
# hacky_discovery = true
添加GUI提示
http://automate-everything.com/2009/08/gnome-and-autospec-notifications/
add spork
gem 'spork', '0.9.0.rc8'
bundle install
bundle exec spork --bootstrap
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'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
# Requires supporting files with custom matchers and macros, etc,
# in ./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
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
end
end
Spork.each_run do
end
Adding the --drb option to the
.rspec
file.
--colour --drb