If is not supported, what is the right way to mock an object once before all the examples ?
Here is what I tried to do and failed:
describe '#build_working_hour' do
context "for open status" do
before(:all) do
@schedule = double(MystoreMigration::StoreSchedule, am_start_time: 900, pm_end_time: 2030)
allow(@schedule).to receive(:has_divided_hours?).and_return(false)
allow(@schedule).to receive(:closed?).and_return(false)
@working_hour = store_migrator.build_working_hour(schedule)
end
it 'should init working hour with open status' do
expect(@working_hour.open?).to be_truthy
end
it 'should init working hour with open status times' do
expect(@working_hour.opens).to eq(32_400_000)
expect(@working_hour.closes).to eq(73_800_000)
expect(@working_hour.divided_opens).to be nil
expect(@working_hour.divided_closes).to be nil
end
end
end
What is wrong with the above approach ? I'd like to 1) check a status, 2) the assigned values. Thank you!