Skip to content

Commit

Permalink
Merge pull request #1173 from jaysonesmith/1021-fix-style-violations-2
Browse files Browse the repository at this point in the history
Fix Lint/DuplicateMethods
  • Loading branch information
mxygem authored Aug 14, 2017
2 parents c1da4ef + 9df470f commit 47811a0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 17 deletions.
5 changes: 0 additions & 5 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ Lint/AmbiguousOperator:
- 'spec/cucumber/formatter/legacy_api/adapter_spec.rb'
- 'spec/cucumber/formatter/spec_helper.rb'

# Offense count: 2
Lint/DuplicateMethods:
Exclude:
- 'lib/cucumber/multiline_argument.rb'

# Offense count: 2
Lint/Eval:
Exclude:
Expand Down
14 changes: 3 additions & 11 deletions lib/cucumber/multiline_argument.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ def from_core(node)
builder.wrap(node)
end

def from(argument, location=nil)
def from(argument, location=nil, content_type=nil)
location ||= Core::Ast::Location.of_caller
case argument
when String
doc_string(argument, 'text/plain', location)
builder.doc_string(Core::Ast::DocString.new(argument, content_type, location))
when Array
location = location.on_line(argument.first.line..argument.last.line)
data_table(argument.map{ |row| row.cells }, location)
builder.data_table(argument.map{ |row| row.cells }, location)
when DataTable, DocString, None
argument
when nil
Expand All @@ -28,14 +28,6 @@ def from(argument, location=nil)
end
end

def doc_string(argument, content_type, location)
builder.doc_string(Core::Ast::DocString.new(argument, content_type, location))
end

def data_table(data, location)
builder.data_table(Core::Ast::DataTable.new(data, location))
end

private

def builder
Expand Down
2 changes: 1 addition & 1 deletion lib/cucumber/runtime/support_code.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def multiline_arg(step, location)

if argument
if argument[:type] == :DocString
MultilineArgument.doc_string(argument[:content], argument[:content_type], location)
MultilineArgument.from(argument[:content], location, argument[:content_type])
else
MultilineArgument::DataTable.from(argument[:rows].map { |row| row[:cells].map { |cell| cell[:value] } })
end
Expand Down

0 comments on commit 47811a0

Please sign in to comment.