summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2017-04-08 18:23:02 +0000
committerbrian m. carlson <sandals@crustytoothpaste.net>2017-04-08 18:23:02 +0000
commit0f08dde705ea14410f19116f80212fc95e53f352 (patch)
treed57d715a1eba446417a415efc320c05ba1d6dff2
parent24d77bcd87f1c5074b5a478fc8ed131d3c20cb20 (diff)
spec: simplify mocking
We don't need to create an actual double here; it's sufficient to simply mock the Time.now method alone. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
-rw-r--r--spec/comic_spec.rb5
1 files changed, 1 insertions, 4 deletions
diff --git a/spec/comic_spec.rb b/spec/comic_spec.rb
index 6e354c0..75bba2d 100644
--- a/spec/comic_spec.rb
+++ b/spec/comic_spec.rb
@@ -34,15 +34,12 @@ describe Comics::Comic do
it 'handles last update times properly' do
early = Time.at(1_491_264_000).gmtime
late = Time.at(1_491_271_200).gmtime
- parse = Time.method(:parse)
- time = class_double('Time').as_stubbed_const
[
[early, '2017-04-03T01:00:00'],
# If the time hasn't happened yet, then use the previous date.
[late, '2017-04-04T01:00:00'],
].each do |(stamp, expected)|
- allow(time).to receive(:now) { stamp }
- allow(time).to receive(:parse) { |*args| parse.call(*args) }
+ allow(Time).to receive(:now) { stamp }
c = config.comic('dilbert')
entry = c.first
expect(entry.date('%FT%T')).to eq expected