From 05c294874e0f7602686b22df8b3193f263db0f09 Mon Sep 17 00:00:00 2001 From: Raghu Betina Date: Thu, 28 Apr 2016 11:15:39 -0500 Subject: [PATCH 1/3] Add tests --- .rspec | 2 +- circle.yml | 11 ++++++ spec/features/1_something_spec.rb | 17 --------- spec/features/guesses_spec.rb | 59 +++++++++++++++++++++++++++++++ spec/models/guess_spec.rb | 5 --- spec/spec_helper.rb | 21 +++++------ 6 files changed, 80 insertions(+), 35 deletions(-) create mode 100644 circle.yml delete mode 100644 spec/features/1_something_spec.rb create mode 100644 spec/features/guesses_spec.rb delete mode 100644 spec/models/guess_spec.rb diff --git a/.rspec b/.rspec index 83e16f8..f7ec799 100644 --- a/.rspec +++ b/.rspec @@ -1,2 +1,2 @@ ---color +--format documentation --require spec_helper diff --git a/circle.yml b/circle.yml new file mode 100644 index 0000000..6adc19e --- /dev/null +++ b/circle.yml @@ -0,0 +1,11 @@ +machine: + ruby: + version: 2.3.0 + +notify: + webhooks: + - url: https://grades.firstdraft.com/builds + +test: + override: + - bundle exec rspec --order default --format documentation --format j --out $CIRCLE_ARTIFACTS/rspec_output.json diff --git a/spec/features/1_something_spec.rb b/spec/features/1_something_spec.rb deleted file mode 100644 index c70fe6c..0000000 --- a/spec/features/1_something_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -require "rails_helper" - -feature "A user can" do - scenario "do a thing" do - visit "/some_path" - - expect(page).to have_selector("p", text: "Something") - end - - xit "see that it looks right" do - visit "/some_path" - - Percy::Capybara.snapshot(page) - - skip "Check the Percy status on your Pull Request for visual comparison" - end -end diff --git a/spec/features/guesses_spec.rb b/spec/features/guesses_spec.rb new file mode 100644 index 0000000..80b6aa9 --- /dev/null +++ b/spec/features/guesses_spec.rb @@ -0,0 +1,59 @@ +require "rails_helper" + +feature "The index page" do + it "has a functional RCAV", points: 5 do + visit "/all_guesses" + + expect(page).to have_selector("h1") + end + + it "has the first sequence", points: 5 do + visit "/all_guesses" + + expect(page).to have_selector("li", text: "2, 4, 8 Obeys the rule") + end + + it "has two forms", points: 5 do + visit "/all_guesses" + + expect(page).to have_selector("form", count: 2) + end + + it "has a \"Check\" button", points: 5 do + visit "/all_guesses" + + expect(page).to have_button("Check") + end + + it "has a \"I think I know it\" button", points: 5 do + visit "/all_guesses" + + expect(page).to have_button("I think I know it") + end + + it "has a reset link", points: 5 do + visit "/all_guesses" + + expect(page).to have_link("Reset") + end +end + +feature "The answer form" do + it "goes to the answer page when submitted", points: 5 do + visit "/all_guesses" + + click_on "I think I know it" + + expect(current_path).to eq "/show_answer" + end + + it "displays the user's answer on the answer page" do + visit "/all_guesses" + + fill_in("rule", with: "A serviceable substitute for wit") + + click_on "I think I know it" + + expect(page).to have_content("A serviceable substitute for wit") + end +end diff --git a/spec/models/guess_spec.rb b/spec/models/guess_spec.rb deleted file mode 100644 index 06e1c2f..0000000 --- a/spec/models/guess_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe Guess, type: :model do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 71ac601..7e4b2d9 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -89,15 +89,6 @@ # as the one that triggered the failure. Kernel.srand config.seed =end - RSpec.configure do |config| - config.before(:suite) do - Percy.config.access_token = ENV["PERCY_TOKEN"] - # Percy.config.default_widths = [320, 768, 1280] # to test responsiveness - end - - config.before(:suite) { Percy::Capybara.initialize_build } - config.after(:suite) { Percy::Capybara.finalize_build } - end class RSpec::Core::Formatters::JsonFormatter def dump_summary(summary) @@ -106,7 +97,7 @@ def dump_summary(summary) map { |example| example.metadata[:points] }. sum - score = summary. + earned_points = summary. examples. select { |example| example.execution_result.status == :passed }. map { |example| example.metadata[:points] }. @@ -118,10 +109,16 @@ def dump_summary(summary) :failure_count => summary.failure_count, :pending_count => summary.pending_count, :total_points => total_points, - :score => score, + :earned_points => earned_points, + :score => earned_points.to_f / total_points } - @output_hash[:summary_line] = "#{summary.totals_line}, #{score}/#{total_points} points" + @output_hash[:summary_line] = [ + "#{summary.example_count} tests", + "#{summary.failure_count} failures", + "#{earned_points}/#{total_points} points", + "#{score}%", + ].join(", ") end private From b01090dce850a2b664a12ca19d9ad5e9cb49658d Mon Sep 17 00:00:00 2001 From: Raghu Betina Date: Fri, 29 Apr 2016 10:38:55 -0500 Subject: [PATCH 2/3] My solution --- app/views/guesses/index.html.erb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/views/guesses/index.html.erb b/app/views/guesses/index.html.erb index 8deb47c..406b87c 100644 --- a/app/views/guesses/index.html.erb +++ b/app/views/guesses/index.html.erb @@ -44,6 +44,8 @@ +asdasd +
From 5fa719ad941d1bb6dcb6cda6e702a2786b3613c3 Mon Sep 17 00:00:00 2001 From: Raghu Betina Date: Fri, 29 Apr 2016 10:41:16 -0500 Subject: [PATCH 3/3] ruby version --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index 6adc19e..8361acf 100644 --- a/circle.yml +++ b/circle.yml @@ -1,6 +1,6 @@ machine: ruby: - version: 2.3.0 + version: 2.2.4 notify: webhooks: