0
我正在执行click_button之后的某个点检索单例不能转储错误。所有rspec输出告诉我是:capybara rspec更深入的日志?
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选项,但我没有得到任何新的信息。在我的控制器中使用日志记录功能后,我可以看到该操作完成并通过重定向完成。在此之后的某个时刻,在接收操作被调用之前,它必须失败。所以如果有办法我可以更好地看到堆栈跟踪,我可能能够查明问题。
新增home_spec.rb
使用shopify_api宝石,你可以看到。
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
我确实安装了pry。我尝试一下,看看这是否让我对发生的事情有了更深入的了解。我添加了spec文件和spec帮助器的代码以防万一。谢谢。 – agmcleod 2012-02-27 18:03:21