我有一个带有使用 Test::Unit 的测试套件的 Rails 项目。我正在尝试设置 Guard 和 Spork 以自动运行我的测试并在通过/失败时发出通知;Guard 和 Spork 运行良好,启动时会发出通知,但我无法让任何测试通知正常工作。我已经尝试将 Growl 和 Mac OS X 通知与 terminal-notifier-guard 一起使用。
这是我的 Gemfile 的相关部分:
group :test do
gem 'sqlite3'
gem 'selenium-webdriver'
gem 'rr', :require => false
gem 'capybara'
gem 'database_cleaner'
gem 'timecop'
end
group :test, :development do
gem 'guard'
gem 'spork'
gem 'spork-testunit'
gem 'guard-test'
gem 'guard-rake'
gem 'guard-spork'
gem 'terminal-notifier-guard', :require => false
gem 'rb-inotify', require: false
gem 'rb-fsevent', require: false
gem 'rb-fchange', require: false
end
和 test_helper.rb:
# -*- encoding : utf-8 -*-
require 'rubygems'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require 'spork'
Spork.prefork do
require 'rubygems'
ENV["RAILS_ENV"] = "test"
require 'capybara/rails'
require 'database_cleaner'
require 'rr'
require 'ostruct'
require "#{Rails.root}/test/test_support"
class ActionController::TestCase
include Devise::TestHelpers
def teardown
super
Timecop.return
end
end
class ActionDispatch::IntegrationTest
self.use_transactional_fixtures = false
include Capybara::DSL
Capybara.default_driver = :selenium
DatabaseCleaner.strategy = :truncation
def setup
super
DatabaseCleaner.clean
end
def teardown
super
DatabaseCleaner.clean
Timecop.return
end
def login_admin(admin=nil)
admin = Admin.create!(:email => "super_badass@wickedawesome.com", :password => "sloppy") if !admin
visit "/admins/sign_in"
fill_in "admin_email", :with => admin.email
fill_in "admin_password", :with => admin.password
click_on "log in"
admin
end
end
end
Spork.each_run do
# This code will be run each time you run your specs.
end
我不知所措。任何帮助将不胜感激。