diff --git a/spec/features/calculations_spec.rb b/spec/features/calculations_spec.rb index 5a6dd11..7242ada 100644 --- a/spec/features/calculations_spec.rb +++ b/spec/features/calculations_spec.rb @@ -1,54 +1,54 @@ require "rails_helper" -feature "Flexible square" do - it "works with input 5", points: 2, hint: h("params_are_strings") do +describe "/flexible/square/[NUMBER TO BE SQUARED]" do + it "works with an input of 5", points: 2, hint: h("params_are_strings") do visit "/flexible/square/5" expect(page).to have_content(25) end end -feature "Flexible square" do - it "works with input 42", points: 4, hint: h("params_are_strings") do +describe "/flexible/square/[NUMBER TO BE SQUARED]" do + it "works with an input of 42", points: 4, hint: h("params_are_strings") do visit "/flexible/square/42" expect(page).to have_content(1764) end end -feature "Flexible square root" do - it "works with input 5", points: 2, hint: h("params_are_strings") do +describe "/flexible/square_root/[NUMBER TO FIND THE SQUARE ROOT OF]" do + it "works with an input of 5", points: 2, hint: h("params_are_strings") do visit "/flexible/square_root/5" expect(page).to have_content(2.236) end end -feature "Flexible square root" do - it "works with input 42", points: 2, hint: h("params_are_strings") do +describe "/flexible/square_root/[NUMBER TO FIND THE SQUARE ROOT OF]" do + it "works with an input of 42", points: 2, hint: h("params_are_strings") do visit "/flexible/square_root/42" expect(page).to have_content(6.4807) end end -feature "Flexible payment" do - it "works", points: 5, hint: h("params_are_strings") do +describe "/flexible/payment/[BASIS POINTS]/[NUMBER OF YEARS]/[PRINCIPAL]" do + it "calculates the loan payment", points: 5, hint: h("params_are_strings") do visit "/flexible/payment/324/5/14600" expect(page).to have_content(263.90) end end -feature "Flexible payment" do - it "rounds the payment", points: 1, hint: h("round") do +describe "/flexible/payment/[BASIS POINTS]/[NUMBER OF YEARS]/[PRINCIPAL]" do + it "rounds the loan payment", points: 1, hint: h("round") do visit "/flexible/payment/324/5/14503" expect(page).to have_content(262.15) end end -feature "Flexible payment" do +describe "/flexible/payment/[BASIS POINTS]/[NUMBER OF YEARS]/[PRINCIPAL]" do it "formats large dollar amounts", points: 2, hint: h("number_to_currency") do visit "/flexible/payment/410/30/250000" @@ -56,7 +56,7 @@ end end -feature "Flexible payment" do +describe "/flexible/payment/[BASIS POINTS]/[NUMBER OF YEARS]/[PRINCIPAL]" do it "formats the rate as a percentage", points: 1, hint: h("number_to_percentage") do visit "/flexible/payment/410/30/250000" @@ -64,7 +64,19 @@ end end -feature "First RCAV for square form" do +describe "/flexible/random/[MINIMUM]/[MAXIMUM]" do + it "creates a constrained random number", points: 1 do + visit "/flexible/random/1/10" + + pattern = /A random number between 1 and 10 is (\d+)/ + matched_groups = pattern.match(page.text) + first_matched_number = matched_groups[1].to_i + expect(first_matched_number).to be >= 1 + expect(first_matched_number).to be <= 10 + end +end + +describe "/square/new" do it "has a form element", points: 1 do visit "/square/new" @@ -72,7 +84,7 @@ end end -feature "First RCAV for square form" do +describe "/square/new" do it "has a label", points: 1, hint: h("copy_must_match label_for_input") do visit "/square/new" @@ -80,7 +92,7 @@ end end -feature "First RCAV for square form" do +describe "/square/new" do it "has an input", points: 1 do visit "/square/new" @@ -88,7 +100,7 @@ end end -feature "First RCAV for square form" do +describe "/square/new" do it "has a button", points: 1, hint: h("copy_must_match") do visit "/square/new" @@ -96,7 +108,7 @@ end end -feature "First RCAV for square form" do +describe "/square/new" do it "has an action attribute", points: 1 do visit "/square/new" @@ -104,8 +116,8 @@ end end -feature "First RCAV for square form" do - it "when submitted leads to another functional RCAV", points: 6, hint: h("button_type") do +describe "/square/new" do + it "leads to another functional RCAV when submitted ", points: 6, hint: h("button_type") do visit "/square/new" click_button "Calculate square" @@ -114,7 +126,7 @@ end end -feature "First RCAV for square form" do +describe "/square/new" do it "captures the user's input in the query string", points: 4, hint: h("names_for_inputs") do visit "/square/new" @@ -122,8 +134,8 @@ end end -feature "Second RCAV for square form" do - it "correctly processes an input of 5", points: 3, hint: h("label_for_input params_are_strings") do +describe "/square/new" do + it "works with an input of 5", points: 3, hint: h("label_for_input params_are_strings") do visit "/square/new" fill_in "Enter a number", with: 5 @@ -134,8 +146,8 @@ end end -feature "Second RCAV for square form" do - it "correctly processes an input of 42.42", points: 3, hint: h("label_for_input params_are_strings") do +describe "/square/new" do + it "works with an input of 42.42", points: 3, hint: h("label_for_input params_are_strings") do visit "/square/new" fill_in "Enter a number", with: 42.42 @@ -146,7 +158,7 @@ end end -feature "First RCAV for square root form" do +describe "/square_root/new" do it "has a form element", points: 1 do visit "/square_root/new" @@ -154,7 +166,7 @@ end end -feature "First RCAV for square root form" do +describe "/square_root/new" do it "has a label", points: 1, hint: h("copy_must_match label_for_input") do visit "/square_root/new" @@ -162,7 +174,7 @@ end end -feature "First RCAV for square root form" do +describe "/square_root/new" do it "has an input", points: 1, hint: h("label_for_input") do visit "/square_root/new" @@ -170,7 +182,7 @@ end end -feature "First RCAV for square root form" do +describe "/square_root/new" do it "has a button", points: 1, hint: h("copy_must_match") do visit "/square_root/new" @@ -178,7 +190,7 @@ end end -feature "First RCAV for square root form" do +describe "/square_root/new" do it "has an action attribute", points: 1 do visit "/square_root/new" @@ -186,8 +198,8 @@ end end -feature "First RCAV for square root form" do - it "when submitted leads to another functional RCAV", points: 6, hint: h("button_type") do +describe "/square_root/new" do + it "leads to another functional RCAV when submitted ", points: 6, hint: h("button_type") do visit "/square_root/new" click_button "Calculate square root" @@ -196,7 +208,7 @@ end end -feature "First RCAV for square root form" do +describe "/square_root/new" do it "captures the user's input in the query string", points: 4, hint: h("names_for_inputs") do visit "/square_root/new" @@ -204,8 +216,8 @@ end end -feature "Second RCAV for square root form" do - it "correctly processes an input of 5", points: 3, hint: h("label_for_input params_are_strings") do +describe "/square_root/new" do + it "works with an input of 5", points: 3, hint: h("label_for_input params_are_strings") do visit "/square_root/new" fill_in "Enter a number", with: 5 @@ -216,8 +228,8 @@ end end -feature "Second RCAV for square root form" do - it "correctly processes an input of 42.42", points: 3, hint: h("label_for_input params_are_strings") do +describe "/square_root/new" do + it "works with an input of 42.42", points: 3, hint: h("label_for_input params_are_strings") do visit "/square_root/new" fill_in "Enter a number", with: 42.42 @@ -228,7 +240,7 @@ end end -feature "First RCAV for payment form" do +describe "/payment/new" do it "has a form element", points: 1 do visit "/payment/new" @@ -236,7 +248,7 @@ end end -feature "First RCAV for payment form" do +describe "/payment/new" do it "has a label for APR", points: 1, hint: h("copy_must_match label_for_input") do visit "/payment/new" @@ -244,7 +256,7 @@ end end -feature "First RCAV for payment form" do +describe "/payment/new" do it "has a label for number of years", points: 1, hint: h("copy_must_match label_for_input") do visit "/payment/new" @@ -252,7 +264,7 @@ end end -feature "First RCAV for payment form" do +describe "/payment/new" do it "has a label for principal", points: 1, hint: h("copy_must_match label_for_input") do visit "/payment/new" @@ -260,7 +272,7 @@ end end -feature "First RCAV for payment form" do +describe "/payment/new" do it "has three inputs", points: 1, hint: h("label_for_input") do visit "/payment/new" @@ -268,7 +280,7 @@ end end -feature "First RCAV for payment form" do +describe "/payment/new" do it "has a button", points: 1, hint: h("copy_must_match") do visit "/payment/new" @@ -276,7 +288,7 @@ end end -feature "First RCAV for payment form" do +describe "/payment/new" do it "has an action attribute", points: 2 do visit "/payment/new" @@ -284,8 +296,8 @@ end end -feature "First RCAV for payment form" do - it "when submitted leads to another functional RCAV", points: 6, hint: h("button_type") do +describe "/payment/new" do + it "leads to another functional RCAV when submitted ", points: 6, hint: h("button_type") do visit "/payment/new" click_button "Calculate monthly payment" @@ -294,7 +306,7 @@ end end -feature "First RCAV for payment form" do +describe "/payment/new" do it "captures the user's input in the query string", points: 4, hint: h("names_for_inputs") do visit "/payment/new" @@ -302,7 +314,7 @@ end end -feature "Second RCAV for payment form" do +describe "/payment/new" do it "correctly processes inputs", points: 3, hint: h("label_for_input params_are_strings") do visit "/payment/new" @@ -316,7 +328,7 @@ end end -feature "Second RCAV for payment form" do +describe "/payment/new" do it "rounds the payment", points: 1, hint: h("round") do visit "/payment/new" @@ -330,7 +342,7 @@ end end -feature "Second RCAV for payment form" do +describe "/payment/new" do it "formats large dollar amounts", points: 2, hint: h("number_to_currency") do visit "/payment/new" @@ -344,7 +356,7 @@ end end -feature "Second RCAV for payment form" do +describe "/payment/new" do it "rounds the interest rate to four digits", points: 1, hint: h("round") do visit "/payment/new" @@ -358,7 +370,7 @@ end end -feature "Second RCAV for payment form" do +describe "/payment/new" do it "formats the rate as a percentage", points: 1, hint: h("number_to_percentage") do visit "/payment/new" @@ -372,7 +384,7 @@ end end -feature "First RCAV for random form" do +describe "/random/new" do it "has a form element", points: 1 do visit "/random/new" @@ -380,7 +392,7 @@ end end -feature "First RCAV for random form" do +describe "/random/new" do it "has a label for minimum", points: 1, hint: h("copy_must_match label_for_input") do visit "/random/new" @@ -388,7 +400,7 @@ end end -feature "First RCAV for random form" do +describe "/random/new" do it "has a label for maximum", points: 1, hint: h("copy_must_match label_for_input") do visit "/random/new" @@ -396,7 +408,7 @@ end end -feature "First RCAV for random form" do +describe "/random/new" do it "has two inputs", points: 1, hint: h("label_for_input") do visit "/random/new" @@ -404,7 +416,7 @@ end end -feature "First RCAV for random form" do +describe "/random/new" do it "has a button", points: 1, hint: h("copy_must_match") do visit "/random/new" @@ -412,7 +424,7 @@ end end -feature "First RCAV for random form" do +describe "/random/new" do it "has an action attribute", points: 1 do visit "/random/new" @@ -420,8 +432,8 @@ end end -feature "First RCAV for random form" do - it "when submitted leads to another functional RCAV", points: 6, hint: h("button_type") do +describe "/random/new" do + it "leads to another functional RCAV when submitted ", points: 6, hint: h("button_type") do visit "/random/new" click_button "Pick random number" @@ -430,7 +442,7 @@ end end -feature "First RCAV for random form" do +describe "/random/new" do it "captures the user's input in the query string", points: 4, hint: h("names_for_inputs") do visit "/random/new"