From 0ca544086fc446cd0041dcf6ba70b9bbe3c2c664 Mon Sep 17 00:00:00 2001 From: Tobias Bielohlawek Date: Fri, 21 Aug 2015 00:42:24 +0200 Subject: [PATCH] Fix rspec warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Spec threw warnings as raise_error didn’t provide an Error Class to assert on. Indeed in one case the wrong error was raised than expected. [fixes #711] --- spec/models/doorkeeper/access_token_spec.rb | 6 +++--- spec/models/doorkeeper/application_spec.rb | 2 +- spec/support/shared/models_shared_examples.rb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/models/doorkeeper/access_token_spec.rb b/spec/models/doorkeeper/access_token_spec.rb index 27114ff52..1c2ad7469 100644 --- a/spec/models/doorkeeper/access_token_spec.rb +++ b/spec/models/doorkeeper/access_token_spec.rb @@ -123,7 +123,7 @@ module NoGenerate it 'is not valid if token exists' do token1 = FactoryGirl.create :access_token, use_refresh_token: true token2 = FactoryGirl.create :access_token, use_refresh_token: true - token2.send :write_attribute, :refresh_token, token1.refresh_token + token2.refresh_token = token1.refresh_token expect(token2).not_to be_valid end @@ -131,9 +131,9 @@ module NoGenerate token1 = FactoryGirl.create :access_token, use_refresh_token: true token2 = FactoryGirl.create :access_token, use_refresh_token: true expect do - token2.write_attribute :refresh_token, token1.refresh_token + token2.refresh_token = token1.refresh_token token2.save(validate: false) - end.to raise_error + end.to raise_error(ActiveRecord::RecordNotUnique) end end diff --git a/spec/models/doorkeeper/application_spec.rb b/spec/models/doorkeeper/application_spec.rb index 4d334d9a2..165d34cf1 100644 --- a/spec/models/doorkeeper/application_spec.rb +++ b/spec/models/doorkeeper/application_spec.rb @@ -90,7 +90,7 @@ module Doorkeeper app1 = FactoryGirl.create(:application) app2 = FactoryGirl.create(:application) app2.uid = app1.uid - expect { app2.save!(validate: false) }.to raise_error + expect { app2.save!(validate: false) }.to raise_error(ActiveRecord::RecordNotUnique) end it 'generate secret on create' do diff --git a/spec/support/shared/models_shared_examples.rb b/spec/support/shared/models_shared_examples.rb index 9489a3eda..0b59d7a7e 100644 --- a/spec/support/shared/models_shared_examples.rb +++ b/spec/support/shared/models_shared_examples.rb @@ -46,7 +46,7 @@ token2.token = token1.token expect do token2.save!(validate: false) - end.to raise_error + end.to raise_error(ActiveRecord::RecordNotUnique) end end end