-
Notifications
You must be signed in to change notification settings - Fork 106
parsers/base: make sure content always ends with an empty line #130
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
base: main
Are you sure you want to change the base?
Changes from all 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 |
|---|---|---|
|
|
@@ -71,16 +71,21 @@ | |
| end | ||
|
|
||
| describe "#content_for_scanner" do | ||
| it "returns the part body with line feed normalized" do | ||
| instance = described_class.new(Whois::Record::Part.new(:body => "This is\r\nthe response.\r\n", :host => "whois.example.test")) | ||
| expect(instance.send(:content_for_scanner)).to eq("This is\nthe response.\n") | ||
| end | ||
|
|
||
| it "returns the part body with line feed normalized" do | ||
| instance = described_class.new(Whois::Record::Part.new(:body => "This is\r\nthe response.", :host => "whois.example.test")) | ||
| expect(instance.send(:content_for_scanner)).to eq("This is\nthe response.") | ||
| expect(instance.send(:content_for_scanner)).to eq("This is\nthe response.\n") | ||
|
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. So I understand that it's better for the scanner to ingest whole lines (including linebreak) instead of just the string on it, thus rendering the line empty but still present, right?
Author
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. Yes |
||
| end | ||
|
|
||
| it "caches the result" do | ||
| instance = described_class.new(Whois::Record::Part.new(:body => "This is\r\nthe response.", :host => "whois.example.test")) | ||
| expect(instance.instance_eval { @content_for_scanner }).to be_nil | ||
| instance.send(:content_for_scanner) | ||
| expect(instance.instance_eval { @content_for_scanner }).to eq("This is\nthe response.") | ||
| expect(instance.instance_eval { @content_for_scanner }).to eq("This is\nthe response.\n") | ||
| end | ||
| end | ||
|
|
||
|
|
||
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.
As a matter of readability, it's not immidiately clear what we're doing here and why we're doing it.
Uh oh!
There was an error while loading. Please reload this page.
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.
What change would you suggest ?
Would that be acceptable ?