cocoon 1.0.14 → 1.0.15
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +87 -70
- data/History.md +8 -0
- data/README.markdown +88 -60
- data/VERSION +1 -1
- data/app/assets/javascripts/cocoon.js +29 -27
- data/cocoon.gemspec +2 -2
- data/spec/generators/install_generator_spec.rb +7 -4
- data/spec/spec_helper.rb +0 -1
- metadata +4 -4
data/Gemfile.lock
CHANGED
@@ -1,97 +1,114 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
rack (~> 1.
|
15
|
-
rack-mount (~> 0.
|
16
|
-
rack-test (~> 0.
|
17
|
-
|
18
|
-
activemodel (3.
|
19
|
-
activesupport (= 3.
|
20
|
-
builder (~>
|
21
|
-
i18n (~> 0.
|
22
|
-
activerecord (3.
|
23
|
-
activemodel (= 3.
|
24
|
-
activesupport (= 3.
|
25
|
-
arel (~> 2.
|
26
|
-
tzinfo (~> 0.3.
|
27
|
-
activeresource (3.
|
28
|
-
activemodel (= 3.
|
29
|
-
activesupport (= 3.
|
30
|
-
activesupport (3.
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
generator_spec (0.8.
|
37
|
-
rails (
|
4
|
+
actionmailer (3.1.3)
|
5
|
+
actionpack (= 3.1.3)
|
6
|
+
mail (~> 2.3.0)
|
7
|
+
actionpack (3.1.3)
|
8
|
+
activemodel (= 3.1.3)
|
9
|
+
activesupport (= 3.1.3)
|
10
|
+
builder (~> 3.0.0)
|
11
|
+
erubis (~> 2.7.0)
|
12
|
+
i18n (~> 0.6)
|
13
|
+
rack (~> 1.3.5)
|
14
|
+
rack-cache (~> 1.1)
|
15
|
+
rack-mount (~> 0.8.2)
|
16
|
+
rack-test (~> 0.6.1)
|
17
|
+
sprockets (~> 2.0.3)
|
18
|
+
activemodel (3.1.3)
|
19
|
+
activesupport (= 3.1.3)
|
20
|
+
builder (~> 3.0.0)
|
21
|
+
i18n (~> 0.6)
|
22
|
+
activerecord (3.1.3)
|
23
|
+
activemodel (= 3.1.3)
|
24
|
+
activesupport (= 3.1.3)
|
25
|
+
arel (~> 2.2.1)
|
26
|
+
tzinfo (~> 0.3.29)
|
27
|
+
activeresource (3.1.3)
|
28
|
+
activemodel (= 3.1.3)
|
29
|
+
activesupport (= 3.1.3)
|
30
|
+
activesupport (3.1.3)
|
31
|
+
multi_json (~> 1.0)
|
32
|
+
arel (2.2.1)
|
33
|
+
builder (3.0.0)
|
34
|
+
diff-lcs (1.1.3)
|
35
|
+
erubis (2.7.0)
|
36
|
+
generator_spec (0.8.4)
|
37
|
+
rails (>= 3.0, < 4.0)
|
38
38
|
rspec-rails
|
39
39
|
git (1.2.5)
|
40
|
-
|
40
|
+
hike (1.2.1)
|
41
|
+
i18n (0.6.0)
|
41
42
|
jeweler (1.6.4)
|
42
43
|
bundler (~> 1.0)
|
43
44
|
git (>= 1.2.5)
|
44
45
|
rake
|
45
|
-
|
46
|
-
|
47
|
-
|
46
|
+
json (1.6.3)
|
47
|
+
json_pure (1.6.3)
|
48
|
+
mail (2.3.0)
|
48
49
|
i18n (>= 0.4.0)
|
49
50
|
mime-types (~> 1.16)
|
50
51
|
treetop (~> 1.4.8)
|
51
|
-
mime-types (1.
|
52
|
-
|
53
|
-
|
54
|
-
rack
|
52
|
+
mime-types (1.17.2)
|
53
|
+
multi_json (1.0.4)
|
54
|
+
polyglot (0.3.3)
|
55
|
+
rack (1.3.5)
|
56
|
+
rack-cache (1.1)
|
57
|
+
rack (>= 0.4)
|
58
|
+
rack-mount (0.8.3)
|
55
59
|
rack (>= 1.0.0)
|
56
|
-
rack-
|
60
|
+
rack-ssl (1.3.2)
|
61
|
+
rack
|
62
|
+
rack-test (0.6.1)
|
57
63
|
rack (>= 1.0)
|
58
|
-
rails (3.
|
59
|
-
actionmailer (= 3.
|
60
|
-
actionpack (= 3.
|
61
|
-
activerecord (= 3.
|
62
|
-
activeresource (= 3.
|
63
|
-
activesupport (= 3.
|
64
|
+
rails (3.1.3)
|
65
|
+
actionmailer (= 3.1.3)
|
66
|
+
actionpack (= 3.1.3)
|
67
|
+
activerecord (= 3.1.3)
|
68
|
+
activeresource (= 3.1.3)
|
69
|
+
activesupport (= 3.1.3)
|
64
70
|
bundler (~> 1.0)
|
65
|
-
railties (= 3.
|
66
|
-
railties (3.
|
67
|
-
actionpack (= 3.
|
68
|
-
activesupport (= 3.
|
71
|
+
railties (= 3.1.3)
|
72
|
+
railties (3.1.3)
|
73
|
+
actionpack (= 3.1.3)
|
74
|
+
activesupport (= 3.1.3)
|
75
|
+
rack-ssl (~> 1.3.2)
|
69
76
|
rake (>= 0.8.7)
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
77
|
+
rdoc (~> 3.4)
|
78
|
+
thor (~> 0.14.6)
|
79
|
+
rake (0.9.2.2)
|
80
|
+
rdoc (3.11)
|
81
|
+
json (~> 1.4)
|
82
|
+
rspec (2.7.0)
|
83
|
+
rspec-core (~> 2.7.0)
|
84
|
+
rspec-expectations (~> 2.7.0)
|
85
|
+
rspec-mocks (~> 2.7.0)
|
86
|
+
rspec-core (2.7.1)
|
87
|
+
rspec-expectations (2.7.0)
|
78
88
|
diff-lcs (~> 1.1.2)
|
79
|
-
rspec-mocks (2.
|
80
|
-
rspec-rails (2.
|
89
|
+
rspec-mocks (2.7.0)
|
90
|
+
rspec-rails (2.7.0)
|
81
91
|
actionpack (~> 3.0)
|
82
92
|
activesupport (~> 3.0)
|
83
93
|
railties (~> 3.0)
|
84
|
-
rspec (~> 2.
|
85
|
-
simplecov (0.4
|
86
|
-
|
87
|
-
|
88
|
-
|
94
|
+
rspec (~> 2.7.0)
|
95
|
+
simplecov (0.5.4)
|
96
|
+
multi_json (~> 1.0.3)
|
97
|
+
simplecov-html (~> 0.5.3)
|
98
|
+
simplecov-html (0.5.3)
|
99
|
+
sprockets (2.0.3)
|
100
|
+
hike (~> 1.2)
|
101
|
+
rack (~> 1.0)
|
102
|
+
tilt (~> 1.1, != 1.3.0)
|
103
|
+
sqlite3 (1.3.5)
|
89
104
|
sqlite3-ruby (1.3.3)
|
90
105
|
sqlite3 (>= 1.3.3)
|
91
106
|
thor (0.14.6)
|
92
|
-
|
107
|
+
tilt (1.3.3)
|
108
|
+
treetop (1.4.10)
|
109
|
+
polyglot
|
93
110
|
polyglot (>= 0.3.1)
|
94
|
-
tzinfo (0.3.
|
111
|
+
tzinfo (0.3.31)
|
95
112
|
|
96
113
|
PLATFORMS
|
97
114
|
ruby
|
data/History.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Change History / Release Notes
|
2
2
|
|
3
|
+
## Version 1.0.15
|
4
|
+
|
5
|
+
* added `data-association-insertion-method` that gives more control over where to insert the new nested fields.
|
6
|
+
It takes a jquery method as parameter that inserts the new data. `before`, `after`, `append`, `prepend`, etc. Default: `before`.
|
7
|
+
* `data-association-insertion-position` is still available and acts as an alias. Probably this will be deprecated in the future.
|
8
|
+
|
9
|
+
|
3
10
|
## Version 1.0.14
|
4
11
|
|
5
12
|
* When playing with `simple_form` and `twitter-bootstrap`, I noticed it is crucial that I call the correct nested-fields function.
|
@@ -29,6 +36,7 @@ If you are using rails < 3.1, you should run
|
|
29
36
|
|
30
37
|
to install the new `cocoon.js` to your `public/javascripts` folder.
|
31
38
|
|
39
|
+
|
32
40
|
## Version 1.0.11
|
33
41
|
|
34
42
|
|
data/README.markdown
CHANGED
@@ -22,29 +22,39 @@ I have a sample project where I demonstrate the use of cocoon with formtastic.
|
|
22
22
|
|
23
23
|
Inside your `Gemfile` add the following:
|
24
24
|
|
25
|
-
|
25
|
+
````ruby
|
26
|
+
gem "cocoon"
|
27
|
+
````
|
26
28
|
|
27
29
|
### Rails 3.1
|
28
30
|
|
29
31
|
Add the following to `application.js` so it compiles to the
|
30
32
|
asset_pipeline
|
31
33
|
|
32
|
-
|
34
|
+
````ruby
|
35
|
+
//= require cocoon
|
36
|
+
````
|
33
37
|
|
34
38
|
### Rails 3.x
|
35
39
|
|
36
40
|
If you are using Rails 3.0.x, you need to run the installation task (since rails 3.1 this is no longer needed):
|
37
41
|
|
38
|
-
|
42
|
+
````ruby
|
43
|
+
rails g cocoon:install
|
44
|
+
````
|
39
45
|
|
40
46
|
This will install the needed javascript file.
|
41
47
|
Inside your `application.html.haml` you will need to add below the default javascripts:
|
42
48
|
|
43
|
-
|
49
|
+
````haml
|
50
|
+
= javascript_include_tag :cocoon
|
51
|
+
````
|
44
52
|
|
45
53
|
or using erb, you write
|
46
54
|
|
47
|
-
|
55
|
+
````ruby
|
56
|
+
<%= javascript_include_tag :cocoon %>
|
57
|
+
````
|
48
58
|
|
49
59
|
That is all you need to do to start using it!
|
50
60
|
|
@@ -52,22 +62,28 @@ That is all you need to do to start using it!
|
|
52
62
|
|
53
63
|
Suppose you have a model `Project`:
|
54
64
|
|
55
|
-
|
65
|
+
````ruby
|
66
|
+
rails g scaffold Project name:string description:string
|
67
|
+
````
|
56
68
|
|
57
69
|
and a project has many `tasks`:
|
58
70
|
|
59
|
-
|
71
|
+
````ruby
|
72
|
+
rails g model Task description:string done:boolean project_id:integer
|
73
|
+
````
|
60
74
|
|
61
75
|
Edit the models to code the relation:
|
62
76
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
77
|
+
````ruby
|
78
|
+
class Project < ActiveRecord::Base
|
79
|
+
has_many :tasks
|
80
|
+
accepts_nested_attributes_for :tasks, :reject_if => :all_blank, :allow_destroy => true
|
81
|
+
end
|
67
82
|
|
68
|
-
|
69
|
-
|
70
|
-
|
83
|
+
class Task < ActiveRecord::Base
|
84
|
+
belongs_to :project
|
85
|
+
end
|
86
|
+
````
|
71
87
|
|
72
88
|
What we want to achieve is to get a form where we can add and remove the tasks dynamically.
|
73
89
|
What we need for this, is that the fields for a new/existing `task` are defined in a partial
|
@@ -79,25 +95,29 @@ We will show the sample usage with the different possible form-builders.
|
|
79
95
|
|
80
96
|
Inside our `projects/_form` partial we then write:
|
81
97
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
98
|
+
````haml
|
99
|
+
- f.inputs do
|
100
|
+
= f.input :name
|
101
|
+
= f.input :description
|
102
|
+
%h3 Tasks
|
103
|
+
#tasks
|
104
|
+
= f.semantic_fields_for :tasks do |task|
|
105
|
+
= render 'task_fields', :f => task
|
106
|
+
.links
|
107
|
+
= link_to_add_association 'add task', f, :tasks
|
108
|
+
-f.buttons do
|
109
|
+
= f.submit 'Save'
|
110
|
+
````
|
93
111
|
|
94
112
|
and inside the `_task_fields` partial we write:
|
95
113
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
114
|
+
````haml
|
115
|
+
.nested-fields
|
116
|
+
= f.inputs do
|
117
|
+
= f.input :description
|
118
|
+
= f.input :done, :as => :boolean
|
119
|
+
= link_to_remove_association "remove task", f
|
120
|
+
````
|
101
121
|
|
102
122
|
That is all there is to it!
|
103
123
|
|
@@ -129,9 +149,11 @@ It takes four parameters:
|
|
129
149
|
- f: referring to the containing form-object
|
130
150
|
- association: the name of the association (plural) of which a new instance needs to be added (symbol or string).
|
131
151
|
- html_options: extra html-options (see `link_to`)
|
132
|
-
There are
|
152
|
+
There are three extra options that allow to control the placement of the new link-data:
|
133
153
|
- `data-association-insertion-node` : the jquery selector of the node
|
134
|
-
- `data-association-insertion-
|
154
|
+
- `data-association-insertion-method` : jquery method that inserts the new data. `before`, `after`, `append`, `prepend`, etc. Default: `before`
|
155
|
+
- `data-association-insertion-position` : old method specifying where to insert new data.
|
156
|
+
- this setting still works but `data-association-insertion-method` takes precedence. may be removed in a future version.
|
135
157
|
|
136
158
|
Optionally you could also leave out the name and supply a block that is captured to give the name (if you want to do something more complicated).
|
137
159
|
|
@@ -153,55 +175,61 @@ Inside the `html_options` you can add an option `:render_options`, and the conta
|
|
153
175
|
form. E.g. especially when using `twitter-bootstrap` and `simple_form` together, the `simple_fields_for` needs the option `:wrapper => 'inline'` which can
|
154
176
|
be handed down as follows:
|
155
177
|
|
156
|
-
|
157
|
-
|
178
|
+
````haml
|
179
|
+
= link_to_add_association 'add something', f, :something, :render_options => {:wrapper => 'inline' }
|
180
|
+
````
|
158
181
|
|
159
182
|
### Callbacks (upon insert and remove of items)
|
160
183
|
|
161
|
-
There is an option to add a callback on insertion or removal. If in your view you have the following snippet to select an `
|
184
|
+
There is an option to add a callback on insertion or removal. If in your view you have the following snippet to select an `owner`
|
162
185
|
(we use slim for demonstration purposes)
|
163
186
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
187
|
+
````haml
|
188
|
+
#owner
|
189
|
+
#owner_from_list
|
190
|
+
= f.association :owner, :collection => Person.all(:order => 'name'), :prompt => 'Choose an existing owner'
|
191
|
+
= link_to_add_association 'add a new person as owner', f, :owner
|
192
|
+
````
|
168
193
|
|
169
194
|
This view part will either let you select an owner from the list of persons, or show the fields to add a new person as owner.
|
170
195
|
|
171
196
|
|
172
197
|
The callbacks can be added as follows:
|
173
198
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
199
|
+
````javascript
|
200
|
+
$(document).ready(function() {
|
201
|
+
$('#owner').bind('insertion-callback',
|
202
|
+
function() {
|
203
|
+
$("#owner_from_list").hide();
|
204
|
+
$("#owner a.add_fields").hide();
|
205
|
+
});
|
206
|
+
$('#owner').bind("removal-callback",
|
207
|
+
function() {
|
208
|
+
$("#owner_from_list").show();
|
209
|
+
$("#owner a.add_fields").show();
|
210
|
+
});
|
211
|
+
});
|
212
|
+
````
|
186
213
|
|
187
214
|
Do note that for the callbacks to work there has to be a surrounding container (div), where you can bind the callbacks to.
|
188
215
|
|
189
216
|
### Control the Insertion behaviour
|
190
217
|
|
191
|
-
The default insertion location is at the back of the current container. But we have added two `data`-attributes that are read to determine the insertion-node and -
|
218
|
+
The default insertion location is at the back of the current container. But we have added two `data`-attributes that are read to determine the insertion-node and -method.
|
192
219
|
|
193
220
|
For example:
|
194
221
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
222
|
+
````javascript
|
223
|
+
$(document).ready(function() {
|
224
|
+
$("#owner a.add_fields").
|
225
|
+
data("association-insertion-method", 'before').
|
226
|
+
data("association-insertion-node", 'this');
|
227
|
+
});
|
228
|
+
````
|
201
229
|
|
202
230
|
The `association-insertion-node` will determine where to add it. You can choose any selector here, or specify this (default it is the parent-container).
|
203
231
|
|
204
|
-
The `association-insertion-
|
232
|
+
The `association-insertion-method` will determine where to add it in relation with the node. Any jQuery DOM Manipulation method can be set but we recommend sticking to any of the following: `before`, `after`, `append`, `prepend`. It is unknown at this time what others would do.
|
205
233
|
|
206
234
|
|
207
235
|
### Partial
|
@@ -224,7 +252,7 @@ There is no limit to the amount of nesting, though.
|
|
224
252
|
|
225
253
|
## Todo
|
226
254
|
|
227
|
-
* add more sample relations: has_many :through
|
255
|
+
* add more sample relations: `has_many :through`, `belongs_to`, ...
|
228
256
|
* improve the tests (test the javascript too)(if anybody wants to lend a hand ...?)
|
229
257
|
|
230
258
|
## Copyright
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.15
|
@@ -11,56 +11,58 @@
|
|
11
11
|
|
12
12
|
$('.add_fields').live('click', function(e) {
|
13
13
|
e.preventDefault();
|
14
|
-
var
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
14
|
+
var $this = $(this),
|
15
|
+
assoc = $this.data('association'),
|
16
|
+
assocs = $this.data('associations'),
|
17
|
+
content = $this.data('template'),
|
18
|
+
insertionMethod = $this.data('association-insertion-method') || $this.data('association-insertion-position') || 'before';
|
19
|
+
insertionNode = $this.data('association-insertion-node'),
|
20
|
+
insertionCallback = $this.data('insertion-callback'),
|
21
|
+
removalCallback = $this.data('removal-callback'),
|
22
|
+
regexp_braced = new RegExp('\\[new_' + assoc + '\\]', 'g'),
|
23
|
+
regexp_underscord = new RegExp('_new_' + assoc + '_', 'g'),
|
24
|
+
new_id = new Date().getTime(),
|
25
|
+
newcontent_braced = '[' + new_id + ']',
|
25
26
|
newcontent_underscord = '_' + new_id + '_',
|
26
|
-
new_content
|
27
|
+
new_content = content.replace(regexp_braced, '[' + new_id + ']');
|
27
28
|
|
28
29
|
if (new_content == content) {
|
29
|
-
regexp_braced
|
30
|
+
regexp_braced = new RegExp('\\[new_' + assocs + '\\]', 'g');
|
30
31
|
regexp_underscord = new RegExp('_new_' + assocs + '_', 'g');
|
31
|
-
new_content
|
32
|
+
new_content = content.replace(regexp_braced, '[' + new_id + ']');
|
32
33
|
}
|
33
34
|
|
34
35
|
new_content = new_content.replace(regexp_underscord, newcontent_underscord);
|
35
36
|
|
36
37
|
if (insertionNode){
|
37
|
-
insertionNode = insertionNode == "this" ? $
|
38
|
+
insertionNode = insertionNode == "this" ? $this : $(insertionNode);
|
38
39
|
} else {
|
39
|
-
insertionNode = $
|
40
|
+
insertionNode = $this.parent();
|
40
41
|
}
|
41
42
|
|
42
43
|
var contentNode = $(new_content);
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
}
|
45
|
+
// allow any of the jquery dom manipulation methods (after, before, append, prepend, etc)
|
46
|
+
// to be called on the node. allows the insertion node to be the parent of the inserted
|
47
|
+
// code and doesn't force it to be a sibling like after/before does. default: 'before'
|
48
|
+
insertionNode[insertionMethod](contentNode);
|
49
49
|
|
50
|
-
$
|
50
|
+
$this.parent().trigger('insertion-callback');
|
51
51
|
});
|
52
52
|
|
53
53
|
$('.remove_fields.dynamic').live('click', function(e) {
|
54
|
-
|
54
|
+
var $this = $(this);
|
55
|
+
trigger_removal_callback($this);
|
55
56
|
e.preventDefault();
|
56
|
-
$
|
57
|
+
$this.closest(".nested-fields").remove();
|
57
58
|
});
|
58
59
|
|
59
60
|
$('.remove_fields.existing').live('click', function(e) {
|
60
|
-
|
61
|
+
var $this = $(this);
|
62
|
+
trigger_removal_callback($this);
|
61
63
|
e.preventDefault();
|
62
|
-
$
|
63
|
-
$
|
64
|
+
$this.prev("input[type=hidden]").val("1");
|
65
|
+
$this.closest(".nested-fields").hide();
|
64
66
|
});
|
65
67
|
|
66
68
|
})(jQuery);
|
data/cocoon.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{cocoon}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.15"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Nathan Van der Auwera"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-12-08}
|
13
13
|
s.description = %q{Unobtrusive nested forms handling, using jQuery. Use this and discover cocoon-heaven.}
|
14
14
|
s.email = %q{nathan@dixis.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -1,4 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'rspec/mocks'
|
3
|
+
require 'rspec/rails/mocks'
|
4
|
+
|
2
5
|
require 'generator_spec/test_case'
|
3
6
|
require 'generators/cocoon/install/install_generator'
|
4
7
|
|
@@ -9,18 +12,18 @@ describe Cocoon::Generators::InstallGenerator do
|
|
9
12
|
|
10
13
|
context "in rails 3.0" do
|
11
14
|
context "with no arguments" do
|
12
|
-
before(:
|
15
|
+
before(:each) do
|
13
16
|
::Rails.stub(:version) { '3.0.8' }
|
14
17
|
prepare_destination
|
15
18
|
run_generator
|
16
19
|
end
|
17
20
|
|
18
21
|
it "stubs the version correctly" do
|
19
|
-
Rails.version[0..2].should == "3.0"
|
22
|
+
::Rails.version[0..2].should == "3.0"
|
20
23
|
end
|
21
24
|
|
22
25
|
it "stubs the version correctly" do
|
23
|
-
test_version = (Rails.version[0..2].to_f >= 3.1)
|
26
|
+
test_version = (::Rails.version[0..2].to_f >= 3.1)
|
24
27
|
test_version.should be_false
|
25
28
|
end
|
26
29
|
|
@@ -32,7 +35,7 @@ describe Cocoon::Generators::InstallGenerator do
|
|
32
35
|
|
33
36
|
context "in rails 3.1" do
|
34
37
|
context "with no arguments" do
|
35
|
-
before(:
|
38
|
+
before(:each) do
|
36
39
|
::Rails.stub(:version) { '3.1.0' }
|
37
40
|
prepare_destination
|
38
41
|
run_generator
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 15
|
10
|
+
version: 1.0.15
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Nathan Van der Auwera
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-12-08 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|