Module: GdsApi::TestHelpers::Calendars
- Defined in:
- lib/gds_api/test_helpers/calendars.rb
Instance Method Summary collapse
- #calendars_endpoint(in_division: nil) ⇒ Object
- #stub_calendars_has_a_bank_holiday_on(date, in_division: nil) ⇒ Object
- #stub_calendars_has_bank_holidays_on(dates, in_division: nil) ⇒ Object
- #stub_calendars_has_no_bank_holidays(in_division: nil) ⇒ Object
Instance Method Details
#calendars_endpoint(in_division: nil) ⇒ Object
4 5 6 7 8 |
# File 'lib/gds_api/test_helpers/calendars.rb', line 4 def calendars_endpoint(in_division: nil) endpoint = "#{Plek.new.website_root}/bank-holidays" endpoint += "/#{in_division}" unless in_division.nil? "#{endpoint}.json" end |
#stub_calendars_has_a_bank_holiday_on(date, in_division: nil) ⇒ Object
51 52 53 |
# File 'lib/gds_api/test_helpers/calendars.rb', line 51 def stub_calendars_has_a_bank_holiday_on(date, in_division: nil) stub_calendars_has_bank_holidays_on([date], in_division:) end |
#stub_calendars_has_bank_holidays_on(dates, in_division: nil) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/gds_api/test_helpers/calendars.rb', line 14 def stub_calendars_has_bank_holidays_on(dates, in_division: nil) events = dates.map.with_index do |date, idx| { title: "Caturday #{idx}!", date: date.to_date.iso8601, notes: "Y'know, for cats!", bunting: true, } end response = if in_division.nil? { "england-and-wales" => { division: "england-and-wales", events:, }, "scotland" => { division: "scotland", events:, }, "northern-ireland" => { division: "northern-ireland", events:, }, } else { division: in_division, events:, } end stub_request(:get, calendars_endpoint(in_division:)) .to_return(body: response.to_json, status: 200) end |
#stub_calendars_has_no_bank_holidays(in_division: nil) ⇒ Object
10 11 12 |
# File 'lib/gds_api/test_helpers/calendars.rb', line 10 def stub_calendars_has_no_bank_holidays(in_division: nil) stub_calendars_has_bank_holidays_on([], in_division:) end |