Note that there are some explanatory texts on larger screens.

plurals
  1. PORuby/Rails continuous automated testing with notifications and html output?
    text
    copied!<p>I'm a newbie in ruby/rails, currently doing the railstutorial book as a part of a university course. I'm using ubuntu 11.04, ruby 1.9.2p290, and Rails 3.0.9, watchr (0.7), rspec (2.6.0), rspec-formatter-webkit (2.1.3) and spork (0.9.0.rc).</p> <p>On github I came across <a href="https://github.com/ged/rspec-formatter-webkit" rel="nofollow">this</a> gem, and I thought it would be very nice to use it. So basically what I'm trying to achieve is continuous automated testing with notifications if finished, and also to generate the nice html output out of it.</p> <p>So what I tried is that I wrote this watchr script:</p> <pre><code>require 'nokogiri' require 'open-uri' watch("spec/.*/*_spec.rb") do |match| run_spec match[0] end watch("app/(.*/.*).rb") do |match| run_spec %{spec/#{match[1]}_spec.rb} end def run_spec(file) unless File.exist?(file) puts "#{file} does not exist" return end puts "Running #{file}" result = `rspec -r rspec/core/formatters/webkit -f RSpec::Core::Formatters::WebKit #{file}` File.open('out.html', 'w') do |f| f.puts result end notify(result) puts "DONE" end def send_notify title, msg, img, pri='low', time=5000 `notify-send -i #{img} -u #{pri} -t #{time} '#{msg}'` end def notify(result) output = result doc = Nokogiri::HTML(result) doc.xpath('//div[@id = "summary"]').each do |node| output = node.text.split.join(" ") end folder = "~/Pictures/autotest/" if output =~ /([123456789]|[\d]{2,})\sfailed/ send_notify "FAIL:", "#{output}", folder+"rails_fail.png", 'critical', 20000 elsif output =~ /[1-9]\d*\spending?/ send_notify "PENDING:", "#{output}", folder+"rails_pending.png", 'normal', 15000 else send_notify "PASS:", "#{output}", folder+"rails_ok.png" end end </code></pre> <p>handling the notifications, and generating the output while testing.</p> <p>If I run this with watchr, everything is nice and working, however the tests are taking a long time of course.</p> <p>The problem comes in here: if I try to use spork, to speed the tests up, I get a bunch of errors, starting with a LoadError:</p> <pre><code>Exception encountered: #&lt;LoadError: no such file to load -- rspec/core/formatters/webkit&gt; backtrace: /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `block in require' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:225:in `block in load_dependency' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:596:in `new_constants_in' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:225:in `load_dependency' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:247:in `block in requires=' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:247:in `map' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:247:in `requires=' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/configuration_options.rb:21:in `block in configure' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/configuration_options.rb:20:in `each' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/configuration_options.rb:20:in `configure' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:17:in `run' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rspec-core-2.6.4/lib/rspec/monkey/spork/test_framework/rspec.rb:5:in `run_tests' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/spork-0.9.0.rc/lib/spork/run_strategy/forking.rb:13:in `block in run' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/spork-0.9.0.rc/lib/spork/forker.rb:21:in `block in initialize' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/spork-0.9.0.rc/lib/spork/forker.rb:18:in `fork' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/spork-0.9.0.rc/lib/spork/forker.rb:18:in `initialize' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/spork-0.9.0.rc/lib/spork/run_strategy/forking.rb:9:in `new' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/spork-0.9.0.rc/lib/spork/run_strategy/forking.rb:9:in `run' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/spork-0.9.0.rc/lib/spork/server.rb:47:in `run' /usr/local/ruby/lib/ruby/1.9.1/drb/drb.rb:1558:in `perform_without_block' /usr/local/ruby/lib/ruby/1.9.1/drb/drb.rb:1518:in `perform' /usr/local/ruby/lib/ruby/1.9.1/drb/drb.rb:1592:in `block (2 levels) in main_loop' /usr/local/ruby/lib/ruby/1.9.1/drb/drb.rb:1588:in `loop' /usr/local/ruby/lib/ruby/1.9.1/drb/drb.rb:1588:in `block in main_loop' </code></pre> <p>which of course don't really say anything to me, being a total newbie.</p> <p>Is there a way to overcome this (or of course produce result in any other way)?</p> <p>Any help is greatly appreciated :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload