Skip to content

Commit ee8ef16

Browse files
committed
Merge pull request #4 from learn-co-curriculum/wip
Wip
2 parents 33a6202 + ffcd959 commit ee8ef16

6 files changed

Lines changed: 95 additions & 31 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

spec/basic_sinatra_forms_spec.rb

Lines changed: 70 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,87 @@
11
describe 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
3987
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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
<html>
33
<head>
44
<meta charset="UTF-8">
5-
<title>Basketball Team</title>
5+
<title>Basketball Team Signup</title>
66
</head>
77
<body>
88

9+
910
</body>
1011
</html>
1112

views/team.erb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
<html>
33
<head>
44
<meta charset="UTF-8">
5-
<title>Basketball Team Sign Up</title>
5+
<title>Basketball Team</title>
66
</head>
77
<body>
8-
<h1> Create a Basketball Team! </h1>
8+
9+
910

1011
</body>
1112
</html>

0 commit comments

Comments
 (0)