|
93 | 93 | fail # didn't raise an error |
94 | 94 | end |
95 | 95 |
|
96 | | - context "with only an error key" do |
97 | | - let(:body) { JSON.dump(:error => "something went wrong") } |
98 | | - |
99 | | - it "should return RecordInvalid with proper message" do |
100 | | - begin |
101 | | - client.connection.get "/non_existent" |
102 | | - rescue ZendeskAPI::Error::RecordInvalid => e |
103 | | - expect(e.errors).to eq("something went wrong") |
104 | | - expect(e.to_s).to eq("ZendeskAPI::Error::RecordInvalid: something went wrong") |
105 | | - else |
106 | | - fail # didn't raise an error |
| 96 | + { |
| 97 | + error: 'There was an error', |
| 98 | + errors: 'There were several errors' |
| 99 | + }.each do |key, message| |
| 100 | + context "with only an #{key} key" do |
| 101 | + let(:body) { JSON.dump(key => message) } |
| 102 | + |
| 103 | + it "should return RecordInvalid with proper message" do |
| 104 | + expect { client.connection.get "/non_existent" }.to raise_error do |error| |
| 105 | + expect(error).to be_a(ZendeskAPI::Error::RecordInvalid) |
| 106 | + expect(error.errors).to eq(message) |
| 107 | + end |
107 | 108 | end |
108 | 109 | end |
109 | 110 | end |
|
129 | 130 | fail # didn't raise an error |
130 | 131 | end |
131 | 132 |
|
132 | | - context "with only an error key" do |
133 | | - let(:body) { JSON.dump(:error => "something went wrong") } |
134 | | - |
135 | | - it "should return RecordInvalid with proper message" do |
136 | | - begin |
137 | | - client.connection.get "/non_existent" |
138 | | - rescue ZendeskAPI::Error::RecordInvalid => e |
139 | | - expect(e.errors).to eq("something went wrong") |
140 | | - expect(e.to_s).to eq("ZendeskAPI::Error::RecordInvalid: something went wrong") |
141 | | - else |
142 | | - fail # didn't raise an error |
| 133 | + { |
| 134 | + error: 'There was an error', |
| 135 | + errors: 'There were several errors' |
| 136 | + }.each do |key, message| |
| 137 | + context "with only an #{key} key" do |
| 138 | + let(:body) { JSON.dump(key => message) } |
| 139 | + |
| 140 | + it "should return RecordInvalid with proper message" do |
| 141 | + expect { client.connection.get "/non_existent" }.to raise_error do |error| |
| 142 | + expect(error).to be_a(ZendeskAPI::Error::RecordInvalid) |
| 143 | + expect(error.errors).to eq(message) |
| 144 | + end |
143 | 145 | end |
144 | 146 | end |
145 | 147 | end |
|
0 commit comments