diff options
author | tommy <kazu9su@gmail.com> | 2019-08-13 09:53:33 -0400 |
---|---|---|
committer | tommy <kazu9su@gmail.com> | 2019-08-13 09:53:33 -0400 |
commit | c6458b2727e5ad7e98c6be7c2634f16ce7cfb677 (patch) | |
tree | 00107e00188bbd894213b71be3e97e52c2ed71ad | |
parent | 10b2118130fc3a7c095697446785267550a4a136 (diff) | |
download | bundler-c6458b2727e5ad7e98c6be7c2634f16ce7cfb677.tar.gz |
Add initial Bundler::BuildMetadata Spec
-rw-r--r-- | spec/bundler/bundler/build_metadata_spec.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/bundler/bundler/build_metadata_spec.rb b/spec/bundler/bundler/build_metadata_spec.rb new file mode 100644 index 0000000000..a28e25511a --- /dev/null +++ b/spec/bundler/bundler/build_metadata_spec.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +require "bundler" +require "bundler/build_metadata" + +RSpec.describe Bundler::BuildMetadata do + 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") + end + end + + describe "#release?" do + it "returns false as default" do + expect(Bundler::BuildMetadata.release?).to be_falsey + end + end + + describe "#git_commit_sha" do + context "if instance valuable is defined" do + before do + Bundler::BuildMetadata.instance_variable_set(:@git_commit_sha, "foo") + end + + after do + Bundler::BuildMetadata.remove_instance_variable(:@git_commit_sha) + end + + it "returns set value" do + expect(Bundler::BuildMetadata.git_commit_sha).to eq "foo" + end + end + end + + describe "#to_h" 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["Git SHA"]).to be_instance_of(String) + expect(subject["Released Version"]).to be_falsey + end + end +end |