Add workaround for shoulda-matchers#1067

https://github.com/thoughtbot/shoulda-matchers/issues/1067
This issue led to the failure of the solution I implemented before in 8f88362264.
Because of it shoulda-matchers will just ignore the given record for the
validation check and just take the first existing one which in this case
can still contain a only-digits code, because it was generated in the
before-block.
This commit is contained in:
Thor77 2018-12-02 21:16:24 +01:00
parent 1afc13c9c3
commit 8261a919fa
No known key found for this signature in database
GPG Key ID: 5051E71B46AA669A
1 changed files with 4 additions and 6 deletions

View File

@ -3,10 +3,6 @@
require 'rails_helper'
RSpec.describe Tournament, type: :model do
before do
@tournament = create(:tournament)
end
describe 'validation' do
it { should validate_presence_of :name }
it { should validate_presence_of :code }
@ -19,11 +15,13 @@ RSpec.describe Tournament, type: :model do
end
describe 'initialization' do
subject { create(:tournament) }
it 'should have a code' do
expect(@tournament.code.length).to be(6)
expect(subject.code.length).to be(6)
end
it 'should be public' do
expect(@tournament.public).to be(true)
expect(subject.public).to be(true)
end
end