Skip to content

Instantly share code, notes, and snippets.

@ralphos
Created July 22, 2014 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ralphos/37691df5eb341869b5cc to your computer and use it in GitHub Desktop.
Save ralphos/37691df5eb341869b5cc to your computer and use it in GitHub Desktop.
Taxon Spec
require 'spec_helper'
feature 'Visitor sees mobile taxon page' do
scenario 'with branding' do
# Stub store
stub_default_store!
store = solidify_stubbed_store!
# Set up Taxonomy, Taxon, Product and TaxonPage
taxonomy = Taxonomy.make(name: 'Brands')
taxon = Taxon.make(name: 'DVD', permalink: 'brands/dvd', taxonomy: taxonomy)
product = Product.make(name: 'Peppa Pig')
product.taxons << taxon
product.master.update_attribute(:available_on, 1.day.ago)
TaxonPage.make(html: "<p>Peppa Pig Promo!</p>",
state: "published",
store_ids: [ store.id ],
taxon_id: taxon.id)
# Create ProductGroup
store.update_attribute(:product_group, ProductGroup.make)
store.product_group.product_scopes.create(:name => "in_taxons", :arguments => ["DVD"])
index_search_server!
visit nested_taxons_path(taxon.permalink)
within('.mobile-promo') do
expect(page).to have_selector 'p', text: 'Peppa Pig Promo!'
end
# Expect page to have product title
expect(page).to have_selector 'h2', text: "Peppa Pig"
end
scenario 'without branding' do
stub_default_store!
solidify_stubbed_store!
create_product_in_brand_taxon("DVD", :name => "Peppa Pig", :permalink => "brands/dvd")
taxon = Taxon.find_by_name('DVD')
visit nested_taxons_path(taxon.permalink)
expect(page).not_to have_css '.mobile-promo'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment