autoforme 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/spec/unit_spec.rb ADDED
@@ -0,0 +1,449 @@
1
+ require './spec/spec_helper'
2
+
3
+ describe AutoForme do
4
+ before(:all) do
5
+ db_setup(:artists=>[[:name, :string]])
6
+ model_setup(:Artist=>[:artists])
7
+ end
8
+ after(:all) do
9
+ Object.send(:remove_const, :Artist)
10
+ end
11
+
12
+ before do
13
+ app_setup(Artist)
14
+ end
15
+
16
+ it "should handle table class lookup" do
17
+ model.table_class_for(:browse, nil).should == 'table table-bordered table-striped'
18
+ framework.table_class 'foo'
19
+ model.table_class_for(:browse, nil).should == 'foo'
20
+ framework.table_class{|mod, type, req| "#{mod.name} #{type} #{req}"}
21
+ model.table_class_for(:browse, 1).should == 'Artist browse 1'
22
+ model.table_class 'baz'
23
+ model.table_class_for(:browse, nil).should == 'baz'
24
+ model.table_class{|type, req| "#{type} #{req}"}
25
+ model.table_class_for(:browse, :foo).should == 'browse foo'
26
+ end
27
+
28
+ it "should handle per page lookup" do
29
+ model.limit_for(:browse, nil).should == 25
30
+ framework.per_page 1
31
+ model.limit_for(:browse, nil).should == 1
32
+ framework.per_page{|mod, type, req| mod.name.length + type.to_s.length + req}
33
+ model.limit_for(:browse, 3).should == 15
34
+ model.per_page 3
35
+ model.limit_for(:browse, nil).should == 3
36
+ model.per_page{|type, req| type.to_s.length + req}
37
+ model.limit_for(:browse, -1).should == 5
38
+ end
39
+
40
+ it "should handle columns lookup" do
41
+ model.columns_for(:browse, nil).should == [:name]
42
+ framework.columns{|mod, type, req| [mod.name.to_sym, type, req]}
43
+ model.columns_for(:browse, :foo).should == [:Artist, :browse, :foo]
44
+ model.columns [:foo]
45
+ model.columns_for(:browse, nil).should == [:foo]
46
+ model.columns{|type, req| req ? [type] : [:foo]}
47
+ model.columns_for(:browse, true).should == [:browse]
48
+ model.columns_for(:browse, nil).should == [:foo]
49
+ end
50
+
51
+ it "should handle column options lookup" do
52
+ model.column_options_for(:show, nil, :foo).should == {:required=>false}
53
+ model.column_options_for(:browse, nil, :foo).should == {}
54
+ framework.column_options :foo=>{:as=>:textarea}
55
+ model.column_options_for(:browse, :bar, :foo).should == {:as=>:textarea}
56
+ model.column_options_for(:search_form, nil, :foo).should == {:required=>false}
57
+ framework.column_options :foo=>proc{|type, req| {:type=>type, :req=>req}}
58
+ model.column_options_for(:browse, :bar, :foo).should == {:type=>:browse, :req=>:bar}
59
+ framework.column_options{|mod, column, type, req| {mod.name.to_sym=>[type, req, column]}}
60
+ model.column_options_for(:browse, :bar, :foo).should == {:Artist=>[:browse, :bar, :foo]}
61
+ framework.column_options{|mod, column, type, req| {5=>6}}
62
+ model.column_options :foo=>{1=>2}
63
+ model.column_options_for(:browse, nil, :foo).should == {1=>2, 5=>6}
64
+ model.column_options :foo=>proc{|type, req| {:type=>type, :req=>req}}
65
+ model.column_options_for(:browse, nil, :foo).should == {:type=>:browse, :req=>nil, 5=>6}
66
+ model.column_options{|col, type, req| {:type=>type, :req=>req, :col=>col}}
67
+ model.column_options_for(:browse, nil, :foo).should == {:type=>:browse, :req=>nil, :col=>:foo, 5=>6}
68
+ end
69
+
70
+ it "should handle order lookup" do
71
+ model.order_for(:browse, nil).should == nil
72
+ framework.order :bar
73
+ model.order_for(:browse, nil).should == :bar
74
+ framework.order{|mod, type, req| [mod.name.to_sym, type, req]}
75
+ model.order_for(:browse, :foo).should == [:Artist, :browse, :foo]
76
+ model.order [:foo]
77
+ model.order_for(:browse, nil).should == [:foo]
78
+ model.order{|type, req| [type, req]}
79
+ model.order_for(:browse, :foo).should == [:browse, :foo]
80
+ end
81
+
82
+ it "should handle eager lookup" do
83
+ model.eager_for(:browse, nil).should == nil
84
+ model.eager [:foo]
85
+ model.eager_for(:browse, nil).should == [:foo]
86
+ model.eager{|type, req| [type, req]}
87
+ model.eager_for(:browse, 1).should == [:browse, 1]
88
+ end
89
+
90
+ it "should handle eager_graph lookup" do
91
+ model.eager_graph_for(:browse, nil).should == nil
92
+ model.eager_graph [:foo]
93
+ model.eager_graph_for(:browse, nil).should == [:foo]
94
+ model.eager_graph{|type, req| [type, req]}
95
+ model.eager_graph_for(:browse, 1).should == [:browse, 1]
96
+ end
97
+
98
+ it "should handle filter lookup" do
99
+ model.filter_for.should == nil
100
+ framework.filter{|mod| lambda{|ds, type, req| [ds, mod.name.to_sym, type, req]}}
101
+ model.filter_for.call(1, :browse, 2).should == [1, :Artist, :browse, 2]
102
+ model.filter{|ds, type, req| [ds, type, req]}
103
+ model.filter_for.call(1, :browse, 2).should == [1, :browse, 2]
104
+ end
105
+
106
+ it "should handle redirect lookup" do
107
+ model.redirect_for.should == nil
108
+ framework.redirect{|mod| lambda{|obj, type, req| [obj, mod.name.to_sym, type, req]}}
109
+ model.redirect_for.call(1, :new, 2).should == [1, :Artist, :new, 2]
110
+ model.redirect{|obj, type, req| [obj, type, req]}
111
+ model.redirect_for.call(1, :new, 2).should == [1, :new, 2]
112
+ end
113
+
114
+ it "should handle display_name lookup" do
115
+ model.display_name_for.should == nil
116
+ framework.display_name :foo
117
+ model.display_name_for.should == :foo
118
+ framework.display_name{|mod| mod.name.to_sym}
119
+ model.display_name_for.should == :Artist
120
+
121
+ framework.display_name{|mod| proc{|obj, type, req| "#{obj} #{type} #{req}"}}
122
+ model.object_display_name(:show, 1, :foo).should == 'foo show 1'
123
+
124
+ model.display_name :foo
125
+ model.display_name_for.should == :foo
126
+ model.display_name{|obj| obj.to_s}
127
+ model.object_display_name(:show, nil, :foo).should == 'foo'
128
+ model.display_name{|obj, type| "#{obj} #{type}"}
129
+ model.object_display_name(:show, nil, :foo).should == 'foo show'
130
+ model.display_name{|obj, type, req| "#{obj} #{type} #{req}"}
131
+ model.object_display_name(:show, 1, :foo).should == 'foo show 1'
132
+ end
133
+
134
+ it "should handle supported_actions lookup" do
135
+ model.supported_action?(:new, nil).should be_true
136
+ model.supported_action?(:edit, nil).should be_true
137
+ model.supported_action?(:search, nil).should be_true
138
+ framework.supported_actions [:new, :search]
139
+ model.supported_action?(:new, nil).should be_true
140
+ model.supported_action?(:edit, nil).should be_false
141
+ model.supported_action?(:search, nil).should be_true
142
+ framework.supported_actions{|mod, req| req ? [:new] : []}
143
+ model.supported_action?(:new, nil).should be_false
144
+ model.supported_action?(:new, true).should be_true
145
+ model.supported_actions [:edit, :search]
146
+ model.supported_action?(:new, nil).should be_false
147
+ model.supported_action?(:edit, nil).should be_true
148
+ model.supported_action?(:search, nil).should be_true
149
+ model.supported_actions{|req| req ? [:new] : []}
150
+ model.supported_action?(:new, nil).should be_false
151
+ model.supported_action?(:new, true).should be_true
152
+ end
153
+
154
+ it "should handle mtm_associations lookup" do
155
+ model.supported_mtm_edit?('foos', nil).should be_false
156
+ model.supported_mtm_edit?('bars', nil).should be_false
157
+ framework.mtm_associations [:foos]
158
+ model.supported_mtm_edit?('foos', nil).should be_true
159
+ model.supported_mtm_edit?('bars', nil).should be_false
160
+ framework.mtm_associations{|mod, req| req ? [:foos] : [:bars]}
161
+ model.supported_mtm_edit?('foos', nil).should be_false
162
+ model.supported_mtm_edit?('bars', nil).should be_true
163
+ model.supported_mtm_edit?('foos', true).should be_true
164
+ model.supported_mtm_edit?('bars', true).should be_false
165
+ model.mtm_associations ['bars']
166
+ model.supported_mtm_edit?('foos', nil).should be_false
167
+ model.supported_mtm_edit?('bars', nil).should be_true
168
+ model.mtm_associations{|req| req ? ['foos'] : ['bars']}
169
+ model.supported_mtm_edit?('foos', nil).should be_false
170
+ model.supported_mtm_edit?('bars', nil).should be_true
171
+ model.supported_mtm_edit?('foos', true).should be_true
172
+ model.supported_mtm_edit?('bars', true).should be_false
173
+ end
174
+
175
+ it "should handle inline_mtm_associations lookup" do
176
+ model.supported_mtm_update?('foos', nil).should be_false
177
+ model.supported_mtm_update?('bars', nil).should be_false
178
+ framework.inline_mtm_associations [:foos]
179
+ model.supported_mtm_update?('foos', nil).should be_true
180
+ model.supported_mtm_update?('bars', nil).should be_false
181
+ framework.inline_mtm_associations{|mod, req| req ? [:foos] : [:bars]}
182
+ model.supported_mtm_update?('foos', nil).should be_false
183
+ model.supported_mtm_update?('bars', nil).should be_true
184
+ model.supported_mtm_update?('foos', true).should be_true
185
+ model.supported_mtm_update?('bars', true).should be_false
186
+ model.inline_mtm_associations ['bars']
187
+ model.supported_mtm_update?('foos', nil).should be_false
188
+ model.supported_mtm_update?('bars', nil).should be_true
189
+ model.inline_mtm_associations{|req| req ? ['foos'] : ['bars']}
190
+ model.supported_mtm_update?('foos', nil).should be_false
191
+ model.supported_mtm_update?('bars', nil).should be_true
192
+ model.supported_mtm_update?('foos', true).should be_true
193
+ model.supported_mtm_update?('bars', true).should be_false
194
+ end
195
+
196
+ it "should handle association_links lookup" do
197
+ model.association_links_for(:show, nil).should == []
198
+ framework.association_links :foo
199
+ model.association_links_for(:show, nil).should == [:foo]
200
+ framework.association_links{|mod, type, req| [mod.name.to_sym, type, req]}
201
+ model.association_links_for(:show, :foo).should == [:Artist, :show, :foo]
202
+ model.association_links [:bar]
203
+ model.association_links_for(:show, nil).should == [:bar]
204
+ model.association_links{|type, req| [type, req]}
205
+ model.association_links_for(:show, :foo).should == [:show, :foo]
206
+ end
207
+
208
+ it "should handle lazy_load_association_links lookup" do
209
+ model.lazy_load_association_links?(:show, nil).should be_false
210
+ framework.lazy_load_association_links true
211
+ model.lazy_load_association_links?(:show, nil).should be_true
212
+ framework.lazy_load_association_links{|mod, type, req| req > 2}
213
+ model.lazy_load_association_links?(:show, 1).should be_false
214
+ model.lazy_load_association_links?(:show, 3).should be_true
215
+ model.lazy_load_association_links false
216
+ model.lazy_load_association_links?(:show, nil).should be_false
217
+ model.lazy_load_association_links{|type, req| req > 2}
218
+ model.lazy_load_association_links?(:show, 1).should be_false
219
+ model.lazy_load_association_links?(:show, 3).should be_true
220
+ end
221
+
222
+ it "should handle form_attributes lookup" do
223
+ model.form_attributes_for(:show, nil).should == {}
224
+ framework.form_attributes :class=>'foo'
225
+ model.form_attributes_for(:show, nil).should == {:class=>'foo'}
226
+ framework.form_attributes{|mod, type, req| {:class=>"#{mod} #{type} #{req}"}}
227
+ model.form_attributes_for(:show, 1).should == {:class=>'Artist show 1'}
228
+
229
+ framework.form_attributes :class=>'foo'
230
+ model.form_attributes :data=>"bar"
231
+ model.form_attributes_for(:show, nil).should == {:class=>'foo', :data=>'bar'}
232
+ model.form_attributes{|type, req| {:data=>"#{type} #{req}"}}
233
+ model.form_attributes_for(:show, 1).should == {:class=>'foo', :data=>'show 1'}
234
+ end
235
+
236
+ it "should handle form_options lookup" do
237
+ model.form_options_for(:show, nil).should == {}
238
+ framework.form_options :class=>'foo'
239
+ model.form_options_for(:show, nil).should == {:class=>'foo'}
240
+ framework.form_options{|mod, type, req| {:class=>"#{mod} #{type} #{req}"}}
241
+ model.form_options_for(:show, 1).should == {:class=>'Artist show 1'}
242
+
243
+ framework.form_options :class=>'foo'
244
+ model.form_options :data=>"bar"
245
+ model.form_options_for(:show, nil).should == {:class=>'foo', :data=>'bar'}
246
+ model.form_options{|type, req| {:data=>"#{type} #{req}"}}
247
+ model.form_options_for(:show, 1).should == {:class=>'foo', :data=>'show 1'}
248
+ end
249
+
250
+ it "should handle page_header lookup" do
251
+ model.page_header_for(:show, nil).should be_nil
252
+ framework.page_header "foo"
253
+ model.page_header_for(:show, nil).should == 'foo'
254
+ framework.page_header{|mod, type, req| "#{mod} #{type} #{req}"}
255
+ model.page_header_for(:show, 1).should == 'Artist show 1'
256
+ model.page_header "bar"
257
+ model.page_header_for(:show, nil).should == 'bar'
258
+ model.page_header{|type, req| "#{type} #{req}"}
259
+ model.page_header_for(:show, 1).should == 'show 1'
260
+ end
261
+
262
+ it "should handle page_footer lookup" do
263
+ model.page_footer_for(:show, nil).should be_nil
264
+ framework.page_footer "foo"
265
+ model.page_footer_for(:show, nil).should == 'foo'
266
+ framework.page_footer{|mod, type, req| "#{mod} #{type} #{req}"}
267
+ model.page_footer_for(:show, 1).should == 'Artist show 1'
268
+ model.page_footer "bar"
269
+ model.page_footer_for(:show, nil).should == 'bar'
270
+ model.page_footer{|type, req| "#{type} #{req}"}
271
+ model.page_footer_for(:show, 1).should == 'show 1'
272
+ end
273
+
274
+ it "should handle autocompletion options" do
275
+ model.autocomplete_options({})
276
+ model.autocomplete(:type=>:show, :query=>'foo').should == []
277
+ a = Artist.create(:name=>'FooBar')
278
+ model.autocomplete(:type=>:show, :query=>'foo').should == ["#{a.id} - FooBar"]
279
+ model.autocomplete(:type=>:show, :query=>'boo').should == []
280
+ b = Artist.create(:name=>'BooFar')
281
+ model.autocomplete(:type=>:show, :query=>'boo').should == ["#{b.id} - BooFar"]
282
+ model.autocomplete(:type=>:show, :query=>'oo').sort.should == ["#{a.id} - FooBar", "#{b.id} - BooFar"]
283
+
284
+ framework.autocomplete_options :display=>:id
285
+ model.autocomplete(:type=>:show, :query=>a.id.to_s).should == ["#{a.id} - #{a.id}"]
286
+ framework.autocomplete_options{|mod, type, req| {:limit=>req}}
287
+ model.autocomplete(:type=>:show, :query=>'oo', :request=>1).should == ["#{a.id} - FooBar"]
288
+ model.autocomplete_options :display=>:id
289
+ model.autocomplete(:type=>:show, :query=>a.id.to_s).should == ["#{a.id} - #{a.id}"]
290
+
291
+ framework.autocomplete_options({})
292
+ model.autocomplete(:type=>:show, :query=>a.id.to_s).should == ["#{a.id} - #{a.id}"]
293
+ model.autocomplete_options :display=>proc{:id}
294
+ model.autocomplete(:type=>:show, :query=>b.id.to_s).should == ["#{b.id} - #{b.id}"]
295
+ model.autocomplete_options :limit=>1
296
+ model.autocomplete(:type=>:show, :query=>'oo').should == ["#{a.id} - FooBar"]
297
+ model.autocomplete_options :limit=>proc{1}
298
+ model.autocomplete(:type=>:show, :query=>'oo').should == ["#{a.id} - FooBar"]
299
+ model.autocomplete_options :callback=>proc{|ds, opts| ds.reverse_order(:id)}
300
+ model.autocomplete(:type=>:show, :query=>'oo').should == ["#{b.id} - BooFar", "#{a.id} - FooBar"]
301
+
302
+ model.autocomplete_options :filter=>proc{|ds, opts| ds.where(:name=>opts[:query])}
303
+ model.autocomplete(:type=>:show, :query=>'foo').should == []
304
+ model.autocomplete(:type=>:show, :query=>'FooBar').should == ["#{a.id} - FooBar"]
305
+
306
+ model.autocomplete_options{|type, req| {:limit=>req}}
307
+ model.autocomplete(:type=>:show, :query=>'oo', :request=>1).should == ["#{a.id} - FooBar"]
308
+ end
309
+ end
310
+
311
+ describe AutoForme do
312
+ before(:all) do
313
+ db_setup(:artists=>[[:name, :string]], :albums=>[[:name, :string], [:artist_id, :integer, {:table=>:artists}]])
314
+ model_setup(:Artist=>[:artists, [[:one_to_many, :albums]]], :Album=>[:albums, [[:many_to_one, :artist]]])
315
+ end
316
+ after(:all) do
317
+ Object.send(:remove_const, :Album)
318
+ Object.send(:remove_const, :Artist)
319
+ end
320
+
321
+ it "should handle autocompletion options with associations" do
322
+ artist = nil
323
+ model = nil
324
+ app_setup do
325
+ model Artist do
326
+ artist = self
327
+ end
328
+ model Album do
329
+ model = self
330
+ columns [:name, :artist]
331
+ end
332
+ end
333
+
334
+ artist.autocomplete_options({})
335
+ model.autocomplete(:query=>'foo', :association=>:artist).should == []
336
+ a = Artist.create(:name=>'FooBar')
337
+ model.autocomplete(:query=>'foo', :association=>:artist).should == ["#{a.id} - FooBar"]
338
+ model.autocomplete(:query=>'boo', :association=>:artist).should == []
339
+ b = Artist.create(:name=>'BooFar')
340
+ model.autocomplete(:query=>'boo', :association=>:artist).should == ["#{b.id} - BooFar"]
341
+ model.autocomplete(:query=>'oo', :association=>:artist).sort.should == ["#{a.id} - FooBar", "#{b.id} - BooFar"]
342
+ artist.autocomplete_options :display=>:id
343
+ model.autocomplete(:query=>a.id.to_s, :association=>:artist).should == ["#{a.id} - #{a.id}"]
344
+ artist.autocomplete_options :display=>proc{:id}
345
+ model.autocomplete(:query=>b.id.to_s, :association=>:artist).should == ["#{b.id} - #{b.id}"]
346
+ artist.autocomplete_options :limit=>1
347
+ model.autocomplete(:query=>'oo', :association=>:artist).should == ["#{a.id} - FooBar"]
348
+ artist.autocomplete_options :limit=>proc{1}
349
+ model.autocomplete(:query=>'oo', :association=>:artist).should == ["#{a.id} - FooBar"]
350
+ artist.autocomplete_options :callback=>proc{|ds, opts| ds.reverse_order(:id)}
351
+ model.autocomplete(:query=>'oo', :association=>:artist).should == ["#{b.id} - BooFar", "#{a.id} - FooBar"]
352
+
353
+ artist.autocomplete_options :filter=>proc{|ds, opts| ds.where(:name=>opts[:query])}
354
+ model.autocomplete(:query=>'foo', :association=>:artist).should == []
355
+ model.autocomplete(:query=>'FooBar', :association=>:artist).should == ["#{a.id} - FooBar"]
356
+ end
357
+ end
358
+
359
+ describe AutoForme do
360
+ before(:all) do
361
+ db_setup(:artists=>[[:name, :string]], :albums=>[[:name, :string]], :albums_artists=>[[:album_id, :integer, {:table=>:albums}], [:artist_id, :integer, {:table=>:artists}]])
362
+ model_setup(:Artist=>[:artists, [[:many_to_many, :albums]]], :Album=>[:albums, [[:many_to_many, :artists]]])
363
+ end
364
+ after(:all) do
365
+ Object.send(:remove_const, :Album)
366
+ Object.send(:remove_const, :Artist)
367
+ end
368
+
369
+ it "should handle autocompletion options with many to many exclusions" do
370
+ artist = nil
371
+ model = nil
372
+ app_setup do
373
+ model Artist do
374
+ artist = self
375
+ end
376
+ model Album do
377
+ model = self
378
+ end
379
+ end
380
+
381
+ artist.autocomplete_options({})
382
+ model.autocomplete(:query=>'foo', :association=>:artists).should == []
383
+ a = Artist.create(:name=>'FooBar')
384
+ model.autocomplete(:query=>'foo', :association=>:artists).should == ["#{a.id} - FooBar"]
385
+ model.autocomplete(:query=>'boo', :association=>:artists).should == []
386
+ b = Artist.create(:name=>'BooFar')
387
+ model.autocomplete(:query=>'boo', :association=>:artists).should == ["#{b.id} - BooFar"]
388
+ model.autocomplete(:query=>'oo', :association=>:artists).sort.should == ["#{a.id} - FooBar", "#{b.id} - BooFar"]
389
+ c = Album.create(:name=>'Quux')
390
+ c.add_artist(a)
391
+ model.autocomplete(:query=>'oo', :association=>:artists, :exclude=>c.id).sort.should == ["#{b.id} - BooFar"]
392
+ artist.autocomplete_options :display=>:id
393
+ model.autocomplete(:query=>a.id.to_s, :association=>:artists).should == ["#{a.id} - #{a.id}"]
394
+ model.autocomplete(:query=>b.id.to_s, :association=>:artists, :exclude=>c.id).should == ["#{b.id} - #{b.id}"]
395
+ artist.autocomplete_options :display=>proc{:id}
396
+ model.autocomplete(:query=>b.id.to_s, :association=>:artists).should == ["#{b.id} - #{b.id}"]
397
+ model.autocomplete(:query=>a.id.to_s, :association=>:artists, :exclude=>c.id).should == []
398
+ artist.autocomplete_options :limit=>1
399
+ model.autocomplete(:query=>'oo', :association=>:artists).should == ["#{a.id} - FooBar"]
400
+ model.autocomplete(:query=>'oo', :association=>:artists, :exclude=>c.id).should == ["#{b.id} - BooFar"]
401
+ artist.autocomplete_options :limit=>proc{1}
402
+ model.autocomplete(:query=>'oo', :association=>:artists).should == ["#{a.id} - FooBar"]
403
+ model.autocomplete(:query=>'oo', :association=>:artists, :exclude=>c.id).should == ["#{b.id} - BooFar"]
404
+ artist.autocomplete_options :callback=>proc{|ds, opts| ds.reverse_order(:id)}
405
+ model.autocomplete(:query=>'oo', :association=>:artists).should == ["#{b.id} - BooFar", "#{a.id} - FooBar"]
406
+ model.autocomplete(:query=>'oo', :association=>:artists, :exclude=>c.id).should == ["#{b.id} - BooFar"]
407
+
408
+ artist.autocomplete_options :filter=>proc{|ds, opts| ds.where(:name=>opts[:query])}
409
+ model.autocomplete(:query=>'foo', :association=>:artists).should == []
410
+ model.autocomplete(:query=>'FooBar', :association=>:artists).should == ["#{a.id} - FooBar"]
411
+ model.autocomplete(:query=>'FooBar', :association=>:artists, :exclude=>c.id).should == []
412
+ end
413
+ end
414
+
415
+
416
+ describe AutoForme::OptsAttributes do
417
+ before do
418
+ @c = Class.new do
419
+ extend AutoForme::OptsAttributes
420
+ opts_attribute :foo
421
+ attr_accessor :opts
422
+ end
423
+ @o = @c.new
424
+ @o.opts = {}
425
+ end
426
+
427
+ it "should act as a getter if given no arguments, and setter if given arguments or a block" do
428
+ @o.foo.should be_nil
429
+ @o.foo(1).should == 1
430
+ @o.foo.should == 1
431
+ p = proc{}
432
+ @o.foo(&p).should == p
433
+ @o.foo.should == p
434
+ end
435
+
436
+ it "should should raise an error if given more than one argument" do
437
+ proc{@o.foo(1, 2)}.should raise_error(ArgumentError)
438
+ end
439
+
440
+ it "should should raise an error if given block and argument" do
441
+ proc{@o.foo(1){}}.should raise_error(ArgumentError)
442
+ end
443
+ end
444
+
445
+ describe AutoForme do
446
+ it ".version should return a typical version string" do
447
+ AutoForme.version.should =~ /\A\d+\.\d+\.\d+\z/
448
+ end
449
+ end
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: autoforme
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
5
+ platform: ruby
6
+ authors:
7
+ - Jeremy Evans
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: forme
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.9.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.9.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rack
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sequel
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: 3.0.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 3.0.0
55
+ description: |
56
+ AutoForme is an web administrative console for Sequel::Model that
57
+ supports Sinatra and Rails. It offers the following features:
58
+
59
+ * Create, update, edit, and view model objects
60
+ * Browse and search model objects
61
+ * Edit many-to-many relationships for model objects
62
+ * Easily access associated objects
63
+ * Support autocompletion for all objects
64
+ * Allow customization for all likely configuration points, using
65
+ any parameters available in the request
66
+ email: code@jeremyevans.net
67
+ executables: []
68
+ extensions: []
69
+ extra_rdoc_files:
70
+ - README.rdoc
71
+ - CHANGELOG
72
+ - MIT-LICENSE
73
+ files:
74
+ - MIT-LICENSE
75
+ - CHANGELOG
76
+ - README.rdoc
77
+ - Rakefile
78
+ - autoforme.js
79
+ - spec/basic_spec.rb
80
+ - spec/sequel_spec_helper.rb
81
+ - spec/sinatra_spec_helper.rb
82
+ - spec/spec_helper.rb
83
+ - spec/unit_spec.rb
84
+ - spec/associations_spec.rb
85
+ - spec/mtm_spec.rb
86
+ - spec/rails_spec_helper.rb
87
+ - lib/autoforme.rb
88
+ - lib/autoforme/action.rb
89
+ - lib/autoforme/framework.rb
90
+ - lib/autoforme/frameworks/sinatra.rb
91
+ - lib/autoforme/frameworks/rails.rb
92
+ - lib/autoforme/model.rb
93
+ - lib/autoforme/table.rb
94
+ - lib/autoforme/models/sequel.rb
95
+ - lib/autoforme/request.rb
96
+ - lib/autoforme/opts_attributes.rb
97
+ - lib/autoforme/version.rb
98
+ homepage: http://gihub.com/jeremyevans/autoforme
99
+ licenses:
100
+ - MIT
101
+ metadata: {}
102
+ post_install_message:
103
+ rdoc_options:
104
+ - --quiet
105
+ - --line-numbers
106
+ - --inline-source
107
+ - --title
108
+ - 'AutoForme: Web Adminstrative Console for Sinatra/Rails and Sequel'
109
+ - --main
110
+ - README.rdoc
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.0.3
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: Web Adminstrative Console for Sinatra/Rails and Sequel
129
+ test_files: []