我正在尝试使用Spork + Guard + Rspec,但显然它失败了。
我的gemfile:
source 'https://rubygems.org'
ruby '2.0.0'
#ruby-gemset=railstutorial_rails_4_0
gem 'rails', '4.0.2'
group :development, :test do
gem 'sqlite3', '1.3.8'
gem 'rspec-rails', '>= 2.14'
# guard
gem 'guard-rspec', '2.5.0'
# spork
gem 'spork-rails', '4.0.0'
gem 'guard-spork', '1.5.0'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
end
gem 'sass-rails', '4.0.1'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
group :doc do
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'pg', '0.15.1'
gem 'rails_12factor', '0.0.2'
end
我的Guardfile:
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do
watch('config/application.rb')
watch('config/environment.rb')
watch('config/environments/test.rb')
watch(%r{^config/initializers/.+\.rb$})
watch('Gemfile.lock')
watch('spec/spec_helper.rb') { :rspec }
watch('test/test_helper.rb') { :test_unit }
watch(%r{features/support/}) { :cucumber }
end
guard 'rspec', all_after_pass: false, cli: '--drb' 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 features specs
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
# Turnip features and steps
watch(%r{^spec/acceptance/(.+)\.feature$})
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end
我的spec_helper:
require 'rubygems'
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}
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
RSpec.configure do |config|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.use_transactional_fixtures = true
config.infer_base_class_for_anonymous_controllers = false
config.order = "random"
config.include Capybara::DSL
end
end
Spork.each_run do
# This code will be run each time you run your specs.
end
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
# Checks for pending migrations before tests are run.
# If you are not using ActiveRecord, you can remove this line.
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
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
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = "random"
config.include Capybara::DSL
end
我完成了所有配置:
bundle exec guard init rspec
bundle exec spork --bootstrap
bundle exec guard init spork
当我尝试bundle exec guard
出现wtf-error时(我没有全部复制,因为它太重了,只是开头):
C:/Users/Leo/Dropbox/Rails_projCe:c/tUss/esrasm/pLleeo_/aDprpo/psbpoexc//Rsapielcs__hperlopjeerc.trsb/:s8a8m:pilne _`a<ptpo/ps p(erce/qsupierce_dh)e>l'pe:r .urnbd:e8f8i:niend `l<otcoapl v(arrieabqluei roerd )m>e'tho:d `uïn»d¿e'f ifonre mda inl:oObcjaeclt v(NaarmeiEarbrolre)
r fmreotmh oCd: /`Rïa»i¿l'sI nfsotra lmlaeirn/:ROubbjye2c.0t.0 /(liNba/mreuEbryr/goemrs/)2.
.0 /fgermos/ma ctCi:ve/sRupapiolrstI-n4s.t0a.l2l/elirb//Raucbtyi2v.e0_.s0u/plpiobr/tr/duebpye/ngdeemnsc/i2e.s0..r0b/:g2e23m:sin/ a`lcotadi'v
e sfruopm pCo:/rRtai-l4s.I0n.s2t/allilebr//aRucbtyi2.v0e._0s/ulpipbo/rrtu/bdye/pgeenmsd/e2n.c0i.e0s/.grebm:s2/2a3c:tiivne su`plpoorat-d4'.0
2/l ifbr/aocmti vCe_:s/uRpapiolrstI/ndsetpaelnldeern/cRiuebsy.2r.b0:.202/3l:iinb /`rbulboyc/kg eimns /l2o.a0d.'0
/ gferomms C/:a/RcatilisvInesstuaplploerrt/-R4u.b0y.22./0.l0i/bl/iabc/triuvbey_/sguepmps/o2r.t0./0d/geepmse/nacdteivnecsuipeposr.t-r4b.:02.223/:liinb /`abcltoicvke _isnu plpooardt'/d
答案 0 :(得分:0)