Skip to content

Commit

Permalink
replace strip_heredoc with ruby 2.3 squiggly
Browse files Browse the repository at this point in the history
rebased version of zendesk#2031
  • Loading branch information
grosser committed Dec 7, 2017
1 parent ea04563 commit c9ea6c7
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions app/controllers/oauth_test_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def show
# alternatively we could call whatever the oauth controller does internally directly
access_token = oauth_client.auth_code.get_token(params[:code], redirect_uri: token_url).token

render plain: <<-TEXT.strip_heredoc
render plain: <<~TEXT
Your access token is: #{access_token}
You can use this to make requests:
Expand Down Expand Up @@ -43,7 +43,7 @@ def oauth_client

def ensure_application
return if application
message = <<-TEXT.strip_heredoc
message = <<~TEXT
Add an OAuth application at
#{new_oauth_application_url}
Expand Down
2 changes: 1 addition & 1 deletion app/mailers/project_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def deleted_email(user, project)

def build_mail(user, project, address, action)
subject = "Samson Project #{action.titleize}: #{project.name}"
body = <<-TEXT.strip_heredoc
body = <<~TEXT
"#{user.name_and_email} just #{action} project #{project.name}
#{project.url}
#{project.repository_homepage}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
end
tarfile.close
builder.send(:untar, tarfile.path)
output.string.must_equal <<-TEXT.strip_heredoc
output.string.must_equal <<~TEXT
About to untar: test.tar
> foo
> bar/bar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

result = FlowdockNotificationRenderer.render(deploy)

result.must_equal <<-RESULT.strip_heredoc.chomp
result.must_equal <<~RESULT.chomp
<p>2 commits by author1 and author2.</p>
<p><strong>Files changed</strong></p>
Expand Down
18 changes: 9 additions & 9 deletions plugins/jenkins/test/models/samson/jenkins_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def stub_add_changeset

describe "with auto-config flag" do
let(:jenkins_xml_new_job) do
<<-XML.strip_heredoc
<<~XML
<?xml version="1.0" encoding="UTF-8"?>
<project>
<description>This is a test line in Description.</description>
Expand Down Expand Up @@ -291,7 +291,7 @@ def stub_add_changeset
end

let(:jenkins_xml_configured) do
<<-XML.strip_heredoc
<<~XML
<?xml version="1.0" encoding="UTF-8"?>
<project>
<description>This is a test line in Description.
Expand Down Expand Up @@ -357,7 +357,7 @@ def stub_add_changeset
end

let(:jenkins_xml_with_build_params_without_desc) do
<<-XML.strip_heredoc
<<~XML
<?xml version="1.0" encoding="UTF-8"?>
<project>
<description>This is a test line in Description.</description>
Expand Down Expand Up @@ -418,7 +418,7 @@ def stub_add_changeset
end

let(:jenkins_xml_with_desc_without_params) do
<<-XML.strip_heredoc
<<~XML
<?xml version='1.0' encoding='UTF-8'?>
<project>
<description>This is a test line in Description.
Expand Down Expand Up @@ -454,7 +454,7 @@ def stub_add_changeset
end

let(:jenkins_xml_with_string_build_params_other_then_samson) do
<<-XML.strip_heredoc
<<~XML
<?xml version="1.0" encoding="UTF-8"?>
<project>
<actions/>
Expand Down Expand Up @@ -500,7 +500,7 @@ def stub_add_changeset
end

let(:jenkins_xml_configured_with_other_params) do
<<-XML.strip_heredoc
<<~XML
<?xml version="1.0" encoding="UTF-8"?>
<project>
<actions/>
Expand Down Expand Up @@ -581,7 +581,7 @@ def stub_add_changeset
end

let(:jenkins_xml_with_some_samson_build_params) do
<<-XML.strip_heredoc
<<~XML
<?xml version='1.0' encoding='UTF-8'?>
<project>
<description>This is a test line in Description.
Expand Down Expand Up @@ -646,7 +646,7 @@ def stub_add_changeset
end

let(:jenkins_xml_configured_with_some_samson_build_params) do
<<-XML.strip_heredoc
<<~XML
<?xml version="1.0" encoding="UTF-8"?>
<project>
<description>This is a test line in Description.
Expand Down Expand Up @@ -727,7 +727,7 @@ def stub_add_changeset
end

let(:jenkins_xml_configured_with_updated_desc) do
<<-XML.strip_heredoc
<<~XML
<?xml version="1.0" encoding="UTF-8"?>
<project>
<description>This is a test line in Description.
Expand Down
2 changes: 1 addition & 1 deletion plugins/kubernetes/test/models/kubernetes/util_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
end

it 'handles a YAML file with multiple entries' do
yaml_input = <<-YAML.strip_heredoc
yaml_input = <<~YAML
---
name: foo
value: 999
Expand Down
2 changes: 1 addition & 1 deletion plugins/samson_ledger/lib/samson_ledger/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def pull_requests(changeset)
"<a href='#{user.url}'><img src='#{user.avatar_url}' width=20 height=20 /></a>"
end

<<-HTML.strip_heredoc.tr("\n", ' ')
<<~HTML.tr("\n", ' ')
<li>
#{github_users.join}
<strong>##{pull_request.number}</strong>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def render

it "renders a nicely formatted pending notification" do
deploy.job.status = "pending"
render.must_equal <<-TEXT.strip_heredoc.chomp
render.must_equal <<~TEXT.chomp
:stopwatch: *[Foo] Super Admin is about to deploy staging to Staging* (<http://sams.on/url|view the deploy>)
_<https://github.com/url|3 commits> and 2 pull requests by author1 and author2._
Expand All @@ -132,7 +132,7 @@ def render
end

it "does not render pull requests for finished deploys" do
render.must_equal <<-TEXT.strip_heredoc.chomp
render.must_equal <<~TEXT.chomp
:white_check_mark: *[Foo] Super Admin deployed staging to Staging* (<http://sams.on/url|view the deploy>)
_<https://github.com/url|3 commits> and 2 pull requests by author1 and author2._
TEXT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

result = ZendeskNotificationRenderer.render(deploy, ticket_id)

result.must_equal <<-RESULT.strip_heredoc.chomp
result.must_equal <<~RESULT.chomp
A fix to Project for this issue has been deployed to Production. Deploy details: [v2.14] (http://example.org/deploys/20)
**Related Commits:**
Expand Down
2 changes: 1 addition & 1 deletion test/controllers/integrations/base_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class BaseTestController < Integrations::BaseController
post :create, params: {test_route: true, token: token, foo: "bar"}
assert_response :success
result = WebhookRecorder.read(project)
log = <<-LOG.strip_heredoc
log = <<~LOG
INFO: Branch master is release branch: true
INFO: Deploying to 0 stages
LOG
Expand Down
18 changes: 9 additions & 9 deletions test/models/changeset/pull_request_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

describe Changeset::PullRequest do
def add_risks
body.replace(<<-BODY.dup.strip_heredoc)
# Risks
- Explosions
body.replace(<<~BODY.dup)
# Risks
- Explosions
BODY
end

def no_risks
body.replace(<<-BODY.dup.strip_heredoc)
Not that risky ...
body.replace(<<~BODY.dup)
Not that risky ...
BODY
end

Expand Down Expand Up @@ -386,23 +386,23 @@ def no_risks
end

it "does not find - None" do
body.replace(<<-BODY.dup.strip_heredoc)
body.replace(<<~BODY.dup)
# Risks
- None
BODY
pr.risks.must_be_nil
end

it "does not find None" do
body.replace(<<-BODY.dup.strip_heredoc)
body.replace(<<~BODY.dup)
# Risks
None
BODY
pr.risks.must_be_nil
end

it "finds risks with underline style markdown headers" do
body.replace(<<-BODY.dup.strip_heredoc)
body.replace(<<~BODY.dup)
Risks
=====
- Snakes
Expand All @@ -411,7 +411,7 @@ def no_risks
end

it "finds risks with closing hashes in atx style markdown headers" do
body.replace(<<-BODY.dup.strip_heredoc)
body.replace(<<~BODY.dup)
## Risks ##
- Planes
BODY
Expand Down

0 comments on commit c9ea6c7

Please sign in to comment.