File: slop_test.rb

package info (click to toggle)
ruby-slop 4.10.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 204 kB
  • sloc: ruby: 1,163; makefile: 6
file content (27 lines) | stat: -rw-r--r-- 627 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
require "test_helper"

describe Slop do
  describe ".parse" do
    it "parses a list of arguments" do
      result = Slop.parse(%w[--name Lee]) do |o|
        o.string "--name"
      end

      assert_equal "Lee", result[:name]
    end
  end

  describe ".option_defined?" do
    it "handles bad constant names" do
      assert_equal false, Slop.option_defined?("Foo?Bar")
    end

    it "returns false if the option is not defined" do
      assert_equal false, Slop.option_defined?("FooBar")
    end

    it "returns true if the option is defined" do
      assert_equal true, Slop.option_defined?("String")
    end
  end
end