Sha256: 6917f9235e09df0b1a40a44b3729fec3bb294e244c44fafbe52e00ce26f0a372

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 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.js.es6"
  end

  test "create route" do
    run_generator ["post"]
    assert_file "#{app_path}/routes/posts.js.es6"
    assert_file "#{config_path}/router.js.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.js.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.js.es6"
      assert_file "#{custom_path}/routes/posts.js.es6"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ember-appkit-rails-0.4.0 test/generators/resource_generator_test.rb
ember-appkit-rails-0.3.2 test/generators/resource_generator_test.rb
ember-appkit-rails-0.3.1 test/generators/resource_generator_test.rb
ember-appkit-rails-0.3.0 test/generators/resource_generator_test.rb