Auto test ruby ​​on rails with rspec

I use autotest with rubies on rails. When I run, I have 2 passing tests. rspec spec/; however, when I try to use autotest, this is the output:

matt@matt-laptop:~/sample_app$ autotest
loading autotest/rails_rspec2
style: RailsRspec2
matt@matt-laptop:~/sample_app$

I do not get results about test results. The same thing works with bundle exec autotest. I saw a message recommending autospec, but this command is deprecated with rspec2. My gemfile is

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

I tried to put the .autotest configuration file in the root directory of my project, as well as in the home directory and do not affect the result. My .autotest file looks like this:

#!/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

I also checked that libnotify-bin is installed and functioning.

+3
source share
2 answers

Autotest. , , - . Rails noob, , , , :

, .autotest :

require 'autotest/growl'
require 'autotest/fsevent'

, , OSX. , "" .autotest, "/" , , "" . , .autotest.

, gem (, rspec-, ). , , , Autotest, 10 .

  • autotest (4.4.6, 4.3.2)
  • autotest-fsevent (0.2.5, 0.2.2)
  • autotest-growl (0.2.9, 0.2.4)
  • autotest-rails-pure (4.1.2, 4.1.0)
  • redgreen (1.2.2)
  • rspec-core (2.5.1, 2.0.0.b.18)
  • rspec- (2.5.0, 2.0.0.18)
  • rspec-mocks (2.5.0, 2.0.0.b.18)
  • rspec-rails (2.5.0, 2.0.0.b.18)
  • spork (0.8.4)
  • webrat (0.7.3)
  • ZenTest (4.5.0)

gem list, , . , .autotest( , ). , , autotest-fsevent OSX.

P.S. , , , STILL , spec/controller/spec_helper.rb:

# Webrat configuration
Webrat.configure do |config|
config.mode = :rails
end
0

Source: https://habr.com/ru/post/1795683/


All Articles