2012-02-26 11 views
0

click_buttonが実行された後に、シングルトンを取得する際にダンプできないエラーが発生します。すべてのRSpecの出力は私に語っている:capybara rspecもっとindepthログですか?

1) home not logged in sign in should contain content with 'Add new charity 
Failure/Error: click_button "Install" 
TypeError: 
    singleton can't be dumped 
# (eval):2:in `click_button' 
# ./spec/integration/home_spec.rb:29:in `block (4 levels) in <top (required)>' 

私は-bオプションを使用してみましたが、私は、新しい情報を得ることはありません。私のコントローラでロギングを使用すると、アクションが進行し、リダイレクトで終了することがわかります。受信アクションが呼び出される前に、それ以降のある時点で失敗する必要があります。だから、もし私がスタックトレースを見ることができる方法があれば、私はその問題点を突き止めることができるかもしれません。

あなたが見ることができるようにshopify_apiの宝石を使用して追加のhome_spec.rb

require 'spec_helper' 

describe "home" do 

    before do 
    @domain = "myshop.myshopify.com" 
    @token = SecureRandom.hex(16) 
    @shopify_session = ShopifyAPI::Session.new(@domain, @token) 
    end 

    context "not logged in" do 
    it "should be at login" do 
     visit "/" 
     page.should have_content("Install this app in a shop to get access to its private admin data") 
    end 

    describe "sign in" do 
     before do 
     ShopifyAPI::Session.should_receive(:new).and_return(@shopify_session) 

     @shopify_session.should_receive(:valid?).and_return(true) 

     ShopifyAPI::Session.any_instance.should_receive(:create_permission_url).and_return("/login/finalize?shop=#{@domain}&t=#{@token}") 
     end 

     it "should contain content with 'Add new charity" do 
     visit "/" 
     fill_in "shop", with: @domain 
     click_button "Install" 
     page.should have_content("Add new charity") 
     end 
    end 
    end 

    context "logged in" do 
    before do 
     page.set_rack_session(:shopify => @shopify_session) 
    end 

    it "should contain content with 'Add new charity" do 
     visit "/" 
     page.should have_content("Add new charity") 
    end 
    end 

end 

spec_helper.rb:

# 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' 
require 'capybara/rails' 
require 'capybara/dsl' 
require "rack_session_access/capybara" 

# 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} 

Rails.application.config do 
    config.middleware.use RackSessionAccess::Middleware 
end 

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/factories" 

    # 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 

    # RSpec automatically cleans stuff out of backtraces; 
    # sometimes this is annoying when trying to debug something e.g. a gem 
    config.backtrace_clean_patterns = [ 
    /\/lib\d*\/ruby\//, 
    /bin\//, 
    /gems/, 
    /spec\/spec_helper\.rb/, 
    /lib\/rspec\/(core|expectations|matchers|mocks)/ 
    ] 
end 

答えて

1

は、あなたがこれを容易にするためにPRYのようなものを使用して検討していますか?これはあなたのhome_specに含まれているあなたのファイルの1つと関係があります。

https://github.com/pry/pry次に、あなたのコードの中であなたがbinding.pryを挿入することができますし、実行環境にドロップすると、IRBのようなセッションで何が起こっているかを検査することができる必要があります:あなたは詮索を見つけることができるのはここ

です。

それ以外の場合は、home_spec.rbを投稿して理論化を開始する必要があります。

+0

私はインストールしています。私はそれを試してみて、それが何が起こっているかをもっと深く知っているかどうかを見ます。スペックファイルとスペックヘルパーのコードを追加しました。ありがとう。 – agmcleod

関連する問題