Answer the question
In order to leave comments, you need to log in
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 `'
bundle exec rspec spec/features/static_pages_spec.rb -
-drb
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
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question