Sha256: 8694266398cd74742242a2d9a2a99f40c2bb1d5c18e6f651a14219c4ca639611

Contents?: true

Size: 1.37 KB

Versions: 7

Compression:

Stored size: 1.37 KB

Contents

require 'test_helper'
require 'generators/ember/scaffold_generator'

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

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

  test "create template" do
    run_generator ["post"]

    assert_files
    assert_inject_into_router
  end

  private

  def assert_files
    assert_file "#{app_path}/models/post.js.es6"

    assert_file "#{app_path}/routes/posts/edit.js.es6"
    assert_file "#{app_path}/routes/posts/index.js.es6"
    assert_file "#{app_path}/routes/posts/new.js.es6"
    assert_file "#{app_path}/routes/posts/show.js.es6"

    assert_file "#{app_path}/templates/posts.hbs"
    assert_file "#{app_path}/templates/posts/edit.hbs"
    assert_file "#{app_path}/templates/posts/form.hbs"
    assert_file "#{app_path}/templates/posts/index.hbs"
    assert_file "#{app_path}/templates/posts/new.hbs"
    assert_file "#{app_path}/templates/posts/show.hbs"
  end

  def assert_inject_into_router
    js = <<-JS
  this.resource('posts', function() {
    this.route('new');
    this.route('show', {path: ':post_id'});
    this.route('edit', {path: ':post_id/edit'});
  });
JS
    assert_file "#{config_path}/router.js.es6" do |content|
      assert_match(/#{Regexp.escape(js.rstrip)}/m, content)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ember-appkit-rails-0.4.0 test/generators/scaffold_generator_test.rb
ember-appkit-rails-0.3.2 test/generators/scaffold_generator_test.rb
ember-appkit-rails-0.3.1 test/generators/scaffold_generator_test.rb
ember-appkit-rails-0.3.0 test/generators/scaffold_generator_test.rb
ember-appkit-rails-0.2.2 test/generators/scaffold_generator_test.rb
ember-appkit-rails-0.2.1 test/generators/scaffold_generator_test.rb
ember-appkit-rails-0.2.0 test/generators/scaffold_generator_test.rb