Skip to content

refinements: removed from individual cases #697

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'generator/exercise_case'

class CollatzConjectureCase < Generator::ExerciseCase
using Generator::Underscore

def workload
case expected
Expand All @@ -25,7 +24,7 @@ def subject_of_test
end

def input
number.underscore
literal(number)
end
end

3 changes: 1 addition & 2 deletions exercises/space-age/.meta/generator/space_age_case.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
require 'generator/exercise_case'

class SpaceAgeCase < Generator::ExerciseCase
using Generator::Underscore

def workload
indent_lines(["age = SpaceAge.new(#{seconds.underscore})",
indent_lines(["age = SpaceAge.new(#{literal(seconds)})",
"assert_in_delta #{expected}, age.on_#{planet.downcase}, DELTA"
], 4)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class SumOfMultiplesCase < Generator::ExerciseCase
using Generator::Underscore

def workload
assert_expected = "assert_equal #{expected.underscore}"
assert_expected = "assert_equal #{underscore(expected)}"
value = "SumOfMultiples.new(#{factors.join(', ')}).to(#{limit})"
indent_lines(["#{assert_expected}, #{value}"], 4)
end
Expand Down
15 changes: 15 additions & 0 deletions lib/generator/exercise_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,20 @@ def method_missing(sym, *args, &block)
def respond_to?(sym, include_private = false)
canonical.respond_to?(sym) || super
end

protected

def literal(number)
number.underscore
end

def underscore(string)
string.underscore
end

def camel_case(string)
string.camel_case
end

end
end