Skip to content

Commit

Permalink
refactoring specs for more efficient factories and validations
Browse files Browse the repository at this point in the history
  • Loading branch information
wrburgess committed May 12, 2013
1 parent 6a762c7 commit 4667cb0
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 21 deletions.
3 changes: 1 addition & 2 deletions spec/models/ingredient_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
describe Ingredient do

it 'has a valid factory' do
ingredient = FactoryGirl.create(:ingredient)
expect(ingredient).to be_valid
expect(FactoryGirl.build(:ingredient)).to be_valid
end

it { should have_many(:step_ingredients) }
Expand Down
3 changes: 1 addition & 2 deletions spec/models/recipe_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
describe Recipe do

it 'has a valid factory' do
recipe = FactoryGirl.create(:recipe)
expect(recipe).to be_valid
expect(FactoryGirl.build(:recipe)).to be_valid
end

it { should have_many(:steps) }
Expand Down
9 changes: 3 additions & 6 deletions spec/models/step_ingredient_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@
describe StepIngredient do

it 'has a valid factory' do
step_ingredient = FactoryGirl.create(:step_ingredient)
expect(step_ingredient).to be_valid
expect(FactoryGirl.build(:step_ingredient)).to be_valid
end

it 'is invalid without a step_id' do
step_ingredient = FactoryGirl.build(:step_ingredient, step_id: nil)
expect(step_ingredient).to be_invalid
expect(FactoryGirl.build(:step_ingredient, step_id: nil)).to be_invalid
end

it 'is invalid without an ingredient_id' do
step_ingredient = FactoryGirl.build(:step_ingredient, ingredient_id: nil)
expect(step_ingredient).to be_invalid
expect(FactoryGirl.build(:step_ingredient, ingredient_id: nil)).to be_invalid
end

it { should belong_to(:step) }
Expand Down
3 changes: 1 addition & 2 deletions spec/models/step_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
describe Step do

it 'has a valid factory' do
step = FactoryGirl.create(:step)
expect(step).to be_valid
expect(FactoryGirl.build(:step)).to be_valid
end

it { should belong_to(:recipe) }
Expand Down
11 changes: 4 additions & 7 deletions spec/models/step_tool_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@
describe StepTool do

it 'has a valid factory' do
step_tool = FactoryGirl.create(:step_tool)
expect(step_tool).to be_valid
expect(FactoryGirl.build(:step_tool)).to be_valid
end

it 'is invalid without a step_id' do
step_tool = FactoryGirl.build(:step_tool, step_id: nil)
expect(step_tool).to be_invalid
end
expect(FactoryGirl.build(:step_tool, step_id: nil)).to be_invalid
end

it 'is invalid without an tool_id' do
step_tool = FactoryGirl.build(:step_tool, tool_id: nil)
expect(step_tool).to be_invalid
expect(FactoryGirl.build(:step_tool, tool_id: nil)).to be_invalid
end

it { should belong_to(:step) }
Expand Down
3 changes: 1 addition & 2 deletions spec/models/tool_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
describe Tool do

it 'has a valid factory' do
tool = FactoryGirl.create(:tool)
expect(tool).to be_valid
expect(FactoryGirl.build(:tool)).to be_valid
end

it { should have_many(:step_tools) }
Expand Down

0 comments on commit 4667cb0

Please sign in to comment.