From 438970931bcc11f460145ea88bbcbfd2ad7bafac Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Fri, 25 Aug 2017 16:56:39 +0200 Subject: ErrorFormat spec: Use `build_stubbed` Speed up these tests by using `build_stubbed` for factories where possible. --- spec/models/concerns/error_format_spec.rb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'spec') 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'}}, -- cgit v1.2.3