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

Luhn with generator #559

Merged
merged 5 commits into from
Apr 21, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion exercises/luhn/example.tt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require_relative 'luhn'
class LuhnTest < Minitest::Test<% test_cases.each do |test_case| %>
def <%= test_case.name %>
<%= test_case.skipped %>
<%= test_case.assertion %> <%= test_case.work_load %>
<%= test_case.work_load %>
end
<% end %>
<%= IO.read(XRUBY_LIB + '/bookkeeping.md') %>
Expand Down
4 changes: 3 additions & 1 deletion lib/luhn_cases.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ def name
end

def work_load
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be workload

Copy link
Contributor

Choose a reason for hiding this comment

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

I've updated the documentation to help clarify this: #560

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a style guide somewhere (other than the README)? Because some of the exercises use work_load and others use workload. In fact, as long as it is the same in both example.tt and <exercise>_cases.rb it should work fine.

Copy link
Contributor

Choose a reason for hiding this comment

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

No, just the README.
I've made a PR to rename the old occurrences to try and clear this up: #561

%Q(Luhn.valid?("#{input}"))
%Q(#{assertion} Luhn.valid?("#{input}"))
Copy link
Contributor

Choose a reason for hiding this comment

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

"#{input}"

This will work, but it's a good habit to use input.inspect which will handle input that contains quotes.

Nice usage of %Q though. 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea!

end

def skipped
index.zero? ? '# skip' : 'skip'
end

private

def assertion
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be made private as it is only needed by workload

expected ? 'assert' : 'refute'
end
Expand Down