spec/cucumber/cli/options_spec.rb in cucumber-2.0.0 vs spec/cucumber/cli/options_spec.rb in cucumber-2.0.1

- old
+ new

@@ -57,20 +57,42 @@ context '--i18n' do context "with LANG specified as 'help'" do include RSpec::WorkInProgress - it "lists all known langues" do + it "lists all known languages" do when_parsing '--i18n help' do expect(Kernel).to receive(:exit) end end it "exits the program" do when_parsing('--i18n help') { expect(Kernel).to receive(:exit) } end end + + context "with invalid LANG" do + include RSpec::WorkInProgress + + it "exits" do + when_parsing '--i18n foo' do + expect(Kernel).to receive(:exit) + end + end + + it "says the language was invalid" do + after_parsing '--i18n foo' do + expect(@output_stream.string).to include("Invalid language 'foo'. Available languages are:") + end + end + + it "displays the language table" do + after_parsing '--i18n foo' do + expect(@output_stream.string).to include(Gherkin::I18n.language_table); + end + end + end end context '-f FORMAT or --format FORMAT' do it "defaults the output for the formatter to the output stream (STDOUT)" do after_parsing('-f pretty') { expect(options[:formats]).to eq [['pretty', output_stream]] } @@ -86,10 +108,39 @@ expect(options[:formats]).to eq [['profile', 'file.txt'], ['pretty', 'file2.txt']] end end end + context 'handling multiple formatters' do + it "catches multiple command line formatters using the same stream" do + expect{ options.parse!(prepare_args('-f pretty -f progress')) }.to raise_error("All but one formatter must use --out, only one can print to each stream (or STDOUT)") + end + + it "catches multiple profile formatters using the same stream" do + given_cucumber_yml_defined_as({'default' => '-f progress -f pretty'}) + options = Options.new(output_stream, error_stream, :default_profile => 'default') + + expect{ options.parse!(%w{}) }.to raise_error("All but one formatter must use --out, only one can print to each stream (or STDOUT)") + end + + it "profiles does not affect the catching of multiple command line formatters using the same stream" do + given_cucumber_yml_defined_as({'default' => '-q'}) + options = Options.new(output_stream, error_stream, :default_profile => 'default') + + expect{ options.parse!(%w{-f progress -f pretty}) }.to raise_error("All but one formatter must use --out, only one can print to each stream (or STDOUT)") + end + + it "merges profile formatters and command line formatters" do + given_cucumber_yml_defined_as({'default' => '-f junit -o result.xml'}) + options = Options.new(output_stream, error_stream, :default_profile => 'default') + + options.parse!(%w{-f pretty}) + + expect(options[:formats]).to eq [['pretty', output_stream], ["junit", "result.xml"]] + end + end + context '-t TAGS --tags TAGS' do it "designates tags prefixed with ~ as tags to be excluded" do after_parsing('--tags ~@foo,@bar') { expect(options[:tag_expressions]).to eq ['~@foo,@bar'] } end @@ -236,9 +287,17 @@ given_cucumber_yml_defined_as('foo' => '-q') options.parse!(%w[-p foo]) expect(options[:snippets]).to be false expect(options[:source]).to be false + expect(options[:duration]).to be false + end + + it "uses --no-duration when defined in the profile" do + given_cucumber_yml_defined_as('foo' => '--no-duration') + options.parse!(%w[-p foo]) + + expect(options[:duration]).to be false end end context '-P or --no-profile' do it "disables profiles" do