0

このリクエストを別の見出しで投稿しましたが、リクエストを情報で更新した後、フィードバックを受け取りませんでした。

save_and_open_page (capybara / launchy) がプロジェクトで動作を停止しました - エラー

私はRailsを学び、TDD/BDDを使用して正しいことをしようとしている単一の開発者であるプライベートプロジェクトに取り組んでいますが、私が言わなければならないこの経験は、私が持っていないので、テストを放棄したいと思っています.環境問題の解決に費やす時間。

私は今、これを修正するために 24 時間の大半を費やしてきました。これらは私が試したことです:

  1. Gemfile.lock を削除し、バンドルを再インストールしました
  2. gemset を削除し、最初からやり直しました
  3. チュートリアル (M.Hartl のゼロから) に従って、環境の一部を再構築しました

昨夜、ローカル プロジェクトからマスターの git バージョンのいくつかの機能の更新を開始するように切り替えたときに --drb オプションが失敗していました (私はまだこれに慣れていないため、2 つのプロジェクトと 2 つの 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/ruby-1.9.3-p125@genie-bb-v3-3/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:238:in `module_eval'
    from /Users/railsdev/.rvm/gems/ruby-1.9.3-p125@genie-bb-v3-3/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:238:in `subclass'
    from /Users/railsdev/.rvm/gems/ruby-1.9.3-p125@genie-bb-v3-3/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/ruby-1.9.3-p125@genie-bb-v3-3/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:238:in `module_eval'
    from /Users/railsdev/.rvm/gems/ruby-1.9.3-p125@genie-bb-v3-3/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:238:in `subclass'
    from /Users/railsdev/.rvm/gems/ruby-1.9.3-p125@genie-bb-v3-3/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/ruby-1.9.3-p125@genie-bb-v3-3/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:238:in `module_eval'
    from /Users/railsdev/.rvm/gems/ruby-1.9.3-p125@genie-bb-v3-3/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:238:in `subclass'
    from /Users/railsdev/.rvm/gems/ruby-1.9.3-p125@genie-bb-v3-3/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:224:in `describe'
    from /Users/railsdev/.rvm/gems/ruby-1.9.3-p125@genie-bb-v3-3/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/ruby-1.9.3-p125@genie-bb-v3-3/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load'
    from /Users/railsdev/.rvm/gems/ruby-1.9.3-p125@genie-bb-v3-3/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `block in load_spec_files'
    from /Users/railsdev/.rvm/gems/ruby-1.9.3-p125@genie-bb-v3-3/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `map'
    from /Users/railsdev/.rvm/gems/ruby-1.9.3-p125@genie-bb-v3-3/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load_spec_files'
    from /Users/railsdev/.rvm/gems/ruby-1.9.3-p125@genie-bb-v3-3/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:22:in `run'
    from /Users/railsdev/.rvm/gems/ruby-1.9.3-p125@genie-bb-v3-3/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:66:in `rescue in run'
    from /Users/railsdev/.rvm/gems/ruby-1.9.3-p125@genie-bb-v3-3/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:62:in `run'
    from /Users/railsdev/.rvm/gems/ruby-1.9.3-p125@genie-bb-v3-3/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 ruby-1.9.3-p125@genie-bb-v3-3 --create

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

rvm -v => rvm 1.16.8 (master) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

ガードファイル:

# 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

回答がなかった他のいくつかの質問と同様に、質問を正しい方法で投稿しているかどうかはわかりません。これはまだ新しく、ここでの助けは計り知れません。事前に感謝します。

これを 2 番目のプロジェクトで機能させるにはどうすればよいですか?

私が気づいたことの 1 つは、[ use] を .rvmrc ファイルに入れ始めてから、ディレクトリに cd すると次のようになることです。

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 は、これらすべてのどこに当てはまりますか? きゅうり関連の逸品だと思いました。

4

1 に答える 1

3

これは新しいユーザーの理解の誤りだと思います。[ save_and_open_page] をitブロック内に配置すると、これが機能することがわかりました。

これについて読んだどのドキュメントにもこれは見当たりませんでしたが、それは理にかなっていると思います。

于 2012-10-06T17:54:17.900 に答える