spec/lib/idy/extension/findy_bump_spec.rb in idy-0.1.3 vs spec/lib/idy/extension/findy_bump_spec.rb in idy-1.0.0
- old
+ new
@@ -1,24 +1,26 @@
# frozen_string_literal: true
require 'rails_helper'
-RSpec.describe '#findy!' do
+RSpec.describe Article, '#findy!' do
context 'when a hash is given' do
- context 'and record is found' do
+ context 'when record is found' do
let!(:record) { Article.create id: 1 }
let!(:hash) { 'My' }
it 'finds the record' do
expect(Article.findy!(hash)).to eq record
end
end
- context 'and record is not found' do
+ context 'when record is not found' do
let!(:hash) { 'My' }
it 'raises' do
- expect { Article.findy!(hash) }.to raise_error ActiveRecord::RecordNotFound, %(Couldn't find User with 'idy'="My")
+ message = %(Couldn't find User with 'idy'="My")
+
+ expect { Article.findy!(hash) }.to raise_error ActiveRecord::RecordNotFound, message
end
end
end
end