Skip to content

Commit

Permalink
Add tests to the adoption, maternity and paternity smart answers to e…
Browse files Browse the repository at this point in the history
…nsure that questions with interpolated values are rendered correctly.

Add test helper method #question_title reads the value of a question as a String, forcing the interpolation to occur, so it can be asserted with a has_content? matcher in integration tests.
  • Loading branch information
erkde committed Nov 5, 2015
1 parent 642c4f6 commit 7f5c483
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/smart_answer_flows/shared_logic/paternity-calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@
due_date
end

calculate :qualifying_week_start do
calculator.qualifying_week.first
end

calculate :p_notice_leave do
calculator.notice_of_leave_deadline
end
Expand Down
2 changes: 1 addition & 1 deletion test/data/maternity-paternity-calculator-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ lib/smart_answer_flows/maternity-paternity-calculator/outcomes/paternity_leave_a
lib/smart_answer_flows/maternity-paternity-calculator/outcomes/paternity_not_entitled_to_leave_or_pay.govspeak.erb: 6909d514cd992d94400407ded6f4a024
lib/smart_answer_flows/shared_logic/adoption-calculator.rb: c166e63f0d4694acc664c789953659ba
lib/smart_answer_flows/shared_logic/maternity-calculator.rb: 5b566b38ef501d2a7c69a5e94ca18c2e
lib/smart_answer_flows/shared_logic/paternity-calculator.rb: 5aa842a23e800ee5575553f17dafbc39
lib/smart_answer_flows/shared_logic/paternity-calculator.rb: b09bdfd9c704ddbe78252173c4ccd0bd
lib/smart_answer/calculators/maternity_paternity_calculator.rb: 24de99189c23e9a7cc048871a817bb3c
lib/data/rates/maternity_paternity_birth.yml: 3eef956f1020576a9343647fec34dd01
lib/data/rates/maternity_paternity_adoption.yml: 453c4d90b6fd9ffe1556782665f313fc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ class AdoptionCalculatorTest < ActiveSupport::TestCase
assert_state_variable "employee_has_contract_adoption", 'yes'
assert_current_node :adoption_is_the_employee_on_your_payroll?
end
should 'render the question title with an interpolated date' do
nodes = Capybara.string(current_question.to_s)
assert nodes.has_content?('Was the employee (or will they be) on your payroll on')
end
context "answer yes" do
setup { add_response :yes }
## QA6
Expand Down
7 changes: 7 additions & 0 deletions test/integration/smart_answer_flows/flow_test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ def current_state
end
end

def current_question
@current_question ||= begin
presenter = QuestionPresenter.new("flow.#{@flow.name}", @flow.node(current_state.current_node), current_state)
presenter.title
end
end

def outcome_body
@outcome_body ||= begin
presenter = OutcomePresenter.new("flow.#{@flow.name}", @flow.node(current_state.current_node), current_state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@ class MaternityCalculatorTest < ActiveSupport::TestCase
should "ask if the employee is on your payroll" do
assert_current_node :is_the_employee_on_your_payroll?
end
should 'render the question title with an interpolated date' do
nodes = Capybara.string(current_question.to_s)
assert nodes.has_content?('Was the employee (or will they be) on your payroll on')
end
context "answer yes" do
setup do
add_response :yes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ class PaternityCalculatorTest < ActiveSupport::TestCase
assert_current_node :employee_on_payroll_paternity?
end

should 'render the question title with an interpolated date' do
nodes = Capybara.string(current_question.to_s)
assert nodes.has_content?('Was the employee (or will they be) on your payroll on')
end
context "answer yes" do
setup { add_response :yes }

Expand Down Expand Up @@ -332,6 +336,10 @@ class PaternityCalculatorTest < ActiveSupport::TestCase
assert_current_node :employee_on_payroll_paternity?
end

should 'render the question title with an interpolated date' do
nodes = Capybara.string(current_question.to_s)
assert nodes.has_content?('Was the employee (or will they be) on your payroll on')
end
context "answer no" do
setup { add_response :no }

Expand Down

0 comments on commit 7f5c483

Please sign in to comment.