From ccfdb22c425cc5f61846cd476de698a5ea016b36 Mon Sep 17 00:00:00 2001 From: Tyler Thrailkill Date: Mon, 6 Oct 2014 14:01:50 -0600 Subject: [PATCH 1/2] Allow cucumber.yml to parse % erb code lines Enable the flag to parse % lines as code lines along with <% --- lib/cucumber/cli/profile_loader.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cucumber/cli/profile_loader.rb b/lib/cucumber/cli/profile_loader.rb index 5682cad04c..a84827a40d 100644 --- a/lib/cucumber/cli/profile_loader.rb +++ b/lib/cucumber/cli/profile_loader.rb @@ -60,7 +60,7 @@ def cucumber_yml require 'erb' require 'yaml' begin - @cucumber_erb = ERB.new(IO.read(cucumber_file)).result(binding) + @cucumber_erb = ERB.new(IO.read(cucumber_file), nil, '%').result(binding) rescue Exception => e raise(YmlLoadError,"cucumber.yml was found, but could not be parsed with ERB. Please refer to cucumber's documentation on correct profile usage.\n#{$!.inspect}") end From a67c796d8458998c6b26879a0c924807afd7fef5 Mon Sep 17 00:00:00 2001 From: Tyler Thrailkill Date: Fri, 10 Oct 2014 14:16:36 -0600 Subject: [PATCH 2/2] Add test for % directive in cucumber.yml file --- spec/cucumber/cli/profile_loader_spec.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spec/cucumber/cli/profile_loader_spec.rb b/spec/cucumber/cli/profile_loader_spec.rb index 54b5543fef..713a9d35da 100644 --- a/spec/cucumber/cli/profile_loader_spec.rb +++ b/spec/cucumber/cli/profile_loader_spec.rb @@ -31,6 +31,16 @@ def loader 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