E
E
eliastro2013-12-01 16:13:40
Ruby on Rails
eliastro, 2013-12-01 16:13:40

Why can't spork work with rspec for Rails4?

Hello!
To speed up the testing process, I installed the spork gem (ver. 0.9.2).
I start the spork server. Produces results like this:

c:\RailsProject\thinkblog>spork rspec
Using RSpec
-- Rinda Ring Server listening for connections...
-- Starting to fill pool...
Wait until at least one slave is provided before running tests...
** CTRL+BREAK to stop Spork and kill all ruby ​​slave processes **
Spork is ready and listening on 8989!
-- build slave 2... -- build slave 1...
Preloading Rails environment
Preloading Rails environment
DL is deprecated, please use Fiddle
For a better pry experience, please use ansicon: adoxa.3eeweb.com/ansicon
/
DL is deprecated , please use Fiddle
For a better pry experience, please use ansicon: adoxa.3eeweb.com/ansicon
/
C:/Ruby200/lib/ruby/gems/2.0.0/gems/spork-0.9.2/lib/spork/app_framework/rails.rb
:56:in `preload_rails': uninitialized constant ActiveModel::Observing (NameError
)
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/spork-0.9.2/lib/spork/app_frame
work/rails.rb:7:in `preload'
from C:/Ruby200/lib/ruby /gems/2.0.0/gems/spork-0.9.2/lib/spork/test_fram
ework.rb:134:in `block in preload'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/ spork-0.9.2/lib/spork.rb:62:in
`exec_prefork'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/spork-0.9.2/lib/spork/test_fram
ework.rb :120:in `preload'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/spork-0.9.2/lib/spork/run_strat
egy/magazine/magazine_slave.rb:27:in `preload'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/spork-0.9.2/lib/spork/run_strat
egy/magazine/magazine_slave.rb :15:in `initialize'
from magazine_slave_provider.rb:21:in `new'
from magazine_slave_provider.rb:21:in `'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/spork-0.9.2 /lib/spork/app_framework/rails.rb
:56:in `preload_rails': uninitialized constant ActiveModel::Observing (NameError
)
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/spork-0.9.2 /lib/spork/app_frame
work/rails.rb:7:in `preload'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/spork-0.9.2/lib/spork/test_fram
ework.rb :134:in `block in preload'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/spork-0.9.2/lib/spork.rb:62:in
`exec_prefork'
from C:/Ruby200/lib/ruby/gems/2.0. 0/gems/spork-0.9.2/lib/spork/test_fram
ework.rb:120:in `preload'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/spork-0.9.2/lib /spork/run_strat
egy/magazine/magazine_slave.rb:27:in `preload'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/spork-0.9.2/lib/spork/run_strat
egy/magazine /magazine_slave.rb:15:in `initialize'
from magazine_slave_provider.rb:21:in `new'
from magazine_slave_provider.rb:21:in `'

I run the test with the --drb flag:
bundle exec rspec spec/features/static_pages_spec.rb -
-drb

But testing is not performed, it does not give errors either.
Perhaps something was tricky with the spec_helper.rb file. Here is its content:
require 'rubygems'
require 'spork'
#uncomment the following line to use spork with the debugger
#require 'spork/ext/ruby-debug'

Spork.prefork do

  ENV["RAILS_ENV"] ||= 'test'
  require File.expand_path("../../config/environment", __FILE__)
  require 'rspec/rails'
  require 'rspec/autorun'

  Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }  

  ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
  
  RSpec.configure do |config|

    config.infer_base_class_for_anonymous_controllers = false
  
    config.order = "random"
  end
end

Spork.each_run do
  # This code will be run each time you run your specs. 
  #Подгружаем каждый раз все файлы из директории app/
  Dir["#{Rails.root}/app/**/*.rb"].each {|file| load file }
  #Подгружаем файл с описанием маршрутизации
  load "#{Rails.root}/config/routes.rb"
end

What am I doing wrong?
Rails 4.0.1, win7.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Sidorov, 2013-12-02
@morr

Everything looks correct, and judging by this https://github.com/sporkrb/spork/issues/199 you just need to wait a little longer after running spork.
ps windows is not the best operating system for rails development, you will have dozens and hundreds of similar situations where something either does not work at all, or does not work as it should, and there is nothing you can do about it. if it is not possible to change Windows to Mac / Linux, then as an option, you can install a virtual machine with ubuntu server and run rails from there, and edit the code from Windows.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question