Skip to content
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

Flaky Spec Try 2: Article Decorator properly handles Names #6048

Merged
merged 2 commits into from
Feb 12, 2020

Conversation

mstruve
Copy link
Contributor

@mstruve mstruve commented Feb 12, 2020

What type of PR is this? (check all applicable)

  • Bug Fix

Description

In a previous PR(#6029) I attempted to fix this flaky spec by removing any periods that might be in the user name figuring if the name is "Sam Jr." then the final period would be removed and we would be good. HOWEVER that doesnt work for a name "Mr. Sam Jr." bc then all of the periods are removed. This updates the spec to use the same end_with logic that the method in the decorator uses so it should be super solid now.

Related Tickets & Documents

#4884

Added tests?

  • no, because they aren't needed

Added to documentation?

  • no documentation needed

alt_text

atsmith813
atsmith813 previously approved these changes Feb 12, 2020
Copy link
Contributor

@atsmith813 atsmith813 left a comment

Choose a reason for hiding this comment

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

Left a suggestion for consideration around style, but LGTM 💯

@@ -57,7 +57,12 @@ def create_article(*args)
it "creates proper description when it is not present and body is not present and long, and tags are present" do
body_markdown = "---\ntitle: Title\npublished: false\ndescription:\ntags: heytag\n---\n\n"
created_article = create_article(body_markdown: body_markdown)
expect(created_article.description_and_tags).to eq("A post by #{created_article.user.name.delete('.')}. Tagged with heytag.")
parsed_post_by_string = if created_article.user.name.end_with?(".")
Copy link
Contributor

@atsmith813 atsmith813 Feb 12, 2020

Choose a reason for hiding this comment

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

This is probably a nitpick/style preference so I'm approving this and leaving this as a suggestion.

What about:

parsed_post_by_string = "A post by #{created_article.user.name}"
parsed_post_by_string += "." unless created_article.user.name.end_with?(".")

So it kind of reads like, "append a period unless it already ends with a period". Only because I had to look twice. At first, I thought the conditions were the same by accident and then I noticed the period.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that actually matches really nicely with the way it is written in the decorator +1

Zhao-Andy
Zhao-Andy previously approved these changes Feb 12, 2020
Copy link
Contributor

@Zhao-Andy Zhao-Andy left a comment

Choose a reason for hiding this comment

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

LGTM! Also agree with @atsmith813's suggestion b/c I did a double take too, but overall am pretty indifferent.

Copy link
Contributor

@Zhao-Andy Zhao-Andy left a comment

Choose a reason for hiding this comment

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

👍 👍 👍

Copy link
Contributor

@atsmith813 atsmith813 left a comment

Choose a reason for hiding this comment

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

LGTM 💯 I appreciate the update and consideration!

@mstruve mstruve merged commit 25b1ad4 into master Feb 12, 2020
@pr-triage pr-triage bot added the PR: merged bot applied label for PR's that are merged label Feb 12, 2020
@mstruve mstruve deleted the mstruve/spec-fix-again branch February 12, 2020 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: merged bot applied label for PR's that are merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants