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

Create Puppy Adoption #16

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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
104 changes: 57 additions & 47 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -74,4 +84,4 @@ DEPENDENCIES
thin

BUNDLED WITH
1.16.1
2.1.4
17 changes: 16 additions & 1 deletion app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,19 @@

class App < Sinatra::Base

end
get '/' do
erb :index
end

get '/new' do
erb :create_puppy
end

post '/puppy' do
@name = params[:name]
@breed = params[:breed]
@age = params[:age]
erb :display_puppy
Comment on lines +14 to +17

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to use the Puppy class here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so like erb :puppy

or were you referring to
@puppy.age = params[:puppy][:age]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More like

@puppy = Puppy.new(params[:name], params[:breed], params[:age])

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
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions views/create_puppy.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<form action = '/puppy' method="post">
<label>Puppy Name: </label>
<input type="text" id="name" name="name">
<label>Puppy Breed: </label>
<input type="text" id="breed" name="breed">
<label>Puppy Age: </label>
<input type="text" id="age" name="age">
<input type="submit" id="submit" value="Submit">
</form>
6 changes: 6 additions & 0 deletions views/display_puppy.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<h1>Puppy Name:</h1>
<p> <%= @name %> </p>
<h1>Puppy Breed:</h1>
<p><%= @breed %></p>
<h1>Puppy Age:</h1>
<p><%= @age %></p>
5 changes: 5 additions & 0 deletions views/index.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<body>
<h1>welcome</h1>

<a href="/new">Click Here To List A Puppy</a>
</body>