2012-10-06 2 views
0

요청을 정보로 업데이트 한 후에 다른 제목 아래이 요청을 게시했으며 피드백을받지 못했습니다. 나는 하나의 개발자 학습 레일입니다 개인 프로젝트를 진행하고 TDD/BDD를 사용하여 옳은 일을하려고하지만, 내가 할말이 경험은 포기하려는 만들고있어save_an_open_page가 작동하지 않음 - 오류 메시지가 나타나면 메소드를 찾을 수 없음을 나타냅니다.하지만 그 이유는 무엇입니까?

save_and_open_page (capybara/launchy) stopped working in a project - error

테스트, 나는 단순히 환경 문제를 해결하려고 할 시간이 없다.

나는 이것을 고치려고 노력하는 데 24 시간을 소비했다.

  1. Gemfile.lock 삭제하고 다시 설치 이어
  2. 가 gemset을 삭제하고 처음
  3. 에서 시작 번들 튜토리얼 (처음부터 M.Hartl 년대) 재건 : 다음은 제가 시도 것들 내 환경의 부분

지난 밤에 내 로컬 프로젝트에서 마스터 용 자식 버전의 일부 기능을 업데이트하기 시작한 날에 --drb 옵션이 실패했습니다. 두 개의 프로젝트와 두 개의 git 폴더).

로컬 프로젝트에서 [open_and_save_page]을 테스트했지만 테스트를 위해 사양을 실행했을 때 다음 배포 단계를 시작하기에 앞서 제대로 작동하지 못했습니다. --drb와 관련된 오류가 발생하여 업그레이드 된 것으로 보입니다. 내가 가드 프로세스를 돌렸을 때 떠나라.

source 'https://rubygems.org' 

gem 'rails', '3.2.8' 

# Bundle edge Rails instead: 
# gem 'rails', :git => 'git://github.com/rails/rails.git' 

group :development, :test do 
    gem 'sqlite3', '1.3.5' 
    gem "rspec-rails", "~> 2.11.0" 
    gem 'guard-rspec', '~> 1.2.1' 
    gem 'annotate', '~> 2.4.1.beta' 
    gem 'pickle' 
    gem 'launchy' 
    gem 'simplecov' 
    gem 'pg', '0.12.2' 
end 

# Gems used only for assets and not required 
# in production environments by default. 
group :assets do 
    gem 'sass-rails', '~> 3.2.5' 
    gem 'coffee-rails', '~> 3.2.2' 

    # See https://github.com/sstephenson/execjs#readme for more supported runtimes 
    # gem 'therubyracer', :platform => :ruby 

    gem 'uglifier', '>= 1.2.3' 
    gem 'bootstrap-sass', '~> 2.0.3.1' 
end 

gem 'jquery-rails', '2.0.2' 
gem 'bootstrap-will_paginate', '0.0.5' 
gem 'bootstrap-datepicker-rails', :require => 'bootstrap-datepicker-rails'#, 
           #:git => 'git://bitbucket.org/railyboy/bootstrap-datepicker-rails.git' 
gem 'will_paginate', '3.0.3' 
gem 'faker', '1.0.1' 
gem 'wicked_pdf' 

# To use ActiveModel has_secure_password 
gem 'bcrypt-ruby', '3.0.1' 

# Test gems on Macintosh OS X 
group :test do 
    gem 'capybara', '1.1.2' 
# gem 'rb-fsevent', '0.4.3.1', :require => false 
    # gem 'rb-fsevent', :git => 'git://github.com/ttilley/rb-fsevent.git', :branch => 'pre-compiled-gem-one-off' 
gem 'rb-fsevent', '~> 0.9.1', :require => false 
    gem 'growl', '1.0.3' 
    gem 'guard-spork', '0.3.2' 
    gem 'spork', '0.9.0' 
    gem 'factory_girl_rails', '~> 4.1.0' 
    gem 'cucumber-rails', '1.2.1', :require => false 
    gem 'database_cleaner', '0.7.0' 
end 

group :production do 
    gem 'pg', '0.12.2' 
end 

.rvmrc 파일

rvm use [email protected] --create 

which rvm => /Users/railsdev/.rvm/bin/rvm 

rvm -v => rvm 1.16.8 (master) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/] 

Guardfile :

여기
imac:Genie railsdev$ rspec spec/requests/authentication_pages_spec.rb --drb 
No DRb server is running. Running in local process instead ... 
/Users/railsdev/Development/railsprojects/Genie/Genie/spec/requests/authentication_pages_spec.rb:47:in `block (3 levels) in <top (required)>': undefined local variable or method `save_and_open_page' for #<Class:0x007ff51d35a8a8> (NameError) 
    from /Users/railsdev/.rvm/gems/[email protected]/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:238:in `module_eval' 
    from /Users/railsdev/.rvm/gems/[email protected]/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:238:in `subclass' 
    from /Users/railsdev/.rvm/gems/[email protected]/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:224:in `describe' 
    from /Users/railsdev/Development/railsprojects/Genie/Genie/spec/requests/authentication_pages_spec.rb:39:in `block (2 levels) in <top (required)>' 
    from /Users/railsdev/.rvm/gems/[email protected]/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:238:in `module_eval' 
    from /Users/railsdev/.rvm/gems/[email protected]/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:238:in `subclass' 
    from /Users/railsdev/.rvm/gems/[email protected]/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:224:in `describe' 
    from /Users/railsdev/Development/railsprojects/Genie/Genie/spec/requests/authentication_pages_spec.rb:24:in `block in <top (required)>' 
    from /Users/railsdev/.rvm/gems/[email protected]/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:238:in `module_eval' 
    from /Users/railsdev/.rvm/gems/[email protected]/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:238:in `subclass' 
    from /Users/railsdev/.rvm/gems/[email protected]/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:224:in `describe' 
    from /Users/railsdev/.rvm/gems/[email protected]/gems/rspec-core-2.11.1/lib/rspec/core/dsl.rb:18:in `describe' 
    from /Users/railsdev/Development/railsprojects/Genie/Genie/spec/requests/authentication_pages_spec.rb:13:in `<top (required)>' 
    from /Users/railsdev/.rvm/gems/[email protected]/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load' 
    from /Users/railsdev/.rvm/gems/[email protected]/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `block in load_spec_files' 
    from /Users/railsdev/.rvm/gems/[email protected]/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `map' 
    from /Users/railsdev/.rvm/gems/[email protected]/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load_spec_files' 
    from /Users/railsdev/.rvm/gems/[email protected]/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:22:in `run' 
    from /Users/railsdev/.rvm/gems/[email protected]/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:66:in `rescue in run' 
    from /Users/railsdev/.rvm/gems/[email protected]/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:62:in `run' 
    from /Users/railsdev/.rvm/gems/[email protected]/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in `block in autorun' 
imac:Genie railsdev$ 

내 Gemfile입니다 : 여기

현재 오류가

# A sample Guardfile 
# More info at https://github.com/guard/guard#readme 

require 'active_support/core_ext' 

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

guard 'rspec', :version => 2, :all_after_pass => false, :cli => '--drb' do 
    watch(%r{^spec/.+_spec\.rb$}) 
    watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } 
    watch('spec/spec_helper.rb') { "spec" } 

    # Rails example 
    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{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_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('spec/spec_helper.rb') { "spec" } 
    watch('config/routes.rb') { "spec/routing" } 
    watch('app/controllers/application_controller.rb') { "spec/controllers" } 
    # Capybara request specs 
    watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" } 
    watch(%r{^app/controllers/(.+)_(controller)\.rb$}) do |m| 
    ["spec/routing/#{m[1]}_routing_spec.rb", 
    "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", 
    "spec/acceptance/#{m[1]}_spec.rb", 
    "spec/requests/#{m[1].singularize}_pages_spec.rb", 
    (m[1][/_pages/] ? "spec/requests/#{m[1]}_spec.rb" : 
         "spec/requests/#{m[1].singularize}_pages_spec.rb")] 
    end 
    watch(%r{^app/views/(.+)/}) do |m| 
    "spec/requests/#{m[1].singularize}_pages_spec.rb" 
    end 

    # 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 
,691 363,210

spec_helper.rb 파일 :

require 'rubygems' 
require 'spork' 
#uncomment the following line to use spork with the debugger 
#require 'spork/ext/ruby-debug' 

Spork.prefork do 
    # Loading more in this block will cause your tests to run faster. However, 
    # if you change any configuration or code from libraries loaded here, you'll 
    # need to restart spork for it take effect. 

    # This file is copied to spec/ when you run 'rails generate rspec:install' 
    ENV["RAILS_ENV"] ||= 'test' 
    require File.expand_path("../../config/environment", __FILE__) 
    require 'rspec/rails' 
    require 'rspec/autorun' 

    # Requires supporting ruby files with custom matchers and macros, etc, 
    # in spec/support/ and its subdirectories. 
    Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} 

    RSpec.configure do |config| 
    # ## Mock Framework 
    # 
    # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: 
    # 
    # config.mock_with :mocha 
    # config.mock_with :flexmock 
    # config.mock_with :rr 
    config.mock_with :rspec 

    # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures 
    config.fixture_path = "#{::Rails.root}/spec/fixtures" 

    # If you're not using ActiveRecord, or you'd prefer not to run each of your 
    # examples within a transaction, remove the following line or assign false 
    # instead of true. 
    config.use_transactional_fixtures = true 

    # If true, the base class of anonymous controllers will be inferred 
    # automatically. This will be the default behavior in future versions of 
    # rspec-rails. 
    config.infer_base_class_for_anonymous_controllers = false 

    # Run specs in random order to surface order dependencies. If you find an 
    # order dependency and want to debug it, you can fix the order by providing 
    # the seed, which is printed after each run. 
    #  --seed 1234 
    config.order = "random" 
    end 



end 

Spork.each_run do 
    # This code will be run each time you run your specs. 

end 

그리고 파일 [save_and_open_page]에서 호출되는 : 내가 올바른 방법으로 내 질문을 게시하고있는 경우

require 'spec_helper' 

# describe "AuthenticationPages" do 
# describe "GET /authentication_pages" do 
#  it "works! (now write some real specs)" do 
#  # Run the generator again with the --webrat flag if you want to use webrat methods/matchers 
#  get authentication_pages_index_path 
#  response.status.should be(200) 
#  end 
# end 
# end 

describe "Authentication" do 

    subject { page } 

    describe "login page" do 
    before { visit login_path } 

    it { should have_selector('h1', text: 'Login') } 
    it { should have_selector('title', text: 'Login') } 
    end 

    describe "login" do 
    before { visit login_path } 

    describe "with invalid information" do 
     before { click_button "Login" } 

     it { should have_selector('title', text: 'Login') } 
     it { should have_error_message('Invalid') } 

     describe "after visiting another page" do 
     before { click_link "Home" } 
     it { should_not have_selector('div.alert.alert-error') } 
     end 
    end 

    describe "with valid information" do 
     let(:user) { FactoryGirl.create(:user) } 
     before { valid_login(user) } 

     it { should have_selector('title', text: user.name) } 
     #it { should have_link('Profile', href: user_path(user)) } 
     it { should have_link('Logout', href: logout_path) } 
     it { should_not have_link('Login', href: login_path) } 
     save_and_open_page 
     # it { should have_content("[#{current_user}]") } 

     describe "followed by logout" do 
     before { click_link "Logout" } 
     it { should have_link('Login') } 
     end 
    end 
    end 

... 
end 

잘 모르겠어요 다른 사람들처럼 저는 어떤 반응도 없었습니다. 이 모든 것에서 여전히 새로운 것이고 여기의 도움은 엄청납니다. 그래서 미리 감사드립니다.

두 번째 프로젝트에서이 작업을 수행하려면 어떻게해야합니까?

디렉토리에 CD를 넣었을 때 .rvmrc 파일에 [use]을 넣기 시작한 이래로 나는주의를 기울였다.

Using /Users/railsdev/.rvm/gems/ruby-1.9.3-p125 with gemset genie-bb-v3-3 
Running /Users/railsdev/.rvm/hooks/after_cd_bundler 

[open_and_save_page]는 카피 바라 방법입니까? 발사가이 모든 것에 어디에 들어 맞습니까? 나는 그것이 오이와 관련된 보석이라고 생각했다.

답변

3

나는 이것이 새로운 사용자 이해 오류라고 생각합니다. 나는 it 블록 내에 [save_and_open_page]을 넣으면 이것을 작동시킬 수 있다는 것을 발견했다.

나는이 문서를 내가 읽은 문서에서 보지 못했지만 그것이 맞는 것 같아요.

+0

이전에'visit ..._ path'를하지 않으면 save_and_open_page가 눈에 띄기 때문에 블록 밖에서 이것을 호출하는 것은 틀린 것입니다. –

+0

예가 작동해야합니다. – user1322092