Module: StandardSingpass::Myinfo::TestPersonas
- Defined in:
- lib/standard_singpass/myinfo/test_personas.rb
Overview
Loads the test-persona fixture set used by Singpass mock-callback flows (E2E only) and RSpec helpers. The fixture file is the single source of truth so Ruby and Playwright sides can’t drift.
The host application can override the fixture path via ‘StandardSingpass::Myinfo.configuration.personas_path = Pathname.new(…)`. Without an override, the gem’s bundled ‘fixtures/myinfo-personas.json` is used.
Defined Under Namespace
Classes: UnknownPersona
Constant Summary collapse
- DEFAULT_KEY =
"default"- GEM_FIXTURE_PATH =
Pathname.new(File.("../../../fixtures/myinfo-personas.json", __dir__)).freeze
Class Method Summary collapse
- .data ⇒ Object
- .fetch(key) ⇒ Object
- .fixture_path ⇒ Object
- .keys ⇒ Object
-
.reload! ⇒ Object
Test-only — call from a spec ‘before(:suite)` if you want to pick up mid-run edits to the fixture file.
Class Method Details
.data ⇒ Object
30 31 32 |
# File 'lib/standard_singpass/myinfo/test_personas.rb', line 30 def self.data @data ||= JSON.parse(fixture_path.read).freeze end |
.fetch(key) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/standard_singpass/myinfo/test_personas.rb', line 19 def self.fetch(key) key = key.to_s.presence || DEFAULT_KEY data.fetch(key) do raise UnknownPersona, "Unknown MyInfo test persona: #{key.inspect}. Known: #{data.keys.inspect}" end end |
.fixture_path ⇒ Object
41 42 43 44 |
# File 'lib/standard_singpass/myinfo/test_personas.rb', line 41 def self.fixture_path configured = StandardSingpass::Myinfo.configuration.personas_path configured ? Pathname.new(configured) : GEM_FIXTURE_PATH end |
.keys ⇒ Object
26 27 28 |
# File 'lib/standard_singpass/myinfo/test_personas.rb', line 26 def self.keys data.keys end |
.reload! ⇒ Object
Test-only — call from a spec ‘before(:suite)` if you want to pick up mid-run edits to the fixture file.
36 37 38 39 |
# File 'lib/standard_singpass/myinfo/test_personas.rb', line 36 def self.reload! @data = nil data end |