ember-appkit-rails 0.0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +21 -3
- data/lib/ember/appkit/rails/version.rb +1 -1
- data/lib/generators/ember/component_generator.rb +24 -0
- data/lib/generators/ember/controller_generator.rb +31 -0
- data/lib/generators/ember/generator_helpers.rb +15 -3
- data/lib/generators/ember/model_generator.rb +47 -0
- data/lib/generators/ember/resource_generator.rb +25 -0
- data/lib/generators/ember/template_generator.rb +20 -0
- data/lib/generators/ember/view_generator.rb +23 -0
- data/lib/generators/templates/array_controller.js.es6 +4 -0
- data/lib/generators/templates/component.js.es6 +2 -0
- data/lib/generators/templates/component.template.hbs +0 -0
- data/lib/generators/templates/controller.js.es6 +3 -0
- data/lib/generators/templates/model.js.es6 +11 -0
- data/lib/generators/templates/object_controller.js.es6 +4 -0
- data/lib/generators/templates/template.hbs +5 -0
- data/lib/generators/templates/view.js.es6 +3 -0
- data/test/dummy/app/assets/javascripts/controllers/index.js.es6 +1 -3
- data/test/dummy/config/environments/development.rb +0 -1
- data/test/dummy/config/environments/test.rb +0 -1
- data/test/dummy/log/development.log +392 -0
- data/test/dummy/log/test.log +1160 -0
- data/test/dummy/tmp/app/assets/javascripts/templates/post.hbs +5 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/{f2a13b6bc27457cb7513b583b4e69ed5 → 07a9ce16127008e142b1b0223c4d7784} +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/19c9bc7dbf67a891e93c7a663a62ff1c +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/22d5df6f378a04858f2123ee6e176ff1 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/{f8c79edb4a48d7e4f74a6113d25f4699 → 2ad53936554864466b852e4eae6d6803} +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/30e6b42a491dc4952ff020137405d502 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/331122f2f78d79778408023cf5bad1e3 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/34b3026e7f937c6a19a0aee7f8451aad +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/36b770b8db4bb47ce9c524d7104be2e9 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/4a1d4e32cd7b9fd1c62bfd553ae56051 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/4bde569e155e5abfc2bc79bb61721688 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/{f46d0d400dce471af50b05c9ac272ba9 → 5776b21d8a87e618d8323a9c4d3c86ff} +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/720ee922899be7948cc2a8b27660ce0b +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/7689ffe6d7c831ee178e07106482b2cc +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/7bf1770d3a1c8bc1b59a4bc89d5c4bca +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/7d008b32a16b10ea72ea849f47d9a095 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/{3b825365f669ab10c71ccee9d64335b6 → 889c68982dadf8d222309363924fe44b} +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/8e9feb35d7e388f760d17aaf89b32731 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/8ebc8c58233ab12eee6edfc0feca2492 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/{0f63b9e77aec7451fc0c21d376f8eb28 → b340d5578308bb4c197a8ca3538b0e24} +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/b3a5b51571520b61f892c51e979b9f53 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/bb4a2293175928af3e23c47488077098 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/bf689240392e7355c0de5cfd47272146 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/c0bb6b15bdd48873e96974816e18abe9 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/c8c4c1b316845f30168739b5795846d6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/{b692b37dad694df23f130ceda8c808dd → dd568c8ef1f3f20b5931d72ef2eb5963} +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/e2a67ad17895f7711966ca1a5ff7af86 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/e44f5ebcd8f42995512e64b96b63c9cf +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/e8aa57b28c86586b8b7344feb891c43f +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/e9abb671d48f6ff2be6ffb463ea652bf +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ed5238112abbfd6a794a100804365903 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/ember-rails/ember.js +185 -120
- data/test/dummy/tmp/generator_test_output/app/assets/javascripts/application.js +0 -0
- data/test/dummy/tmp/generator_test_output/app/assets/javascripts/custom/application.js +0 -0
- data/test/dummy/tmp/generator_test_output/app/assets/javascripts/views/post.js.es6 +3 -0
- data/test/generators/bootstrap_generator_test.rb +18 -0
- data/test/generators/component_generator_test.rb +58 -0
- data/test/generators/controller_generator_test.rb +51 -0
- data/test/generators/model_generator_test.rb +48 -0
- data/test/generators/resource_generator_test.rb +43 -0
- data/test/generators/template_generator_test.rb +31 -0
- data/test/generators/view_generator_test.rb +55 -0
- data/test/support/generator_test_support.rb +14 -1
- data/vendor/assets/javascripts/app.js.es6 +13 -0
- data/{test/dummy/tmp/cache/assets/development/sprockets/ebc77031c7503fcc60aaa5c603aa9138 → vendor/assets/javascripts/ember-appkit/almond.js} +0 -0
- data/vendor/assets/javascripts/ember-appkit/index.js +5 -0
- data/vendor/assets/javascripts/ember-appkit/resolver.js +169 -0
- metadata +68 -132
- data/test/dummy/tmp/cache/assets/development/sprockets/009d416d9e579ca73b72e11a882283db +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/0f63b9e77aec7451fc0c21d376f8eb28 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/13c56481151a0f8ff72b183daf16c0ba +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/19c9bc7dbf67a891e93c7a663a62ff1c +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/22d5df6f378a04858f2123ee6e176ff1 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/30095b6d23a5bac343099341a88a9768 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/30e6b42a491dc4952ff020137405d502 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/32a4bf18777e24ecbd1bb7bf1afb9d41 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/331122f2f78d79778408023cf5bad1e3 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/34b3026e7f937c6a19a0aee7f8451aad +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/36b770b8db4bb47ce9c524d7104be2e9 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/3a168599f447464b14332bdfd140ff00 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/3b825365f669ab10c71ccee9d64335b6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/3f60ef531652da88a591066588c06000 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/3fa9b534ed1d39ba8274b7ab49a38d11 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/4138a0978ec2097970b05e52c1d1cf94 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/61df2fa75b3733030a82b166f1c135e9 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/720ee922899be7948cc2a8b27660ce0b +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/7689ffe6d7c831ee178e07106482b2cc +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/776c336ba7d7935e564e9bf5072e3dd8 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/7bf1770d3a1c8bc1b59a4bc89d5c4bca +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/7d008b32a16b10ea72ea849f47d9a095 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/832a081f27208b2b977b49b487d2bc89 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/8333b0a9d6f14badf985b50415d5deee +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/8e9feb35d7e388f760d17aaf89b32731 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/8ebc8c58233ab12eee6edfc0feca2492 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/8fc8cc19ffe18f3fb8d3a8506d9169b3 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/91ce00d4fbb2d91206d66229af2dda20 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/9475a88de7edd7f2eb6268573986cbdd +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/aee731d32c121990e31f5d68a034087c +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/b6477f770c118c6b4362a1043ea87879 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/b692b37dad694df23f130ceda8c808dd +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/b7ee576b652da2c60e89e6a466d073f4 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/c0bb6b15bdd48873e96974816e18abe9 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/c8c4c1b316845f30168739b5795846d6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d05ba20923e543730084eb723e770f12 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e1658f6900cfc0ba388976a2fd25f94f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e2a67ad17895f7711966ca1a5ff7af86 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e44f5ebcd8f42995512e64b96b63c9cf +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e610538e56e78934ee9fa328294fcc06 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e8aa57b28c86586b8b7344feb891c43f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/ed5238112abbfd6a794a100804365903 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f2a13b6bc27457cb7513b583b4e69ed5 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f46d0d400dce471af50b05c9ac272ba9 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f8c79edb4a48d7e4f74a6113d25f4699 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/fa20075040efd309e2e2fdb310135e63 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/fdcd9e39dbe03f947086b7e6c1ce29d2 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/009d416d9e579ca73b72e11a882283db +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/32a4bf18777e24ecbd1bb7bf1afb9d41 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/3a168599f447464b14332bdfd140ff00 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/3fa9b534ed1d39ba8274b7ab49a38d11 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/91ce00d4fbb2d91206d66229af2dda20 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/fdcd9e39dbe03f947086b7e6c1ce29d2 +0 -0
File without changes
|
File without changes
|
@@ -32,4 +32,22 @@ class BootstrapGeneratorTest < Rails::Generators::TestCase
|
|
32
32
|
assert_file "#{ember_path}/ember-app.js.es6", /MyApp = /
|
33
33
|
assert_file "#{ember_path}/router.js.es6"
|
34
34
|
end
|
35
|
+
|
36
|
+
test "Uses config.ember.app_name" do
|
37
|
+
with_config app_name: 'Blazorz' do
|
38
|
+
run_generator
|
39
|
+
assert_file "#{ember_path}/ember-app.js.es6", /Blazorz = /
|
40
|
+
assert_file "#{ember_path}/router.js.es6"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
test "Uses config.ember.ember_path" do
|
45
|
+
custom_path = ember_path("custom")
|
46
|
+
|
47
|
+
with_config ember_path: custom_path do
|
48
|
+
run_generator
|
49
|
+
assert_file "#{custom_path}/ember-app.js.es6"
|
50
|
+
assert_file "#{custom_path}/router.js.es6"
|
51
|
+
end
|
52
|
+
end
|
35
53
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'generators/ember/component_generator'
|
3
|
+
|
4
|
+
class ComponentGeneratorTest < Rails::Generators::TestCase
|
5
|
+
include GeneratorTestSupport
|
6
|
+
|
7
|
+
tests Ember::Generators::ComponentGenerator
|
8
|
+
destination File.join(Rails.root, "tmp", "generator_test_output")
|
9
|
+
|
10
|
+
setup :prepare_destination
|
11
|
+
|
12
|
+
test "default_component" do
|
13
|
+
run_generator ["PostChart"]
|
14
|
+
assert_file "app/assets/javascripts/components/post-chart_component.js.es6"
|
15
|
+
assert_file "app/assets/javascripts/templates/components/post-chart.hbs"
|
16
|
+
end
|
17
|
+
|
18
|
+
test "Assert files are properly created (CamelCase)" do
|
19
|
+
run_generator %w(PostChart)
|
20
|
+
assert_file "#{ember_path}/components/post-chart_component.js.es6"
|
21
|
+
assert_file "#{ember_path}/templates/components/post-chart.hbs"
|
22
|
+
end
|
23
|
+
|
24
|
+
test "Assert object names are properly created with CamelCase name" do
|
25
|
+
run_generator %w(PostChart)
|
26
|
+
assert_file "#{ember_path}/components/post-chart_component.js.es6"
|
27
|
+
assert_file "#{ember_path}/templates/components/post-chart.hbs"
|
28
|
+
end
|
29
|
+
|
30
|
+
test "Assert files are properly created (lower-case)" do
|
31
|
+
run_generator %w(post-chart)
|
32
|
+
assert_file "#{ember_path}/components/post-chart_component.js.es6"
|
33
|
+
assert_file "#{ember_path}/templates/components/post-chart.hbs"
|
34
|
+
end
|
35
|
+
|
36
|
+
test "Assert object names are properly created with lower-case name" do
|
37
|
+
run_generator %w(post-chart)
|
38
|
+
assert_file "#{ember_path}/components/post-chart_component.js.es6"
|
39
|
+
assert_file "#{ember_path}/templates/components/post-chart.hbs"
|
40
|
+
end
|
41
|
+
|
42
|
+
test "Assert files are properly created with custom path" do
|
43
|
+
custom_path = ember_path("custom")
|
44
|
+
run_generator [ "PostChart", "-d", custom_path ]
|
45
|
+
assert_file "#{custom_path}/components/post-chart_component.js.es6"
|
46
|
+
assert_file "#{custom_path}/templates/components/post-chart.hbs"
|
47
|
+
end
|
48
|
+
|
49
|
+
test "Uses config.ember.ember_path" do
|
50
|
+
custom_path = ember_path("custom")
|
51
|
+
|
52
|
+
with_config ember_path: custom_path do
|
53
|
+
run_generator ["PostChart"]
|
54
|
+
assert_file "#{custom_path}/components/post-chart_component.js.es6"
|
55
|
+
assert_file "#{custom_path}/templates/components/post-chart.hbs"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'generators/ember/controller_generator'
|
3
|
+
|
4
|
+
class ControllerGeneratorTest < Rails::Generators::TestCase
|
5
|
+
include GeneratorTestSupport
|
6
|
+
|
7
|
+
tests Ember::Generators::ControllerGenerator
|
8
|
+
destination File.join(Rails.root, "tmp", "generator_test_output")
|
9
|
+
|
10
|
+
setup :prepare_destination
|
11
|
+
|
12
|
+
test "array_controller" do
|
13
|
+
run_generator ["post", "--array"]
|
14
|
+
assert_file "app/assets/javascripts/controllers/post.js.es6"
|
15
|
+
end
|
16
|
+
|
17
|
+
test "object_controller" do
|
18
|
+
run_generator ["post", "--object"]
|
19
|
+
assert_file "app/assets/javascripts/controllers/post.js.es6"
|
20
|
+
end
|
21
|
+
|
22
|
+
test "default_controller" do
|
23
|
+
run_generator ["post"]
|
24
|
+
assert_file "app/assets/javascripts/controllers/post.js.es6"
|
25
|
+
end
|
26
|
+
|
27
|
+
test "default_controller namespaced" do
|
28
|
+
run_generator ["post/index"]
|
29
|
+
assert_file "#{ember_path}/controllers/post/index.js.es6", /PostIndexController/
|
30
|
+
end
|
31
|
+
|
32
|
+
test "Assert files are properly created" do
|
33
|
+
run_generator %w(ember)
|
34
|
+
assert_file "#{ember_path}/controllers/ember.js.es6"
|
35
|
+
end
|
36
|
+
|
37
|
+
test "Assert files are properly created with custom path" do
|
38
|
+
custom_path = ember_path("custom")
|
39
|
+
run_generator [ "ember", "-d", custom_path ]
|
40
|
+
assert_file "#{custom_path}/controllers/ember.js.es6"
|
41
|
+
end
|
42
|
+
|
43
|
+
test "Uses config.ember.ember_path" do
|
44
|
+
custom_path = ember_path("custom")
|
45
|
+
|
46
|
+
with_config ember_path: custom_path do
|
47
|
+
run_generator ["post", "--object"]
|
48
|
+
assert_file "#{custom_path}/controllers/post.js.es6"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'generators/ember/model_generator'
|
3
|
+
|
4
|
+
class ModelGeneratorTest < Rails::Generators::TestCase
|
5
|
+
include GeneratorTestSupport
|
6
|
+
|
7
|
+
tests Ember::Generators::ModelGenerator
|
8
|
+
destination File.join(Rails.root, "tmp", "generator_test_output")
|
9
|
+
|
10
|
+
setup :prepare_destination
|
11
|
+
|
12
|
+
test "create model" do
|
13
|
+
run_generator ["post", "title:string"]
|
14
|
+
assert_file "app/assets/javascripts/models/post.js.es6"
|
15
|
+
end
|
16
|
+
|
17
|
+
test "create namespaced model" do
|
18
|
+
run_generator ["post/doineedthis", "title:string"]
|
19
|
+
assert_file "app/assets/javascripts/models/post/doineedthis.js.es6"
|
20
|
+
end
|
21
|
+
|
22
|
+
test "leave parentheses when create model w/o attributes" do
|
23
|
+
run_generator ["post"]
|
24
|
+
assert_file "app/assets/javascripts/models/post.js.es6", /export default = DS.Model.extend/
|
25
|
+
end
|
26
|
+
|
27
|
+
test "Assert files are properly created" do
|
28
|
+
run_generator %w(ember)
|
29
|
+
|
30
|
+
assert_file "#{ember_path}/models/ember.js.es6"
|
31
|
+
end
|
32
|
+
|
33
|
+
test "Assert files are properly created with custom path" do
|
34
|
+
custom_path = ember_path("custom")
|
35
|
+
run_generator [ "ember", "-d", custom_path ]
|
36
|
+
|
37
|
+
assert_file "#{custom_path}/models/ember.js.es6"
|
38
|
+
end
|
39
|
+
|
40
|
+
test "Uses config.ember.ember_path" do
|
41
|
+
custom_path = ember_path("custom")
|
42
|
+
|
43
|
+
with_config ember_path: custom_path do
|
44
|
+
run_generator ["ember"]
|
45
|
+
assert_file "#{custom_path}/models/ember.js.es6"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'generators/ember/resource_generator'
|
3
|
+
|
4
|
+
class ResourceGeneratorTest < Rails::Generators::TestCase
|
5
|
+
include GeneratorTestSupport
|
6
|
+
|
7
|
+
tests Ember::Generators::ResourceGenerator
|
8
|
+
destination File.join(Rails.root, "tmp")
|
9
|
+
setup :prepare_destination
|
10
|
+
|
11
|
+
|
12
|
+
test "create template" do
|
13
|
+
run_generator ["post"]
|
14
|
+
assert_file "app/assets/javascripts/templates/post.hbs"
|
15
|
+
end
|
16
|
+
|
17
|
+
test "create controller" do
|
18
|
+
run_generator ["post"]
|
19
|
+
assert_file "app/assets/javascripts/controllers/post.js.es6"
|
20
|
+
end
|
21
|
+
|
22
|
+
test "create route" do
|
23
|
+
run_generator ["post"]
|
24
|
+
assert_file "app/assets/javascripts/routes/post.js.es6"
|
25
|
+
end
|
26
|
+
|
27
|
+
test "skip route" do
|
28
|
+
run_generator ["post", "--skip-route"]
|
29
|
+
assert_no_file "app/assets/javascripts/routes/post.js.es6"
|
30
|
+
end
|
31
|
+
|
32
|
+
test "Uses config.ember.ember_path" do
|
33
|
+
custom_path = ember_path("custom")
|
34
|
+
|
35
|
+
with_config ember_path: custom_path do
|
36
|
+
run_generator ["post"]
|
37
|
+
assert_file "#{custom_path}/controllers/post.js.es6"
|
38
|
+
assert_file "#{custom_path}/routes/post.js.es6"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'generators/ember/template_generator'
|
3
|
+
|
4
|
+
class TemplateGeneratorTest < Rails::Generators::TestCase
|
5
|
+
include GeneratorTestSupport
|
6
|
+
|
7
|
+
tests Ember::Generators::TemplateGenerator
|
8
|
+
destination File.join(Rails.root, "tmp")
|
9
|
+
|
10
|
+
setup :prepare_destination
|
11
|
+
|
12
|
+
test "generates template" do
|
13
|
+
run_generator ["post"]
|
14
|
+
assert_file "app/assets/javascripts/templates/post.hbs"
|
15
|
+
end
|
16
|
+
|
17
|
+
test "Assert files are properly created with custom path" do
|
18
|
+
custom_path = ember_path("custom")
|
19
|
+
run_generator [ "post", "-d", custom_path ]
|
20
|
+
assert_file "#{custom_path}/templates/post.hbs"
|
21
|
+
end
|
22
|
+
|
23
|
+
test "Uses config.ember.ember_path" do
|
24
|
+
custom_path = ember_path("custom")
|
25
|
+
|
26
|
+
with_config ember_path: custom_path do
|
27
|
+
run_generator ["post"]
|
28
|
+
assert_file "#{custom_path}/templates/post.hbs"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'generators/ember/view_generator'
|
3
|
+
|
4
|
+
class ViewGeneratorTest < Rails::Generators::TestCase
|
5
|
+
include GeneratorTestSupport
|
6
|
+
|
7
|
+
tests Ember::Generators::ViewGenerator
|
8
|
+
destination File.join(Rails.root, "tmp", "generator_test_output")
|
9
|
+
|
10
|
+
setup :prepare_destination
|
11
|
+
|
12
|
+
test "create view with template by default" do
|
13
|
+
run_generator ["post"]
|
14
|
+
assert_file "app/assets/javascripts/views/post.js.es6"
|
15
|
+
assert_file "app/assets/javascripts/templates/post.hbs"
|
16
|
+
end
|
17
|
+
|
18
|
+
test "create view without a template" do
|
19
|
+
run_generator ["post", "--without-template"]
|
20
|
+
assert_file "app/assets/javascripts/views/post.js.es6"
|
21
|
+
assert_no_file "app/assets/javascripts/templates/post.hbs"
|
22
|
+
end
|
23
|
+
|
24
|
+
test "create view and template (using ember-rails flags)" do
|
25
|
+
run_generator ["post", "--with-template"]
|
26
|
+
assert_file "app/assets/javascripts/views/post.js.es6"
|
27
|
+
assert_file "app/assets/javascripts/templates/post.hbs"
|
28
|
+
end
|
29
|
+
|
30
|
+
test "create namespaced view" do
|
31
|
+
run_generator ["post/index"]
|
32
|
+
assert_file "app/assets/javascripts/views/post/index.js.es6"
|
33
|
+
end
|
34
|
+
|
35
|
+
test "Assert files are properly created" do
|
36
|
+
run_generator %w(ember)
|
37
|
+
assert_file "#{ember_path}/views/ember.js.es6"
|
38
|
+
end
|
39
|
+
|
40
|
+
test "Assert files are properly created with custom path" do
|
41
|
+
custom_path = ember_path("custom")
|
42
|
+
run_generator [ "ember", "-d", custom_path ]
|
43
|
+
assert_file "#{custom_path}/views/ember.js.es6"
|
44
|
+
end
|
45
|
+
|
46
|
+
test "Uses config.ember.ember_path" do
|
47
|
+
custom_path = ember_path("custom")
|
48
|
+
|
49
|
+
with_config ember_path: custom_path do
|
50
|
+
run_generator [ "ember"]
|
51
|
+
assert_file "#{custom_path}/views/ember.js.es6"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
@@ -12,7 +12,20 @@ module GeneratorTestSupport
|
|
12
12
|
File.write(dest.join('custom/application.js'), "")
|
13
13
|
end
|
14
14
|
|
15
|
-
|
15
|
+
def with_config(options = {})
|
16
|
+
original_values = ::Rails.configuration.ember.to_h
|
17
|
+
|
18
|
+
options.each do |(key, value)|
|
19
|
+
::Rails.configuration.ember[key] = value
|
20
|
+
end
|
21
|
+
|
22
|
+
yield
|
23
|
+
ensure
|
24
|
+
::Rails.configuration.ember.clear
|
25
|
+
original_values.each do |(key, value)|
|
26
|
+
::Rails.configuration.ember[key] = value
|
27
|
+
end
|
28
|
+
end
|
16
29
|
|
17
30
|
def assert_new_dirs(options = {})
|
18
31
|
path = options[:in_path] || ember_path
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import Resolver from 'resolver';
|
2
|
+
|
3
|
+
var App = Ember.Application.extend({
|
4
|
+
LOG_ACTIVE_GENERATION: true,
|
5
|
+
LOG_MODULE_RESOLVER: true,
|
6
|
+
LOG_TRANSITIONS: true,
|
7
|
+
LOG_TRANSITIONS_INTERNAL: true,
|
8
|
+
LOG_VIEW_LOOKUPS: true,
|
9
|
+
modulePrefix: 'appkit', // TODO: loaded via config
|
10
|
+
Resolver: Resolver
|
11
|
+
});
|
12
|
+
|
13
|
+
export default App;
|
Binary file
|
@@ -0,0 +1,169 @@
|
|
1
|
+
// Fetched from: https://raw.github.com/stefanpenner/ember-jj-abrams-resolver/master/dist/ember-resolver.js
|
2
|
+
// Fetched on: 2013-10-31T03:00:41Z
|
3
|
+
// ==========================================================================
|
4
|
+
// Project: Ember - JavaScript Application Framework
|
5
|
+
// Copyright: Copyright 2013 Stefan Penner and Ember App Kit Contributors
|
6
|
+
// License: Licensed under MIT license
|
7
|
+
// See https://raw.github.com/stefanpenner/ember-jj-abrams-resolver/master/LICENSE
|
8
|
+
// ==========================================================================
|
9
|
+
|
10
|
+
|
11
|
+
// Version: 0.0.1
|
12
|
+
|
13
|
+
(function() {
|
14
|
+
/*globals define registry requirejs */
|
15
|
+
|
16
|
+
define("resolver",
|
17
|
+
["exports"],
|
18
|
+
function(__exports__) {
|
19
|
+
"use strict";
|
20
|
+
/*
|
21
|
+
* This module defines a subclass of Ember.DefaultResolver that adds two
|
22
|
+
* important features:
|
23
|
+
*
|
24
|
+
* 1) The resolver makes the container aware of es6 modules via the AMD
|
25
|
+
* output. The loader's _seen is consulted so that classes can be
|
26
|
+
* resolved directly via the module loader, without needing a manual
|
27
|
+
* `import`.
|
28
|
+
* 2) is able provide injections to classes that implement `extend`
|
29
|
+
* (as is typical with Ember).
|
30
|
+
*/
|
31
|
+
|
32
|
+
function classFactory(klass) {
|
33
|
+
return {
|
34
|
+
create: function (injections) {
|
35
|
+
if (typeof klass.extend === 'function') {
|
36
|
+
return klass.extend(injections);
|
37
|
+
} else {
|
38
|
+
return klass;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
};
|
42
|
+
}
|
43
|
+
|
44
|
+
var underscore = Ember.String.underscore;
|
45
|
+
var classify = Ember.String.classify;
|
46
|
+
var get = Ember.get;
|
47
|
+
|
48
|
+
function parseName(fullName) {
|
49
|
+
/*jshint validthis:true */
|
50
|
+
|
51
|
+
var nameParts = fullName.split(":"),
|
52
|
+
type = nameParts[0], fullNameWithoutType = nameParts[1],
|
53
|
+
name = fullNameWithoutType,
|
54
|
+
namespace = get(this, 'namespace'),
|
55
|
+
root = namespace;
|
56
|
+
|
57
|
+
return {
|
58
|
+
fullName: fullName,
|
59
|
+
type: type,
|
60
|
+
fullNameWithoutType: fullNameWithoutType,
|
61
|
+
name: name,
|
62
|
+
root: root,
|
63
|
+
resolveMethodName: "resolve" + classify(type)
|
64
|
+
};
|
65
|
+
}
|
66
|
+
|
67
|
+
function chooseModuleName(seen, moduleName) {
|
68
|
+
var underscoredModuleName = Ember.String.underscore(moduleName);
|
69
|
+
|
70
|
+
if (moduleName !== underscoredModuleName && seen[moduleName] && seen[underscoredModuleName]) {
|
71
|
+
throw new TypeError("Ambigous module names: `" + moduleName + "` and `" + underscoredModuleName + "`");
|
72
|
+
}
|
73
|
+
|
74
|
+
if (seen[moduleName]) {
|
75
|
+
return moduleName;
|
76
|
+
} else if (seen[underscoredModuleName]) {
|
77
|
+
return underscoredModuleName;
|
78
|
+
} else {
|
79
|
+
return moduleName;
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
83
|
+
function resolveRouter(parsedName) {
|
84
|
+
/*jshint validthis:true */
|
85
|
+
|
86
|
+
var prefix = this.namespace.modulePrefix,
|
87
|
+
routerModule;
|
88
|
+
|
89
|
+
if (parsedName.fullName === 'router:main') {
|
90
|
+
// for now, lets keep the router at app/router.js
|
91
|
+
if (requirejs._eak_seen[prefix + '/router']) {
|
92
|
+
routerModule = require(prefix + '/router');
|
93
|
+
if (routerModule.default) { routerModule = routerModule.default; }
|
94
|
+
|
95
|
+
return routerModule;
|
96
|
+
}
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
function resolveOther(parsedName) {
|
101
|
+
/*jshint validthis:true */
|
102
|
+
|
103
|
+
var prefix = this.namespace.modulePrefix;
|
104
|
+
Ember.assert('module prefix must be defined', prefix);
|
105
|
+
|
106
|
+
var pluralizedType = parsedName.type + 's';
|
107
|
+
var name = parsedName.fullNameWithoutType;
|
108
|
+
|
109
|
+
var moduleName = prefix + '/' + pluralizedType + '/' + name;
|
110
|
+
|
111
|
+
// allow treat all dashed and all underscored as the same thing
|
112
|
+
// supports components with dashes and other stuff with underscores.
|
113
|
+
var normalizedModuleName = chooseModuleName(requirejs._eak_seen, moduleName);
|
114
|
+
|
115
|
+
if (requirejs._eak_seen[normalizedModuleName]) {
|
116
|
+
var module = require(normalizedModuleName, null, null, true /* force sync */);
|
117
|
+
|
118
|
+
if (module.default) { module = module.default };
|
119
|
+
|
120
|
+
if (module === undefined) {
|
121
|
+
throw new Error(" Expected to find: '" + parsedName.fullName + "' within '" + normalizedModuleName + "' but got 'undefined'. Did you forget to `export default` within '" + normalizedModuleName + "'?");
|
122
|
+
}
|
123
|
+
|
124
|
+
if (this.shouldWrapInClassFactory(module, parsedName)) {
|
125
|
+
module = classFactory(module);
|
126
|
+
}
|
127
|
+
|
128
|
+
if (Ember.ENV.LOG_MODULE_RESOLVER) {
|
129
|
+
Ember.Logger.info('hit', moduleName);
|
130
|
+
}
|
131
|
+
|
132
|
+
return module;
|
133
|
+
} else {
|
134
|
+
if (Ember.ENV.LOG_MODULE_RESOLVER) {
|
135
|
+
Ember.Logger.info('miss', moduleName);
|
136
|
+
}
|
137
|
+
return this._super(parsedName);
|
138
|
+
}
|
139
|
+
}
|
140
|
+
// Ember.DefaultResolver docs:
|
141
|
+
// https://github.com/emberjs/ember.js/blob/master/packages/ember-application/lib/system/resolver.js
|
142
|
+
var Resolver = Ember.DefaultResolver.extend({
|
143
|
+
resolveTemplate: resolveOther,
|
144
|
+
resolveOther: resolveOther,
|
145
|
+
resolveRouter: resolveRouter,
|
146
|
+
parseName: parseName,
|
147
|
+
shouldWrapInClassFactory: function(module, parsedName){
|
148
|
+
return false;
|
149
|
+
},
|
150
|
+
normalize: function(fullName) {
|
151
|
+
// replace `.` with `/` in order to make nested controllers work in the following cases
|
152
|
+
// 1. `needs: ['posts/post']`
|
153
|
+
// 2. `{{render "posts/post"}}`
|
154
|
+
// 3. `this.render('posts/post')` from Route
|
155
|
+
return Ember.String.dasherize(fullName.replace(/\./g, '/'));
|
156
|
+
}
|
157
|
+
});
|
158
|
+
|
159
|
+
__exports__.default = Resolver;
|
160
|
+
});
|
161
|
+
|
162
|
+
})();
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
(function() {
|
167
|
+
|
168
|
+
})();
|
169
|
+
|