ember-appkit-rails 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ember/appkit/rails.rb +4 -0
- data/lib/ember/appkit/rails/engine.rb +6 -1
- data/lib/ember/appkit/rails/teaspoon.rb +5 -0
- data/lib/ember/appkit/rails/teaspoon/engine.rb +3 -0
- data/lib/ember/appkit/rails/teaspoon/suite.rb +7 -0
- data/lib/ember/appkit/rails/version.rb +1 -1
- data/lib/ember/appkit/rails/views/teaspoon/spec/_eak_rails.html.erb +10 -0
- data/lib/generators/ember/bootstrap_generator.rb +27 -9
- data/lib/generators/ember/component_generator.rb +2 -2
- data/lib/generators/ember/controller_generator.rb +4 -4
- data/lib/generators/ember/generator_helpers.rb +4 -0
- data/lib/generators/ember/install_generator.rb +150 -0
- data/lib/generators/ember/model_generator.rb +7 -2
- data/lib/generators/ember/resource_generator.rb +1 -1
- data/lib/generators/ember/route_generator.rb +2 -2
- data/lib/generators/ember/scaffold_generator.rb +17 -3
- data/lib/generators/ember/serializer_override.rb +18 -0
- data/lib/generators/ember/view_generator.rb +2 -2
- data/{test/dummy/config/adapters/application.js.es6.erb → lib/generators/templates/adapters/application.es6.erb} +0 -0
- data/lib/generators/templates/application.js.erb +1 -0
- data/lib/generators/templates/{array_controller.js.es6 → array_controller.es6} +0 -0
- data/lib/generators/templates/{component.js.es6 → component.es6} +0 -0
- data/lib/generators/templates/{controller.js.es6 → controller.es6} +0 -0
- data/lib/generators/templates/environment.js.erb +2 -0
- data/lib/generators/templates/environments/development.js.erb +5 -5
- data/lib/generators/templates/environments/production.js.erb +2 -2
- data/lib/generators/templates/environments/test.js.erb +1 -1
- data/lib/generators/templates/initializers/teaspoon.rb +63 -0
- data/lib/generators/templates/{model.js.es6 → model.es6} +0 -0
- data/lib/generators/templates/{object_controller.js.es6 → object_controller.es6} +0 -0
- data/lib/generators/templates/{route.js.es6 → route.es6} +0 -0
- data/lib/generators/templates/{router.js.es6 → router.es6} +0 -0
- data/lib/generators/templates/scaffold/route/{edit.js.es6 → edit.es6} +1 -1
- data/lib/generators/templates/scaffold/route/{index.js.es6 → index.es6} +1 -1
- data/lib/generators/templates/scaffold/route/{new.js.es6 → new.es6} +1 -1
- data/lib/generators/templates/scaffold/route/{show.js.es6 → show.es6} +1 -1
- data/lib/generators/templates/scaffold/template/form.hbs +3 -4
- data/lib/generators/templates/scaffold/template/index.hbs +2 -2
- data/lib/generators/templates/scaffold/template/show.hbs +2 -2
- data/lib/generators/templates/scaffold_controller/controller.rb +2 -2
- data/lib/generators/templates/test/model.es6 +7 -0
- data/lib/generators/templates/test/route.es6 +23 -0
- data/lib/generators/templates/test/teaspoon_env.rb +38 -0
- data/lib/generators/templates/test/test_helper.js +55 -0
- data/lib/generators/templates/{view.js.es6 → view.es6} +0 -0
- data/test/dummy/config/adapters/application.es6.erb +3 -0
- data/test/dummy/config/application.js +1 -0
- data/test/dummy/config/environment.js.erb +2 -0
- data/test/dummy/config/environments/development.js.erb +5 -5
- data/test/dummy/config/environments/production.js.erb +2 -2
- data/test/dummy/config/environments/test.js.erb +1 -1
- data/test/dummy/config/initializers/secret_token.rb +1 -1
- data/test/dummy/config/initializers/teaspoon.rb +63 -0
- data/test/dummy/config/{router.js.es6 → router.es6} +0 -0
- data/test/dummy/log/test.log +71 -8
- data/test/dummy/test/teaspoon_env.rb +38 -0
- data/test/dummy/test/test_helper.js +55 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/{eeb5bd38d1dad0d908461fd114f702bc → 08230536deeb8bca57aa54c1cf9a8a67} +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/0f4e288e1e01cda64059f8f521519f5a +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/{492d1909e24832f58ebca96dade2a876 → 1318d49b0a8b80264cc6d140438953bf} +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/39492898b23538577ff8db562a35fb7c +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/3f9cb5a26b08b9e25de91fe142228ad2 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/4a1d4e32cd7b9fd1c62bfd553ae56051 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/4d3cadf0ab91b4a77adf81282a5550a1 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/{1f15c49a05b13c3a7ee50d2ac3900f38 → 571f65ff5db500e9ad70fc11060270a8} +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/660bc633c8899c6c1b20514637fa0169 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/67afcba9807cd5e57b80b5fdf9f26758 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/{47fb03bce147145961cb3deeafca54d7 → 7190c4707840ff0d7c60920ae9739c79} +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/7ca4966e0a480430a858a7ab74518c75 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/83030d43d9bff738a1a01366d61d7691 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/83af35bb6b852de883a26a9458fd4e3a +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/8adfb5e646dca2c629e5d3dc88e2c2e9 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/9160f792acb62d1f7721c714681fcfe6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/a6a0d79927cb0ec286aa0afb9812685c +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/{66c0ce49a71def0f29dcf0bcaf8fb28d → c4eca8931f39b747ea9f916a3b42d8da} +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/cdbe9110f011148cc7a1f172dc18a883 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d5a48c6656341c56cac8a8e42bb925a5 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/{d4cb455bee790d041fb3111fb1636531 → d5b1e7219e29c039a8ebb0a4e5b19a2b} +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/{ce7582379ff02bb25cee3ac0486fe1f2 → d5ce5243d4ca4a3739a15e60e3c685ba} +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/de0932670a6c856bc6eda1586fd29061 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/e9abb671d48f6ff2be6ffb463ea652bf +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/{e36a853a1349d7f33f6c0083c05f897b → fb43f1b92235ac87bedc9ac12be00188} +0 -0
- data/test/dummy/tmp/generator_test_output/app/views/{post.js.es6 → post.es6} +0 -0
- data/test/fixtures/vcr_cassettes/fetch_ember_beta.yml +39609 -0
- data/test/fixtures/vcr_cassettes/fetch_ember_canary.yml +41381 -0
- data/test/fixtures/vcr_cassettes/fetch_ember_data_tagged.yml +4283 -0
- data/test/fixtures/vcr_cassettes/fetch_ember_release.yml +38824 -0
- data/test/fixtures/vcr_cassettes/fetch_ember_tagged.yml +29518 -0
- data/test/generators/bootstrap_generator_test.rb +12 -4
- data/test/generators/component_generator_test.rb +6 -6
- data/test/generators/controller_generator_test.rb +5 -5
- data/test/generators/install_generator_test.rb +163 -0
- data/test/generators/model_generator_test.rb +29 -7
- data/test/generators/resource_generator_test.rb +6 -6
- data/test/generators/route_generator_test.rb +1 -1
- data/test/generators/scaffold_generator_test.rb +59 -10
- data/test/generators/serializer_override_test.rb +19 -0
- data/test/generators/view_generator_test.rb +6 -6
- data/test/integration/engine_test.rb +4 -0
- data/test/support/generator_test_support.rb +2 -2
- data/vendor/assets/javascripts/{app.js.es6.erb → app.es6.erb} +3 -1
- data/vendor/assets/javascripts/ember-appkit/index.js +0 -1
- data/vendor/assets/javascripts/ember-appkit/resolver.js +235 -32
- data/vendor/assets/javascripts/fake_xml_http_request.js +473 -0
- data/vendor/assets/javascripts/fakehr.js +52 -0
- data/vendor/assets/javascripts/httpRespond.js +24 -0
- metadata +126 -55
- data/lib/generators/templates/adapter.js.erb +0 -3
- data/test/dummy/tmp/cache/assets/test/sprockets/10fe949cc641775f5630b5dad6deb5fc +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/129b422236f443119233cdb0a4525a06 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/25b8b60341168a02f48dabd2b0aa82ad +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/827fafc13575b345cc572fd041ef1fba +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/83a9a7d15d681a382363d2bccb9528bb +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/de94a60b438eb5bf57653f3a220acd80 +0 -0
- data/vendor/assets/javascripts/ember-appkit/resolver_ext.js +0 -40
@@ -25,7 +25,7 @@ class BootstrapGeneratorTest < Rails::Generators::TestCase
|
|
25
25
|
run_generator ["-a", custom_path]
|
26
26
|
|
27
27
|
assert_files custom_path, config_path
|
28
|
-
assert_file 'config/application.rb', /config\.ember\.
|
28
|
+
assert_file 'config/application.rb', /config\.ember\.paths\.app = '#{custom_path}'/
|
29
29
|
end
|
30
30
|
|
31
31
|
test "create bootstrap with and custom config path" do
|
@@ -33,7 +33,7 @@ class BootstrapGeneratorTest < Rails::Generators::TestCase
|
|
33
33
|
run_generator ["-c", custom_path]
|
34
34
|
|
35
35
|
assert_files app_path, custom_path
|
36
|
-
assert_file 'config/application.rb', /config\.ember\.
|
36
|
+
assert_file 'config/application.rb', /config\.ember\.paths\.config = '#{custom_path}'/
|
37
37
|
end
|
38
38
|
|
39
39
|
test "create bootstrap with custom app name" do
|
@@ -95,14 +95,22 @@ class BootstrapGeneratorTest < Rails::Generators::TestCase
|
|
95
95
|
private
|
96
96
|
|
97
97
|
def assert_files(app_path = app_path, config_path = config_path)
|
98
|
+
%W{models controllers views routes components templates templates/components mixins}.each do |dir|
|
99
|
+
assert_directory "#{app_path}/#{dir}"
|
100
|
+
end
|
101
|
+
assert_directory "#{config_path}/serializers"
|
102
|
+
|
98
103
|
assert_file "#{config_path}/environment.js.erb"
|
99
104
|
assert_file "#{config_path}/environments/development.js.erb"
|
100
105
|
assert_file "#{config_path}/environments/production.js.erb"
|
101
106
|
assert_file "#{config_path}/environments/test.js.erb"
|
102
107
|
assert_file "#{config_path}/application.js"
|
103
|
-
assert_file "#{config_path}/router.
|
104
|
-
assert_file "#{config_path}/adapters/application.
|
108
|
+
assert_file "#{config_path}/router.es6"
|
109
|
+
assert_file "#{config_path}/adapters/application.es6.erb"
|
105
110
|
assert_file "#{config_path}/initializers/csrf.js"
|
111
|
+
assert_file "config/initializers/teaspoon.rb"
|
112
|
+
assert_file "test/teaspoon_env.rb"
|
113
|
+
assert_file "test/test_helper.js"
|
106
114
|
end
|
107
115
|
|
108
116
|
def confirm_turbolinks_removed(file)
|
@@ -11,31 +11,31 @@ class ComponentGeneratorTest < Rails::Generators::TestCase
|
|
11
11
|
|
12
12
|
test "default_component" do
|
13
13
|
run_generator ["PostChart"]
|
14
|
-
assert_file "#{app_path}/components/post-chart.
|
14
|
+
assert_file "#{app_path}/components/post-chart.es6"
|
15
15
|
assert_file "#{app_path}/templates/components/post-chart.hbs"
|
16
16
|
end
|
17
17
|
|
18
18
|
test "Assert files are properly created (CamelCase)" do
|
19
19
|
run_generator %w(PostChart)
|
20
|
-
assert_file "#{app_path}/components/post-chart.
|
20
|
+
assert_file "#{app_path}/components/post-chart.es6"
|
21
21
|
assert_file "#{app_path}/templates/components/post-chart.hbs"
|
22
22
|
end
|
23
23
|
|
24
24
|
test "Assert object names are properly created with CamelCase name" do
|
25
25
|
run_generator %w(PostChart)
|
26
|
-
assert_file "#{app_path}/components/post-chart.
|
26
|
+
assert_file "#{app_path}/components/post-chart.es6"
|
27
27
|
assert_file "#{app_path}/templates/components/post-chart.hbs"
|
28
28
|
end
|
29
29
|
|
30
30
|
test "Assert files are properly created (lower-case)" do
|
31
31
|
run_generator %w(post-chart)
|
32
|
-
assert_file "#{app_path}/components/post-chart.
|
32
|
+
assert_file "#{app_path}/components/post-chart.es6"
|
33
33
|
assert_file "#{app_path}/templates/components/post-chart.hbs"
|
34
34
|
end
|
35
35
|
|
36
36
|
test "Assert object names are properly created with lower-case name" do
|
37
37
|
run_generator %w(post-chart)
|
38
|
-
assert_file "#{app_path}/components/post-chart.
|
38
|
+
assert_file "#{app_path}/components/post-chart.es6"
|
39
39
|
assert_file "#{app_path}/templates/components/post-chart.hbs"
|
40
40
|
end
|
41
41
|
|
@@ -44,7 +44,7 @@ class ComponentGeneratorTest < Rails::Generators::TestCase
|
|
44
44
|
|
45
45
|
with_config paths: {app: custom_path} do
|
46
46
|
run_generator ["PostChart"]
|
47
|
-
assert_file "#{custom_path}/components/post-chart.
|
47
|
+
assert_file "#{custom_path}/components/post-chart.es6"
|
48
48
|
assert_file "#{custom_path}/templates/components/post-chart.hbs"
|
49
49
|
end
|
50
50
|
end
|
@@ -11,22 +11,22 @@ class ControllerGeneratorTest < Rails::Generators::TestCase
|
|
11
11
|
|
12
12
|
test "array_controller" do
|
13
13
|
run_generator ["post", "--array"]
|
14
|
-
assert_file "#{app_path}/controllers/post.
|
14
|
+
assert_file "#{app_path}/controllers/post.es6"
|
15
15
|
end
|
16
16
|
|
17
17
|
test "object_controller" do
|
18
18
|
run_generator ["post", "--object"]
|
19
|
-
assert_file "#{app_path}/controllers/post.
|
19
|
+
assert_file "#{app_path}/controllers/post.es6"
|
20
20
|
end
|
21
21
|
|
22
22
|
test "default_controller" do
|
23
23
|
run_generator ["post"]
|
24
|
-
assert_file "#{app_path}/controllers/post.
|
24
|
+
assert_file "#{app_path}/controllers/post.es6"
|
25
25
|
end
|
26
26
|
|
27
27
|
test "Assert files are properly created" do
|
28
28
|
run_generator %w(ember)
|
29
|
-
assert_file "#{app_path}/controllers/ember.
|
29
|
+
assert_file "#{app_path}/controllers/ember.es6"
|
30
30
|
end
|
31
31
|
|
32
32
|
test "Uses config.ember.appkit.paths.app" do
|
@@ -34,7 +34,7 @@ class ControllerGeneratorTest < Rails::Generators::TestCase
|
|
34
34
|
|
35
35
|
with_config paths: {app: custom_path} do
|
36
36
|
run_generator ["post", "--object"]
|
37
|
-
assert_file "#{custom_path}/controllers/post.
|
37
|
+
assert_file "#{custom_path}/controllers/post.es6"
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
@@ -0,0 +1,163 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'generators/ember/install_generator'
|
3
|
+
require 'vcr'
|
4
|
+
|
5
|
+
|
6
|
+
class InstallGeneratorTest < Rails::Generators::TestCase
|
7
|
+
tests Ember::Generators::InstallGenerator
|
8
|
+
destination File.join(Rails.root, "tmp", "generator_test_output")
|
9
|
+
|
10
|
+
setup :prepare_destination, :set_test_environment
|
11
|
+
|
12
|
+
def copy_directory(dir)
|
13
|
+
source = Rails.root.join(dir)
|
14
|
+
dest = Rails.root.join("tmp", "generator_test_output", File.dirname(dir))
|
15
|
+
|
16
|
+
FileUtils.mkdir_p dest
|
17
|
+
FileUtils.cp_r source, dest
|
18
|
+
end
|
19
|
+
|
20
|
+
def set_test_environment
|
21
|
+
ENV['THOR_DEBUG'] = '1'
|
22
|
+
VCR.configure do |c|
|
23
|
+
c.cassette_library_dir = 'test/fixtures/vcr_cassettes'
|
24
|
+
c.hook_into :webmock # or :fakeweb
|
25
|
+
c.default_cassette_options = { :record => :new_episodes }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def create_directory(dir)
|
30
|
+
dest = Rails.root.join("tmp", "generator_test_output", dir)
|
31
|
+
FileUtils.mkdir_p dest
|
32
|
+
end
|
33
|
+
|
34
|
+
test "without any options it load the release channel" do
|
35
|
+
|
36
|
+
VCR.use_cassette('fetch_ember_release') do
|
37
|
+
run_generator
|
38
|
+
assert_all_ember_files
|
39
|
+
# assert_all_ember_data_files TODO: Remove after ember data is released
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
test "with options channel=release it should load the release ember-data & ember files" do
|
44
|
+
VCR.use_cassette('fetch_ember_release') do
|
45
|
+
run_generator ['--channel=release']
|
46
|
+
assert_all_ember_files
|
47
|
+
# assert_all_ember_data_files TODO: Remove after ember data is released
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
test "with options channel=beta it should load the beta ember-data & ember files" do
|
53
|
+
VCR.use_cassette('fetch_ember_beta') do
|
54
|
+
run_generator ['--channel=beta']
|
55
|
+
assert_all_ember_files
|
56
|
+
assert_all_ember_data_files
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
test "with options channel=canary it should load the beta ember-data & ember files" do
|
61
|
+
VCR.use_cassette('fetch_ember_canary') do
|
62
|
+
run_generator ['--channel=canary']
|
63
|
+
assert_all_ember_files
|
64
|
+
assert_all_ember_data_files
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
test "with unknown channel option it should raise exception InvalidChannel" do
|
69
|
+
assert_raise ::InvalidChannel do
|
70
|
+
run_generator ['--channel=unkown']
|
71
|
+
end
|
72
|
+
assert_no_ember_files
|
73
|
+
assert_no_ember_data_files
|
74
|
+
end
|
75
|
+
|
76
|
+
test "with option ember_only it should only load ember" do
|
77
|
+
VCR.use_cassette('fetch_ember_release') do
|
78
|
+
run_generator ['--ember_only']
|
79
|
+
end
|
80
|
+
assert_all_ember_files
|
81
|
+
assert_no_ember_data_files
|
82
|
+
end
|
83
|
+
|
84
|
+
test "option --ember aliases --ember_only" do
|
85
|
+
VCR.use_cassette('fetch_ember_release') do
|
86
|
+
run_generator ['--ember']
|
87
|
+
end
|
88
|
+
assert_all_ember_files
|
89
|
+
assert_no_ember_data_files
|
90
|
+
end
|
91
|
+
|
92
|
+
test "with option ember-data_only it should only load ember" do
|
93
|
+
VCR.use_cassette('fetch_ember_beta') do
|
94
|
+
run_generator ['--ember_data_only', '--channel=beta']
|
95
|
+
end
|
96
|
+
assert_no_ember_files
|
97
|
+
assert_all_ember_data_files
|
98
|
+
end
|
99
|
+
|
100
|
+
|
101
|
+
test "option --ember-data aliasses --ember_data_only" do
|
102
|
+
VCR.use_cassette('fetch_ember_beta') do
|
103
|
+
run_generator ['--ember-data', '--channel=beta']
|
104
|
+
end
|
105
|
+
assert_no_ember_files
|
106
|
+
assert_all_ember_data_files
|
107
|
+
end
|
108
|
+
|
109
|
+
|
110
|
+
test "with options --tag=v1.0.0-beta.1 --ember-data" do
|
111
|
+
VCR.use_cassette('fetch_ember_data_tagged') do
|
112
|
+
run_generator ['--tag=v1.0.0-beta.1', '--ember-data']
|
113
|
+
end
|
114
|
+
assert_no_ember_files
|
115
|
+
assert_all_ember_data_files
|
116
|
+
end
|
117
|
+
|
118
|
+
|
119
|
+
test "with option --tag=v1.2.0-beta.2 --ember" do
|
120
|
+
VCR.use_cassette('fetch_ember_tagged') do
|
121
|
+
run_generator ['--tag=v1.2.0-beta.2', '--ember']
|
122
|
+
end
|
123
|
+
assert_all_ember_files
|
124
|
+
assert_no_ember_data_files
|
125
|
+
end
|
126
|
+
|
127
|
+
test "with options --channel set and options --tag it should raise exception ConflictingOptions" do
|
128
|
+
assert_raise ::ConflictingOptions do
|
129
|
+
run_generator ['--channel=canary', '--tag=v1.2.0-beta.2/ember']
|
130
|
+
end
|
131
|
+
assert_no_ember_files
|
132
|
+
assert_no_ember_data_files
|
133
|
+
end
|
134
|
+
|
135
|
+
test "with options --tag without --ember or --ember-data it should raise exception InsufficientOptions" do
|
136
|
+
assert_raise ::InsufficientOptions do
|
137
|
+
run_generator ['--tag=v1.2.0-beta.2']
|
138
|
+
end
|
139
|
+
assert_no_ember_files
|
140
|
+
assert_no_ember_data_files
|
141
|
+
end
|
142
|
+
|
143
|
+
|
144
|
+
def assert_all_ember_files
|
145
|
+
assert_file "vendor/assets/javascripts/ember.js"
|
146
|
+
assert_file "vendor/assets/javascripts/ember.prod.js"
|
147
|
+
end
|
148
|
+
|
149
|
+
def assert_all_ember_data_files
|
150
|
+
assert_file "vendor/assets/javascripts/ember-data.js"
|
151
|
+
assert_file "vendor/assets/javascripts/ember-data.prod.js"
|
152
|
+
end
|
153
|
+
|
154
|
+
def assert_no_ember_files
|
155
|
+
assert_no_file "vendor/assets/javascripts/ember.js"
|
156
|
+
assert_no_file "vendor/assets/javascripts/ember.prod.js"
|
157
|
+
end
|
158
|
+
|
159
|
+
def assert_no_ember_data_files
|
160
|
+
assert_no_file "vendor/assets/javascripts/ember-data.js"
|
161
|
+
assert_no_file "vendor/assets/javascripts/ember-data.prod.js"
|
162
|
+
end
|
163
|
+
end
|
@@ -11,29 +11,29 @@ class ModelGeneratorTest < Rails::Generators::TestCase
|
|
11
11
|
|
12
12
|
test "create model" do
|
13
13
|
run_generator ["post", "title:string"]
|
14
|
-
assert_file "#{app_path}/models/post.
|
14
|
+
assert_file "#{app_path}/models/post.es6"
|
15
15
|
end
|
16
16
|
|
17
17
|
test "create namespaced model" do
|
18
18
|
run_generator ["post/dog", "title:string"]
|
19
|
-
assert_file "#{app_path}/models/post/dog.
|
19
|
+
assert_file "#{app_path}/models/post/dog.es6"
|
20
20
|
end
|
21
21
|
|
22
22
|
test "leave parentheses when create model w/o attributes" do
|
23
23
|
run_generator ["post"]
|
24
|
-
assert_file "#{app_path}/models/post.
|
24
|
+
assert_file "#{app_path}/models/post.es6", /export default DS.Model.extend/
|
25
25
|
end
|
26
26
|
|
27
27
|
test "forces pluarl names to singular" do
|
28
28
|
run_generator ["posts"]
|
29
|
-
assert_file "#{app_path}/models/post.
|
30
|
-
assert_no_file "#{app_path}/models/posts.
|
29
|
+
assert_file "#{app_path}/models/post.es6"
|
30
|
+
assert_no_file "#{app_path}/models/posts.es6"
|
31
31
|
end
|
32
32
|
|
33
33
|
test "Assert files are properly created" do
|
34
34
|
run_generator %w(ember)
|
35
35
|
|
36
|
-
assert_file "#{app_path}/models/ember.
|
36
|
+
assert_file "#{app_path}/models/ember.es6"
|
37
37
|
end
|
38
38
|
|
39
39
|
test "Uses config.ember.appkit.paths.app" do
|
@@ -41,7 +41,29 @@ class ModelGeneratorTest < Rails::Generators::TestCase
|
|
41
41
|
|
42
42
|
with_config paths: {app: custom_path} do
|
43
43
|
run_generator ["ember"]
|
44
|
-
assert_file "#{custom_path}/models/ember.
|
44
|
+
assert_file "#{custom_path}/models/ember.es6"
|
45
45
|
end
|
46
46
|
end
|
47
|
+
|
48
|
+
test "create test" do
|
49
|
+
run_generator ["post", "title:string"]
|
50
|
+
assert_file "test/models/post_test.es6"
|
51
|
+
end
|
52
|
+
|
53
|
+
test "imports model for test" do
|
54
|
+
run_generator ["post", "title:string"]
|
55
|
+
|
56
|
+
assert_file 'test/models/post_test.es6', /^import Post from 'app\/models\/post';$/
|
57
|
+
end
|
58
|
+
|
59
|
+
test "create namespaced test" do
|
60
|
+
run_generator ["post/dog", "title:string"]
|
61
|
+
assert_file "test/models/post/dog_test.es6"
|
62
|
+
end
|
63
|
+
|
64
|
+
test "imports namespaced model for test" do
|
65
|
+
run_generator ["post/dog", "title:string"]
|
66
|
+
|
67
|
+
assert_file 'test/models/post/dog_test.es6', /^import Dog from 'app\/models\/post\/dog';$/
|
68
|
+
end
|
47
69
|
end
|
@@ -15,20 +15,20 @@ class ResourceGeneratorTest < Rails::Generators::TestCase
|
|
15
15
|
|
16
16
|
test "create controller" do
|
17
17
|
run_generator ["post"]
|
18
|
-
assert_file "#{app_path}/controllers/posts.
|
18
|
+
assert_file "#{app_path}/controllers/posts.es6"
|
19
19
|
end
|
20
20
|
|
21
21
|
test "create route" do
|
22
22
|
run_generator ["post"]
|
23
|
-
assert_file "#{app_path}/routes/posts.
|
24
|
-
assert_file "#{config_path}/router.
|
23
|
+
assert_file "#{app_path}/routes/posts.es6"
|
24
|
+
assert_file "#{config_path}/router.es6" do |content|
|
25
25
|
assert_match(%r{this.resource\('posts'\);}, content)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
test "skip route" do
|
30
30
|
run_generator ["post", "--skip-route"]
|
31
|
-
assert_no_file "#{app_path}/routes/posts.
|
31
|
+
assert_no_file "#{app_path}/routes/posts.es6"
|
32
32
|
end
|
33
33
|
|
34
34
|
test "Uses config.ember.appkit.paths.app" do
|
@@ -37,8 +37,8 @@ class ResourceGeneratorTest < Rails::Generators::TestCase
|
|
37
37
|
|
38
38
|
with_config paths: {app: custom_path} do
|
39
39
|
run_generator ["post"]
|
40
|
-
assert_file "#{custom_path}/controllers/posts.
|
41
|
-
assert_file "#{custom_path}/routes/posts.
|
40
|
+
assert_file "#{custom_path}/controllers/posts.es6"
|
41
|
+
assert_file "#{custom_path}/routes/posts.es6"
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -9,28 +9,43 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase
|
|
9
9
|
setup :prepare_destination, :copy_router
|
10
10
|
|
11
11
|
test "create template" do
|
12
|
-
run_generator ["post"]
|
12
|
+
run_generator ["post", "published_at:date"]
|
13
13
|
|
14
14
|
assert_files
|
15
|
+
assert_test_files
|
15
16
|
assert_inject_into_router
|
16
17
|
end
|
17
18
|
|
19
|
+
test "with namespaced name" do
|
20
|
+
run_generator ["post/dog"]
|
21
|
+
|
22
|
+
assert_namespaced_model_find
|
23
|
+
end
|
24
|
+
|
25
|
+
|
18
26
|
private
|
19
27
|
|
20
28
|
def assert_files
|
21
|
-
assert_file "#{app_path}/models/post.
|
29
|
+
assert_file "#{app_path}/models/post.es6"
|
30
|
+
assert_file "test/models/post_test.es6"
|
22
31
|
|
23
|
-
assert_file "#{app_path}/routes/posts/edit.
|
24
|
-
assert_file "#{app_path}/routes/posts/index.
|
25
|
-
assert_file "#{app_path}/routes/posts/new.
|
26
|
-
assert_file "#{app_path}/routes/posts/show.
|
32
|
+
assert_file "#{app_path}/routes/posts/edit.es6"
|
33
|
+
assert_file "#{app_path}/routes/posts/index.es6"
|
34
|
+
assert_file "#{app_path}/routes/posts/new.es6"
|
35
|
+
assert_file "#{app_path}/routes/posts/show.es6"
|
27
36
|
|
28
37
|
assert_file "#{app_path}/templates/posts.hbs"
|
29
38
|
assert_file "#{app_path}/templates/posts/edit.hbs"
|
30
|
-
assert_file "#{app_path}/templates/posts/form.hbs"
|
31
|
-
|
39
|
+
assert_file "#{app_path}/templates/posts/form.hbs" do |content|
|
40
|
+
assert_match(/value=publishedAt/, content)
|
41
|
+
end
|
42
|
+
assert_file "#{app_path}/templates/posts/index.hbs" do |content|
|
43
|
+
assert_match(/{{publishedAt}}/, content)
|
44
|
+
end
|
32
45
|
assert_file "#{app_path}/templates/posts/new.hbs"
|
33
|
-
assert_file "#{app_path}/templates/posts/show.hbs"
|
46
|
+
assert_file "#{app_path}/templates/posts/show.hbs" do |content|
|
47
|
+
assert_match(/{{publishedAt}}/, content)
|
48
|
+
end
|
34
49
|
end
|
35
50
|
|
36
51
|
def assert_inject_into_router
|
@@ -41,8 +56,42 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase
|
|
41
56
|
this.route('edit', {path: ':post_id/edit'});
|
42
57
|
});
|
43
58
|
JS
|
44
|
-
assert_file "#{config_path}/router.
|
59
|
+
assert_file "#{config_path}/router.es6" do |content|
|
45
60
|
assert_match(/#{Regexp.escape(js.rstrip)}/m, content)
|
46
61
|
end
|
47
62
|
end
|
63
|
+
|
64
|
+
def assert_namespaced_model_find
|
65
|
+
assert_file "#{app_path}/routes/dogs/edit.es6" do |content|
|
66
|
+
assert_match(/return this\.store\.find\('post\/dog', params.dog_id\);/, content)
|
67
|
+
end
|
68
|
+
assert_file "#{app_path}/routes/dogs/index.es6" do |content|
|
69
|
+
assert_match(/return this\.store\.find\('post\/dog'\);/, content)
|
70
|
+
end
|
71
|
+
assert_file "#{app_path}/routes/dogs/new.es6" do |content|
|
72
|
+
assert_match(/return this\.store\.createRecord\('post\/dog'\);/, content)
|
73
|
+
end
|
74
|
+
assert_file "#{app_path}/routes/dogs/show.es6" do |content|
|
75
|
+
assert_match(/return this\.store\.find\('post\/dog', params.dog_id\);/, content)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def assert_test_files
|
80
|
+
assert_file "test/routes/posts/edit_test.es6" do |content|
|
81
|
+
assert_match(/^import PostsEditRoute from 'app\/routes\/posts\/edit';/, content)
|
82
|
+
assert_match(/'Unit - PostsEditRoute'/, content)
|
83
|
+
end
|
84
|
+
assert_file "test/routes/posts/index_test.es6" do |content|
|
85
|
+
assert_match(/^import PostsIndexRoute from 'app\/routes\/posts\/index';/, content)
|
86
|
+
assert_match(/'Unit - PostsIndexRoute'/, content)
|
87
|
+
end
|
88
|
+
assert_file "test/routes/posts/new_test.es6" do |content|
|
89
|
+
assert_match(/^import PostsNewRoute from 'app\/routes\/posts\/new';/, content)
|
90
|
+
assert_match(/'Unit - PostsNewRoute'/, content)
|
91
|
+
end
|
92
|
+
assert_file "test/routes/posts/show_test.es6" do |content|
|
93
|
+
assert_match(/^import PostsShowRoute from 'app\/routes\/posts\/show';/, content)
|
94
|
+
assert_match(/'Unit - PostsShowRoute'/, content)
|
95
|
+
end
|
96
|
+
end
|
48
97
|
end
|