Skip to content

Commit 5ddeb97

Browse files
committed
none of the tests work
1 parent 33a6202 commit 5ddeb97

8 files changed

Lines changed: 153 additions & 28 deletions

File tree

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ group :test do
1414
gem 'rspec'
1515
gem 'capybara'
1616
gem 'rack-test'
17+
gem 'poltergeist'
1718
end

Gemfile.lock

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,22 @@ GEM
77
rack (>= 1.0.0)
88
rack-test (>= 0.5.4)
99
xpath (~> 2.0)
10+
cliver (0.3.2)
1011
coderay (1.1.0)
1112
daemons (1.2.3)
1213
diff-lcs (1.2.5)
1314
eventmachine (1.0.8)
1415
method_source (0.8.2)
1516
mime-types (2.6.2)
1617
mini_portile (0.6.2)
18+
multi_json (1.11.2)
1719
nokogiri (1.6.6.2)
1820
mini_portile (~> 0.6.0)
21+
poltergeist (1.8.0)
22+
capybara (~> 2.1)
23+
cliver (~> 0.3.1)
24+
multi_json (~> 1.0)
25+
websocket-driver (>= 0.2.0)
1926
pry (0.10.1)
2027
coderay (~> 1.1.0)
2128
method_source (~> 0.8.1)
@@ -52,6 +59,9 @@ GEM
5259
eventmachine (~> 1.0)
5360
rack (~> 1.0)
5461
tilt (1.4.1)
62+
websocket-driver (0.6.3)
63+
websocket-extensions (>= 0.1.0)
64+
websocket-extensions (0.1.2)
5565
xpath (2.0.0)
5666
nokogiri (~> 1.3)
5767

@@ -60,6 +70,7 @@ PLATFORMS
6070

6171
DEPENDENCIES
6272
capybara
73+
poltergeist
6374
pry
6475
rack-test
6576
rake
@@ -70,4 +81,4 @@ DEPENDENCIES
7081
thin
7182

7283
BUNDLED WITH
73-
1.10.3
84+
1.10.6

app.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,20 @@
22

33
class App < Sinatra::Base
44

5+
get '/newteam' do
6+
erb :newteam
7+
end
8+
9+
post '/team' do
10+
@name = params[:name]
11+
@coach = params[:coach]
12+
@pg = params[:pg]
13+
@sg = params[:sg]
14+
@sf = params[:sf]
15+
@pf = params[:pf]
16+
@c = params[:c]
17+
erb :team
18+
end
19+
520

621
end
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Basketball Team</title>
6+
</head>
7+
<body>
8+
<form action="/team" method="post">
9+
</form>
10+
Name<input type="text" name="name">
11+
Coach<input type="text" name="coach">
12+
Point Guard<input type="text" name="pg">
13+
Shooting Guard<input type="text" name="sg">
14+
Power Guard<input type="text" name="pf">
15+
Small Forward<input type="text" name="sf">
16+
Center <input type="text" name="c">
17+
<input type="submit" value="submit" id="submit"/>
18+
</form>
19+
20+
</body>
21+
</html>
22+
23+

spec/basic_sinatra_forms_spec.rb

Lines changed: 75 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,92 @@
11
describe 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
3992
end

spec/spec_helper.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
ENV["SINATRA_ENV"] = "test"
2-
32
require_relative '../config/environment'
43
require 'rack/test'
4+
require 'capybara/poltergeist'
5+
6+
Capybara.javascript_driver = :poltergeist
57

68
RSpec.configure do |config|
7-
config.run_all_when_everything_filtered = true
8-
config.filter_run :focus
9+
config.include Capybara::DSL
910
config.include Rack::Test::Methods
10-
1111
config.order = 'default'
1212
end
1313

1414
def app
1515
Rack::Builder.parse_file('config.ru').first
16-
end
16+
end
17+
18+
Capybara.app = app

views/newteam.erb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@
55
<title>Basketball Team</title>
66
</head>
77
<body>
8+
<form action="/team" method="post">
9+
</form>
10+
Name<input type="text" name="name">
11+
Coach<input type="text" name="coach">
12+
Point Guard<input type="text" name="pg">
13+
Shooting Guard<input type="text" name="sg">
14+
Power Guard<input type="text" name="pf">
15+
Small Forward<input type="text" name="sf">
16+
Center <input type="text" name="c">
17+
<input type="submit" name="submit" value="submit" id="submit"/>
18+
</form>
819

920
</body>
1021
</html>

views/team.erb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66
</head>
77
<body>
88
<h1> Create a Basketball Team! </h1>
9+
Team Name: <%= @name %>
10+
Coach: <%= @coach %>
11+
Point Guard: <%=@pg %>
12+
Power Foward: <%=@pf %>
13+
Shooting Guard: <%=@sg %>
14+
Small Forward: <%=@sf %>
15+
Center: <%=@c %>
16+
17+
918

1019
</body>
1120
</html>

0 commit comments

Comments
 (0)