Skip to content
This repository has been archived by the owner on Jul 24, 2020. It is now read-only.

Commit

Permalink
Avoid needlessly persisting to db in equipment model spec
Browse files Browse the repository at this point in the history
Resolves #1665
-change spec to build_stubbed instead of build
  • Loading branch information
zeffman committed Apr 8, 2017
1 parent 08e04ec commit 3182017
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions spec/models/equipment_model_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def mock_eq_model(**attrs)
end

describe 'basic validations' do
subject { EquipmentModel.new(ordering: 1) }
let!(:model) { mock_eq_model }
it { is_expected.to have_and_belong_to_many(:requirements) }
it { is_expected.to have_many(:equipment_items) }
it { is_expected.to have_many(:reservations) }
Expand All @@ -23,17 +23,20 @@ def mock_eq_model(**attrs)
it { is_expected.to accept_nested_attributes_for(:checkout_procedures) }
it { is_expected.to have_and_belong_to_many(:associated_equipment_models) }
it { is_expected.to validate_presence_of(:name) }
it { is_expected.to validate_uniqueness_of(:name) }
it { is_expected.to validate_presence_of(:description) }
it { is_expected.to belong_to(:category) }
it { is_expected.to validate_presence_of(:ordering) }
it 'requires an associated category' do
model = mock_eq_model
model.category = nil
expect(model.valid?).to be_falsey
end
end

describe 'validations requiring peristance' do
subject { FactoryGirl.build(:equipment_model) }
it { is_expected.to validate_uniqueness_of(:name) }
end

describe 'attribute-specific validations' do
shared_examples 'integer attribute' do |attr|
it 'is valid with an integer value' do
Expand Down

0 comments on commit 3182017

Please sign in to comment.