Skip to content

Commit

Permalink
Fix failing test
Browse files Browse the repository at this point in the history
Version 3.13.2 of the rspec-expectations gems updates the `include` matcher to
raise an exception if no arguments are passed. See rspec/rspec-expectations#1479

The `expected_interim_fees_for` helper is meant to return an array of expected
options in a case type selection to be used in the `include` matcher. However,
in some cases `nil` is returned resulting in no arguments resulting in an
exception. This was masking failures as the test was checking that the list
included items in an empty array and was therefore always passing.

It turns out that an update to `govuk-form-builder` from some time ago changed
the id of select boxes and so the list of options being tested was always
empty. This should have immediately resulted in a a failure but it was missed
due to the bug in `expected_interim_fees_for`.
  • Loading branch information
jrmhaig committed Aug 23, 2024
1 parent 4cb339a commit 565df59
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion features/page_objects/sections/lgfs_interim_fee_section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class SelectOptionSection < SitePrism::Section
class LGFSInterimFeeSection < SitePrism::Section
include SelectHelper

sections :fee_type_select_options, SelectOptionSection, 'select#claim_interim_fee_attributes_fee_type_id option', visible: false
sections :fee_type_select_options, SelectOptionSection, 'select#claim-interim-fee-attributes-fee-type-id-field option', visible: false
element :select_container, '.fee-type select', visible: false

# common interim fee fields
Expand Down
7 changes: 4 additions & 3 deletions features/step_definitions/litigator_interim_claim_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@
end

def expected_interim_fees_for(case_type_name)
expected = ['Disbursement only', 'Warrant']
expected += ['Effective PCMH', 'Trial start'] if case_type_name.casecmp('trial').eql?(0)
expected += ['Retrial start','Retrial new solicitor'] if case_type_name.casecmp('retrial').eql?(0)
return ['Disbursement only', 'Warrant', 'Effective PCMH', 'Trial start'] if case_type_name.casecmp('trial').eql?(0)
return ['Disbursement only', 'Warrant', 'Retrial start','Retrial new solicitor'] if case_type_name.casecmp('retrial').eql?(0)

['Disbursement only', 'Warrant']
end

0 comments on commit 565df59

Please sign in to comment.