diff options
| author | Teddy Wing | 2017-08-25 16:56:39 +0200 |
|---|---|---|
| committer | Teddy Wing | 2017-08-25 16:56:39 +0200 |
| commit | 438970931bcc11f460145ea88bbcbfd2ad7bafac (patch) | |
| tree | c1f970a606a6b08ee980b601f3fa1f7f2e129482 /spec/models | |
| parent | 1994b1f0fdb4f74102bf61c8a3791af59860597a (diff) | |
| download | chouette-core-438970931bcc11f460145ea88bbcbfd2ad7bafac.tar.bz2 | |
ErrorFormat spec: Use `build_stubbed`
Speed up these tests by using `build_stubbed` for factories where
possible.
Diffstat (limited to 'spec/models')
| -rw-r--r-- | spec/models/concerns/error_format_spec.rb | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/spec/models/concerns/error_format_spec.rb b/spec/models/concerns/error_format_spec.rb index 7f7df22b6..9b0110bcd 100644 --- a/spec/models/concerns/error_format_spec.rb +++ b/spec/models/concerns/error_format_spec.rb @@ -3,18 +3,20 @@ 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 + expect( + described_class.details(build_stubbed(:referential)) + ).to be_empty end it 'if no validation has been carried out' do - invalid = build :referential, name: nil + invalid = build_stubbed(: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 + invalid = build_stubbed(:referential, name: nil) expect( invalid ).not_to be_valid expect( described_class.details(invalid) ).to eq([ {name: {error: 'doit ĂȘtre rempli(e)', value: nil}} @@ -22,8 +24,12 @@ RSpec.describe ErrorFormat do end it 'and can even hold many errors' do - create :referential, name: 'hello' - invalid = build :referential, name: 'hello', slug: 'hello world' + create(:referential, name: 'hello') + invalid = build_stubbed( + :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'}}, |
