From fab0d9c2f94675e9139e57ceced42a4eca168853 Mon Sep 17 00:00:00 2001 From: Anthony Phillips Date: Thu, 8 Aug 2024 11:52:11 -0400 Subject: [PATCH 1/4] Create puppy class --- Gemfile.lock | 104 ++++++++++++++++++++++++-------------------- models/puppy.rb | 10 +++++ spec/spec_helper.rb | 4 +- 3 files changed, 69 insertions(+), 49 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 6072aff..020b97a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,62 +1,72 @@ GEM remote: https://rubygems.org/ specs: - addressable (2.5.2) - public_suffix (>= 2.0.2, < 4.0) - capybara (2.18.0) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + base64 (0.2.0) + capybara (3.39.2) addressable + matrix mini_mime (>= 0.1.3) - nokogiri (>= 1.3.3) - rack (>= 1.0.0) - rack-test (>= 0.5.4) - xpath (>= 2.0, < 4.0) - coderay (1.1.2) - daemons (1.2.6) - diff-lcs (1.3) - eventmachine (1.2.5) - method_source (0.9.0) - mini_mime (1.0.0) - mini_portile2 (2.3.0) - mustermann (1.0.2) - nokogiri (1.8.2) - mini_portile2 (~> 2.3.0) - pry (0.11.3) - coderay (~> 1.1.0) - method_source (~> 0.9.0) - public_suffix (3.0.2) - rack (2.0.4) - rack-protection (2.0.1) - rack - rack-test (0.8.2) - rack (>= 1.0, < 3) - rake (12.3.0) - require_all (1.5.0) - rspec (3.7.0) - rspec-core (~> 3.7.0) - rspec-expectations (~> 3.7.0) - rspec-mocks (~> 3.7.0) - rspec-core (3.7.1) - rspec-support (~> 3.7.0) - rspec-expectations (3.7.0) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (>= 1.5, < 3.0) + xpath (~> 3.2) + coderay (1.1.3) + daemons (1.4.1) + diff-lcs (1.5.1) + eventmachine (1.2.7) + matrix (0.4.2) + method_source (1.1.0) + mini_mime (1.1.5) + mini_portile2 (2.8.7) + mustermann (3.0.1) + ruby2_keywords (~> 0.0.1) + nokogiri (1.15.6) + mini_portile2 (~> 2.8.2) + racc (~> 1.4) + pry (0.14.2) + coderay (~> 1.1) + method_source (~> 1.0) + public_suffix (5.1.1) + racc (1.8.1) + rack (2.2.9) + rack-protection (3.2.0) + base64 (>= 0.1.0) + rack (~> 2.2, >= 2.2.4) + rack-test (2.1.0) + rack (>= 1.3) + rake (13.2.1) + regexp_parser (2.9.2) + require_all (3.0.0) + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.0) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-mocks (3.7.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-support (3.7.1) + rspec-support (~> 3.13.0) + rspec-support (3.13.1) + ruby2_keywords (0.0.5) shotgun (0.9.2) rack (>= 1.0) - sinatra (2.0.1) - mustermann (~> 1.0) - rack (~> 2.0) - rack-protection (= 2.0.1) + sinatra (3.2.0) + mustermann (~> 3.0) + rack (~> 2.2, >= 2.2.4) + rack-protection (= 3.2.0) tilt (~> 2.0) - thin (1.7.2) + thin (1.8.2) daemons (~> 1.0, >= 1.0.9) eventmachine (~> 1.0, >= 1.0.4) rack (>= 1, < 3) - tilt (2.0.8) - xpath (3.0.0) + tilt (2.4.0) + xpath (3.2.0) nokogiri (~> 1.8) PLATFORMS @@ -74,4 +84,4 @@ DEPENDENCIES thin BUNDLED WITH - 1.16.1 + 2.1.4 diff --git a/models/puppy.rb b/models/puppy.rb index e69de29..ab7799d 100644 --- a/models/puppy.rb +++ b/models/puppy.rb @@ -0,0 +1,10 @@ +class Puppy + attr_accessor :name, :breed, :age + + def initialize(name, breed, age) + @name = name + @breed = breed + @age = age + end + +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index cc6174d..09608d1 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,12 +2,12 @@ require_relative '../config/environment.rb' require 'capybara/dsl' require 'rack/test' -require 'capybara/dsl' +require 'capybara/dsl' RSpec.configure do |config| config.include Capybara::DSL config.include Rack::Test::Methods - config.order = 'default' + # config.order = 'default'git end def app From 786c4f4b2ca8722d254ee53bbf26ab2263e99e84 Mon Sep 17 00:00:00 2001 From: Anthony Phillips Date: Thu, 8 Aug 2024 13:21:01 -0400 Subject: [PATCH 2/4] Create puppy form --- app.rb | 10 +++++++++- models/puppy.rb | 1 - views/create_puppy.erb | 9 +++++++++ views/index.erb | 1 + 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app.rb b/app.rb index b1f74e9..751778e 100644 --- a/app.rb +++ b/app.rb @@ -2,4 +2,12 @@ class App < Sinatra::Base -end \ No newline at end of file + get '/' do + erb :index + end + + get '/new' do + erb :create_puppy + end + +end diff --git a/models/puppy.rb b/models/puppy.rb index ab7799d..2b54bed 100644 --- a/models/puppy.rb +++ b/models/puppy.rb @@ -6,5 +6,4 @@ def initialize(name, breed, age) @breed = breed @age = age end - end diff --git a/views/create_puppy.erb b/views/create_puppy.erb index e69de29..2d216d0 100644 --- a/views/create_puppy.erb +++ b/views/create_puppy.erb @@ -0,0 +1,9 @@ +
+ + + + + + + +
diff --git a/views/index.erb b/views/index.erb index e69de29..f9990e4 100644 --- a/views/index.erb +++ b/views/index.erb @@ -0,0 +1 @@ +

Welcome to Puppy Adoption Site

From f5c56e3afd89af514b7d17f47a1d0aa0501016e1 Mon Sep 17 00:00:00 2001 From: Anthony Phillips Date: Thu, 8 Aug 2024 13:37:18 -0400 Subject: [PATCH 3/4] Diplay new puppy --- app.rb | 7 +++++++ views/display_puppy.erb | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/app.rb b/app.rb index 751778e..a6e7c45 100644 --- a/app.rb +++ b/app.rb @@ -10,4 +10,11 @@ class App < Sinatra::Base erb :create_puppy end + post '/puppy' do + @name = params[:name] + @breed = params[:breed] + @age = params[:age] + erb :display_puppy + end + end diff --git a/views/display_puppy.erb b/views/display_puppy.erb index e69de29..adb838c 100644 --- a/views/display_puppy.erb +++ b/views/display_puppy.erb @@ -0,0 +1,6 @@ +

Puppy Name:

+

<%= @name %>

+

Puppy Breed:

+

<%= @breed %>

+

Puppy Age:

+

<%= @age %>

From d0bb68c53c949e3656ce4a1b45353e5d63205a6a Mon Sep 17 00:00:00 2001 From: Anthony Phillips Date: Thu, 8 Aug 2024 13:51:03 -0400 Subject: [PATCH 4/4] Display link to form --- views/index.erb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/views/index.erb b/views/index.erb index f9990e4..0e1ebd5 100644 --- a/views/index.erb +++ b/views/index.erb @@ -1 +1,5 @@ -

Welcome to Puppy Adoption Site

+ +

welcome

+ +Click Here To List A Puppy +