File: generator_test.rb

package info (click to toggle)
ruby-friendly-id 5.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 432 kB
  • sloc: ruby: 3,143; makefile: 3
file content (38 lines) | stat: -rw-r--r-- 1,021 bytes parent folder | download
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
26
27
28
29
30
31
32
33
34
35
36
37
38
require "helper"
require "rails/generators"
require "generators/friendly_id_generator"

class FriendlyIdGeneratorTest < Rails::Generators::TestCase
  tests FriendlyIdGenerator
  destination File.expand_path("../../tmp", __FILE__)

  setup :prepare_destination

  test "should generate a migration" do
    run_generator
    assert_migration "db/migrate/create_friendly_id_slugs"
  ensure
    FileUtils.rm_rf destination_root
  end

  test "should skip the migration when told to do so" do
    run_generator ["--skip-migration"]
    assert_no_migration "db/migrate/create_friendly_id_slugs"
  ensure
    FileUtils.rm_rf destination_root
  end

  test "should generate an initializer" do
    run_generator
    assert_file "config/initializers/friendly_id.rb"
  ensure
    FileUtils.rm_rf destination_root
  end

  test "should skip the initializer when told to do so" do
    run_generator ["--skip-initializer"]
    assert_no_file "config/initializers/friendly_id.rb"
  ensure
    FileUtils.rm_rf destination_root
  end
end