Rails 4.2.2-Windows 7/git Bash 上没有显示测试结果:bundle exec guard
Rails 4.2.2-Windows 7/No test results displayed on git Bash for: bundle exec guard
一切都很好,除了,
当我 运行
$ bundle exec guard
我看不到测试结果,就像我 运行:
$ bundle exec rake test
每次我编辑文件时都会发生这种情况。
02:28:43 - INFO - Run 'gem install win32console' to use color on Windows
02:28:44 - INFO - Guard::Minitest 2.3.1 is running, with Minitest::Unit 5.7.0!
02:28:44 - INFO - Running: all tests
←]2;[Minitest results] Running: all tests
[1] guard(main)> Guard is now watching at 'c:/row/dev1/sample_app'
02:29:08 - INFO - Running: test/controllers/static_pages_controller_test.rb
[1] guard(main)> ults] Running: test/controllers/static_pages_controller_test.rb
但是我看不到测试结果,因为我 运行
$ bundle exec rake test
输出是
ansi: 'gem install win32console' to use color on Windows
Started
FAIL["test_should_get_home", StaticPagesControllerTest, 2015-07-12 12:20:51 -0700]
test_should_get_home#StaticPagesControllerTest (1436728851.31s)
<Home | Ruby on Rails Tutorial Sample App> expected but was
<| Ruby on Rails Tutorial Sample App>..
Expected 0 to be >= 1.
test/controllers/static_pages_controller_test.rb:7:in `block in <class:StaticPagesControllerTest>
3/3: [===================================] 100% Time: 00:00:00, Time: 00:00:00
Finished in 0.37550s
3 tests, 6 assertions, 1 failures, 0 errors, 0 skips
02:54:47 - INFO - Run 'gem install win32console' to use color on Windows
←]2;[Minitest results] 3 tests
我看不出我有错误,尽管测试似乎 运行nin... 还是我遗漏了什么?
这是我的 Guardfile
# Defines the matching rules for Guard.
guard :minitest, spring: true, all_on_start: true do
watch(%r{^test/(.*)/?(.*)_test\.rb$})
watch('test/test_helper.rb') { 'test' }
watch('config/routes.rb') { integration_tests }
watch(%r{^app/models/(.*?)\.rb$}) do |matches|
"test/models/#{matches[1]}_test.rb"
end
watch(%r{^app/controllers/(.*?)_controller\.rb$}) do |matches|
resource_tests(matches[1])
end
watch(%r{^app/views/([^/]*?)/.*\.html\.erb$}) do |matches|
["test/controllers/#{matches[1]}_controller_test.rb"] +
integration_tests(matches[1])
end
watch(%r{^app/helpers/(.*?)_helper\.rb$}) do |matches|
integration_tests(matches[1])
end
watch('app/views/layouts/application.html.erb') do
'test/integration/site_layout_test.rb'
end
watch('app/helpers/sessions_helper.rb') do
integration_tests << 'test/helpers/sessions_helper_test.rb'
end
watch('app/controllers/sessions_controller.rb') do
['test/controllers/sessions_controller_test.rb',
'test/integration/users_login_test.rb']
end
watch('app/controllers/account_activations_controller.rb') do
'test/integration/users_signup_test.rb'
end
watch(%r{app/views/users/*}) do
resource_tests('users') +
['test/integration/microposts_interface_test.rb']
end
end
# Returns the integration tests corresponding to the given resource.
def integration_tests(resource = :all)
if resource == :all
Dir["test/integration/*"]
else
Dir["test/integration/#{resource}_*.rb"]
end
end
# Returns the controller tests corresponding to the given resource.
def controller_test(resource)
"test/controllers/#{resource}_controller_test.rb"
end
# Returns all tests for the given resource.
def resource_tests(resource)
integration_tests(resource) << controller_test(resource)
end
这是我的gem文件
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.2'
# Use SCSS for stylesheets
gem 'sass-rails', '5.0.2'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '2.5.3'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '4.1.0'
# Use jquery as the JavaScript library
gem 'jquery-rails', '4.0.3'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '2.2.3'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'turbolinks', '2.3.0'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', '3.4.0'
gem 'sqlite3', '1.3.10'
gem 'web-console', '2.2.1'
gem 'spring', '1.1.3'
gem 'tzinfo-data'
end
# adding group for postgresql production
group :production do
gem 'pg', '0.17.1'
gem 'rails_12factor', '0.0.2'
end
group :test do
gem 'minitest-reporters', '1.0.5'
gem 'mini_backtrace', '0.1.3'
gem 'guard-minitest', '2.3.1'
gem 'wdm', '>= 0.1.0' if Gem.win_platform?
end
从我的应用程序的根目录我 运行:
bundle exec guard init
然后我进入
bundle exec guard
有任何想法吗?
我需要另一个 gem 吗?
还是我不明白什么?
谢谢!
起初我以为您缺少 wdm,但事实并非如此。安装 wdm gem 后,我的输出从与您的相同变为以下内容:
$ bundle exec 守卫
20:02:44 - 信息 - 运行 'gem install win32console' 在 Windows 上使用颜色
20:02:46 - 信息 - Guard::Minitest 2.3.1 是 运行,Minitest::Unit 5.8.3!
[1] guard(main)> Guard is now watching at 'c:/Users/GeoffRuby/Desktop/sample_app'
20:02:59 - 信息 - 运行ning: test/controllers/static_pages_controller_test.rb
[1] 后卫(主力)>
可以看到guard命令行的错误输出没有了。我将与 wdm 的创建者讨论,希望我们能得到一些答案。
一切都很好,除了,
当我 运行
$ bundle exec guard
我看不到测试结果,就像我 运行:
$ bundle exec rake test
每次我编辑文件时都会发生这种情况。
02:28:43 - INFO - Run 'gem install win32console' to use color on Windows
02:28:44 - INFO - Guard::Minitest 2.3.1 is running, with Minitest::Unit 5.7.0!
02:28:44 - INFO - Running: all tests
←]2;[Minitest results] Running: all tests
[1] guard(main)> Guard is now watching at 'c:/row/dev1/sample_app'
02:29:08 - INFO - Running: test/controllers/static_pages_controller_test.rb
[1] guard(main)> ults] Running: test/controllers/static_pages_controller_test.rb
但是我看不到测试结果,因为我 运行
$ bundle exec rake test
输出是
ansi: 'gem install win32console' to use color on Windows
Started
FAIL["test_should_get_home", StaticPagesControllerTest, 2015-07-12 12:20:51 -0700]
test_should_get_home#StaticPagesControllerTest (1436728851.31s)
<Home | Ruby on Rails Tutorial Sample App> expected but was
<| Ruby on Rails Tutorial Sample App>..
Expected 0 to be >= 1.
test/controllers/static_pages_controller_test.rb:7:in `block in <class:StaticPagesControllerTest>
3/3: [===================================] 100% Time: 00:00:00, Time: 00:00:00
Finished in 0.37550s
3 tests, 6 assertions, 1 failures, 0 errors, 0 skips
02:54:47 - INFO - Run 'gem install win32console' to use color on Windows
←]2;[Minitest results] 3 tests
我看不出我有错误,尽管测试似乎 运行nin... 还是我遗漏了什么?
这是我的 Guardfile
# Defines the matching rules for Guard.
guard :minitest, spring: true, all_on_start: true do
watch(%r{^test/(.*)/?(.*)_test\.rb$})
watch('test/test_helper.rb') { 'test' }
watch('config/routes.rb') { integration_tests }
watch(%r{^app/models/(.*?)\.rb$}) do |matches|
"test/models/#{matches[1]}_test.rb"
end
watch(%r{^app/controllers/(.*?)_controller\.rb$}) do |matches|
resource_tests(matches[1])
end
watch(%r{^app/views/([^/]*?)/.*\.html\.erb$}) do |matches|
["test/controllers/#{matches[1]}_controller_test.rb"] +
integration_tests(matches[1])
end
watch(%r{^app/helpers/(.*?)_helper\.rb$}) do |matches|
integration_tests(matches[1])
end
watch('app/views/layouts/application.html.erb') do
'test/integration/site_layout_test.rb'
end
watch('app/helpers/sessions_helper.rb') do
integration_tests << 'test/helpers/sessions_helper_test.rb'
end
watch('app/controllers/sessions_controller.rb') do
['test/controllers/sessions_controller_test.rb',
'test/integration/users_login_test.rb']
end
watch('app/controllers/account_activations_controller.rb') do
'test/integration/users_signup_test.rb'
end
watch(%r{app/views/users/*}) do
resource_tests('users') +
['test/integration/microposts_interface_test.rb']
end
end
# Returns the integration tests corresponding to the given resource.
def integration_tests(resource = :all)
if resource == :all
Dir["test/integration/*"]
else
Dir["test/integration/#{resource}_*.rb"]
end
end
# Returns the controller tests corresponding to the given resource.
def controller_test(resource)
"test/controllers/#{resource}_controller_test.rb"
end
# Returns all tests for the given resource.
def resource_tests(resource)
integration_tests(resource) << controller_test(resource)
end
这是我的gem文件
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.2'
# Use SCSS for stylesheets
gem 'sass-rails', '5.0.2'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '2.5.3'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '4.1.0'
# Use jquery as the JavaScript library
gem 'jquery-rails', '4.0.3'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '2.2.3'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'turbolinks', '2.3.0'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', '3.4.0'
gem 'sqlite3', '1.3.10'
gem 'web-console', '2.2.1'
gem 'spring', '1.1.3'
gem 'tzinfo-data'
end
# adding group for postgresql production
group :production do
gem 'pg', '0.17.1'
gem 'rails_12factor', '0.0.2'
end
group :test do
gem 'minitest-reporters', '1.0.5'
gem 'mini_backtrace', '0.1.3'
gem 'guard-minitest', '2.3.1'
gem 'wdm', '>= 0.1.0' if Gem.win_platform?
end
从我的应用程序的根目录我 运行:
bundle exec guard init
然后我进入
bundle exec guard
有任何想法吗? 我需要另一个 gem 吗? 还是我不明白什么? 谢谢!
起初我以为您缺少 wdm,但事实并非如此。安装 wdm gem 后,我的输出从与您的相同变为以下内容:
$ bundle exec 守卫
20:02:44 - 信息 - 运行 'gem install win32console' 在 Windows 上使用颜色
20:02:46 - 信息 - Guard::Minitest 2.3.1 是 运行,Minitest::Unit 5.8.3!
[1] guard(main)> Guard is now watching at 'c:/Users/GeoffRuby/Desktop/sample_app'
20:02:59 - 信息 - 运行ning: test/controllers/static_pages_controller_test.rb
[1] 后卫(主力)>
可以看到guard命令行的错误输出没有了。我将与 wdm 的创建者讨论,希望我们能得到一些答案。