我正在努力控制Jasmine测试。我曾尝试过含有jasminerice的茉莉花,带有茉莉花环的茉莉花和茶匙。我最终得到了相同的错误 - 我第一次设置防护时测试工作,但每次我保存spec文件或javascript文件时测试都不会更新。当我在防护中运行测试时,或者如果我在浏览器中运行它(即/ jasmine用于jasmine-rails或/茶匙用于茶匙)时,这是正确的,当我运行rails s时测试工作,但是当不运行时更新测试我保存并刷新页面。
我只在spec / javascripts目录中看到这种行为,当我在spec / controllers中运行测试时,guard按预期工作。
关于可能出现什么问题的任何建议?
这是我的Guardfile:
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard 'livereload' do
watch(%r{app/views/.+\.(erb|haml|slim)$})
watch(%r{app/helpers/.+\.rb})
watch(%r{config/locales/.+\.yml})
# Rails Assets Pipeline
watch(%r{(app|vendor)(/assets/\w+/(.+\.(css|js|html|sass))).*}) { |m| "/assets/#{m[3]}" }
end
guard :teaspoon do
# Implementation files
watch(%r{app/assets/javascripts/(.+).js}) { |m| "#{m[1]}_spec" }
# Specs / Helpers
watch(%r{spec/javascripts/(.*)})
end
guard 'rspec', all_after_pass: false, all_on_start: false, bundler: true, cli: "--color --format=doc" 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('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
watch(%r{^app/views/(.+)/}) { |m| "spec/requests/#{m[1]}_spec.rb" }
# Capybara request specs
#watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{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
谢谢,
答案 0 :(得分:1)
更改
watch(%r{app/assets/javascripts/(.+).js}) { |m| "#{m[1]}_spec" }
到
watch(%r{app/assets/javascripts/(.+).js}) { |m| "#{m[1]}_spec.js" }