Sha256: bf8bf864aeb3d05fdb86ce2fee78860e7b6f0991ecf0ef633a643a6b93ae6475

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

require 'test_helper'
require 'lib/generators/slim/testing_helper'

class Slim::Generators::ScaffoldGeneratorTest < Rails::Generators::TestCase
  include SlimLintHelpers

  destination File.join(Rails.root)
  tests Rails::Generators::ScaffoldGenerator
  arguments %w(product_line title:string price:integer --template-engine slim --orm active-record)

  setup :prepare_destination
  setup :copy_routes

  test "should invoke template engine" do
    run_generator

    %w(index edit new show _form).each { |view| assert_file File.join "app", "views", "product_lines", "#{view}.html.slim" }
    assert_no_file File.join "app", "views", "layouts", "product_lines.html.slim"
  end

  test "should revoke template engine" do
    run_generator
    run_generator ["product_line", "--orm", "active-record"], behavior: :revoke

    assert_no_file File.join "app", "views", "product_lines"
    assert_no_file File.join "app", "views", "layouts", "product_lines.html.slim"
  end

  test "should generate SlimLint valid templates" do
    run_generator
    templates = Dir[File.join(Rails.root, 'app', 'views', '**', '*.slim')]
    assert_empty lint(templates)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
slim-rails-3.3.0 test/lib/generators/slim/scaffold_generator_test.rb