Skip to content

Instantly share code, notes, and snippets.

@ridget
Created January 30, 2015 04:43
Show Gist options
  • Save ridget/e842a77ca38da9bfb02e to your computer and use it in GitHub Desktop.
Save ridget/e842a77ca38da9bfb02e to your computer and use it in GitHub Desktop.
view spec sample
# spec/views/products/_product.html.erb_spec.rb
describe 'products/_product.html.erb' do
context 'when the product has a url' do
it 'displays the url' do
assign(:product, build(:product, url: 'http://example.com')
render
expect(rendered).to have_link 'Product', href: 'http://example.com'
end
end
context 'when the product url is nil' do
it "displays 'None'" do
assign(:product, build(:product, url: nil)
render
expect(rendered).to have_content 'None'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment