summaryrefslogtreecommitdiff
path: root/spec/bundler/bundler
diff options
context:
space:
mode:
authorlolwut <lol@wut.com>2019-08-16 09:12:40 -0400
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2019-08-21 08:10:49 +0900
commita230e65e8b08003c6b346e6ef177bc8655de55b7 (patch)
tree3ef0af17cc402be57212b2adc98ddc918c40330e /spec/bundler/bundler
parent1c2774526eef733ea95e5dda576c95169341ba7e (diff)
[bundler/bundler] Freeze time to avoid failures at midnight
Specify just a string set @built_at as nil before testing https://github.com/bundler/bundler/commit/578ec96c9c
Diffstat (limited to 'spec/bundler/bundler')
-rw-r--r--spec/bundler/bundler/build_metadata_spec.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/spec/bundler/bundler/build_metadata_spec.rb b/spec/bundler/bundler/build_metadata_spec.rb
index a28e25511a..afa2d1716f 100644
--- a/spec/bundler/bundler/build_metadata_spec.rb
+++ b/spec/bundler/bundler/build_metadata_spec.rb
@@ -4,9 +4,14 @@ require "bundler"
require "bundler/build_metadata"
RSpec.describe Bundler::BuildMetadata do
+ before do
+ allow(Time).to receive(:now).and_return(Time.at(0))
+ Bundler::BuildMetadata.instance_variable_set(:@built_at, nil)
+ end
+
describe "#built_at" do
it "returns %Y-%m-%d formatted time" do
- expect(Bundler::BuildMetadata.built_at).to eq Time.now.strftime("%Y-%m-%d")
+ expect(Bundler::BuildMetadata.built_at).to eq "1970-01-01"
end
end
@@ -36,7 +41,7 @@ RSpec.describe Bundler::BuildMetadata do
subject { Bundler::BuildMetadata.to_h }
it "returns a hash includes Built At, Git SHA and Released Version" do
- expect(subject["Built At"]).to eq Time.now.strftime("%Y-%m-%d")
+ expect(subject["Built At"]).to eq "1970-01-01"
expect(subject["Git SHA"]).to be_instance_of(String)
expect(subject["Released Version"]).to be_falsey
end