Rspec nie widzi pliku rspec_helper

Witam
Uruchamiam ‘AUTOFEATURE=true autotest’ i oto co widzę:

└─┤02:40 |$├─> AUTOFEATURE=true autotest loading autotest/cucumber_rails /home/bartek/.rvm/gems/ruby-head/gems/cucumber-0.10.0/lib/cucumber/ast/feature.rb:15: warning: method redefined; discarding old gherkin_statement /home/bartek/.rvm/gems/ruby-head/gems/gherkin-2.3.2/lib/gherkin/tag_expression.rb:23: warning: assigned but unused variable - vars /home/bartek/.rvm/gems/ruby-head/gems/cucumber-0.10.0/lib/cucumber/ast/feature_element.rb:10: warning: method redefined; discarding old gherkin_statement /home/bartek/.rvm/gems/ruby-head/gems/cucumber-0.10.0/lib/cucumber/ast/table.rb:80: warning: assigned but unused variable - transposed /home/bartek/.rvm/gems/ruby-head/gems/cucumber-0.10.0/lib/cucumber/ast/table.rb:384: warning: shadowing outer local variable - hash /home/bartek/.rvm/gems/ruby-head/gems/cucumber-0.10.0/lib/cucumber/ast/table.rb:672: warning: assigned but unused variable - hash /home/bartek/.rvm/gems/ruby-head/gems/cucumber-0.10.0/lib/cucumber/ast/step.rb:18: warning: method redefined; discarding old gherkin_statement /home/bartek/.rvm/gems/ruby-head/gems/cucumber-0.10.0/lib/cucumber/ast/examples.rb:11: warning: method redefined; discarding old gherkin_statement /home/bartek/.rvm/gems/ruby-head/gems/cucumber-0.10.0/lib/cucumber/runtime/user_interface.rb:63: warning: assigned but unused variable - e <internal:lib/rubygems/custom_require>:29: warning: loading in progress, circular require considered harmful - /home/bartek/.rvm/gems/ruby-head/gems/cucumber-0.10.0/lib/cucumber.rb from /home/bartek/.rvm/gems/ruby-head/bin/autotest:19:in `<main>' from /home/bartek/.rvm/gems/ruby-head/bin/autotest:19:in `load' from /home/bartek/.rvm/gems/ruby-head/gems/ZenTest-4.4.1/bin/autotest:7:in `<top (required)>' from /home/bartek/.rvm/gems/ruby-head/gems/ZenTest-4.4.1/lib/autotest.rb:152:in `runner' from <internal:lib/rubygems/custom_require>:29:in `require' from <internal:lib/rubygems/custom_require>:33:in `rescue in require' from <internal:lib/rubygems/custom_require>:33:in `require' from /home/bartek/.rvm/gems/ruby-head/gems/cucumber-0.10.0/lib/autotest/cucumber_rails.rb:2:in `<top (required)>' from <internal:lib/rubygems/custom_require>:29:in `require' from <internal:lib/rubygems/custom_require>:29:in `require' from /home/bartek/.rvm/gems/ruby-head/gems/cucumber-0.10.0/lib/autotest/cucumber_mixin.rb:3:in `<top (required)>' from <internal:lib/rubygems/custom_require>:29:in `require' from <internal:lib/rubygems/custom_require>:29:in `require' from /home/bartek/.rvm/gems/ruby-head/gems/cucumber-0.10.0/lib/cucumber.rb:8:in `<top (required)>' from <internal:lib/rubygems/custom_require>:29:in `require' from <internal:lib/rubygems/custom_require>:29:in `require' from /home/bartek/.rvm/gems/ruby-head/gems/cucumber-0.10.0/lib/cucumber/cli/main.rb:8:in `<top (required)>' from <internal:lib/rubygems/custom_require>:29:in `require' from <internal:lib/rubygems/custom_require>:29:in `require' /home/bartek/.rvm/gems/ruby-head/gems/cucumber-0.10.0/lib/cucumber/parser/gherkin_builder.rb:35: warning: assigned but unused variable - steps /home/bartek/.rvm/gems/ruby-head/gems/cucumber-0.10.0/lib/cucumber/parser/gherkin_builder.rb:51: warning: assigned but unused variable - steps /home/bartek/.rvm/gems/ruby-head/gems/cucumber-0.10.0/lib/cucumber/parser/gherkin_builder.rb:67: warning: assigned but unused variable - steps /home/bartek/.rvm/gems/ruby-head/gems/cucumber-0.10.0/lib/cucumber/parser/gherkin_builder.rb:68: warning: assigned but unused variable - example_sections /home/bartek/.rvm/gems/ruby-head/gems/cucumber-0.10.0/lib/cucumber/cli/drb_client.rb:23: warning: assigned but unused variable - e /home/bartek/.rvm/gems/ruby-head/gems/autotest-notification-2.3.1/lib/autotest_notification/doom.rb:23: warning: assigned but unused variable - percent /home/bartek/.rvm/gems/ruby-head/gems/cucumber-0.10.0/lib/autotest/cucumber_mixin.rb:24: warning: global variable `$f' not initialized /home/bartek/.rvm/gems/ruby-head/gems/ZenTest-4.4.1/lib/autotest.rb:606: Use RbConfig instead of obsolete and deprecated Config. /home/bartek/.rvm/rubies/ruby-head/bin/ruby -I.:lib:test -rubygems -e "%w[test/unit spec/requests/admin_reviews_spec.rb spec/requests/users_spec.rb spec/requests/layout_links_spec.rb spec/requests/admin_users_spec.rb spec/requests/admin_layout_spec.rb].each { |f| require f }" | unit_diff -u <internal:lib/rubygems/custom_require>:29:in `require': cannot load such file -- spec_helper (LoadError) from <internal:lib/rubygems/custom_require>:29:in `require' from /home/bartek/Aptana.Studio.3.Workspace/ipod_games/spec/requests/admin_reviews_spec.rb:2:in `<top (required)>' from <internal:lib/rubygems/custom_require>:29:in `require' from <internal:lib/rubygems/custom_require>:29:in `require' from -e:1:in `block in <main>' from -e:1:in `each' from -e:1:in `<main>' /home/bartek/.rvm/gems/ruby-head/gems/ZenTest-4.4.1/lib/unit_diff.rb:123: warning: assigned but unused variable - found /home/bartek/.rvm/gems/ruby-head/gems/ZenTest-4.4.1/lib/unit_diff.rb:202: warning: assigned but unused variable - first /home/bartek/.rvm/gems/ruby-head/gems/ZenTest-4.4.1/lib/unit_diff.rb:203: warning: assigned but unused variable - second /home/bartek/.rvm/gems/ruby-head/gems/ZenTest-4.4.1/lib/unit_diff.rb:265: warning: assigned but unused variable - count /home/bartek/.rvm/gems/ruby-head/gems/ZenTest-4.4.1/lib/zentest.rb:352: warning: assigned but unused variable - e /home/bartek/.rvm/gems/ruby-head/gems/ZenTest-4.4.1/lib/zentest.rb:342: warning: assigned but unused variable - methods
Wnioskuję z backtrace’a, że linia require 'spec_helper'
w admin_reviews_spec.rb sprawia nie lada problemy. Oczywiście spec_helper.rb jest na swoim miejscu, czyli w Rails.root/spec. [code=Gemfile]source ‘http://rubygems.org

gem ‘rails’, ‘3.0.2’
gem ‘mysql2’
gem ‘gravatar_image_tag’
gem ‘formtastic’
gem ‘validation_reflection’
gem ‘will_paginate’, ‘3.0.pre2’
gem ‘haml’
gem ‘hoe’
gem ‘rubyforge’
group :development, :test do
gem ‘mongrel’, ‘1.2.0.pre2’
end
group :development do
gem ‘rspec-rails’
gem ‘annotate-models’
gem ‘faker’
end

group :test do

gem ‘johnson’, :git => ‘git://github.com/jbarnette/johnson.git’, :branch => ‘1.9.1’

gem ‘factory_girl_rails’, ‘1.1.beta1’
gem ‘rspec’
gem ‘spork’
gem ‘autotest-notification’
gem ‘webrat’
gem “cucumber”
gem “cucumber-rails”
gem “capybara”

gem “capybara-envjs”

end[/code]

Czy to może być spowodowane tym, że ruby > 1.9.2 już nie bierze pod uwagę bieżącego katalogu przy dołączaniu plików?

Ugh, s/require ‘spec_helper’/require ‘spec/spec_helper’/

Więc problem rozwiązany, czy nadal występuje? :wink:

Ja w plikach typu admin_reviews_spec.rb po prostu daję require_relative "spec_helper".

Właśnie na nowo siadłem do testów i tym razem autotest niby coś uruchamia, ale w wyniku dostaję linię: 0 run, 0 passed, 0 failed, więc jakby nagle przestał widzieć wszystkie testy. Ale gdy odpalę osobno

rspec spec/

i cucumber
to testy wykonują się poprawnie. Jeśli chodzi o linię z require, to powróciłem do starej formy require 'spec_helper'
. To musi być jakiś problem z autotestem.

To na pewno jakiś problem z autotestem. spec_helper zawsze powinien być w PATH, właśnie dlatego, żeby nie trzeba było robić nic więcej nie require ‘spec_helper’, albo jakichś dziwnych konstrukcji typu:

require File.expand_path("../../spec_helper.rb", __FILE__)

Mówię mam :smiley: Wersja ZenTest 4.4.2 rozwiązuje problem.