-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent cucumber yml being read twice #416
Conversation
Nice one @tooky! I don't mind the global variable too much, but leaving it behind does niggle, doesn't it? Other ideas:
|
Well none of them feel great @mattwynne. I wasn't able to output to the output stream, just STDOUT. This just seems ugly. it "only parses cucumber.yml once" do
::ParseCounter = Class.new do
attr_accessor :count
end.new
ParseCounter.count = 0
given_cucumber_yml_defined_as(<<-END
<% ParseCounter.count += 1 %>
default: --format pretty
END
)
options = Options.new(output_stream, error_stream, :default_profile => 'default')
options.parse!(%w(-f progress))
ParseCounter.count.should == 1
Object.send(:remove_const, :ParseCounter)
end I think, I'll reset the $global_variable to whatever it was before the test - which should be nil. it "only parses cucumber.yml once" do
original_parse_count = $parse_count
$parse_count = 0
given_cucumber_yml_defined_as(<<-END
<% $parse_count += 1 %>
default: --format pretty
END
)
options = Options.new(output_stream, error_stream, :default_profile => 'default')
options.parse!(%w(-f progress))
$parse_count.should == 1
$parse_count = original_parse_count
end |
@tooky I think you should reset the variable in ensure block, to have it restored even if some exception has been thrown. |
@os97673 - good point, thanks! |
…l_being_read_twice Conflicts: lib/cucumber/cli/options.rb
…_twice Prevent cucumber yml being read twice closes #217
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This fixes #217.
We were rereading cucumber.yml for every profile we were merging in because we were creating a new
profile_loader
each time we were parsing options.I've used a global variable and erb to test how many times the cucumber.yml is parsed: https://github.com/cucumber/cucumber/compare/prevent_cucumber_yml_being_read_twice#L1R231
Does anyone have a better idea?