Skip to content

Commit

Permalink
refactor(test-mailer): replace active_template lets with method
Browse files Browse the repository at this point in the history
  • Loading branch information
difernandez committed Jun 3, 2019
1 parent 7a90a5f commit 9eaabe9
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions spec/dummy/spec/mailers/test_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -543,16 +543,12 @@ def expect_sg_api_get_template_request(status_code, result = nil)
end

context "with succesful response" do
let(:active_template) {
"<h1>Active version</h1>"\
"<span>This should be replaced: %key%</span>"\
"<span>This should not be replaced: %key2%</span>"
}
let(:active_template_with_substitutions) {
def active_template(sub = "%key%")
"<h1>Active version</h1>"\
"<span>This should be replaced: #{sub}</span>"\
"<span>This should not be replaced: %key2%</span>"
}
end

let(:response) { {
versions: [
{
Expand All @@ -572,10 +568,10 @@ def expect_sg_api_get_template_request(status_code, result = nil)
end

it "gets templates form sendgrid api, applies substitutions to active one and "\
"uses LetterOpener to open deliver it" do
"uses LetterOpener to deliver it" do
expect_valid_sg_api_get_template_request(response)
expect(lo).to have_received(:deliver!) do |arg|
expect(arg.html_part.to_s).to include(active_template_with_substitutions)
expect(arg.html_part.to_s).to include(active_template(sub))
end
end
end
Expand Down

0 comments on commit 9eaabe9

Please sign in to comment.