Sha256: 9d2cece50b82864c6d1d0a820de3ce04fa5e9f3a2e4e140c8690f05fd2dbd93a

Contents?: true

Size: 1.45 KB

Versions: 2

Compression:

Stored size: 1.45 KB

Contents

require 'test_helper'
require 'generators/ember/controller_generator'

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

  tests Ember::Generators::ControllerGenerator
  destination File.join(Rails.root, "tmp", "generator_test_output")

  setup :prepare_destination

  test "array_controller" do
    run_generator ["post", "--array"]
    assert_file "app/assets/javascripts/controllers/post.js.es6"
  end

  test "object_controller" do
    run_generator ["post", "--object"]
    assert_file "app/assets/javascripts/controllers/post.js.es6"
  end

  test "default_controller" do
    run_generator ["post"]
    assert_file "app/assets/javascripts/controllers/post.js.es6"
  end

  test "default_controller namespaced" do
    run_generator ["post/index"]
    assert_file "#{ember_path}/controllers/post/index.js.es6", /PostIndexController/
  end

  test "Assert files are properly created" do
    run_generator %w(ember)
    assert_file "#{ember_path}/controllers/ember.js.es6"
  end

  test "Assert files are properly created with custom path" do
    custom_path = ember_path("custom")
    run_generator [ "ember", "-d", custom_path ]
    assert_file "#{custom_path}/controllers/ember.js.es6"
  end

  test "Uses config.ember.ember_path" do
    custom_path = ember_path("custom")

    with_config ember_path: custom_path do
      run_generator ["post", "--object"]
      assert_file "#{custom_path}/controllers/post.js.es6"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ember-appkit-rails-0.1.2 test/generators/controller_generator_test.rb
ember-appkit-rails-0.1.1 test/generators/controller_generator_test.rb