diff --git a/app.rb b/app.rb index b1f74e9..d28491b 100644 --- a/app.rb +++ b/app.rb @@ -2,4 +2,17 @@ class App < Sinatra::Base -end \ No newline at end of file + 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 diff --git a/models/puppy.rb b/models/puppy.rb index e69de29..2b54bed 100644 --- a/models/puppy.rb +++ b/models/puppy.rb @@ -0,0 +1,9 @@ +class Puppy + attr_accessor :name, :breed, :age + + def initialize(name, breed, age) + @name = name + @breed = breed + @age = age + end +end diff --git a/spec/models/puppy_spec.rb b/spec/models/puppy_spec.rb index 7e65639..c472da5 100644 --- a/spec/models/puppy_spec.rb +++ b/spec/models/puppy_spec.rb @@ -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 \ No newline at end of file +end diff --git a/views/create_puppy.erb b/views/create_puppy.erb index e69de29..7513f5d 100644 --- a/views/create_puppy.erb +++ b/views/create_puppy.erb @@ -0,0 +1,8 @@ +

List a puppy for adoption:

+ +
+
+
+
+ +
diff --git a/views/display_puppy.erb b/views/display_puppy.erb index e69de29..0aba9b3 100644 --- a/views/display_puppy.erb +++ b/views/display_puppy.erb @@ -0,0 +1,7 @@ +

Puppy Name:

+

<%= @puppy.name %>

+

Puppy Breed:

+

<%= @puppy.breed %>

+

Puppy Age:

+

<%= @puppy.age %>

+ diff --git a/views/index.erb b/views/index.erb index e69de29..41dbac6 100644 --- a/views/index.erb +++ b/views/index.erb @@ -0,0 +1,2 @@ +

Welcome to the Puppy Adoption Site!

+Click Here To List A Puppy