describe Clock do - context 'new(10, 20, 00)' do - let(:clock) { Clock.new(10, 20, 0) } + let(:clock_10_20) { Clock.new(10, 20, 0) } - specify { expect(clock.hour).to eq 10 } - specify { expect(clock.min).to eq 20 } - specify { expect(clock.sec).to eq 0 } + context 'new(10, 20, 00)' do + specify { expect(clock_10_20.hour).to eq 10 } + specify { expect(clock_10_20.min).to eq 20 } + specify { expect(clock_10_20.sec).to eq 0 } end context 'new(12, 30, 00)' do @@ -24,17 +24,20 @@ describe Clock do end describe '#to_time' do - let(:clock) { Clock.new(10, 20, 0) } context '(Date.today)' do - let(:time) { clock.to_time(Date.new(2016, 6, 22)) } + let(:time) { clock_10_20.to_time(Date.new(2016, 6, 22)) } specify { expect(time.iso8601).to eq '2016-06-22T10:20:00+09:00' } end context '(2016-08-01)' do - let(:time) { clock.to_time(Date.new(2016, 8, 1)) } + let(:time) { clock_10_20.to_time(Date.new(2016, 8, 1)) } specify { expect(time.iso8601).to eq '2016-08-01T10:20:00+09:00' } end end ͷɺલʹRefactoring: