how to check condition in rspec. The problem is that is ignored the condition.how to check condition in rspec. The problem is that is ignored the condition.
Have test. I check helper_method :gta_data
if @dynamic_page
gaPageUid = 'category-' + @dynamic_page.uid
elsif @product
gaPageUid = 'product'
else
gaPageUid = 'other'
end
describe '#gtm_data' do
before :each do
I18n.region = "de"
I18n.language = "de"
I18n.locale = "de"
end
context "when dynamic page" do
let!(:object) {
FactoryGirl.create(:dynamic_page_published,
og_title: translation_for(:de),
og_site_name: translation_for(:de),
og_description: translation_for(:de),
slug: "/with-og-attributes")
}
it do
expect(subject.gtm_data).to eq({gaLocale: 'de', gaLanguage: 'de', gaRegion: 'de',
gaPageUid: 'category-' + object.uid})
end
end
end
I get the following message.
expected: {:gaLocale=>"de", :gaLanguage=>"de", :gaRegion=>"de", :gaPageUid=>"category-misc-1"}
got: {:gaLocale=>nil, :gaLanguage=>nil, :gaRegion=>"de", :gaPageUid=>"other"}
Aucun commentaire:
Enregistrer un commentaire