2017-08-14 13:08:09 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-06 13:16:09 -04:00
|
|
|
require "generators/generators_test_helper"
|
|
|
|
require "rails/generators/rails/task/task_generator"
|
2011-12-13 06:06:36 -05:00
|
|
|
|
|
|
|
class TaskGeneratorTest < Rails::Generators::TestCase
|
|
|
|
include GeneratorsTestHelper
|
|
|
|
arguments %w(feeds foo bar)
|
|
|
|
|
2012-10-23 05:43:11 -04:00
|
|
|
def test_task_is_created
|
2011-12-13 06:06:36 -05:00
|
|
|
run_generator
|
2013-11-23 10:48:19 -05:00
|
|
|
assert_file "lib/tasks/feeds.rake" do |content|
|
|
|
|
assert_match(/namespace :feeds/, content)
|
|
|
|
assert_match(/task foo:/, content)
|
|
|
|
assert_match(/task bar:/, content)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_task_on_revoke
|
2016-08-06 13:16:09 -04:00
|
|
|
task_path = "lib/tasks/feeds.rake"
|
2013-11-23 10:48:19 -05:00
|
|
|
run_generator
|
|
|
|
assert_file task_path
|
2016-08-06 13:16:09 -04:00
|
|
|
run_generator ["feeds"], behavior: :revoke
|
2013-11-23 10:48:19 -05:00
|
|
|
assert_no_file task_path
|
2011-12-13 06:06:36 -05:00
|
|
|
end
|
|
|
|
end
|