Files
growstuff/spec/models/plant_part_spec.rb
Daniel O'Connor f1acb35520 Merge pull request #4537 from Growstuff/FactoryBot/SyntaxMethods
Rubocop: FactoryBot/SyntaxMethods
2026-04-23 22:29:24 +09:30

37 lines
893 B
Ruby

# frozen_string_literal: true
require 'rails_helper'
describe PlantPart do
it 'stringifies' do
@pp = create(:plant_part)
@pp.to_s.should eq @pp.name
end
it 'has crops' do
@maize = create(:maize)
@tomato = create(:tomato)
@pp1 = create(:plant_part)
@h1 = create(:harvest,
crop: @tomato,
plant_part: @pp1)
@h2 = create(:harvest,
crop: @maize,
plant_part: @pp1)
@pp1.crops.should include @tomato
@pp1.crops.should include @maize
end
it "doesn't duplicate crops" do
@maize = create(:maize)
@pp1 = create(:plant_part)
@h1 = create(:harvest,
crop: @maize,
plant_part: @pp1)
@h2 = create(:harvest,
crop: @maize,
plant_part: @pp1)
@pp1.crops.should eq [@maize]
end
end