summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2017-04-09 17:55:07 +0000
committerbrian m. carlson <sandals@crustytoothpaste.net>2017-04-09 17:55:07 +0000
commit60acae460444cba42a7c4ac92614c9173705868e (patch)
tree417e4ef6179d116a9ec8e4588b7bfbfda4efec5b
parent0f08dde705ea14410f19116f80212fc95e53f352 (diff)
spec: simplify further
Use the main example configuration file as a test fixture and write timestamps in a way that is more readable and makes it more obvious what we want to test. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
-rw-r--r--spec/comic_spec.rb33
1 files changed, 5 insertions, 28 deletions
diff --git a/spec/comic_spec.rb b/spec/comic_spec.rb
index 75bba2d..759fdee 100644
--- a/spec/comic_spec.rb
+++ b/spec/comic_spec.rb
@@ -4,40 +4,17 @@ require 'comics/data'
require 'stringio'
describe Comics::Comic do
+ let(:main_dir) { File.expand_path(File.join(File.dirname(__FILE__), '..')) }
let(:config) do
- Comics::Configuration.new(StringIO.new(<<-EOM, 'r'))
- {
- "comics":{
- "dilbert":{
- "name":"Dilbert",
- "comics":{
- "daily":{
- "website": "http://www.dilbert.com/strips/comic/",
- "link": "http://www.dilbert.com/strips/comic/%F/",
- "type":"link",
- "frequency":"daily",
- "time":"01:00"
- }
- }
- }
- },
- "config": {
- "id":"https://example.org/",
- "css":"",
- "default":{
- }
- }
- }
- EOM
+ Comics::Configuration.new(File.new(File.join(main_dir,
+ %w[doc/example/config.json])))
end
it 'handles last update times properly' do
- early = Time.at(1_491_264_000).gmtime
- late = Time.at(1_491_271_200).gmtime
[
- [early, '2017-04-03T01:00:00'],
+ [Time.new(2017, 4, 4, 11, 0, 0, 0), '2017-04-03T12:00:00'],
# If the time hasn't happened yet, then use the previous date.
- [late, '2017-04-04T01:00:00'],
+ [Time.new(2017, 4, 4, 13, 0, 0, 0), '2017-04-04T12:00:00'],
].each do |(stamp, expected)|
allow(Time).to receive(:now) { stamp }
c = config.comic('dilbert')