summaryrefslogtreecommitdiff
path: root/vendor/bundle/ruby/3.4.0/gems/mercenary-0.4.0/spec/option_spec.rb
diff options
context:
space:
mode:
authorBenjamin Sanders <ben@Benjamins-MacBook-Pro.local>2025-10-11 10:34:24 -0400
committerBenjamin Sanders <ben@Benjamins-MacBook-Pro.local>2025-10-11 10:34:24 -0400
commit5571dc766e2143e39762ff0b47c41d1c2e154f4c (patch)
treef4f124d314a7e76c04484515aa0fd1f2e271a601 /vendor/bundle/ruby/3.4.0/gems/mercenary-0.4.0/spec/option_spec.rb
parent359f3309c97fc894b63e0a295c76ab298504d635 (diff)
Vendor bundled gems for deployment
Diffstat (limited to 'vendor/bundle/ruby/3.4.0/gems/mercenary-0.4.0/spec/option_spec.rb')
-rw-r--r--vendor/bundle/ruby/3.4.0/gems/mercenary-0.4.0/spec/option_spec.rb84
1 files changed, 84 insertions, 0 deletions
diff --git a/vendor/bundle/ruby/3.4.0/gems/mercenary-0.4.0/spec/option_spec.rb b/vendor/bundle/ruby/3.4.0/gems/mercenary-0.4.0/spec/option_spec.rb
new file mode 100644
index 0000000..ce10a62
--- /dev/null
+++ b/vendor/bundle/ruby/3.4.0/gems/mercenary-0.4.0/spec/option_spec.rb
@@ -0,0 +1,84 @@
+# frozen_string_literal: true
+
+require "spec_helper"
+
+describe(Mercenary::Option) do
+ let(:config_key) { "largo" }
+ let(:description) { "This is a description" }
+ let(:switches) { ["-l", "--largo"] }
+ let(:option) { described_class.new(config_key, [switches, description].flatten.reject(&:nil?)) }
+
+ it "knows its config key" do
+ expect(option.config_key).to eql(config_key)
+ end
+
+ it "knows its description" do
+ expect(option.description).to eql(description)
+ end
+
+ it "knows its switches" do
+ expect(option.switches).to eql(switches)
+ end
+
+ it "knows how to present itself" do
+ expect(option.to_s).to eql(" -l, --largo #{description}")
+ end
+
+ it "has an OptionParser representation" do
+ expect(option.for_option_parser).to eql([switches, description].flatten)
+ end
+
+ it "compares itself with other options well" do
+ new_option = described_class.new(config_key, ["-l", "--largo", description])
+ expect(option.eql?(new_option)).to be(true)
+ expect(option.hash.eql?(new_option.hash)).to be(true)
+ end
+
+ it "has a custom #hash" do
+ expect(option.hash.to_s).to match(%r!\d+!)
+ end
+
+ context "with just the long switch" do
+ let(:switches) { ["--largo"] }
+
+ it "adds an empty string in place of the short switch" do
+ expect(option.switches).to eql(["", "--largo"])
+ end
+
+ it "sets its description properly" do
+ expect(option.description).to eql(description)
+ end
+
+ it "knows how to present the switch" do
+ expect(option.formatted_switches).to eql(" --largo ")
+ end
+ end
+
+ context "with just the short switch" do
+ let(:switches) { ["-l"] }
+
+ it "adds an empty string in place of the long switch" do
+ expect(option.switches).to eql(["-l", ""])
+ end
+
+ it "sets its description properly" do
+ expect(option.description).to eql(description)
+ end
+
+ it "knows how to present the switch" do
+ expect(option.formatted_switches).to eql(" -l ")
+ end
+ end
+
+ context "without a description" do
+ let(:description) { nil }
+
+ it "knows there is no description" do
+ expect(option.description).to be(nil)
+ end
+
+ it "knows both inputs are switches" do
+ expect(option.switches).to eql(switches)
+ end
+ end
+end