I have the following code:
RSpec.describe OtsState do
let(:campaign) { build(:campaign, from: Time.now+1.weeks, to: Time.now+2.weeks) }
subject { campaign.deployment.ots_state }
before { campaign.deployment.build_ots_state }
describe "#set_target" do
def check_ots_target(target,expected)
ots_state = subject
ots_state.set_target(target)
expect(ots_state.ots_target).to eq(expected)
end
it 'should set target to 5 when 1 week period and set target to 5' do
check_ots_target(5,5)
end
it 'should set target to 2 when 2 week period and set target to 1' do
campaign.set(to: campaign.from+2.weeks)
check_ots_target(1,2)
end
it 'should set target to 1 when 1 day period and set target to 7' do
campaign.set(to: campaign.from+1.days)
check_ots_target(7,1)
end
end
end
is there a way in RSpec to write it as a single test with 3 parameter sets?