Sha256: 9de374e48dfb2be83e02b543bb1cc1ed0686907d8c7e62032927401abc31f4da

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

require 'test_helper'
require 'generators/ember/resource_generator'

class ResourceGeneratorTest < Rails::Generators::TestCase
  include GeneratorTestSupport

  tests Ember::Generators::ResourceGenerator
  destination File.join(Rails.root, "tmp")
  setup :prepare_destination, :copy_router

  test "create template" do
    run_generator ["post"]
    assert_file "#{app_path}/templates/posts.hbs"
  end

  test "create controller" do
    run_generator ["post"]
    assert_file "#{app_path}/controllers/posts.es6"
  end

  test "create route" do
    run_generator ["post"]
    assert_file "#{app_path}/routes/posts.es6"
    assert_file "#{config_path}/router.es6" do |content|
      assert_match(%r{this.resource\('posts'\);}, content)
    end
  end

  test "skip route" do
    run_generator ["post", "--skip-route"]
    assert_no_file "#{app_path}/routes/posts.es6"
  end

  test "Uses config.ember.appkit.paths.app" do
    custom_path = app_path("custom")
    copy_router(custom_path)

    with_config paths: {app: custom_path} do
      run_generator ["post"]
      assert_file "#{custom_path}/controllers/posts.es6"
      assert_file "#{custom_path}/routes/posts.es6"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ember-appkit-rails-0.5.0 test/generators/resource_generator_test.rb