11describe App do
22
33 describe 'GET /newteam' do
4- before do
5- get '/team '
6- end
4+ # before do
5+ # visit '/newteam '
6+ # end
77
88 it 'sends a 200 status code' do
9+ get '/newteam'
910 expect ( last_response . status ) . to eq ( 200 )
1011 end
1112
1213 it 'renders basketball team form' do
13- expect ( last_response . body ) . to include ( "Create a Basketball Team!" )
14- expect ( last_response . body ) . to include ( "<form" )
14+ visit '/newteam'
15+ expect ( page ) . to have_selector ( "form" )
16+ expect ( page ) . to have_field ( :name )
17+ expect ( page ) . to have_field ( :coach )
18+ expect ( page ) . to have_field ( :pg )
19+ expect ( page ) . to have_field ( :sg )
20+ expect ( page ) . to have_field ( :sf )
21+ expect ( page ) . to have_field ( :pf )
22+ expect ( page ) . to have_field ( :c )
1523 end
1624 end
1725
1826 describe 'POST /team' do
19- before do
20- post '/team' , {
21- :name => "The Astronauts" ,
22- :coach => "George Washington" ,
23- :pg => "Abraham Lincoln" ,
24- :sg => "James Madison" ,
25- :sf => "Andre the Giant" ,
26- :pf => "John Adams" ,
27- :c => "Mario Batagli"
28- }
29- end
27+ it "displays the basketball team name in the browser" do
28+ visit '/newteam'
29+
30+ fill_in ( :name , :with => "Bballers" )
31+ click_button "submit"
32+ binding . pry
33+ expect ( page ) . to have_text ( "Team Name: Bballers" )
34+ end
35+
36+ it "displays the coach's name in the browser" do
37+ visit '/newteam'
38+
39+ fill_in ( :coach , :with => "Walter" )
40+ click_button "submit"
41+
42+ expect ( page ) . to have_text ( "Coach: Walter" )
43+ end
44+
45+ it "displays the point guard's name in the browser" do
46+ visit '/newteam'
47+
48+ fill_in ( :pg , :with => "Jeff" )
49+ click_button "submit"
50+
51+ expect ( page ) . to have_text ( "Point Guard: Jeff" )
52+ end
53+
54+ it "displays the shooting guard's name in the browser" do
55+ visit '/newteam'
56+
57+ fill_in ( :pg , :with => "Ralph" )
58+ click_button "submit"
59+
60+ expect ( page ) . to have_text ( "Shooting Guard: Ralph" )
61+ end
62+
63+ it "displays the power forward's name in the browser" do
64+ visit '/newteam'
65+
66+ fill_in ( :pf , :with => "Danny" )
67+ click_button "submit"
68+
69+ expect ( page ) . to have_text ( "Power Forward: Danny" )
70+ end
71+
72+ it "displays the shooting gaurd's name in the browser" do
73+ visit '/newteam'
74+
75+ fill_in ( :sg , :with => "Joe" )
76+ click_button "submit"
77+
78+ expect ( page ) . to have_text ( "Shooting Guard: Joe" )
79+ end
80+
81+ it "displays the center's name in the browser" do
82+ visit '/newteam'
83+
84+ fill_in ( :c , :with => "Avi" )
85+ click_button "submit"
86+
87+ expect ( page ) . to have_text ( "Center: Avi" )
88+ end
3089
31- it 'sends a 200 status code' do
32- expect ( last_response . status ) . to eq ( 200 )
33- end
3490
35- it 'displays the team info upon submission' do
36- expect ( last_response . body ) . to include ( "The Astronauts" )
37- end
3891 end
3992end
0 commit comments