0
I持って、次のテスト...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
注Iからロードしようとしています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に 'extend SubdomainHelpers'とrequire 'support/subdomain_helpers'の両方が必要です。 – Lumbee