1
Rails 3.2.12
我有一個樣本測試規格/型號/ user_spec.rb
require 'spec_helper'
describe User do
pending "add some examples to (or delete) #{__FILE__}"
end
規格/ spec_helper.rb
require 'spork'
Spork.prefork do
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 }
RSpec.configure do |config|
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.use_transactional_fixtures = true
config.infer_base_class_for_anonymous_controllers = false
config.order = "random"
config.color_enabled = true
config.tty = true
config.formatter = :documentation # :progress, :html, :textmate
end
end
Spork.each_run do
end
當我運行測試沒有 Spork我得到:
$ rspec
c:/ruby/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.12/lib/active_support
/dependencies.rb:251:in `block in require': iconv will be deprecated in the futu
re, use String#encode instead.
User
add some examples to (or delete) d:/sites/efiling/spec/models/user_spec.rb (PE
NDING: No reason given)
Pending:
User add some examples to (or delete) d:/sites/efiling/spec/models/user_spec.r
b
# No reason given
# ./spec/models/user_spec.rb:4
Finished in 0.31249 seconds
1 example, 0 failures, 1 pending
Randomized with seed 10437
當我與叉勺運行測試我得到:
$ rspec . --drb
<-- Slave(1) run done!
在叉勺窗口:
Loading Spork.prefork block...
--> DRb magazine_slave_service: 1 provided...
Running tests with args ["--color", "."]...
<-- take tuple(1); slave.run...
-- (1);run done
Done.
-- build slave 1...
Preloading Rails environment
爲什麼Rspec的提供有關未決沒有資料,失敗等測試時,我將它與Spork一起使用?