Skip to content

Commit

Permalink
Add tests for define option handling with and without equal sign
Browse files Browse the repository at this point in the history
  • Loading branch information
ydah committed Feb 5, 2025
1 parent 7e064de commit 5dfb6a3
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions spec/lrama/option_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,22 @@
end

context "when define option is passed" do
it "returns hash of define options" do
option_parser = Lrama::OptionParser.new
option_parser.send(:parse, ["--define=YYDEBUG=1", fixture_path("command/basic.y")])
options = option_parser.instance_variable_get(:@options)
expect(options.define).to eq({'YYDEBUG' => "1"})
context "when value includes equal sign" do
it "returns hash of define options" do
option_parser = Lrama::OptionParser.new
option_parser.send(:parse, ["--define=foo=1", fixture_path("command/basic.y")])
options = option_parser.instance_variable_get(:@options)
expect(options.define).to eq({'foo' => "1"})
end
end

context "when value doesn't include equal sign" do
it "returns hash of define options" do
option_parser = Lrama::OptionParser.new
option_parser.send(:parse, ["--define=foo", fixture_path("command/basic.y")])
options = option_parser.instance_variable_get(:@options)
expect(options.define).to eq({'foo' => nil})
end
end
end
end
Expand Down

0 comments on commit 5dfb6a3

Please sign in to comment.