Sha256: c13fc03f875dc9a0d1c765087729591182646cd4fa25c00677828e4b00f005c1

Contents?: true

Size: 1.65 KB

Versions: 3

Compression:

Stored size: 1.65 KB

Contents

require 'test_helper'

class Jax::Generators::Controller::ControllerGeneratorTest < Jax::Generators::TestCase
  setup :copy_routes

  test "with no arguments" do
    # since this test was first written, it's become apparent that the 'index' action is
    # pretty much ubiquitous -- enough so that it's safe to auto-generate it if omitted.

    generate 'welcome'
    
    assert_file "app/controllers/welcome_controller.js", /^\s*index: function\(\)\s*\{/
    assert_file "app/views/welcome/index.js"
    assert_file "config/routes.rb", /^  map ['"]welcome\/index["']/
    assert_file "spec/javascripts/controllers/welcome_controller_spec.js"
  end
  
  test "with --root option" do
    generate 'welcome', '--root'
    
    assert_file "config/routes.rb", /root ['"]welcome["']/
  end
  
  test "with arguments" do
    generate "welcome", "index"
    
    assert_file "app/controllers/welcome_controller.js", /^\s*index: function\(\)\s*\{/
    assert_file "app/views/welcome/index.js"
    assert_file "config/routes.rb", /^  map ['"]welcome\/index["']/
    assert_file "spec/javascripts/controllers/welcome_controller_spec.js"
  end
  
  include TestHelpers::Paths
  include TestHelpers::Generation

  test "in plugin" do
    build_app
    plugin_generator 'clouds'
    boot_app
    
    generate "welcome", "index"
    assert_file "vendor/plugins/clouds/app/controllers/welcome_controller.js", /^\s*index: function\(\)\s*\{/
    assert_file "vendor/plugins/clouds/app/views/welcome/index.js"
    assert_file "vendor/plugins/clouds/config/routes.rb", /^  map ['"]welcome\/index["']/
    assert_file "vendor/plugins/clouds/spec/javascripts/controllers/welcome_controller_spec.js"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jax-1.1.1 spec/generators/controller_generator_test.rb
jax-1.1.0 spec/generators/controller_generator_test.rb
jax-1.1.0.rc1 spec/generators/controller_generator_test.rb