我在軌道上使用紅寶石自動測試。跑步時我已經通過了2次測試。 rspec spec/
;然而,當我嘗試使用自動測試時,這是輸出:自定義紅寶石與rspec軌道
[email protected]:~/sample_app$ autotest
loading autotest/rails_rspec2
style: RailsRspec2
[email protected]:~/sample_app$
我得不到關於測試結果的輸出。同樣的事情適用於bundle exec autotest
。我看到一條帖子推薦autospec
,但該命令已棄用rspec2。我的Gemfile是
source 'http://rubygems.org'
gem 'rails', '3.0.5'
gem 'sqlite3-ruby', '1.3.2', :require => 'sqlite3'
group :development do
gem 'rspec-rails', '2.5.0'
gem 'autotest','4.4.4'
end
group :test do
gem 'rspec', '2.5.0'
gem 'webrat', '0.7.1'
gem 'autotest', '4.4.4'
gem 'redgreen', '1.2.2'
end
我試圖把.autotest配置文件在我的項目的根目錄,以及主目錄,並沒有使對輸出的差異。我的.autotest文件看起來像這樣
#!/bin/ruby
require 'autotest/timestamp'
module Autotest::GnomeNotify
def self.notify title, msg, img
system "notify-send '#{title}' '#{msg}' -i #{img} -t 3000"
end
Autotest.add_hook :ran_command do |at|
image_root = "~/.autotest_images"
results = [at.results].flatten.join("\n")
results.gsub!(/\\e\[\d+m/,'')
output = results.slice(/(\d+)\sexamples?,\s(\d+)\sfailures?(,\s(\d+)\spending?|)/)
full_sentence, green, failures, garbage, pending = $~.to_a.map(&:to_i)
if output
if failures > 0
notify "FAIL", "#{output}", "#{image_root}/fail.png"
elsif pending > 0
notify "Pending", "#{output}", "#{image_root}/pending.png"
else
notify "Pass", "#{output}", "#{image_root}/pass.png"
end
end
end
end
我也檢查過libnotify-bin已安裝並正在運行。
謝謝!看守寶石使它的工作就像那樣! – 2011-03-02 08:26:04
不客氣,我很高興幫助你:) – Spyros 2011-03-02 08:27:56