diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2016-04-18 17:25:36 -0500 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2016-04-18 17:25:36 -0500 |
commit | 52a1f7ffd1fb8cabaed7990b0b9cf92f351bebfb (patch) | |
tree | 4634981ea1ea42fc8333ede669d16bb6159bb791 | |
parent | 795f89170401cf604d70aa6e88bcf7a56d9fad10 (diff) | |
download | bundler-52a1f7ffd1fb8cabaed7990b0b9cf92f351bebfb.tar.gz |
Add lockfile parser unit tests
-rw-r--r-- | spec/bundler/lockfile_parser_spec.rb | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/spec/bundler/lockfile_parser_spec.rb b/spec/bundler/lockfile_parser_spec.rb new file mode 100644 index 00000000..44772c8b --- /dev/null +++ b/spec/bundler/lockfile_parser_spec.rb @@ -0,0 +1,94 @@ +# frozen_string_literal: true +require "spec_helper" +require "bundler/lockfile_parser" + +describe Bundler::LockfileParser do + let(:lockfile_contents) { strip_whitespace(<<-L) } + GIT + remote: https://github.com/alloy/peiji-san.git + revision: eca485d8dc95f12aaec1a434b49d295c7e91844b + specs: + peiji-san (1.2.0) + + GEM + remote: https://rubygems.org/ + specs: + rake (10.3.2) + + PLATFORMS + ruby + + DEPENDENCIES + peiji-san! + rake + + RUBY VERSION + ruby 2.1.3p242 + + BUNDLED WITH + 1.12.0.rc.2 + L + + describe ".attributes_in_lockfile" do + it "returns the attributes" do + attributes = described_class.attributes_in_lockfile(lockfile_contents) + expect(attributes).to contain_exactly( + "BUNDLED WITH", "DEPENDENCIES", "GEM", "GIT", "PLATFORMS", "RUBY VERSION" + ) + end + end + + describe ".unknown_attributes_in_lockfile" do + let(:lockfile_contents) { strip_whitespace(<<-L) } + UNKNOWN ATTR + + UNKNOWN ATTR 2 + random contents + L + + it "returns the unknown attributes" do + attributes = described_class.unknown_attributes_in_lockfile(lockfile_contents) + expect(attributes).to contain_exactly("UNKNOWN ATTR", "UNKNOWN ATTR 2") + end + end + + describe ".attributes_to_ignore" do + subject { described_class.attributes_to_ignore(base_version) } + + context "with a nil base version" do + let(:base_version) { nil } + + it "returns the same as > 1.0" do + expect(subject).to contain_exactly( + described_class::BUNDLED, described_class::RUBY + ) + end + end + + context "with a prerelease base version" do + let(:base_version) { Gem::Version.create("1.11.0.rc.1") } + + it "returns the same as for the release version" do + expect(subject).to contain_exactly( + described_class::RUBY + ) + end + end + + context "with a current version" do + let(:base_version) { Gem::Version.create(Bundler::VERSION) } + + it "returns an empty array" do + expect(subject).to eq([]) + end + end + + context "with a future version" do + let(:base_version) { Gem::Version.create("5.5.5") } + + it "returns an empty array" do + expect(subject).to eq([]) + end + end + end +end |