Skip to content

Isogram Exercise improvements: change method name/add failure messages#664

Merged
Insti merged 2 commits intoexercism:masterfrom
alexdebugs:isogram-exercise-improvements
Jun 7, 2017
Merged

Isogram Exercise improvements: change method name/add failure messages#664
Insti merged 2 commits intoexercism:masterfrom
alexdebugs:isogram-exercise-improvements

Conversation

@alexdebugs
Copy link
Copy Markdown
Contributor

@alexdebugs alexdebugs commented May 31, 2017

Why?

  • Improves the Isogram Exercise by adding failure messages and simplifying the method name
  • Helps bring the exercise up to standard

What?

  • Added failure messages to tell you what value was expected and what input was tested
  • Shortened the method name from is_isogram? to isogram?
  • Changed from version 3 to version #4

How Has This Been Tested?

  • By generating the test for this exercise by running `bin/generate -f isogram' and then
    testing the generated test.

Screenshots (if appropriate):

screen shot 2017-05-31 at 11 53 27 am

Types of changes

  • n/a Bug fix (non-breaking change which fixes an issue)
  • Enhancement (non-breaking change which adds functionality)
  • Breaking change (fix or enhancement that would cause existing functionality to change)
  • n/a Gardening (code and/or documentation cleanup)

Picked breaking change too because the method name changed so if you went back and ran the
version 3 solutions against this version they would fail.

References and Closures

references #475

Checklist:

  • I have read the CONTRIBUTING document.
  • My change relies on a pending issue/pull request
  • n/a My change requires a change to the documentation.
  • n/a I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Comment thread exercises/isogram/isogram_test.rb Outdated
# skip
string = ""
assert Isogram.is_isogram?(string)
assert Isogram.isogram?(string), "Expected 'true', '' is an isogram"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am not sure if true/false should be quoted. I have a slight preference for not quoting it.
@kotp?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We don't want people to think they have to return a string.

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.

No definitely, I get what you're saying! I guess I was just going off the triangle exercise test case more or less. If we decide to change it on here I can also go back and change it here later https://github.com/exercism/xruby/blob/master/exercises/triangle/triangle_test.rb. 😄

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.

Boolean should not be quoted.

@Insti
Copy link
Copy Markdown
Contributor

Insti commented May 31, 2017

Looks good 👍
I want to wait for @kotp to look this over, he has a good eye for this sort of thing.

end

def type
"#{expected ? 'is' : 'is not'} an isogram"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I like how you've left the 'is' in both cases. 👍

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.

Thank you!

Copy link
Copy Markdown
Member

@kotp kotp May 31, 2017

Choose a reason for hiding this comment

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

  def failure_message
    %Q("Expected '#{expected}', '#{input}' #{reason}")
  end

  def reason
    "#{is_or_not} an isogram"
  end

  def is_or_not
    expected ? 'is' : 'is not'
  end

Since we aren't really getting a type, the method name is not quite right.

EDIT: I left input as it is, but perhaps that is result instead. input always seems too generic, and often is not expressing what it is well enough.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I like reason but think the input is part of the reason.
%Q("Expected '#{expected}', #{reason}")

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.

For me it is a little bit easier to read it as Q("Expected '#{expected}', #{reason}") rather than %Q("Expected '#{expected}', '#{input}' #{reason}") if say I was just skimming through it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment on @kotp's edit: input is the input - the string that is provided as input to the method under test.

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.

Nothing we should do regarding 'input' for sure. I was just re-reading the code as you were writing the response.

Copy link
Copy Markdown
Member

@kotp kotp left a comment

Choose a reason for hiding this comment

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

Some considerations to be made.

end

def type
"#{expected ? 'is' : 'is not'} an isogram"
Copy link
Copy Markdown
Member

@kotp kotp May 31, 2017

Choose a reason for hiding this comment

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

  def failure_message
    %Q("Expected '#{expected}', '#{input}' #{reason}")
  end

  def reason
    "#{is_or_not} an isogram"
  end

  def is_or_not
    expected ? 'is' : 'is not'
  end

Since we aren't really getting a type, the method name is not quite right.

EDIT: I left input as it is, but perhaps that is result instead. input always seems too generic, and often is not expressing what it is well enough.

Comment thread exercises/isogram/isogram_test.rb Outdated
# skip
string = ""
assert Isogram.is_isogram?(string)
assert Isogram.isogram?(string), "Expected 'true', '' is an isogram"
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.

Boolean should not be quoted.

def test_bookkeeping
skip
assert_equal 3, BookKeeping::VERSION
assert_equal 4, BookKeeping::VERSION
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.

If messages are the only thing being changed, and not the tests themselves, then VERSION should not change.

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.

Ah yes, removed the query part that is common in languages where the question mark cannot be used. So it is a good version bump.

@alexdebugs
Copy link
Copy Markdown
Contributor Author

Wow thank you for all the feedback @kotp ! When I was making the method name I was actually wondering what to call it, so I'm happy for your insight.

@alexdebugs
Copy link
Copy Markdown
Contributor Author

Submitted another commit and integrated your great feedback.
Let me know if you have any other feedback 😄

@Insti
Copy link
Copy Markdown
Contributor

Insti commented Jun 3, 2017

Thanks @deohtee, I will look at this when I get a chance.

Copy link
Copy Markdown
Member

@kotp kotp left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@Insti Insti merged commit 63ee9f5 into exercism:master Jun 7, 2017
@Insti
Copy link
Copy Markdown
Contributor

Insti commented Jun 7, 2017

Thanks @deohtee ❤️

@Insti Insti removed the ready label Jun 8, 2017
@Insti
Copy link
Copy Markdown
Contributor

Insti commented Jun 8, 2017

Why didn't Travis run on these changes?

@kotp
Copy link
Copy Markdown
Member

kotp commented Jun 8, 2017

It looks like a missed hook communication.

@Insti
Copy link
Copy Markdown
Contributor

Insti commented Jun 9, 2017

Travis CI had some issues between May 31 and June 2 it looks like this PR came in during that window and the PR was never picked up by Travis.
Ref: https://www.traviscistatus.com/#month (link will go out of date with time.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants