Sha256: d4d21b1f6c1cb969f2e03195fa509cce852d99545a9a4f4c89ae8224b2b367ea

Contents?: true

Size: 1.79 KB

Versions: 4

Compression:

Stored size: 1.79 KB

Contents

require "spec_helper"

describe "Product pages" do
	subject {page}

	let(:user) { Factory(:user) }
	before do 
		visit adminpanel.signin_path
		valid_signin(user)
	end
	
	describe "index" do
		let(:product) { Factory(:product) }
		before do
			visit adminpanel.products_path
		end

		it { should have_link(I18n.t("product.new"), adminpanel.new_product_path)}
		it { should have_link("i", adminpanel.product_path(product)) }
		it { should have_link("i", adminpanel.edit_product_path(product)) }
	end

	describe "new" do
		let(:category) { Factory(:category) }
		before do 
			category.id = 1 #to force instantiation so it becomes available in the select
			visit adminpanel.new_product_path
		end

		it { should have_title(I18n.t("product.new")) }

		describe "with invalid information" do
			before { find("form#new_product").submit_form! }

			it { should have_title(I18n.t("product.new")) }
			it { should have_selector("div#alerts") }
		end

		describe "with valid information" do
			before do
				fill_in "product_name", :with => "product name"
				fill_in "product_brief", :with => "little brief"
				find(:xpath, "//input[@id='description-field']").set "a little longer text"
				select category.name, :from => "product_category_id"
				find("form#new_product").submit_form!
			end

			it { should have_content(I18n.t("product.success"))}
		end
	end

	describe "show" do
		let(:product) { Factory(:product) }

		before do
			visit adminpanel.product_path(product)
		end

		it { page.should have_selector("div", :text => product.name.humanize) }
		it { page.should have_selector("div", :text => product.brief) }
		it { page.should have_selector("div", :text => product.description) }
		it { page.should have_selector("div", :text => product.category.name) }
	end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
adminpanel-0.1.1 spec/features/product_pages_spec.rb
adminpanel-0.1.0cl.2 spec/features/product_pages_spec.rb
adminpanel-0.1.0cl spec/features/product_pages_spec.rb
adminpanel-0.1.0 spec/features/product_pages_spec.rb