Skip to content

Commit 05c2948

Browse files
committed
Add tests
1 parent f7b16e7 commit 05c2948

6 files changed

Lines changed: 80 additions & 35 deletions

File tree

.rspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
--color
1+
--format documentation
22
--require spec_helper

circle.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
machine:
2+
ruby:
3+
version: 2.3.0
4+
5+
notify:
6+
webhooks:
7+
- url: https://grades.firstdraft.com/builds
8+
9+
test:
10+
override:
11+
- bundle exec rspec --order default --format documentation --format j --out $CIRCLE_ARTIFACTS/rspec_output.json

spec/features/1_something_spec.rb

Lines changed: 0 additions & 17 deletions
This file was deleted.

spec/features/guesses_spec.rb

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
require "rails_helper"
2+
3+
feature "The index page" do
4+
it "has a functional RCAV", points: 5 do
5+
visit "/all_guesses"
6+
7+
expect(page).to have_selector("h1")
8+
end
9+
10+
it "has the first sequence", points: 5 do
11+
visit "/all_guesses"
12+
13+
expect(page).to have_selector("li", text: "2, 4, 8 Obeys the rule")
14+
end
15+
16+
it "has two forms", points: 5 do
17+
visit "/all_guesses"
18+
19+
expect(page).to have_selector("form", count: 2)
20+
end
21+
22+
it "has a \"Check\" button", points: 5 do
23+
visit "/all_guesses"
24+
25+
expect(page).to have_button("Check")
26+
end
27+
28+
it "has a \"I think I know it\" button", points: 5 do
29+
visit "/all_guesses"
30+
31+
expect(page).to have_button("I think I know it")
32+
end
33+
34+
it "has a reset link", points: 5 do
35+
visit "/all_guesses"
36+
37+
expect(page).to have_link("Reset")
38+
end
39+
end
40+
41+
feature "The answer form" do
42+
it "goes to the answer page when submitted", points: 5 do
43+
visit "/all_guesses"
44+
45+
click_on "I think I know it"
46+
47+
expect(current_path).to eq "/show_answer"
48+
end
49+
50+
it "displays the user's answer on the answer page" do
51+
visit "/all_guesses"
52+
53+
fill_in("rule", with: "A serviceable substitute for wit")
54+
55+
click_on "I think I know it"
56+
57+
expect(page).to have_content("A serviceable substitute for wit")
58+
end
59+
end

spec/models/guess_spec.rb

Lines changed: 0 additions & 5 deletions
This file was deleted.

spec/spec_helper.rb

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,6 @@
8989
# as the one that triggered the failure.
9090
Kernel.srand config.seed
9191
=end
92-
RSpec.configure do |config|
93-
config.before(:suite) do
94-
Percy.config.access_token = ENV["PERCY_TOKEN"]
95-
# Percy.config.default_widths = [320, 768, 1280] # to test responsiveness
96-
end
97-
98-
config.before(:suite) { Percy::Capybara.initialize_build }
99-
config.after(:suite) { Percy::Capybara.finalize_build }
100-
end
10192

10293
class RSpec::Core::Formatters::JsonFormatter
10394
def dump_summary(summary)
@@ -106,7 +97,7 @@ def dump_summary(summary)
10697
map { |example| example.metadata[:points] }.
10798
sum
10899

109-
score = summary.
100+
earned_points = summary.
110101
examples.
111102
select { |example| example.execution_result.status == :passed }.
112103
map { |example| example.metadata[:points] }.
@@ -118,10 +109,16 @@ def dump_summary(summary)
118109
:failure_count => summary.failure_count,
119110
:pending_count => summary.pending_count,
120111
:total_points => total_points,
121-
:score => score,
112+
:earned_points => earned_points,
113+
:score => earned_points.to_f / total_points
122114
}
123115

124-
@output_hash[:summary_line] = "#{summary.totals_line}, #{score}/#{total_points} points"
116+
@output_hash[:summary_line] = [
117+
"#{summary.example_count} tests",
118+
"#{summary.failure_count} failures",
119+
"#{earned_points}/#{total_points} points",
120+
"#{score}%",
121+
].join(", ")
125122
end
126123

127124
private

0 commit comments

Comments
 (0)