2013-09-29 2 views
0

Guard가 Spork 및 Cucumber와 함께 작동하도록하려고합니다. rspec.R을 사용하여 Rails 응용 프로그램을 만들고 있습니다. 나는 여러 가지 다른 것을 시도했지만 패배감을 느낍니다.Guard가 rspec을 사용하여 Rails에서 Spork 및 Cucumber로 작업하는 중 오류가 발생했습니다.

문제는 Gemfile 또는 Guardfile에 있어야한다고 가정합니다. 나는 초보자 일 뿐이므로 학습 내용을 향상시키고 /하거나하지 않고 무언가를 볼 수 있다면 알려 주시기 바랍니다. 나는 약간의 피드백을 원합니다.

내가 알 수있는 한, 오이가 효과가있는 것으로 보인다. 그러나, 나는 가드를 실행하려고 할 때마다, 그것은 말한다 : 마지막으로, 여기에

guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do 
    watch('config/application.rb') 
    watch('config/environment.rb') 
    watch('config/environments/test.rb') 
    watch(%r{^config/initializers/.+\.rb$}) 
    watch('Gemfile.lock') 
    watch('spec/spec_helper.rb') { :rspec } 
    watch('test/test_helper.rb') { :test_unit } 
    watch(%r{features/support/}) { :cucumber } 
end 

guard 'cucumber' do 
watch(%r{^features/.+\.feature$}) 
watch(%r{^features/support/.+$}) { 'features' } 
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' } 
end 

guard 'spork-rails' do 
    watch('config/application.rb') 
    watch('config/environment.rb') 
    watch(%r{^config/environments/.*\.rb$}) 
    watch(%r{^config/initializers/.*\.rb$}) 
    watch('Gemfile.lock') 
    watch('spec/spec_helper.rb') { :rspec } 
    watch(%r{features/support/}) { :cucumber } 
end 


guard 'bundler' do 
  watch('Gemfile') 
  watch(%r{^.+\.gemspec$}) 
end 

guard 'webrick' do 
end 

guard :yaml do 
    watch(%r{^config/(.*).yml}) 
end 

guard 'rspec', after_all_pass: false, cli: '--color --format nested --drb' do 
    watch(%r{^spec/.+_spec\.rb$}) 
    watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } 

    watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } 
    watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } 
    watch(%r{^app/controllers/(.+)\.rb}) { |m| "spec/requests/#{m[1]}_spec.rb" } 
    watch(%r{^app/decorators/(.+)_decorator\.rb$}) { |m| "spec/requests/#{m[1]}_controller_spec.rb" } 
    watch('app/controllers/application_controller.rb') { "spec/requests" } 

    watch(%r{^app/views/(.+)/(.+)\.rabl$}) { |m| "spec/requests/#{m[1]}_controller_spec.rb" } 
    watch(%r{^spec/requests/support/views/(.+)_view\.rb$}) { |m| "spec/requests/#{m[1]}_controller_spec.rb" } 

    # Rails example 
    watch(%r{^app/(.+)\.rb$})       { |m| "spec/#{m[1]}_spec.rb" } 
    watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$})   { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } 
    watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] } 
    watch(%r{^spec/support/(.+)\.rb$})     { "spec" } 
    watch('config/routes.rb')       { "spec/routing" } 
    watch('app/controllers/application_controller.rb') { "spec/controllers" } 

    # Capybara features specs 
    watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$})  { |m| "spec/features/#{m[1]}_spec.rb" } 

    # Turnip features and steps 
    watch(%r{^spec/acceptance/(.+)\.feature$}) 
    watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' } 
end 

및 내 Guardfile

source 'https://rubygems.org' 

gem 'rails' 
gem 'pg' 
gem 'sass-rails' 
gem 'uglifier' 
gem 'coffee-rails' 
gem 'jquery-rails' 
gem 'turbolinks' 
gem 'jbuilder' 
gem 'guard-gitpusher' 
gem 'bundler' 

group :development, :test do 
    gem 'rspec-rails' 
    gem 'guard-rails' 
    gem 'guard' 
    gem 'guard-rspec' 
    gem 'growl' 
    gem 'guard-rake' 
    gem 'guard-gitpusher' 
    gem 'guard-yaml' 
    gem 'guard-cucumber' 
    gem 'gherkin' 
    gem 'spork-rails', github: 'sporkrb/spork-rails' 
    gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~ /darwin/i 
    gem 'guard-spork', '1.4.2' 
    gem 'childprocess', '0.3.6' 
end 

group :test do 
    gem 'rspec-rails' 
    gem 'shoulda-matchers' 
    gem 'guard-migrate' 
    gem 'guard-rake' 
    gem 'guard-migrate' 
    gem 'guard-webrick' 
    gem 'guard-gitpusher' 
    gem 'guard-yaml' 
    gem 'cucumber', '1.2.5' 
    gem 'cucumber-rails', '1.3.0', :require => false 
    gem 'selenium-webdriver' 
    gem 'capybara' 
    gem 'factory_girl_rails' 
    gem 'database_cleaner' 
end 

하고 여기에 있습니다 :

여기
ERROR - Could not load 'guard/spork-rails' or find class Guard::Sporkrails 
ERROR - cannot load such file -- guard/spork-rails 
ERROR - Invalid Guardfile, original error is: > [#] undefined method `new' for nil:NilClass 
ERROR - Could not start Spork server for RSpec, Cucumber. Make sure you can use it manually first. 

내 Gemfile입니다 내 spec_helper.rb :

require 'rubygems' 
require 'spork' 

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.fixture_path = "#{::Rails.root}/spec/fixtures" 

    config.use_transactional_fixtures = true 

    config.infer_base_class_for_anonymous_controllers = false 


    config.order = "random" 
end 

end 

Spork.each_run do 

end 

모든 의견 및/또는 통찰력이 매우 도움이 될 것입니다!

답변

1

보석 spork-rails은 Spork 서버이며 Guard 플러그인이 아니지만 guard-spork은 Spork 서버를 관리하기위한 Guard 플러그인입니다. 그래서 당신은 가드가 시작될 때 자동으로 Spork 서버를 시작

` guard 'spork-rails' do

guard 'spork' do

에 변경해야합니다.