2012-10-06 10 views
0

我貼了不同的標題下的這一請求,並沒有收到任何反饋我更新了信息的請求後。save_an_open_page無法工作 - 錯誤信息表明未找到方法 - 但爲什麼呢?

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

我的工作我的一個開發人員學習Rails的一個私人項目,並努力做正確的事,使用TDD/BDD,但這樣的經歷,我不得不說正在想放棄測試,因爲我根本沒有時間去嘗試解決環境問題。

我花了24小時的最好的部分,現在試圖解決這一問題。這是我已經試過的東西:刪除了Gemfile.lock的

  1. 並重新安裝的軟件包
  2. 刪除的寶石,並從頭開始
  3. 開始跟着教程(從頭M.Hartl的)重建我的環境的一部分

昨晚--drb選項是失敗,當我從我的本地項目切換到開始更新Git版本的主某些功能(如我還是新本我運行兩個項目和兩個git文件夾)。

我有[open_and_save_page]在本地項目中工作,但是當我運行我的規格測試時,在開始下一個階段的交付之前,我得到了有關-drb的故障,所以我升級了,似乎當我轉過防守程序時離開。

這是當前的錯誤:

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:

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:

# 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 

的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 

我不知道如果我張貼我在正確的道路問題就像其他一些人一樣,我沒有得到任何迴應。在這一切仍然是新的,在這裏的幫助是巨大的。所以先謝謝了。

我需要做什麼才能在第二個項目上實現這個目標?

我注意到的一件事是,自從我開始將[use]放入.rvmrc文件時,我在進入目錄時收到以下內容。

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]水豚方法? launchy在哪裏適合所有這些?我以爲這是一個黃瓜相關的寶石。

回答

3

我相信這是一個新的用戶理解錯誤。我發現如果將[save_and_open_page]置於it塊內,我可以實現這個功能。

我沒有看到這在任何我這個閱讀文檔的,但它是有道理我猜。

+0

剛纔注意到save_and_open_page甚至不存在,如果你之前沒有訪問過......路徑,所以在這個塊之外調用它肯定是錯誤的 –

+0

是的,它必須在塊中才能工作...... – user1322092

相關問題