我一直在关注http://ruby.railstutorial.org/chapters/static-pages的教程,我使用Rails 4.0.2的ruby 2.0.0。我安装了Guard,它配置为使用spork。 Everythign正在运作 - sorta。
我遇到了https://github.com/guard/guard/issues/495
中提到的错误我已经尝试更改版本要求,因此我在开发组中使用了最新版本的gem,但是当更改触发guard的内容以运行规范时,它会运行3次。
这是我的宝石文件:
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 'mysql2'
gem 'rspec-rails'#, '2.13.1'
gem 'guard-rspec'#, '2.5.0'
gem 'spork-rails'#, '4.0.0'
gem 'guard-spork'#, '1.5.0'
gem 'childprocess'#, '0.4.2'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
gem 'libnotify'#, '0.8.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
这是我的GuardFile
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
require 'active_support/inflector'
interactor :simple
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|\.slim)$}) { |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' }
watch(%r{^app/views/(.+)/}) { |m| (m[1][/_pages/] ? "spec/requests/#{m[1]}_spec.rb" : "spec/requests/#{m[1].singularize}_pages_spec.rb")}
# Capybara features specs
watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |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
这是我的规范助手:
require 'rubygems'
require 'spork'
Spork.prefork do
rubymine_home = '/home/matt/Desktop/RubyMine-6.0.3/'
if rubymine_home
$:.unshift(File.expand_path('rb/testing/patch/common', rubymine_home))
$:.unshift(File.expand_path('rb/testing/patch/bdd', rubymine_home))
end
... Defaults Here ...
end
Spork.each_run do
# This code will be run each time you run your specs.
end
以下是bundle show
的结果Gems included by the bundle:
* actionmailer (4.0.2)
* actionpack (4.0.2)
* activemodel (4.0.2)
* activerecord (4.0.2)
* activerecord-deprecated_finders (1.0.3)
* activesupport (4.0.2)
* arel (4.0.2)
* atomic (1.1.14)
* builder (3.1.4)
* bundler (1.5.3)
* capybara (2.1.0)
* celluloid (0.15.2)
* celluloid-io (0.15.0)
* childprocess (0.4.2)
* coderay (1.1.0)
* coffee-rails (4.0.1)
* coffee-script (2.2.0)
* coffee-script-source (1.7.0)
* diff-lcs (1.2.5)
* erubis (2.7.0)
* execjs (2.0.2)
* ffi (1.9.3)
* formatador (0.2.4)
* guard (2.4.0)
* guard-rspec (2.5.0)
* guard-spork (1.5.0)
* hike (1.2.3)
* i18n (0.6.9)
* jbuilder (1.0.2)
* jquery-rails (3.0.4)
* json (1.8.1)
* libnotify (0.8.0)
* listen (2.5.0)
* lumberjack (1.0.4)
* mail (2.5.4)
* method_source (0.8.2)
* mime-types (1.25.1)
* mini_portile (0.5.2)
* minitest (4.7.5)
* multi_json (1.8.4)
* mysql2 (0.3.15)
* nio4r (1.0.0)
* nokogiri (1.6.1)
* polyglot (0.3.3)
* pry (0.9.12.6)
* rack (1.5.2)
* rack-test (0.6.2)
* rails (4.0.2)
* railties (4.0.2)
* rake (10.1.1)
* rb-fsevent (0.9.4)
* rb-inotify (0.9.3)
* rdoc (3.12.2)
* rspec (2.13.0)
* rspec-core (2.13.1)
* rspec-expectations (2.13.0)
* rspec-mocks (2.13.1)
* rspec-rails (2.13.1)
* rubyzip (0.9.9)
* sass (3.2.14)
* sass-rails (4.0.1)
* sdoc (0.3.20)
* selenium-webdriver (2.35.1)
* slop (3.4.7)
* spork (1.0.0rc4)
* spork-rails (4.0.0)
* sprockets (2.10.1)
* sprockets-rails (2.0.1)
* thor (0.18.1)
* thread_safe (0.1.3)
* tilt (1.4.1)
* timers (1.1.0)
* treetop (1.4.15)
* turbolinks (1.1.1)
* tzinfo (0.3.38)
* uglifier (2.1.1)
* websocket (1.0.7)
* xpath (2.0.0)
我已经在轨道上用红宝石编程了4天(其中2个试图让它工作)。为什么宝石兼容性必须如此复杂!?我应该用什么来解决我遇到的防范问题?
答案 0 :(得分:1)
在发布问题之前,我一直在研究这个问题差不多一个小时但是后来我突然意识到guard-rspec是需要更新的。我不知道如何告诉ruby使用最新的稳定版本。如果有人可以在评论中澄清,我会很感激。
解决方案是更改gem文件: gem'guard-rspec','4.2.6'
然后进行捆绑更新
再次杀死并再次出击防守(或者对于一些防守队员来说)