Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ You can find them in the `spec/features` directory.

## Development

NOTE: Whenever you change a ruby file, you need to stop the server, and restart it.
NOTE: Whenever you change a ruby file, you need to stop the server, and restart it.

## Heroku Staging

URL: http://thawing-cove-8931.herokuapp.com/
5 changes: 0 additions & 5 deletions Rakefile

This file was deleted.

5 changes: 4 additions & 1 deletion lib/app.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
require 'erb'
require 'item'
require 'menu'

class App
def call(env)
Expand All @@ -20,7 +22,8 @@ def body
if File.exist?(index_html)
File.open(index_html, File::RDONLY)
else
[ERB.new(File.open(index_erb, File::RDONLY).read).result]
file_contents = File.open(index_erb, File::RDONLY).read
[ERB.new(file_contents).result]
end
end
end
13 changes: 13 additions & 0 deletions lib/item.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Item
attr_reader :name, :price, :description
def initialize(name, price, description)
@name = name
@price = price
@description = description
end
def == (other)
self.name == other.name
self.price == other.price
self.description == other.description
end
end
10 changes: 10 additions & 0 deletions lib/menu.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require 'item'

class Menu
def item
[
Item.new("Channa Masala", 5.95, "Yummy Goodness"),
Item.new("Chicken Tikka Masala", 5.95, "Yummy Goodness")
]
end
end
13 changes: 7 additions & 6 deletions public/index.html → public/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@
<img src="/images/food1.jpg">

<dl>
<dt>Channa Masala - 5.95</dt>
<dd>Yummy goodness</dd>

<dt>Chicken Tikka Masala - 5.95</dt>
<dd>Yummy goodness</dd>

<% Menu.new.item.each do |item| %>
<dt> <%= item.name %> - <%= item.price %> </dt>
<dt> <%= item.description %> <dt/>
<% end %>

</dl>
</main>

Expand All @@ -45,7 +46,7 @@
Boulder, CO 80301
<a href="mailto:bob@example.com">Contact Us</a>
</address>
&copy; 2013
&copy; <%= Date.today.year %>
</footer>

</body>
Expand Down
9 changes: 8 additions & 1 deletion spec/features/homepage_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'spec_helper'
require 'item'

describe 'Visiting the home page' do

Expand All @@ -7,5 +8,11 @@
expect(page).to have_content("Channa Masala")
expect(page).to have_content("Chicken Tikka Masala")
end


it "displays the current year for the copyright" do
visit "/"
within("footer") do
expect(page).to have_content("2014")
end
end
end
26 changes: 26 additions & 0 deletions spec/models/item_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
require 'spec_helper'
require 'item'

describe Item do
it "has a name" do
item = Item.new("Channa Masala", 5.95, "Yummy")

expect(item.name).to eq "Channa Masala"
end
it "has a price" do
item = Item.new("Channa Masala", 5.95, "Yummy")

expect(item.price).to eq 5.95
end
it "has a description" do
item = Item.new("Channa Masala", 5.95, "Yummy")

expect(item.description).to eq "Yummy"
end
it "knows that two items are the same if they have the same attributes" do
item1 = Item.new("Channa Masala", 5.95, "Yummy")
item2 = Item.new("Channa Masala", 5.95, "Yummy")

expect(item1).to eq item2
end
end
14 changes: 14 additions & 0 deletions spec/models/menu_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require 'spec_helper'

require 'menu'

describe Menu do
it "know about the menu items" do
menu = Menu.new

expect(menu.item).to match_array [
Item.new("Channa Masala", 5.95, "Yummy Goodness"),
Item.new("Chicken Tikka Masala", 5.95, "Yummy Goodness")
]
end
end