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