diff options
| author | Robert | 2017-08-21 20:24:50 +0200 |
|---|---|---|
| committer | Robert | 2017-08-22 09:37:30 +0200 |
| commit | 61c4a303183284fc107325aeeef5ace7a3e68c0c (patch) | |
| tree | 71bbfe5e5fe9eddb9e381aa0536b44476f461bc1 /spec | |
| parent | 327b1ec771a056451b0635ba80cc346fa1765299 (diff) | |
| download | chouette-core-61c4a303183284fc107325aeeef5ace7a3e68c0c.tar.bz2 | |
Refs: #4273@3h;
Debugging Java Integration (ZipService -> HTTPService -> Object Creation)
- Created an ErrorFormat concern to see what went wrong in the HTTP call
as so many things can go wrong due to:
* Timeout Issues
* Illegal database setup or cleaning before tests
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/models/concerns/error_format_spec.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/models/concerns/error_format_spec.rb b/spec/models/concerns/error_format_spec.rb new file mode 100644 index 000000000..7f7df22b6 --- /dev/null +++ b/spec/models/concerns/error_format_spec.rb @@ -0,0 +1,35 @@ +RSpec.describe ErrorFormat do + + context '#details' do + context 'are empty' do + it 'if no errors are present' do + expect( described_class.details(create :referential) ).to be_empty + end + + it 'if no validation has been carried out' do + invalid = build :referential, name: nil + expect( described_class.details(invalid) ).to be_empty + end + end + + context 'are not empty' do + it 'if an error is present and validation has been carried out' do + invalid = build :referential, name: nil + expect( invalid ).not_to be_valid + expect( described_class.details(invalid) ).to eq([ + {name: {error: 'doit ĂȘtre rempli(e)', value: nil}} + ]) + end + + it 'and can even hold many errors' do + create :referential, name: 'hello' + invalid = build :referential, name: 'hello', slug: 'hello world' + expect( invalid ).not_to be_valid + expect( described_class.details(invalid) ).to eq([ + {name: {error: "n'est pas disponible", value: 'hello'}}, + {slug: {error: "n'est pas valide", value: 'hello world'}} + ]) + end + end + end +end |
