ember-konacha-rails 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/EmberStructure.md +129 -0
- data/README.md +73 -12
- data/ember-konacha-rails.gemspec +1 -0
- data/lib/ember/konacha/rails/version.rb +1 -1
- data/lib/ember/resource_controller.rb +86 -0
- data/lib/generators/ember_konacha/install_generator.rb +36 -8
- data/lib/generators/ember_konacha/setup_guide.rb +60 -0
- data/lib/generators/ember_konacha/templates/spec_helper.js.coffee +19 -19
- data/lib/generators/ember_konacha/templates/specs/controller/array_controller_spec.js.coffee.erb +3 -3
- data/lib/generators/ember_konacha/templates/specs/controller/base_controller_spec.js.coffee.erb +1 -1
- data/lib/generators/ember_konacha/templates/specs/model_spec.js.coffee.erb +2 -2
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 417711f4a932963803b19dce898cfca5f0e020ad
|
4
|
+
data.tar.gz: c24adee490dee6614c5a173c863e8a32a2a1fd70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecbf799670c97f937fc638bd6729fe70090a01e20a94c84c2f94878ee09aaf251de88473c15069ccb18ebec2ea574c0dba483785cab2f81233b0b90b5357780f
|
7
|
+
data.tar.gz: 8ebf08d5b905d88f23d97804881f76d03b86dd1bb16d525fd4d02d3722b4580fa97845e87896baea629698a297eab4acbde02aa589e9eac71acea67328eb9bd2
|
data/EmberStructure.md
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
## Ember app structure
|
2
|
+
|
3
|
+
Proposed (recommended) app structure for large Ember app.
|
4
|
+
|
5
|
+
```
|
6
|
+
|
7
|
+
- application.js
|
8
|
+
|
9
|
+
+ app
|
10
|
+
- _loader.js
|
11
|
+
+ authentication
|
12
|
+
+ mixins
|
13
|
+
|
14
|
+
+ config
|
15
|
+
+ locales
|
16
|
+
- locale.js
|
17
|
+
- logging.js
|
18
|
+
- display.js
|
19
|
+
|
20
|
+
+ controllers
|
21
|
+
+ _mixins
|
22
|
+
+ users
|
23
|
+
- user_controller
|
24
|
+
- users_controller
|
25
|
+
- session_controller
|
26
|
+
|
27
|
+
+ helpers
|
28
|
+
+ lib
|
29
|
+
+ mixins
|
30
|
+
|
31
|
+
+ models
|
32
|
+
+ extensions
|
33
|
+
+ mixins
|
34
|
+
- user.js
|
35
|
+
|
36
|
+
+ views
|
37
|
+
+ extensions
|
38
|
+
+ mixins
|
39
|
+
- new_user_view.js
|
40
|
+
- user_view.js
|
41
|
+
- users_view.js
|
42
|
+
|
43
|
+
+ routes
|
44
|
+
+ helpers
|
45
|
+
+ mixins
|
46
|
+
+ shortcuts
|
47
|
+
- user_router.js
|
48
|
+
- index_router.js
|
49
|
+
|
50
|
+
+ state_managers
|
51
|
+
+ templates
|
52
|
+
- config.js
|
53
|
+
- controllers.js
|
54
|
+
- router.js
|
55
|
+
- helpers.js
|
56
|
+
- lib.js
|
57
|
+
- mixins.js
|
58
|
+
- models.js
|
59
|
+
- views.js
|
60
|
+
```
|
61
|
+
|
62
|
+
## application.js
|
63
|
+
|
64
|
+
```
|
65
|
+
# application.js
|
66
|
+
|
67
|
+
#= require modernizr
|
68
|
+
#= require jquery
|
69
|
+
#= require handlebars
|
70
|
+
#= require ruby
|
71
|
+
#= require ember
|
72
|
+
#= require ember-data
|
73
|
+
#= require ember-data-validations
|
74
|
+
#= require ember-formBuilder
|
75
|
+
#= require bootstrap
|
76
|
+
|
77
|
+
#= require app/_loader_
|
78
|
+
|
79
|
+
#= require rails.validations
|
80
|
+
#= require rails.validations.ember
|
81
|
+
|
82
|
+
window.App = Ember.Application.create LOG_TRANSITIONS: true
|
83
|
+
|
84
|
+
# Defer App readiness until it should be advanced for either
|
85
|
+
# testing or production.
|
86
|
+
App.deferReadiness()
|
87
|
+
|
88
|
+
```
|
89
|
+
|
90
|
+
## app/_loader_.js
|
91
|
+
|
92
|
+
Responsible for loading all the Ember app files
|
93
|
+
|
94
|
+
```javascript
|
95
|
+
# app/_loader_.js
|
96
|
+
|
97
|
+
#= require_self
|
98
|
+
|
99
|
+
#= require_tree lib
|
100
|
+
#= require_tree mixins
|
101
|
+
#= require_tree helpers
|
102
|
+
#= require_tree config
|
103
|
+
|
104
|
+
#= require store
|
105
|
+
#= require models
|
106
|
+
#= require controllers
|
107
|
+
#= require views
|
108
|
+
#= require templates
|
109
|
+
|
110
|
+
#= require state_managers
|
111
|
+
#= require authentication
|
112
|
+
#= require router
|
113
|
+
|
114
|
+
```
|
115
|
+
|
116
|
+
## models.js
|
117
|
+
|
118
|
+
Index files such as 'models.js' are useful in order to quickly change the load order of files or add/remove files to be included in the app ;)
|
119
|
+
|
120
|
+
You will likley have specific mixins for models, that should be loaded before the models they are mixed into - the reason for this pattern.
|
121
|
+
|
122
|
+
```javascript
|
123
|
+
# models.js
|
124
|
+
#= require_tree ./models/mixins
|
125
|
+
#= require_tree ./models
|
126
|
+
```
|
127
|
+
|
128
|
+
And so on ...
|
129
|
+
|
data/README.md
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
Generators to help setup an [ember-rails](https://github.com/emberjs/ember-rails) app with [konacha](https://github.com/jfirebaugh/konacha) testing.
|
4
4
|
|
5
|
-
PS: Still young and under development... Please help improve it :)
|
6
|
-
|
7
5
|
## What?
|
8
6
|
|
9
7
|
This gem has the stated goal of making it _easy_ to setup a good testing infrastructure for testing your *Ember-Rails* apps.
|
@@ -36,7 +34,7 @@ You can find more generators/scaffolders as part of [ember-tools](https://github
|
|
36
34
|
|
37
35
|
Add this line to your application's Gemfile:
|
38
36
|
|
39
|
-
gem 'ember-konacha-rails'
|
37
|
+
gem 'ember-konacha-rails'
|
40
38
|
|
41
39
|
And then execute:
|
42
40
|
|
@@ -46,7 +44,6 @@ Or install it yourself (from rubygems) as:
|
|
46
44
|
|
47
45
|
$ gem install ember-konacha-rails
|
48
46
|
|
49
|
-
|
50
47
|
To see if the generators are installed:
|
51
48
|
|
52
49
|
$ rails g
|
@@ -89,6 +86,7 @@ spec/javascripts/app/store_spec.js.coffee
|
|
89
86
|
|
90
87
|
*Clean run (default settings)*
|
91
88
|
|
89
|
+
```
|
92
90
|
$ rails g ember_konacha:install
|
93
91
|
gemfile konacha
|
94
92
|
gemfile poltergeist
|
@@ -102,15 +100,17 @@ Trying to download sinon.js (http://sinonjs.org/releases/sinon-1.6.js) ...
|
|
102
100
|
gsub app/assets/javascripts/application.js.coffee
|
103
101
|
append app/assets/javascripts/application.js.coffee
|
104
102
|
================================================================================
|
103
|
+
```
|
104
|
+
|
105
105
|
Note: poltergeist requires you have installed PhantomJS headless JS driver.
|
106
106
|
|
107
107
|
via Homebrew:
|
108
108
|
|
109
|
-
brew install phantomjs
|
109
|
+
brew install phantomjs
|
110
110
|
|
111
111
|
MacPorts:
|
112
112
|
|
113
|
-
sudo port install phantomjs
|
113
|
+
sudo port install phantomjs
|
114
114
|
|
115
115
|
See https://github.com/jonleighton/poltergeist
|
116
116
|
|
@@ -131,9 +131,16 @@ Now run Konacha!
|
|
131
131
|
|
132
132
|
$ bundle exec rake konacha:run
|
133
133
|
|
134
|
+
To run specs in browser
|
135
|
+
|
136
|
+
$ bundle exec rake konacha:serve
|
137
|
+
$ open http://localhost:3500
|
138
|
+
|
134
139
|
See more run options at https://github.com/jfirebaugh/konacha
|
135
140
|
|
136
|
-
|
141
|
+
## Notice
|
142
|
+
|
143
|
+
Make sure that the following is at the end of your `application.js.coffee` file (or similar for pure javascript):
|
137
144
|
|
138
145
|
```javascript
|
139
146
|
window.App = Ember.Application.create LOG_TRANSITIONS: true
|
@@ -143,17 +150,24 @@ window.App = Ember.Application.create LOG_TRANSITIONS: true
|
|
143
150
|
App.deferReadiness()
|
144
151
|
```
|
145
152
|
|
146
|
-
(or similar for pure javascript)
|
147
|
-
|
148
153
|
The basic test setup/configuration can be found in `support/koncha_config.js.coffee` and `spec_helper.js.coffee` files.
|
149
154
|
|
150
|
-
The `spec_helper` initializes the app explicitly using `App.advanceReadiness()` within `Ember.run` in the `beforeEach` closure. To run your app in the browser, while also allowing for testing, you need to explicitly call `App.advanceReadiness()
|
155
|
+
The `spec_helper` initializes the app explicitly using `App.advanceReadiness()` within `Ember.run` in the `beforeEach` closure. To run your app in the browser, while also allowing for testing, you need to explicitly call `App.advanceReadiness()`, f.ex when your DOM is ready.
|
156
|
+
|
157
|
+
```javascript
|
158
|
+
$ ->
|
159
|
+
App.advanceReadiness()
|
160
|
+
```
|
161
|
+
|
162
|
+
If you run the `install` generator with the `--with-index` option on, it will attempt to generate a standard application layout and index view file, with this all setup for you (using slim templating language!)
|
163
|
+
|
164
|
+
### Install options
|
151
165
|
|
152
166
|
To see install options, run:
|
153
167
|
|
154
168
|
$ rails g ember_konacha:install --help
|
155
169
|
|
156
|
-
Note: To avoid having to `bundle exec` install the gem in your current system gem repository,
|
170
|
+
Note: To avoid having to `bundle exec` install the gem in your current system gem repository, use `gem install ember_konacha` (when this is an official gem!).
|
157
171
|
|
158
172
|
## Guard Koncha config generator
|
159
173
|
|
@@ -203,7 +217,7 @@ Will generate an object controller, since persons is not a valid plural form!
|
|
203
217
|
|
204
218
|
### Generate Helper spec
|
205
219
|
|
206
|
-
$ rails g ember_konacha:
|
220
|
+
$ rails g ember_konacha:helper_spec gravitation
|
207
221
|
|
208
222
|
`spec/javascripts/helpers/gravitation_helper_spec.js.coffee`
|
209
223
|
|
@@ -213,6 +227,51 @@ The install generator will attempt to download sinon.js, first via httparty and
|
|
213
227
|
|
214
228
|
Read more on [http://sinonjs.org/] for mocking, stubbing and creating test spies ;)
|
215
229
|
|
230
|
+
### Application structure
|
231
|
+
|
232
|
+
A proposed [Ember App structure](https://github.com/kristianmandrup/ember-konacha-rails/EmberStructure.md) is included for reference.
|
233
|
+
|
234
|
+
### Ember::ResourceController
|
235
|
+
|
236
|
+
An `Ember::ResourceController` module is now included, which contains utility methods for setting up the Controller actions to respond wth JSON resources.
|
237
|
+
To use it:
|
238
|
+
|
239
|
+
```ruby
|
240
|
+
require 'ember/resource_controller'
|
241
|
+
|
242
|
+
class User
|
243
|
+
include Ember::ResourceController
|
244
|
+
|
245
|
+
# optional: overrides auto-detection via Controller name convention
|
246
|
+
resource :user
|
247
|
+
end
|
248
|
+
```
|
249
|
+
|
250
|
+
Generates controller actions methods:
|
251
|
+
|
252
|
+
```ruby
|
253
|
+
class UsersController
|
254
|
+
def index
|
255
|
+
render_json users
|
256
|
+
end
|
257
|
+
|
258
|
+
def show
|
259
|
+
render_json user
|
260
|
+
end
|
261
|
+
|
262
|
+
def destroy
|
263
|
+
render_json user.destroy
|
264
|
+
end
|
265
|
+
|
266
|
+
def update
|
267
|
+
render_json user.update(user_params)
|
268
|
+
end
|
269
|
+
|
270
|
+
def create
|
271
|
+
render_json user.save
|
272
|
+
end
|
273
|
+
```
|
274
|
+
|
216
275
|
## Contributing
|
217
276
|
|
218
277
|
Please help make it easier for developers tp get started using *Test Driven Development* (or BDD) for Ember with Rails.
|
@@ -222,3 +281,5 @@ Please help make it easier for developers tp get started using *Test Driven Deve
|
|
222
281
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
223
282
|
4. Push to the branch (`git push origin my-new-feature`)
|
224
283
|
5. Create new Pull Request
|
284
|
+
|
285
|
+
Note: This gem could really use some specs ;) Please help out!
|
data/ember-konacha-rails.gemspec
CHANGED
@@ -0,0 +1,86 @@
|
|
1
|
+
module Ember
|
2
|
+
end
|
3
|
+
|
4
|
+
module Ember::ResourceController
|
5
|
+
def self.plural_actions
|
6
|
+
[:index]
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.singular_actions
|
10
|
+
[:show, :destroy, :update, :create]
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.resource name
|
14
|
+
@resource_name = name
|
15
|
+
end
|
16
|
+
|
17
|
+
def index
|
18
|
+
render_json all_resources
|
19
|
+
end
|
20
|
+
|
21
|
+
def show
|
22
|
+
render_json single_resource
|
23
|
+
end
|
24
|
+
|
25
|
+
def destroy
|
26
|
+
render_json single_resource.destroy
|
27
|
+
end
|
28
|
+
|
29
|
+
def update
|
30
|
+
render_json single_resource.update(params)
|
31
|
+
end
|
32
|
+
|
33
|
+
def create
|
34
|
+
render_json single_resource.save
|
35
|
+
end
|
36
|
+
|
37
|
+
protected
|
38
|
+
|
39
|
+
def render_json data, opts = {}
|
40
|
+
render json: data, opts
|
41
|
+
end
|
42
|
+
|
43
|
+
def new_resource
|
44
|
+
@new_resource ||= resource_class.new params
|
45
|
+
end
|
46
|
+
|
47
|
+
def all_resources
|
48
|
+
resource_class.all.to_a
|
49
|
+
end
|
50
|
+
|
51
|
+
def resource
|
52
|
+
@resource ||= resource_class.find resource_id
|
53
|
+
end
|
54
|
+
|
55
|
+
def resource_id
|
56
|
+
params[:id]
|
57
|
+
end
|
58
|
+
|
59
|
+
def params
|
60
|
+
params[resource_name.to_sym]
|
61
|
+
end
|
62
|
+
|
63
|
+
def controller_resource_name
|
64
|
+
@@resource_name || this.clazz.to_s.gsub(/Controller$/, '').demodulize
|
65
|
+
end
|
66
|
+
|
67
|
+
def resource_class
|
68
|
+
resource_class_name.constantize
|
69
|
+
end
|
70
|
+
|
71
|
+
def resource_class_name
|
72
|
+
controller_resource_name.camelize
|
73
|
+
end
|
74
|
+
|
75
|
+
def resource_name
|
76
|
+
@@resource_name || controller_resource_name.singularize
|
77
|
+
end
|
78
|
+
|
79
|
+
def single_resource
|
80
|
+
send resource_name.singularize
|
81
|
+
end
|
82
|
+
|
83
|
+
def all_resources
|
84
|
+
send resource_name.pluralize
|
85
|
+
end
|
86
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'generators/ember_konacha/gem_helper'
|
2
|
+
require 'generators/ember_konacha/setup_guide'
|
2
3
|
|
3
4
|
module EmberKonacha
|
4
5
|
module Generators
|
@@ -15,6 +16,10 @@ module EmberKonacha
|
|
15
16
|
desc: 'Generate default view files for single page app',
|
16
17
|
banner: 'Generate html view (index.html)'
|
17
18
|
|
19
|
+
class_option :guide, type: :boolean, default: false,
|
20
|
+
desc: 'Display a brief Ember Rails setup guide',
|
21
|
+
banner: 'Display setup guide'
|
22
|
+
|
18
23
|
source_root File.expand_path('../templates', __FILE__)
|
19
24
|
|
20
25
|
def do_validations
|
@@ -93,12 +98,30 @@ Using sinon-1.6.js supplied by this gem ;)}
|
|
93
98
|
|
94
99
|
def create_view_files
|
95
100
|
return unless with_index?
|
101
|
+
|
102
|
+
gem 'slim' unless has_gem? 'slim'
|
96
103
|
|
97
|
-
|
98
|
-
|
104
|
+
draw_border
|
105
|
+
say "Creating application index file and layout (slim)", :green
|
106
|
+
|
107
|
+
copy_file 'views/layouts/application.html.slim', 'app/views/layouts/application.html.slim'
|
108
|
+
copy_file 'views/application/index.html.slim', 'app/views/application/index.html.slim'
|
109
|
+
|
110
|
+
bundle_gems!
|
99
111
|
end
|
100
112
|
|
113
|
+
def setup_guide
|
114
|
+
return unless guide?
|
101
115
|
|
116
|
+
draw_border
|
117
|
+
say %q{You might consider using RailsAPI (gem 'rails-api') for the REST API routes
|
118
|
+
The root route should go through a normal Rails controller (< ActionController::Base)
|
119
|
+
}, :green
|
120
|
+
|
121
|
+
draw_border
|
122
|
+
say setup_example, :green
|
123
|
+
end
|
124
|
+
|
102
125
|
def post_install_notice
|
103
126
|
return if skipped_driver?
|
104
127
|
|
@@ -107,14 +130,11 @@ Using sinon-1.6.js supplied by this gem ;)}
|
|
107
130
|
|
108
131
|
protected
|
109
132
|
|
133
|
+
include EmberKonacha::SetupGuide
|
110
134
|
include EmberKonacha::GemHelper
|
111
135
|
|
112
|
-
def
|
113
|
-
|
114
|
-
end
|
115
|
-
|
116
|
-
def skipped_driver?
|
117
|
-
@skipped_driver
|
136
|
+
def draw_border width = 80
|
137
|
+
say border(width), :green
|
118
138
|
end
|
119
139
|
|
120
140
|
def nice text
|
@@ -125,6 +145,14 @@ Using sinon-1.6.js supplied by this gem ;)}
|
|
125
145
|
@border ||= "=" * width + "\n"
|
126
146
|
end
|
127
147
|
|
148
|
+
def skip_driver
|
149
|
+
@skipped_driver = true
|
150
|
+
end
|
151
|
+
|
152
|
+
def skipped_driver?
|
153
|
+
@skipped_driver
|
154
|
+
end
|
155
|
+
|
128
156
|
def coffee?
|
129
157
|
true
|
130
158
|
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module EmberKonacha
|
2
|
+
module SetupGuide
|
3
|
+
def guide?
|
4
|
+
options[:guide]
|
5
|
+
end
|
6
|
+
|
7
|
+
def setup_example
|
8
|
+
%Q{#{routes_ex}
|
9
|
+
#{base_controllers_ex}
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
def routes_ex
|
14
|
+
%q{
|
15
|
+
# Using 'sweet_routing' gem API
|
16
|
+
|
17
|
+
EmberRailsAPI::Application.routes.draw do
|
18
|
+
|
19
|
+
app_root 'application#index'
|
20
|
+
|
21
|
+
json_resource :users, :except => :edit
|
22
|
+
end
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def base_controllers_ex
|
27
|
+
%q{
|
28
|
+
# Only for root page
|
29
|
+
class ApplicationController < ActionController::Base
|
30
|
+
protect_from_forgery
|
31
|
+
|
32
|
+
def index
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Base class for all REST API controllers used with Ember
|
37
|
+
class APIController < ActionController::API
|
38
|
+
end
|
39
|
+
|
40
|
+
# Authorization controller
|
41
|
+
class AuthController < APIController
|
42
|
+
helper_method :current_user_json
|
43
|
+
|
44
|
+
rescue_from CanCan::AccessDenied do |exception|
|
45
|
+
redirect_to root_path, :alert => exception.message
|
46
|
+
end
|
47
|
+
|
48
|
+
# Perhaps check out ActiveSerializer CanCan
|
49
|
+
def current_user_json
|
50
|
+
if current_user
|
51
|
+
UserSerializer.new(current_user, :scope => current_user, :root => false).to_json
|
52
|
+
else
|
53
|
+
{}.to_json
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
}
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#= require sinon
|
3
3
|
|
4
4
|
# Load all testing support files
|
5
|
-
#= require_tree support
|
5
|
+
#= require_tree ./support
|
6
6
|
|
7
7
|
#= require application
|
8
8
|
|
@@ -38,29 +38,29 @@ window.T = Test
|
|
38
38
|
Konacha.reset = Ember.K
|
39
39
|
|
40
40
|
beforeEach( (done) ->
|
41
|
-
|
42
|
-
|
41
|
+
# Fake XHR
|
42
|
+
window.server = TestUtil.fakeServer()
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
# Prevent automatic scheduling of runloops. For tests, we
|
45
|
+
# want to have complete control of runloops.
|
46
|
+
Ember.testing = true
|
47
47
|
|
48
|
-
|
49
|
-
|
48
|
+
# reset all test variables!
|
49
|
+
window.Test = {}
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
51
|
+
Ember.run( ->
|
52
|
+
# Advance App readiness, which was deferred when the app
|
53
|
+
# was created.
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
55
|
+
# This needs to be done here, after each iframe has been setup,
|
56
|
+
# instead of in a global `before`.
|
57
|
+
App.advanceReadiness()
|
58
58
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
)
|
59
|
+
# When App readiness promise resolves, setup is complete
|
60
|
+
App.then( ->
|
61
|
+
done()
|
63
62
|
)
|
63
|
+
)
|
64
64
|
)
|
65
65
|
|
66
66
|
afterEach( ->
|
@@ -74,4 +74,4 @@ afterEach( ->
|
|
74
74
|
|
75
75
|
# Restore XHR
|
76
76
|
window.server.restore()
|
77
|
-
)
|
77
|
+
)
|
data/lib/generators/ember_konacha/templates/specs/controller/array_controller_spec.js.coffee.erb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#= require spec_helper
|
2
2
|
|
3
|
-
describe "
|
3
|
+
describe "<%= array_controller_name %>", ->
|
4
4
|
beforeEach( ->
|
5
5
|
Test.store = TestUtil.lookupStore()
|
6
6
|
|
@@ -11,13 +11,13 @@ describe "#{array_controller_name}", ->
|
|
11
11
|
{id: 3, name: 'Zeus'},
|
12
12
|
])
|
13
13
|
|
14
|
-
controller = <%=
|
14
|
+
controller = <%= array_controller_name %>.create()
|
15
15
|
controller.set 'content', Test.store.findMany(<%= model_name %>, [1, 2, 3])
|
16
16
|
)
|
17
17
|
)
|
18
18
|
|
19
19
|
it "displays items", ->
|
20
|
-
assert.equal controller.get('length'), 3
|
20
|
+
assert.equal controller.get('length'), 3
|
21
21
|
assert.equal controller.objectAt(0).get('id'), '3'
|
22
22
|
assert.equal controller.objectAt(1).get('id'), '2'
|
23
23
|
assert.equal controller.objectAt(2).get('id'), '1'
|
@@ -12,13 +12,13 @@ describe "<%= model_name %>", ->
|
|
12
12
|
describe "attribute: name", ->
|
13
13
|
it "can be created with valid value", ->
|
14
14
|
Ember.run( ->
|
15
|
-
Test.contact = <%=
|
15
|
+
Test.contact = Test.store.createRecord '<%= class_name.downcase %>', name: 'Joe'
|
16
16
|
)
|
17
17
|
expect(Test.contact.get 'name').to.equal 'Joe'
|
18
18
|
|
19
19
|
it "can NOT be created with invalid value", ->
|
20
20
|
Ember.run( ->
|
21
|
-
Test.contact = <%=
|
21
|
+
Test.contact = Test.store.createRecord '<%= class_name.downcase %>', name: '123'
|
22
22
|
)
|
23
23
|
expect(Test.contact.get 'name').to.not.equal 'Joe'
|
24
24
|
expect(Test.contact.isValid).to.be false
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ember-konacha-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kristian Mandrup
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.9'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: konacha
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,6 +88,7 @@ extensions: []
|
|
74
88
|
extra_rdoc_files: []
|
75
89
|
files:
|
76
90
|
- .gitignore
|
91
|
+
- EmberStructure.md
|
77
92
|
- Gemfile
|
78
93
|
- LICENSE.txt
|
79
94
|
- README.md
|
@@ -81,6 +96,7 @@ files:
|
|
81
96
|
- ember-konacha-rails.gemspec
|
82
97
|
- lib/ember/konacha/rails.rb
|
83
98
|
- lib/ember/konacha/rails/version.rb
|
99
|
+
- lib/ember/resource_controller.rb
|
84
100
|
- lib/generators/ember_konacha/base_helper.rb
|
85
101
|
- lib/generators/ember_konacha/controller_spec_generator.rb
|
86
102
|
- lib/generators/ember_konacha/gem_helper.rb
|
@@ -88,6 +104,7 @@ files:
|
|
88
104
|
- lib/generators/ember_konacha/helper_spec_generator.rb
|
89
105
|
- lib/generators/ember_konacha/install_generator.rb
|
90
106
|
- lib/generators/ember_konacha/model_spec_generator.rb
|
107
|
+
- lib/generators/ember_konacha/setup_guide.rb
|
91
108
|
- lib/generators/ember_konacha/templates/.DS_Store
|
92
109
|
- lib/generators/ember_konacha/templates/Guard_konacha.erb
|
93
110
|
- lib/generators/ember_konacha/templates/konacha_config.js.coffee
|