gpt4 book ai didi

ruby - 守卫监视文件的控制台中没有 rspec 输出

转载 作者:数据小太阳 更新时间:2023-10-29 07:29:09 26 4
gpt4 key购买 nike

我已经安装了“guard”和“guard-rspec”,我还配置了 Guardfile(以观察“app/views”中的变化)但是当我运行“bundle exec guard”时,我总是得到这个:

  vagrant@vagrant-debian-squeeze:/vagrant/sample_app$ bundle exec guard
Guard could not detect any of the supported notification libraries.
Guard is now watching at '/vagrant/sample_app'
Guard::RSpec is running, with RSpec 2!
Running all specs
........

Finished in 0.97359 seconds
8 examples, 0 failures
>

它已经完成了 guard 控制台提示,如果我从“app/views/”编辑一些文件(例如 app/view/static_pages/home.html.erb)并保存它,guard 没有显示任何规范输出,仍然等待一些控制台命令。

我想它应该在保存监视文件后显示一些 rspec 输出。

gem 文件:

source 'https://rubygems.org'

gem 'rails', '3.2.3'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

group :development, :test do
gem 'sqlite3', '1.3.5'
gem 'rspec-rails', '2.9.0'
gem 'guard-rspec', '0.5.5'
gem 'guard'
end

# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '3.2.4'
gem 'coffee-rails', '3.2.2'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer'

gem 'uglifier', '1.2.3'
end

gem 'jquery-rails', '2.0.0'

group :test do
gem 'capybara', '1.1.2'
# gem 'rb-inotify', '0.8.8'
# gem 'libnotify', '0.5.9'
end

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the app server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'

保护文件:

# A sample Guardfile
# More info at https://github.com/guard/guard#readme

require 'active_support/core_ext'

guard 'rspec', :version => 2, :all_after_pass => false 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{^spec/.+_spec\.rb$})
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{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_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", (m[1][/_pages/] ? "spec/requests/#{m[1]}_spec.rb" : "spec/requests/#{m[1].singularize}_pages_spec.rb")]}
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('spec/spec_helper.rb') { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
# Capybara request specs
watch(%r{^app/views/(.+)/}) do |m|
"spec/requests/#{m[1].singularize}_pages_spec.rb"
end
end

“app/views”的守卫规则是

  watch(%r{^app/views/(.+)/}) do |m|
"spec/requests/#{m[1].singularize}_pages_spec.rb"
end

运行时环境:

Debian-Squeeze 32 位 Vagrant 盒子

顺便说一句。我正在学习 Rails 表单 ruby-on-rails-tutorial-book并停留在 Automated tests with Guard

感谢任何帮助,谢谢。

最佳答案

Guard doesn't pick up filesystems changes made by the Vagrant host (在我的例子中是 Ubuntu)。

你可以通过 -p 选项来强制 guard 轮询文件系统(增加 CPU 使用率,不断地撞击硬盘并可能导致你的笔记本电脑温度升高——虽然不理想但它有效)

bundle exec guard -p

关于ruby - 守卫监视文件的控制台中没有 rspec 输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10350365/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com