-
-
Notifications
You must be signed in to change notification settings - Fork 511
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
Separate canonical data methods from ExerciseCase #648
Changes from all commits
dc07550
fa15669
01f7147
a6e77a5
3f5328a
58661b5
8844c7a
144d61f
e08ebb2
9d43bea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ def simple_test | |
end | ||
|
||
def add_to_clock | ||
" + #{add}" if add | ||
" + #{add}" if respond_to?(:add) | ||
end | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,4 @@ def single_quote(string) | |
string.inspect.tr('"', "'") | ||
end | ||
|
||
def ignore_method_length | ||
"# rubocop:disable MethodLength\n " if board.length > 8 | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yay! This is gone! |
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ def indent(size, lines) | |
end | ||
|
||
def assertion | ||
return error_assertion unless expected | ||
return error_assertion if expected == false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Or
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How do the other cases address the assertions? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where is Neither of these will work.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That answers that then. 👍 Thanks. |
||
return message_assertion if message | ||
|
||
"assert_equal(#{expected}, WordProblem.new(question).answer)" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,31 @@ | ||
require 'ostruct' | ||
|
||
module Generator | ||
class ExerciseCase < OpenStruct | ||
class ExerciseCase | ||
using Generator::Underscore | ||
include CaseHelpers | ||
include Assertion | ||
|
||
attr_reader :canonical | ||
def initialize(canonical:) | ||
@canonical = canonical | ||
end | ||
|
||
def name | ||
'test_%s' % description.underscore | ||
'test_%s' % canonical.description.underscore | ||
end | ||
|
||
def skipped(index) | ||
index.zero? ? '# skip' : 'skip' | ||
end | ||
|
||
def method_missing(sym, *args, &block) | ||
return canonical.send(sym) if canonical.respond_to?(sym) | ||
super(sym, *args, &block) | ||
end | ||
|
||
def respond_to?(sym, include_private = false) | ||
canonical.respond_to?(sym) || super | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm...
beginning
andending
would be a match here, and would avoid the 'stroop effect' caused by the standard use ofbegin
andend
in Ruby.Something to consider. Not a required change for bringing this in though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These names come from the canonical data so we're constrained by what it provides.