Class: GovukRSpecHelpers::WithinGovukFieldset
- Inherits:
-
Object
- Object
- GovukRSpecHelpers::WithinGovukFieldset
- Defined in:
- lib/within_govuk_fieldset.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#hint ⇒ Object
readonly
Returns the value of attribute hint.
-
#legend_text ⇒ Object
readonly
Returns the value of attribute legend_text.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
Instance Method Summary collapse
-
#initialize(page:, legend_text:, hint:, block:) ⇒ WithinGovukFieldset
constructor
A new instance of WithinGovukFieldset.
- #within ⇒ Object
Constructor Details
#initialize(page:, legend_text:, hint:, block:) ⇒ WithinGovukFieldset
Returns a new instance of WithinGovukFieldset.
6 7 8 9 10 11 |
# File 'lib/within_govuk_fieldset.rb', line 6 def initialize(page:, legend_text:, hint:, block:) @legend_text = legend_text @hint = hint @page = page @block = block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
4 5 6 |
# File 'lib/within_govuk_fieldset.rb', line 4 def block @block end |
#hint ⇒ Object (readonly)
Returns the value of attribute hint.
4 5 6 |
# File 'lib/within_govuk_fieldset.rb', line 4 def hint @hint end |
#legend_text ⇒ Object (readonly)
Returns the value of attribute legend_text.
4 5 6 |
# File 'lib/within_govuk_fieldset.rb', line 4 def legend_text @legend_text end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
4 5 6 |
# File 'lib/within_govuk_fieldset.rb', line 4 def page @page end |
Instance Method Details
#within ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/within_govuk_fieldset.rb', line 13 def within legends = page.all('legend', text: legend_text, exact_text: true, normalize_ws: true) if legends.size == 0 check_for_fieldset_id_match raise "No fieldset found with matching legend" end legend = legends.first @fieldset = legend.ancestor('fieldset') check_hint @page.within(@fieldset) do block.call end end |