Sha256: 7a66dcba5867fc33d0caa3fe76539fc54a190ac9b80fd070f75fdceb0cf3bd43

Contents?: true

Size: 1.67 KB

Versions: 19

Compression:

Stored size: 1.67 KB

Contents

require 'spec_helper'
require 'yaml'

module Cucumber
  module Cli
    describe ProfileLoader do
      def given_cucumber_yml_defined_as(hash_or_string)
        allow(Dir).to receive(:glob).with('{,.config/,config/}cucumber{.yml,.yaml}') { ['cucumber.yml'] }
        allow(File).to receive(:exist?) { true }

        cucumber_yml = hash_or_string.is_a?(Hash) ? hash_or_string.to_yaml : hash_or_string

        allow(IO).to receive(:read).with('cucumber.yml') { cucumber_yml }
      end

      def loader
        ProfileLoader.new
      end

      it "treats backslashes as literals in rerun.txt when on Windows (JRuby or MRI)" do
        given_cucumber_yml_defined_as({'default' => '--format "pretty" features\sync_imap_mailbox.feature:16:22'})
        if(Cucumber::WINDOWS)
          expect(loader.args_from('default')).to eq ['--format','pretty','features\sync_imap_mailbox.feature:16:22']
        else
          expect(loader.args_from('default')).to eq ['--format','pretty','featuressync_imap_mailbox.feature:16:22']
        end
      end

      it "treats forward slashes as literals" do
        given_cucumber_yml_defined_as({'default' => '--format "ugly" features/sync_imap_mailbox.feature:16:22'})

        expect(loader.args_from('default')).to eq ['--format','ugly','features/sync_imap_mailbox.feature:16:22']
      end

      it "treats percent sign as ERB code block after YAML directive" do
        yml = <<-HERE
---
% x = '--format "pretty" features/sync_imap_mailbox.feature:16:22'
default: <%= x %>
        HERE
        given_cucumber_yml_defined_as yml
        expect(loader.args_from('default')).to eq ['--format','pretty','features/sync_imap_mailbox.feature:16:22']
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
cucumber-2.99.0 spec/cucumber/cli/profile_loader_spec.rb
mobiusloop-0.1.5 spec/cucumber/cli/profile_loader_spec.rb
cucumber-2.4.0 spec/cucumber/cli/profile_loader_spec.rb
mobiusloop-0.1.3 spec/cucumber/cli/profile_loader_spec.rb
mobiusloop-0.1.2 spec/cucumber/cli/profile_loader_spec.rb
cucumber-2.3.3 spec/cucumber/cli/profile_loader_spec.rb
cucumber-2.3.2 spec/cucumber/cli/profile_loader_spec.rb
cucumber-2.3.1 spec/cucumber/cli/profile_loader_spec.rb
cucumber-2.3.0 spec/cucumber/cli/profile_loader_spec.rb
cucumber-2.2.0 spec/cucumber/cli/profile_loader_spec.rb
cucumber-2.1.0 spec/cucumber/cli/profile_loader_spec.rb
cucumber-2.0.2 spec/cucumber/cli/profile_loader_spec.rb
cucumber-2.0.1 spec/cucumber/cli/profile_loader_spec.rb
cucumber-2.0.0 spec/cucumber/cli/profile_loader_spec.rb
cucumber-2.0.0.rc.5 spec/cucumber/cli/profile_loader_spec.rb
cucumber-2.0.0.rc.4 spec/cucumber/cli/profile_loader_spec.rb
cucumber-2.0.0.rc.3 spec/cucumber/cli/profile_loader_spec.rb
cucumber-2.0.0.rc.2 spec/cucumber/cli/profile_loader_spec.rb
cucumber-2.0.0.rc.1 spec/cucumber/cli/profile_loader_spec.rb