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
Adding trim option to ERB, closes #840 #846
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -378,6 +378,18 @@ | |
expect(parse_options[:formatters]).to eq([['local']]) | ||
end | ||
|
||
it "parses options file correctly if erb code has trimming options" do | ||
File.open("./.rspec", "w") do |f| | ||
f << "<% if 1 == 1 -%>\n" | ||
f << "--format local\n" | ||
f << "<%- end %>\n" | ||
end | ||
|
||
expect do | ||
expect(parse_options[:formatters]).to eq([['local']]) | ||
end.to_not raise_error(SyntaxError) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Generally, it's best not to pass an error class to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I narrowed down to SyntaxError because if trim option is not present, SyntaxError is raised. It is an explicite sign if actual code cannot parse the However, this test code is tests trim option existence, not the quality of the actual file parsing code. If another error is raised, it should be covered by another test, not by this. But if you still want, I can remove the concrete error class. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
expect do
expect(parse_options[:formatters]).to eq([['global']])
end.to_not raise_error(SyntaxError) The inner expectation fails and raises a I think my preference is to remove the outer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, but... my problem is future maintenance. As ERB is simply What about if i split this into two example? Still unacceptable? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hron84 the real thing you're expecting though is no error whatsoever, not, specifically, no syntax error. Therefore if we have no to_not raise_error expectation, the spec will fail if any error is given. This helps us catch a lot more cases and actually makes the spec more resilient to future breakage (not less!). I'm personally in favour of completely removing the block like @myronmarston said. |
||
end | ||
|
||
context "with custom options file" do | ||
it "ignores project and global options files" do | ||
File.open("./.rspec", "w") {|f| f << "--format project"} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if 1 == 1
seems like a convulated way to have anif true
conditional...any reason not to just useif true
? That more clearly states the intention, I think.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I dunno why not used
true
. Fixed.