[英]Autotest ruby on rails with rspec
我在軌道上使用帶有紅寶石的自動測試。 我跑的時候通過了2次通過考試。 rspec spec/
; 但是,當我嘗試使用自動測試時,這是輸出:
matt@matt-laptop:~/sample_app$ autotest
loading autotest/rails_rspec2
style: RailsRspec2
matt@matt-laptop:~/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的安裝和運行情況。
要從rspec獲取詳細結果,請在根項目文件夾中創建.rspec文件並編寫:
--format documentation
如果我可以,請允許我建議觀察者而不是自動測試(也有spork)。 非常容易設置,非常有效。
看一眼
如果你喜歡。
我和Autotest有同樣的問題。 我不確定,但我相信它對於依賴版本可能非常挑剔。 我有點像Rails noob,但由於我最近分享了你的麻煩,讓我告訴你我為解決這個問題做了些什么:
我能夠通過刪除.autotest文件中的所有代碼並將其替換為:
require 'autotest/growl'
require 'autotest/fsevent'
需要明確的是,第二行應該僅適用於您使用OSX的情況。 我認為您可以放心地刪除.autotest文件中的所有“代碼”,因為它與手動“紅色/綠色”咆哮通知有關,一旦安裝了“redgreen”gem,就不再需要了。 簡而言之,您最終會得到一個或兩行.autotest文件。
以下是我通過gem安裝的一些文件(有些文件,如rspec-expectations,應該自動安裝為依賴項)。 以下文件是我認為應該與您的自動測試設置相關的文件,版本是編寫此響應前10分鍾的最新版本。
執行gem list
命令以查看已安裝的命令。 更新您的版本並簡化.autotest文件可能是一件簡單的事情(如果您關心位置,我的主目錄中有我的文件)。 另外,不要忘記autotest-fsevent文件僅適用於OSX。
PS除非你在spec / controllers / spec_helper.rb文件的最后添加一些額外的代碼,否則你可能仍然會得到無法解釋的自動測試錯誤:
# Webrat configuration
Webrat.configure do |config|
config.mode = :rails
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.