Skip to content

Commit

Permalink
Customer views book details page
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim Remsik committed Jun 6, 2010
1 parent f645c8f commit cfd8626
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 5 deletions.
11 changes: 11 additions & 0 deletions app/views/books/show.html.haml
@@ -0,0 +1,11 @@
#book_detail
.book_gallery
%img{:src=> book.image, :alt=> book.title}
#book_details
%h1= book.title
%p.meta= "by #{book.author}"

%h2= number_to_currency(book.price)
.buy= link_to "Purchase Book", '#'

%p= book.description
5 changes: 5 additions & 0 deletions public/stylesheets/application.css
Expand Up @@ -141,6 +141,11 @@ form label { font-weight: bold; }
width: 220px;
display: inline;
}
.book_gallery img {
width: 220px;
height: 273px;
}

.book_details {
float: left;
width: 700px;
Expand Down
38 changes: 33 additions & 5 deletions spec/integration/customer_views_book_details_spec.rb
@@ -1,14 +1,42 @@
require 'spec_helper'

context "Customer on the Book details page" do
context "Customer viewing the book index page" do
let(:book) { Factory.create(:book) }
let(:war_and_peace) { Factory.create(:war_and_peace) }

before do
book
visit book_path(book)
war_and_peace
visit books_path
click war_and_peace.title
end

it "sees a purchase link" do
page.should have_xpath("//*[@id='book_details']//a[@href='#']", :text => 'Purchase Book')
context "who has clicked through to the details page for War and Peace" do
it "sees the book image" do
page.should have_xpath("//*[@id='book_detail']//*[@class='book_gallery']/img[@alt='#{war_and_peace.title}']")
end

it "sees the book title" do
page.should have_xpath("//*[@id='book_details']/h1", :text => war_and_peace.title)
end

it "sees the book author" do
page.should have_xpath("//*[@id='book_details']//*[@class='meta']", :text => "by #{war_and_peace.author}")
end

it "sees the book price" do
page.should have_content("$29.00")
end

it "sees the book description" do
page.should have_content(war_and_peace.description)
end

it "sees a purchase link" do
page.should have_xpath("//*[@id='book_details']//a[@href='#']", :text => 'Purchase Book')
end

it "does not see Ulysse" do
page.should_not have_content(book.title)
end
end
end

0 comments on commit cfd8626

Please sign in to comment.