|
49 | 49 | let(:response_data) { nil } |
50 | 50 | let(:status) { 404 } |
51 | 51 |
|
52 | | - it "raises ActiveResource::ResourceNotFound" do |
53 | | - expect { described_class.find(tag: :archived, form_id: form_id) }.to raise_error(ActiveResource::ResourceNotFound) |
| 52 | + it "returns nil" do |
| 53 | + expect(described_class.find(tag: :archived, form_id: form_id)).to be_nil |
54 | 54 | end |
55 | 55 | end |
56 | 56 | end |
57 | 57 |
|
58 | 58 | context "when the form id contains non-alpha-numeric chars" do |
59 | 59 | let(:form_id) { "<id>" } |
60 | 60 |
|
61 | | - it "returns ResourceNotFound when the id contains non-alpha-numeric chars" do |
62 | | - expect { |
63 | | - described_class.find(tag:, form_id:) |
64 | | - }.to raise_error(ActiveResource::ResourceNotFound) |
| 61 | + it "returns nil when the id contains non-alpha-numeric chars" do |
| 62 | + expect(described_class.find(tag:, form_id:)).to be_nil |
65 | 63 | end |
66 | 64 | end |
67 | 65 |
|
68 | 66 | context "when the form id is blank" do |
69 | 67 | let(:form_id) { "" } |
70 | 68 |
|
71 | | - it "returns ResourceNotFound when the id is blank" do |
72 | | - expect { |
73 | | - described_class.find(tag:, form_id:) |
74 | | - }.to raise_error(ActiveResource::ResourceNotFound) |
| 69 | + it "returns nil when the id is blank" do |
| 70 | + expect(described_class.find(tag:, form_id:)).to be_nil |
75 | 71 | end |
76 | 72 | end |
77 | 73 |
|
|
80 | 76 | let(:response_data) { nil } |
81 | 77 | let(:status) { 404 } |
82 | 78 |
|
83 | | - it "raises an exception" do |
84 | | - expect { |
85 | | - described_class.find(tag:, form_id:) |
86 | | - }.to raise_error(ActiveResource::ResourceNotFound) |
| 79 | + it "returns nil" do |
| 80 | + expect(described_class.find(tag:, form_id:)).to be_nil |
87 | 81 | end |
88 | 82 | end |
89 | 83 |
|
|
132 | 126 | expect(form_snapshot.pages).to all be_a Page |
133 | 127 | end |
134 | 128 |
|
135 | | - it "raises an exception if the form does not exist" do |
136 | | - expect { |
137 | | - described_class.find_with_mode(form_id: "99", mode: Mode.new("preview-draft")) |
138 | | - }.to raise_error(ActiveResource::ResourceNotFound) |
| 129 | + it "returns nil if the form does not exist" do |
| 130 | + expect(described_class.find_with_mode(form_id: "99", mode: Mode.new("preview-draft"))).to be_nil |
139 | 131 | end |
140 | 132 |
|
141 | 133 | context "when mode is live" do |
|
171 | 163 | end |
172 | 164 |
|
173 | 165 | context "when validating the provided form id" do |
174 | | - it "returns ResourceNotFound when the id contains non-alpha-numeric chars" do |
175 | | - expect { |
176 | | - described_class.find_with_mode(form_id: "<id>", mode: Mode.new("preview-draft")) |
177 | | - }.to raise_error(ActiveResource::ResourceNotFound) |
| 166 | + it "returns nil when the id contains non-alpha-numeric chars" do |
| 167 | + expect(described_class.find_with_mode(form_id: "<id>", mode: Mode.new("preview-draft"))).to be_nil |
178 | 168 | end |
179 | 169 |
|
180 | | - it "returns ResourceNotFound when the id is blank" do |
181 | | - expect { |
182 | | - described_class.find_with_mode(form_id: "", mode: Mode.new("preview-draft")) |
183 | | - }.to raise_error(ActiveResource::ResourceNotFound) |
| 170 | + it "returns nil when the id is blank" do |
| 171 | + expect(described_class.find_with_mode(form_id: "", mode: Mode.new("preview-draft"))).to be_nil |
184 | 172 | end |
185 | 173 |
|
186 | 174 | it "returns the form when the id is alphanumeric" do |
|
0 commit comments