Я получаю сообщение об ошибке Singleton не может быть сброшено в какой-то момент после выполнения кнопки click_button. Весь вывод 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