Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Done #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Done #12

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
15 changes: 14 additions & 1 deletion app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,17 @@

class App < Sinatra::Base

end
get '/' do
erb :index
end

get '/new' do
erb :create_puppy
end

post '/display_puppy' do
@puppy = Puppy.new(params[:name], params[:breed], params[:age])
erb :display_puppy
end

end
9 changes: 9 additions & 0 deletions models/puppy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Puppy
attr_accessor :name, :breed, :age

def initialize(name, breed, age)
@name = name
@breed = breed
@age = age
end
end
16 changes: 8 additions & 8 deletions spec/models/puppy_spec.rb
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
describe 'Puppy class' do
describe 'Puppy class' do
let!(:puppy) { Puppy.new("brad", "black lab", 2) }

it 'can create a new instance of the puppy class' do
expect(Puppy.new("brad", "black lab", 2)).to be_an_instance_of(Puppy)
end

it 'can read a puppy name' do
it 'can read a puppy name' do
expect(puppy.name).to eq("brad")
end

it 'can read a puppy breed' do
it 'can read a puppy breed' do
expect(puppy.breed).to eq("black lab")
end

it 'can read a puppy age' do
it 'can read a puppy age' do
expect(puppy.age).to eq(2)
end

it 'can change puppy age' do
it 'can change puppy age' do
puppy.age = 3
expect(puppy.age).to eq(3)
end

it 'can change puppy name' do
it 'can change puppy name' do
puppy.name = "brad the beast"
expect(puppy.name).to eq("brad the beast")
end

it 'can change puppy breed' do
it 'can change puppy breed' do
puppy.breed = "the best black lab"
expect(puppy.breed).to eq("the best black lab")
end
end
end
8 changes: 8 additions & 0 deletions views/create_puppy.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<h1>List a puppy for adoption: </h1>

<form method="POST" action="/display_puppy">
<label>Name: <input type="text" name="name"></label><br>
<label>Breed: <input type="text" name="breed"></label><br>
<label>Age: <input type="text" name="age"></label><br>
<input type="submit" value="submit">
</form>
7 changes: 7 additions & 0 deletions views/display_puppy.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<h1>Puppy Name:</h1>
<h3><%= @puppy.name %></h3>
<h1>Puppy Breed:</h1>
<h3><%= @puppy.breed %></h3>
<h1>Puppy Age:</h1>
<h3><%= @puppy.age %></h3>

2 changes: 2 additions & 0 deletions views/index.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>Welcome to the Puppy Adoption Site!</h1>
<a href="/new">Click Here To List A Puppy</a>