11describe App do
22
33 describe 'GET /newteam' do
4- before do
5- get '/team'
6- end
7-
84 it 'sends a 200 status code' do
5+ get '/newteam'
96 expect ( last_response . status ) . to eq ( 200 )
107 end
118
129 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" )
10+ visit '/newteam'
11+ expect ( page ) . to have_selector ( "form" )
12+ expect ( page ) . to have_field ( :name )
13+ expect ( page ) . to have_field ( :coach )
14+ expect ( page ) . to have_field ( :pg )
15+ expect ( page ) . to have_field ( :sg )
16+ expect ( page ) . to have_field ( :sf )
17+ expect ( page ) . to have_field ( :pf )
18+ expect ( page ) . to have_field ( :c )
1519 end
1620 end
1721
1822 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
23+ it "displays the basketball team name in the browser" do
24+ visit '/newteam'
3025
31- it 'sends a 200 status code' do
32- expect ( last_response . status ) . to eq ( 200 )
26+ fill_in ( :name , :with => "Bballers" )
27+ click_button "submit"
28+ expect ( page ) . to have_text ( "Team Name: Bballers" )
3329 end
3430
35- it 'displays the team info upon submission' do
36- expect ( last_response . body ) . to include ( "The Astronauts" )
37- end
31+ it "displays the coach's name in the browser" do
32+ visit '/newteam'
33+
34+ fill_in ( :coach , :with => "Walter" )
35+ click_button "submit"
36+
37+ expect ( page ) . to have_text ( "Coach: Walter" )
38+ end
39+
40+ it "displays the point guard's name in the browser" do
41+ visit '/newteam'
42+
43+ fill_in ( :pg , :with => "Jeff" )
44+ click_button "submit"
45+
46+ expect ( page ) . to have_text ( "Point Guard: Jeff" )
47+ end
48+
49+ it "displays the shooting guard's name in the browser" do
50+ visit '/newteam'
51+
52+ fill_in ( :pg , :with => "Ralph" )
53+ click_button "submit"
54+
55+ expect ( page ) . to have_text ( "Shooting Guard: Ralph" )
56+ end
57+
58+ it "displays the power forward's name in the browser" do
59+ visit '/newteam'
60+
61+ fill_in ( :pf , :with => "Danny" )
62+ click_button "submit"
63+
64+ expect ( page ) . to have_text ( "Power Forward: Danny" )
65+ end
66+
67+ it "displays the shooting gaurd's name in the browser" do
68+ visit '/newteam'
69+
70+ fill_in ( :sg , :with => "Joe" )
71+ click_button "submit"
72+
73+ expect ( page ) . to have_text ( "Shooting Guard: Joe" )
74+ end
75+
76+ it "displays the center's name in the browser" do
77+ visit '/newteam'
78+
79+ fill_in ( :c , :with => "Avi" )
80+ click_button "submit"
81+
82+ expect ( page ) . to have_text ( "Center: Avi" )
83+ end
84+
85+
3886 end
3987end
0 commit comments