tests/option_parser.fy in fancy-0.8.0 vs tests/option_parser.fy in fancy-0.9.0

- old
+ new

@@ -1,9 +1,9 @@ require: "lib/option_parser" FancySpec describe: OptionParser with: { - it: "parses an option with no argument" when: { + it: "parses an option with no argument" with: 'parse: when: { parsed_option? = false o = OptionParser new: @{ with: "--test" doc: "Do something" do: { parsed_option? = true @@ -13,11 +13,11 @@ parsed_option? is: false o parse: ["foo", "bar", "--test", "baz"] parsed_option? is: true } - it: "parses no option if none are passed" when: { + it: "parses no option if none are passed" with: 'parse: when: { parsed_option? = false o = OptionParser new: @{ with: "--foo [arg]" doc: "bla" do: |arg| { parsed_option? = true } @@ -29,11 +29,11 @@ parsed_option? is: false o parse: ["hello", "foo", "bar", "no expected options given!"] parsed_option? is: false } - it: "parses an option with an argument" when: { + it: "parses an option with an argument" with: 'parse: when: { parsed_option? = false passed_args = [] o = OptionParser new: @{ with: "--my-val [arg]" doc: "gimme an argument!" do: |arg| { @@ -74,7 +74,16 @@ with: "--my-flag" doc: "" do: {} } args = [1, "-value", "foo", "--my-flag", 2] o parse: args args is: [1, 2] + } + + it: "parses options as a hash" with: 'parse_hash: when: { + o = OptionParser new: @{ + with: "--some-option [some-value]" doc: "foo" + } + + hash = o parse_hash: ["foo", "bar", "--some-option", "hello world!", "baz"] + hash is: <["--some-option" => "hello world!"]> } }