aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/generators/task_generator_test.rb
blob: 1896dc5c87217b102535e3b9df876a6b8b8fb937 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# frozen_string_literal: true
require "generators/generators_test_helper"
require "rails/generators/rails/task/task_generator"

class TaskGeneratorTest < Rails::Generators::TestCase
  include GeneratorsTestHelper
  arguments %w(feeds foo bar)

  def test_task_is_created
    run_generator
    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
    task_path = "lib/tasks/feeds.rake"
    run_generator
    assert_file task_path
    run_generator ["feeds"], behavior: :revoke
    assert_no_file task_path
  end
end