- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我正在尝试使用一些 Ruby 文件和 RSpec 测试在小型 Ruby 中创建一个 Guardfile。这不是 Rails 项目。
当我运行 gem install guard
时,我得到以下信息:
$ gem install guard
Fetching: listen-1.3.1.gem (100%)
Successfully installed listen-1.3.1
Fetching: lumberjack-1.0.4.gem (100%)
Successfully installed lumberjack-1.0.4
Fetching: guard-1.8.3.gem (100%)
Successfully installed guard-1.8.3
Installing ri documentation for listen-1.3.1
Installing ri documentation for lumberjack-1.0.4
unable to convert "\xCF" from ASCII-8BIT to UTF-8 for bin/fsevent_watch_guard, skipping
Installing ri documentation for guard-1.8.3
3 gems installed
显然应该安装“\xCF”,但实际上没有。我无法弄清楚这是什么,也不知道它是否是我的问题的可能原因。
稍后,当我尝试为 RSpec 测试创建守卫时,会发生以下情况:
$ guard init rspec
19:45:11 - INFO - Writing new Guardfile to /home/kathryn/demo3/Guardfile
19:45:11 - ERROR - Could not load 'guard/rspec' or '~/.guard/templates/rspec' or find class Guard::Rspec
正如 INFO 所建议的那样,创建了一个新的 Guardfile,但其中充满了一条注释,指示我查看 gem 的 README,而不是 RSpec 的 guard。如果我手动为 RSpec 添加守卫,然后尝试运行 guard
,结果是:
$ guard
19:41:03 - ERROR - Could not load 'guard/rspec' or find class Guard::Rspec
19:41:03 - ERROR - cannot load such file -- guard/rspec
19:41:03 - ERROR - Invalid Guardfile, original error is:
> [#] undefined method `new' for nil:NilClass
19:41:03 - ERROR - No guards found in Guardfile, please add at least one.
19:41:03 - INFO - Guard is using NotifySend to send notifications.
19:41:03 - INFO - Guard is using TerminalTitle to send notifications.
19:41:04 - INFO - Guard is now watching at '/home/kathryn/demo3'
我看到 gem 找不到它需要的一些文件,但我不确定从这里去哪里。这是我第一次使用守卫。任何帮助表示赞赏。
这是我当前的 Guardfile:
guard :rspec do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
end
那不是自动生成的。当我第一次创建 Guardfile 时,内容是:
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
我在此处添加了作为标准 RubyGem 项目守卫出现的 RSpec 守卫:https://github.com/guard/guard-rspec . (需要说明的是,我没有使用那个 gem 。它只是一个很容易找到守卫的地方。)
最佳答案
安装 guard-rspec
gem 后,它应该“正常工作”。
以下是我为使它干净地加载而正在执行的步骤:
▶ gem install guard-rspec rspec
Fetching: rspec-core-2.14.5.gem (100%)
Successfully installed rspec-core-2.14.5
Fetching: diff-lcs-1.2.4.gem (100%)
Successfully installed diff-lcs-1.2.4
Fetching: rspec-expectations-2.14.2.gem (100%)
Successfully installed rspec-expectations-2.14.2
Fetching: rspec-mocks-2.14.3.gem (100%)
Successfully installed rspec-mocks-2.14.3
Fetching: rspec-2.14.1.gem (100%)
Successfully installed rspec-2.14.1
Fetching: guard-rspec-3.0.3.gem (100%)
Successfully installed guard-rspec-3.0.3
Parsing documentation for rspec-core-2.14.5
Installing ri documentation for rspec-core-2.14.5
Parsing documentation for diff-lcs-1.2.4
Installing ri documentation for diff-lcs-1.2.4
Parsing documentation for rspec-expectations-2.14.2
Installing ri documentation for rspec-expectations-2.14.2
Parsing documentation for rspec-mocks-2.14.3
Installing ri documentation for rspec-mocks-2.14.3
Parsing documentation for rspec-2.14.1
Installing ri documentation for rspec-2.14.1
Parsing documentation for guard-rspec-3.0.3
Installing ri documentation for guard-rspec-3.0.3
Done installing documentation for rspec-core, diff-lcs, rspec-expectations, rspec-mocks, rspec, guard-rspec after 15 seconds
Successfully installed rspec-2.14.1
Parsing documentation for rspec-2.14.1
Done installing documentation for rspec after 0 seconds
7 gems installed
完成后,我执行此命令:
▶ guard init rspec
00:55:13 - INFO - rspec guard added to Guardfile, feel free to edit it
我的 Guardfile 看起来像这样:
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard :rspec 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" }
# 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
当我执行 guard start
命令时,这些错误不会显示:
▶ guard start
00:57:08 - INFO - Guard uses NotifySend to send notifications.
00:57:08 - INFO - Guard uses Tmux to send notifications.
00:57:08 - INFO - Guard uses TerminalTitle to send notifications.
00:57:09 - INFO - Guard::RSpec is running
00:57:09 - INFO - Guard is now watching at '/home/vgoff/my_gems'
关于ruby - 新生成的 Guardfile 为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18863207/
我正在尝试使用一些 Ruby 文件和 RSpec 测试在小型 Ruby 中创建一个 Guardfile。这不是 Rails 项目。 当我运行 gem install guard 时,我得到以下信息
我在子文件夹中组织了我的功能,如下所示: app/ features/ users/ feature1.feature feature2.feature 但是
我在一个 ruby 的非 Rails 项目中使用 Guard。 (是的,rails 标签就在那里,所以合适的人会找到它。) 我有一个系统设置,它正在由我的 Guardfile 不断构建。当我 ru
尽管可以轻松地在Sublime Text中设置给定(打开)文件的语言,但我想知道是否有什么办法可以提前告诉编辑器,应将类似于Ruby代码的高亮显示为“Guardfile”的任何内容。有谁知道如何做到这
我是一名优秀的程序员,十分优秀!