1+ describe App do
12
2- require 'pry'
3- describe "Puppy Adoption Site" do
4- describe "GET '/'" do
5- before ( :each ) do
3+ describe 'GET /' do
4+
5+ it 'sends a 200 status code' do
66 get '/'
7- end
8-
9- it "returns a 200 status code" do
107 expect ( last_response . status ) . to eq ( 200 )
118 end
129
13- it " renders a welcome" do
14- expect ( last_response . body ) . to include ( "Welcome to the puppy adoption site!" )
15- expect ( last_response . body ) . to include ( "Click Here To List A Puppy" )
10+ it ' renders welcome' do
11+ visit '/'
12+ expect ( page ) . to have_link ( "Click Here To List A Puppy" )
1613 end
1714 end
1815
19- describe "GET '/new'" do
20- before ( :each ) do
21- get '/new'
22- end
23-
24- it "returns a 200 status code" do
16+ describe 'GET /NEW' do
17+ it 'sends a 200 status code' do
18+ get '/'
2519 expect ( last_response . status ) . to eq ( 200 )
2620 end
2721
28- it "renders a new form element on the page" do
29- expect ( last_response . body ) . to include ( "<form" )
30- expect ( last_response . body ) . to include ( "</form>" )
31- end
32-
33- it "renders the puppy input fields for name, breed, and age attributes on the page" do
34- # binding.pry
35- expect ( last_response . body ) . to include ( "name" )
36- expect ( last_response . body ) . to include ( "breed" )
37- expect ( last_response . body ) . to include ( "age" )
22+ it 'renders the form' do
23+ visit '/new'
24+ expect ( page ) . to have_selector ( "form" )
25+ expect ( page ) . to have_field ( :name )
26+ expect ( page ) . to have_field ( :breed )
27+ expect ( page ) . to have_field ( :age )
3828 end
3929 end
4030
41- describe "POST '/puppy'" do
42- before do
43- post '/puppy' , {
44- "name" => "Ian" ,
45- "breed" => "Dalmation" ,
46- "age" => "6" ,
47- }
48- end
49-
50- it "returns a 200 status code" do
51- expect ( last_response . status ) . to eq ( 200 )
52- end
31+ describe 'POST /' do
32+ it "displays the puppy" do
33+ visit '/new'
5334
54- it "displays the puppy information upon form submission" do
55- expect ( last_response . body ) . to include ( "Ian" )
56- expect ( last_response . body ) . to include ( "Dalmation" )
57- expect ( last_response . body ) . to include ( "6" )
35+ fill_in ( :name , :with => "Butch" )
36+ fill_in ( :breed , :with => "Mastiff" )
37+ fill_in ( :age , :with => "6 months" )
38+ click_button "submit"
39+ expect ( page ) . to have_text ( "Puppy Name:\n Butch" )
40+ expect ( page ) . to have_text ( "Puppy Breed:\n Mastiff" )
41+ expect ( page ) . to have_text ( "Puppy Age:\n 6 months" )
5842 end
43+ end
5944
6045
61- end
6246end
0 commit comments