Skip to content

Commit

Permalink
cqfn#125 Add parsing the name parameter from the rake task.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Vinogradov committed Jul 10, 2019
1 parent 89ec500 commit 9ff4023
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
22 changes: 19 additions & 3 deletions lib/pdd/rake_task.rb
Expand Up @@ -5,9 +5,25 @@
module PDD
# Rake task
class RakeTask < Rake::TaskLib
def initialize
# @todo #114:30m We need to create implementation of this class. At
# the moment it's just a stub. Implement it and remove the abort call.
attr_accessor :name
def initialize(*args, &task_block)
# @todo #125:30m Needs to have more parameters to run this task.
# For now, we just have a single parameter - the name.
# Needs more parameters like the xcop rake task has.
@name = args.shift || :pdd
desc 'Run PDD' unless ::Rake.application.last_description
task(name, *args) do |_, task_args|
RakeFileUtils.send(:verbose, true) do
yield(*[self, task_args].slice(0, task_block.arity)) if block_given?
run
end
end
end

def run
# @todo #125:30m need to implement this method.
# For now, it's just a task,
# that accepts one parameter and throws a system error.
abort('NOT IMPLEMENTED')
end
end
Expand Down
3 changes: 2 additions & 1 deletion test/test_rake_task.rb
Expand Up @@ -6,8 +6,9 @@
# Test for RakeTask
class TestRakeTask < Minitest::Test
def test_base
PDD::RakeTask.new(:pdd1)
error = assert_raises SystemExit do
PDD::RakeTask.new
Rake::Task['pdd1'].invoke
end
assert_equal('NOT IMPLEMENTED', error.message)
end
Expand Down

0 comments on commit 9ff4023

Please sign in to comment.