Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions language/fixtures/squiggly_heredoc.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module StringSpecs
def self.squiggly_message
<<~HEREDOC
character density, n.:
The number of very weird people in the office.
HEREDOC
end
end
10 changes: 10 additions & 0 deletions language/string_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

require File.expand_path('../../spec_helper', __FILE__)

ruby_version_is "2.3" do
require File.expand_path('../fixtures/squiggly_heredoc', __FILE__)
end

# TODO: rewrite these horrid specs. it "are..." seriously?!

describe "Ruby character strings" do
Expand Down Expand Up @@ -176,6 +180,12 @@
s.should == ' foo bar#{@ip}' + "\n"
end

ruby_version_is "2.3" do
it "allows HEREDOC with <<~'identifier', allowing to indent identifier and content" do

@eregon eregon Oct 19, 2016 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable (s) is not indented in this case 😉 , maybe add a couple spaces before s = ?
Alternatively, this could be a fixture file under language/fixtures to improve readability.

@eregon eregon Oct 19, 2016 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, you meant the heredoc identifier, not the variable.
I think it's worth moving this to a fixture and under a method (say StringSpec.squiggly) to improve readability and make it a more real-world example.
You can then require fixture(__FILE__, "squiggly_heredoc.rb") in this spec example.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

StringSpecs.squiggly_message.should == "character density, n.:\n The number of very weird people in the office.\n"
end
end

it "calls #to_s when the object is not a String" do
obj = mock('to_s')
obj.stub!(:to_s).and_return('42')
Expand Down