0
我有以下测试......在一个RSpec测试加载一个模块
规格/功能/用户/ sign_in_spec.rb
require "rails_helper"
feature "User sign in" do
extend SubdomainHelpers
let!(:account) { FactoryGirl.create(:account) }
let(:sign_in_url) { "http://#{account.subdomain}.example.com/sign_in" }
let(:root_url) { "http://#{account.subdomain}.example.com/" }
within_account_subdomain do
scenario "signs in as an account owner successfully" do
visit root_url
expect(page.current_url).to eq(sign_in_url)
fill_in "Email", :with => account.owner.email
fill_in "Password", :with => "password"
click_button "Sign in"
expect(page).to have_content("You are now signed in.")
expect(page.current_url).to eq(root_url)
end
end
end
注3号线extend SubdomainHelpers
我想从加载...
规格/支持/ subdomain_helpers.rb
module SubdomainHelpers
def within_account_subdomain
let(:subdomain_url) { "http://#{account.subdomain}.example.com" }
before { Capybara.default_host = subdomain_url }
after { Capybara.default_host = "http://www.example.com" }
yield
end
end
当我运行文本我得到的错误uninitialized constant SubdomainHelpers (NameError)
如何从测试中调用SubdomainHelpers模块?
对于后代,我需要在sign_in_spec.rb中扩展SubdomainHelpers和require'support/subdomain_helpers'来运行测试。 – Lumbee