merb-helpers 0.9.12 → 0.9.13

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,10 +1,4 @@
1
- require 'rubygems'
2
- require 'rake/gempackagetask'
3
- require "extlib"
4
- require 'merb-core/tasks/merb_rake_helper'
5
- require "spec/rake/spectask"
6
-
7
- require File.join(File.dirname(__FILE__), "../merb-core/lib/merb-core/version.rb")
1
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "rake_helpers"))
8
2
 
9
3
  ##############################################################################
10
4
  # Package && release
@@ -1,4 +1,4 @@
1
- <%= form_for @obj do %>
1
+ <%= form_for @obj, :action => "/" do %>
2
2
  <%= check_box(:baz) %>
3
3
  <%= check_box(:bat) %>
4
4
  <% end =%>
@@ -1,3 +1,3 @@
1
- <%= form_for @model do %>
1
+ <%= form_for @model, :action => "/" do %>
2
2
  <%= hidden_field(:foo, :bar =>"7") %>
3
3
  <% end =%>
@@ -1,3 +1,3 @@
1
- <%= form_for @obj do %>
1
+ <%= form_for @obj, :action => "/" do %>
2
2
  <%= password_field(:foo, :bar => "7", :label => "LABEL") %>
3
3
  <% end =%>
@@ -1,3 +1,3 @@
1
- <%= form_for @obj do %>
1
+ <%= form_for @obj, :action => "/" do %>
2
2
  <%= radio_button(:foo, :bar => "7", :label => "LABEL") %>
3
3
  <% end =%>
@@ -1,3 +1,3 @@
1
- <%= form_for @obj do %>
1
+ <%= form_for @obj, :action => "/" do %>
2
2
  <%= text_field :foo, :bar => "7", :label => "LABEL" %>
3
3
  <% end =%>
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <title>Fresh Merb App</title>
5
5
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
6
- <link rel="stylesheet" href="/stylesheets/master.css" type="text/css" media="screen" charset="utf-8">
6
+ <link rel="stylesheet" href="/stylesheets/master.css" type="text/css" media="screen" charset="utf-8"/>
7
7
  </head>
8
8
  <body>
9
9
  <%= catch_content :for_layout %>
data/spec/merb.main.pid CHANGED
@@ -1 +1 @@
1
- 13407
1
+ 56944
@@ -120,25 +120,25 @@ describe "form" do
120
120
 
121
121
  it "should use the post method by default" do
122
122
  ret = @c.render(:post_by_default)
123
- ret.should match_tag(:form, :method => "post")
123
+ ret.should have_selector("form[method=post]")
124
124
  ret.should include("CONTENT")
125
125
  end
126
126
 
127
127
  it "should use the get method if set" do
128
128
  ret = @c.render(:get_if_set)
129
- ret.should match_tag(:form, :method => "get")
129
+ ret.should have_selector("form[method=get]")
130
130
  end
131
131
 
132
132
  it "should fake out the put method if set" do
133
133
  ret = @c.render(:fake_put_if_set)
134
- ret.should match_tag(:form, :method => "post")
135
- ret.should match_tag(:input, :type => "hidden", :name => "_method", :value => "put")
134
+ ret.should have_selector("form[method=post]")
135
+ ret.should have_selector("input[type=hidden][name=_method][value=put]")
136
136
  end
137
137
 
138
138
  it "should fake out the delete method if set" do
139
139
  ret = @c.render(:fake_delete_if_set)
140
- ret.should match_tag(:form, :method => "post")
141
- ret.should match_tag(:input, :type => "hidden", :name => "_method", :value => "delete")
140
+ ret.should have_selector("form[method=post]")
141
+ ret.should have_selector("input[type=hidden][name=_method][value=delete]")
142
142
  end
143
143
 
144
144
  # TODO: Why is this required?
@@ -153,14 +153,14 @@ describe "form" do
153
153
  # end
154
154
 
155
155
  it "should take create a form" do
156
- ret = @c.render(:create_a_form)
157
- ret.should match_tag(:form, :action => "foo", :method => "post")
156
+ ret = @c.render(:create_a_form)
157
+ ret.should have_selector("form[action=foo][method=post]")
158
158
  ret.should include("Hello")
159
159
  end
160
160
 
161
161
  it "should set a form to be multipart" do
162
162
  ret = @c.render(:create_a_multipart_form)
163
- ret.should match_tag( :form, :action => "foo", :method => "post", :enctype => "multipart/form-data")
163
+ ret.should have_selector("form[action=foo][method=post][enctype='multipart/form-data']")
164
164
  ret.should include("CONTENT")
165
165
  end
166
166
  end
@@ -175,22 +175,22 @@ describe "form_for" do
175
175
 
176
176
  it "should wrap the contents in a form tag" do
177
177
  form = @c.render :basic
178
- form.should match_tag(:form, :method => "post")
179
- form.should match_tag(:input, :type => "hidden", :value => "put", :name => "_method")
178
+ form.should have_selector("form[method=post]")
179
+ form.should have_selector("input[type=hidden][value=put][name=_method]")
180
180
  end
181
181
 
182
182
  it "should set the method to post be default" do
183
183
  new_fake_model = FakeModel2.new
184
184
  @c.instance_variable_set(:@obj, new_fake_model)
185
185
  form = @c.render :basic
186
- form.should match_tag(:form, :method => "post")
187
- form.should_not match_tag(:input, :type => "hidden", :name => "_method")
186
+ form.should have_selector("form[method=post]")
187
+ form.should_not have_selector("input[type=hidden][name=_method]")
188
188
  end
189
189
 
190
190
  it "should support PUT if the object passed in is not a new_record? via a hidden field" do
191
191
  form = @c.render :basic
192
- form.should match_tag(:form, :method => "post")
193
- form.should match_tag(:input, :type => "hidden", :value => "put", :name => "_method")
192
+ form.should have_selector("form[method=post]")
193
+ form.should have_selector("input[type=hidden][value=put][name=_method]")
194
194
  end
195
195
 
196
196
  end
@@ -206,25 +206,25 @@ describe "fields_for" do
206
206
 
207
207
  it "should dump the contents in the context of the object" do
208
208
  r = @c.render :basic
209
- r.should match_tag(:input, :type => "text", :value => "foowee")
209
+ r.should have_selector("input[type=text][value=foowee]")
210
210
  end
211
211
 
212
212
  it "should be able to modify the context midstream" do
213
213
  @c.instance_variable_set(:@obj2, FakeModel2.new)
214
214
  r = @c.render :midstream
215
- r.should match_tag(:input, :type => "text", :value => "foowee")
216
- r.should match_tag(:input, :name => "fake_model2[foo]", :type => "text", :value => "foowee2")
215
+ r.should have_selector("input[type=text][value=foowee]")
216
+ r.should have_selector("input[name='fake_model2[foo]'][type=text][value=foowee2]")
217
217
  end
218
218
 
219
219
  it "should handle an explicit nil attribute" do
220
220
  r = @c.render :nil
221
- r.should match_tag(:input, :name => "fake_model[foo]", :value => "foowee", :type => "text")
221
+ r.should have_selector("input[name='fake_model[foo]'][value=foowee][type=text]")
222
222
  end
223
223
 
224
224
  it "should pass context back to the old object after exiting block" do
225
225
  @c.instance_variable_set(:@obj2, FakeModel2.new)
226
226
  r = @c.render :midstream
227
- r.should match_tag(:input, :id => "fake_model_foo", :name => "fake_model[foo]", :type => "text", :extra => "true")
227
+ r.should have_selector("input[id=fake_model_foo][name='fake_model[foo]'][type=text][extra=true]")
228
228
  end
229
229
  end
230
230
 
@@ -236,7 +236,7 @@ describe "text_field" do
236
236
 
237
237
  it "should return a basic text field based on the values passed in" do
238
238
  r = @c.render :basic
239
- r.should match_tag( :input, :type => "text", :name => "foo", :value => "bar")
239
+ r.should have_selector("input[type=text][name=foo][value=bar]")
240
240
  end
241
241
 
242
242
  it "should provide an additional label tag if the :label option is passed in" do
@@ -251,7 +251,7 @@ describe "text_field" do
251
251
 
252
252
  it "should be disabled if :disabled => true is passed in" do
253
253
  r = @c.render :disabled
254
- r.should match_tag(:input, :type => "text", :disabled => "disabled")
254
+ r.should have_selector("input[type=text][disabled=disabled]")
255
255
  end
256
256
 
257
257
  it "should provide an additional label tag if the :label option is passed in as a hash" do
@@ -270,24 +270,23 @@ describe "bound_text_field" do
270
270
 
271
271
  it "should take a string object and return a useful text control" do
272
272
  r = @c.render :basic
273
- r.should match_tag(:input, :type => "text", :name => "fake_model[foo]", :value => "foowee")
273
+ r.should have_selector("input[type=text][name='fake_model[foo]'][value=foowee]")
274
274
  end
275
275
 
276
276
  it "should take additional attributes and use them" do
277
277
  r = @c.render :basic
278
- r.should match_tag(:input, :type => "text", :name => "fake_model[foo]", :value => "foowee", :bar => "7")
278
+ r.should have_selector("input[type=text][name='fake_model[foo]'][value=foowee][bar='7']")
279
279
  end
280
280
 
281
281
  it "should provide an additional label tag if the :label option is passed in" do
282
282
  form = @c.render :basic
283
283
  form.should match(/<label.*>LABEL<\/label><input/)
284
- res = form.scan(/<[^>]*>/)
285
- res[2].should_not match_tag(:input, :label => "LABEL")
284
+ form.should_not have_selector("input[label=LABEL]")
286
285
  end
287
286
 
288
287
  it "should not errorify the field for a new object" do
289
288
  r = @c.render :basic
290
- r.should_not match_tag(:input, :type => "text", :name => "fake_model[foo]", :class => "error")
289
+ r.should_not have_selector("input[type=text][name='fake_model[foo]'][class=error]")
291
290
  end
292
291
 
293
292
  it "should errorify a field for a model with errors" do
@@ -301,7 +300,7 @@ describe "bound_text_field" do
301
300
  model.stub!(:errors).and_return(errors)
302
301
  @c.instance_variable_set(:@obj, model)
303
302
  r = @c.render :basic
304
- r.should match_tag(:input, :class => "error text")
303
+ r.should have_selector("input[class='error text']")
305
304
  end
306
305
  end
307
306
 
@@ -314,24 +313,23 @@ describe "bound_radio_button" do
314
313
 
315
314
  it "should take a string object and return a useful text control" do
316
315
  r = @c.render :basic
317
- r.should match_tag(:input, :type => "radio", :name => "fake_model[foo]", :value => "foowee")
316
+ r.should have_selector("input[type=radio][name='fake_model[foo]'][value=foowee]")
318
317
  end
319
318
 
320
319
  it "should take additional attributes and use them" do
321
320
  r = @c.render :basic
322
- r.should match_tag(:input, :type => "radio", :name => "fake_model[foo]", :value => "foowee", :bar => "7")
321
+ r.should have_selector("input[type=radio][name='fake_model[foo]'][value=foowee][bar='7']")
323
322
  end
324
323
 
325
324
  it "should provide an additional label tag if the :label option is passed in" do
326
325
  form = @c.render :basic
327
- form.should match(/<input.*><label.*>LABEL<\/label>/)
328
- res = form.scan(/<[^>]*>/)
329
- res[2].should_not match_tag(:input, :label => "LABEL")
326
+ form.should have_selector("input + label:contains('LABEL')")
327
+ form.should_not have_selector("input[label]")
330
328
  end
331
329
 
332
330
  it "should not errorify the field for a new object" do
333
331
  r = @c.render :basic
334
- r.should_not match_tag(:input, :type => "radio", :name => "fake_model[foo]", :class => "error")
332
+ r.should_not have_selector("input[type=radio][name='fake_model[foo]'][class=error]")
335
333
  end
336
334
 
337
335
  it "should errorify a field for a model with errors" do
@@ -345,7 +343,7 @@ describe "bound_radio_button" do
345
343
  model.stub!(:errors).and_return(errors)
346
344
  @c.instance_variable_set(:@obj, model)
347
345
  r = @c.render :basic
348
- r.should match_tag(:input, :class => "error radio")
346
+ r.should have_selector("input[class='error radio']")
349
347
  end
350
348
  end
351
349
 
@@ -357,12 +355,12 @@ describe "password_field" do
357
355
 
358
356
  it "should return a basic password field, but omit the value" do
359
357
  r = @c.render :basic
360
- r.should match_tag(:input, :type => "password", :name => "foo")
358
+ r.should have_selector("input[type=password][name=foo]")
361
359
  end
362
360
 
363
361
  it "should provide an additional label tag if the :label option is passed in" do
364
362
  r = @c.render :basic
365
- r.should match(/<label.*>LABEL<\/label>/)
363
+ r.should have_selector("label:contains('LABEL')")
366
364
  end
367
365
 
368
366
  it "should be disabled if :disabled => true is passed in" do
@@ -392,8 +390,7 @@ describe "bound_password_field" do
392
390
  it "should provide an additional label tag if the :label option is passed in" do
393
391
  r = @c.render :basic
394
392
  r.should match(/<label.*>LABEL<\/label><input/)
395
- res = r.scan(/<[^>]*>/)
396
- res[2].should_not match_tag(:input, :label => "LABEL")
393
+ r.should_not match_tag(:input, :label => "LABEL")
397
394
  end
398
395
 
399
396
  it "should not errorify the field for a new object" do
@@ -512,7 +509,7 @@ describe "bound_check_box" do
512
509
  it "should take a string and return a useful checkbox control" do
513
510
  r = @c.render :basic
514
511
  r.should match_tag(:input, :type =>"checkbox", :name => "fake_model[baz]", :class => "checkbox", :value => "1", :checked => "checked", :id => "fake_model_baz")
515
- r.should match_tag(:input, :type =>"checkbox", :name => "fake_model[bat]", :class => "checkbox", :value => "0")
512
+ r.should match_tag(:input, :type =>"hidden", :name => "fake_model[baz]", :value => "0")
516
513
  end
517
514
 
518
515
  it "should raise an error if you try to use :value" do
@@ -529,25 +526,27 @@ describe "bound_check_box" do
529
526
  :value => "1",
530
527
  :checked => "checked",
531
528
  :id => "fake_dm_model_baz")
532
- r.should match_tag(:input, :type =>"checkbox", :name => "fake_dm_model[bat]", :class => "checkbox", :value => "0")
529
+
530
+ r.should match_tag(:input, :type =>"hidden", :name => "fake_dm_model[bat]", :value => "0")
531
+ r.should match_tag(:input, :type =>"checkbox", :name => "fake_dm_model[bat]", :class => "checkbox", :value => "1")
533
532
  end
534
533
 
535
534
  it "should allow a user to set the :off value" do
536
535
  r = @c.render :on_and_off
537
- r.should match_tag(:input, :type =>"checkbox", :name => "fake_model[bat]", :class => "checkbox", :value => "off")
536
+ r.should match_tag(:input, :type =>"hidden", :name => "fake_model[bat]", :value => "off")
537
+ r.should match_tag(:input, :type =>"checkbox", :name => "fake_model[bat]", :class => "checkbox", :value => "on")
538
538
  end
539
539
 
540
540
  it "should render controls with errors if their attribute contains an error" do
541
541
  r = @c.render :errors
542
542
  r.should match_tag(:input, :type =>"checkbox", :name => "fake_model[bazbad]", :class => "error checkbox", :value => "1", :checked => "checked")
543
- r.should match_tag(:input, :type =>"checkbox", :name => "fake_model[batbad]", :class => "error checkbox", :value => "0")
543
+ r.should match_tag(:input, :type =>"hidden", :name => "fake_model[batbad]", :value => "0")
544
544
  end
545
545
 
546
546
  it "should provide an additional label tag if the :label option is passed in" do
547
547
  form = @c.render :label
548
548
  form.should match( /<input.*><label.*>LABEL<\/label>/ )
549
- res = form.scan(/<[^>]*>/)
550
- res[0].should_not match_tag(:input, :label => "LABEL")
549
+ form.should_not match_tag(:input, :label => "LABEL")
551
550
  end
552
551
 
553
552
  it "should not errorify the field for a new object" do
@@ -581,7 +580,7 @@ describe "bound_check_box" do
581
580
  it "should be checked if the value of the model's attribute is equal to the value of :on" do
582
581
  r = @c.render :checked
583
582
  r.should match_tag(:input, :type =>"checkbox", :value => "foowee", :checked => "checked")
584
- r.should match_tag(:input, :type =>"checkbox", :value => "YES", :checked => "checked")
583
+ r.should match_tag(:input, :type =>"checkbox", :value => "YES")
585
584
 
586
585
  end
587
586
  end
@@ -705,14 +704,11 @@ describe "radio_group" do
705
704
  it "should accept array of hashes as options" do
706
705
  radio = @c.render :hash
707
706
  radio.scan( /<input.*?><label.*?>(Five|Bar)<\/label>/ ).size.should == 2
708
- radio = radio.scan(/<[^>]*>/)
709
- radio.size.should == 6
710
- radio[0].should match_tag(:input, :value => 5)
711
- radio[1].should match_tag(:label)
712
- radio[2].should match_tag('/label')
713
- radio[3].should match_tag(:input, :value => 'bar', :id => 'bar_id')
714
- radio[4].should match_tag(:label, :for => 'bar_id')
715
- radio[5].should match_tag('/label')
707
+ radio.scan(/<[^>]*>/).size.should == 6
708
+ radio.should match_tag(:input, :value => 5)
709
+ radio.should match_tag(:label)
710
+ radio.should match_tag(:input, :value => 'bar', :id => 'bar_id')
711
+ radio.should match_tag(:label, :for => 'bar_id')
716
712
  end
717
713
 
718
714
  it "should apply attributes to each element" do
@@ -740,10 +736,9 @@ describe "bound_radio_group" do
740
736
 
741
737
  it "should return a group of radio buttons" do
742
738
  r = @c.render :basic
743
- radio = r.scan(/<[^>]*>/)
744
- radio[2].should match_tag(:input, :type => "radio", :name => "fake_model[foo]", :value => "foowee", :checked => "checked")
745
- radio[5].should match_tag(:input, :type => "radio", :name => "fake_model[foo]", :value => "baree")
746
- radio[6].should not_match_tag(:checked => "checked")
739
+ r.should match_tag(:input, :type => "radio", :name => "fake_model[foo]", :value => "foowee", :checked => "checked")
740
+ r.should match_tag(:input, :type => "radio", :name => "fake_model[foo]", :value => "baree")
741
+ r.should_not match_tag(:checked => "checked")
747
742
  end
748
743
 
749
744
  it "should provide an additional label tag for each option in array-based options" do
@@ -757,37 +752,31 @@ describe "bound_radio_group" do
757
752
  it "should accept array of hashes as options" do
758
753
  r = @c.render :hashes
759
754
  r.scan( /<input.*?><label.*?>(Five|Bar)<\/label>/ ).size.should == 2
760
- radio = r.scan(/<[^>]*>/)[2..-2]
761
- radio.size.should == 6
762
- radio[0].should match_tag(:input, :value => 5)
763
- radio[1].should match_tag(:label)
764
- radio[2].should match_tag('/label')
765
- radio[3].should match_tag(:input, :value => 'bar', :id => 'bar_id')
766
- radio[4].should match_tag(:label, :for => 'bar_id')
767
- radio[5].should match_tag('/label')
755
+ r.scan(/<[^>]*>/)[2..-2].size.should == 6
756
+ r.should match_tag(:input, :value => 5)
757
+ r.should match_tag(:label)
758
+ r.should match_tag(:input, :value => 'bar', :id => 'bar_id')
759
+ r.should match_tag(:label, :for => 'bar_id')
768
760
  end
769
761
 
770
762
  it "should provide autogenerated id for inputs" do
771
763
  r = @c.render :mixed
772
- radio = r.scan(/<[^>]*>/)[2..-2]
773
- radio[0].should match_tag(:input, :id => 'fake_model_foo_bar')
774
- radio[1].should match_tag(:label, :for => 'fake_model_foo_bar')
775
- radio[3].should match_tag(:input, :id => 'fake_model_foo_bar')
776
- radio[4].should match_tag(:label, :for => 'fake_model_foo_bar')
764
+ r.should match_tag(:input, :id => 'fake_model_foo_bar')
765
+ r.should match_tag(:label, :for => 'fake_model_foo_bar')
766
+ r.should match_tag(:input, :id => 'fake_model_foo_bar')
767
+ r.should match_tag(:label, :for => 'fake_model_foo_bar')
777
768
  end
778
769
 
779
770
  it "should override autogenerated id for inputs with hash-given id" do
780
771
  r = @c.render :override_id
781
- radio = r.scan(/<[^>]*>/)[2..-2]
782
- radio[0].should match_tag(:input, :id => 'bar_id')
783
- radio[1].should match_tag(:label, :for => 'bar_id')
772
+ r.should match_tag(:input, :id => 'bar_id')
773
+ r.should match_tag(:label, :for => 'bar_id')
784
774
  end
785
775
 
786
776
  it "should only have one element with the checked property" do
787
777
  r = @c.render :basic
788
- radio = r.scan(/<[^>]*>/)[2..-2]
789
- radio[0].should match_tag(:input, :checked => "checked")
790
- radio[3].should_not match_tag(:input, :checked => "false")
778
+ r.should match_tag(:input, :checked => "checked")
779
+ r.should_not match_tag(:input, :checked => "false")
791
780
  end
792
781
  end
793
782
 
@@ -819,8 +808,7 @@ describe "text_area" do
819
808
  it "should render a label when the label is passed in" do
820
809
  result = @c.render :label
821
810
  result.should match(/<label.*>LABEL<\/label><textarea/)
822
- res = result.scan(/<[^>]*>/)
823
- res[1].should_not match_tag(:textarea, :label => "LABEL")
811
+ result.should_not match_tag(:textarea, :label => "LABEL")
824
812
  end
825
813
 
826
814
  it "should be disabled if :disabled => true is passed in" do
@@ -1035,7 +1023,6 @@ describe "option tags" do
1035
1023
 
1036
1024
  it "should not pollute the <select> attributes with <option> attributes" do
1037
1025
  r = @c.render :clean
1038
- r = r.slice(/<select[^>]*>/)
1039
1026
  r.should_not match_tag(:select, :value => "banana", :selected => "selected")
1040
1027
  end
1041
1028
  end
@@ -1048,12 +1035,7 @@ describe "fieldset" do
1048
1035
 
1049
1036
  it "should provide legend option" do
1050
1037
  r = @c.render :legend
1051
- # res = fieldset :legend => 'TEST' do
1052
- # _buffer << "CONTENT"
1053
- # end
1054
- r.should include("CONTENT")
1055
- r.should match_tag(:fieldset, {})
1056
- r.should match_tag(:legend, :content => 'TEST')
1038
+ r.should have_selector("fieldset legend:contains('TEST')")
1057
1039
  end
1058
1040
 
1059
1041
  end
@@ -1066,8 +1048,7 @@ describe "label" do
1066
1048
 
1067
1049
  it "should render a label tag" do
1068
1050
  r = @c.render :basic
1069
- #r = label("First Name", :id => "user_first_name")
1070
- r.should match_tag(:label, :for => "user_first_name", :content => "First Name")
1051
+ r.should have_selector("label[for=user_first_name]:contains('First Name')")
1071
1052
  end
1072
1053
  end
1073
1054
 
@@ -1079,23 +1060,22 @@ describe "file_field" do
1079
1060
 
1080
1061
  it "should return a basic file field based on the values passed in" do
1081
1062
  r = @c.render :with_values
1082
- #file_field(:name => "foo", :value => "bar")
1083
- r.should match_tag( :input, :type => "file", :name => "foo", :value => "bar")
1063
+ r.should have_selector("input[type=file][name=foo][value=bar]")
1084
1064
  end
1085
1065
 
1086
1066
  it "should wrap the field in a label if the :label option is passed to the file" do
1087
1067
  r = @c.render :with_label
1088
- r.should match(/<label>LABEL<\/label><input type="file" class="file"\s*\/>/)
1068
+ r.should have_selector("label:contains('LABEL') + input.file[type=file]")
1089
1069
  end
1090
1070
 
1091
1071
  it "should be disabled if :disabled => true is passed in" do
1092
1072
  r = @c.render :disabled
1093
- r.should match_tag(:input, :type => "file", :disabled => "disabled")
1073
+ r.should have_selector("input[type=file][disabled=disabled]")
1094
1074
  end
1095
1075
 
1096
1076
  it "should make the surrounding form multipart" do
1097
1077
  r = @c.render :makes_multipart
1098
- r.should match_tag(:form, :enctype => "multipart/form-data")
1078
+ r.should have_selector("form[enctype='multipart/form-data']")
1099
1079
  end
1100
1080
  end
1101
1081
 
@@ -1108,22 +1088,18 @@ describe "bound_file_field" do
1108
1088
 
1109
1089
  it "should take a string object and return a useful file control" do
1110
1090
  r = @c.render :takes_string
1111
- r.should match_tag(:input, :type => "file", :name => "fake_model[foo]", :value => "foowee")
1091
+ r.should have_selector("input[type=file][name='fake_model[foo]'][value=foowee]")
1112
1092
  end
1113
1093
 
1114
1094
  it "should take additional attributes and use them" do
1115
1095
  r = @c.render :additional_attributes
1116
- r.should match_tag(:input, :type => "file", :name => "fake_model[foo]", :value => "foowee", :bar => "7")
1096
+ r.should have_selector("input[type=file][name='fake_model[foo]'][value=foowee][bar='7']")
1117
1097
  end
1118
1098
 
1119
1099
  it "should wrap the file_field in a label if the :label option is passed in" do
1120
1100
  r = @c.render :with_label
1121
- # form = form_for @obj do
1122
- # _buffer << text_field(:foo, :label => "LABEL")
1123
- # end
1124
- r.should match(/<label.*>LABEL<\/label><input/)
1125
- res = r.scan(/<[^>]*>/)
1126
- res[2].should_not match_tag(:input, :label => "LABEL")
1101
+ r.should have_selector("label:contains('LABEL')")
1102
+ r.should_not have_selector("input[label=LABEL]")
1127
1103
  end
1128
1104
  end
1129
1105
 
@@ -1135,20 +1111,18 @@ describe "submit" do
1135
1111
 
1136
1112
  it "should return a basic submit input based on the values passed in" do
1137
1113
  r = @c.render :submit_with_values
1138
- r.should match_tag(:input, :type => "submit", :name => "foo", :value => "Done")
1114
+ r.should have_selector("input[type=submit][name=foo][value=Done]")
1139
1115
  end
1140
1116
 
1141
1117
  it "should provide an additional label tag if the :label option is passed in" do
1142
1118
  r = @c.render :submit_with_label
1143
- r.should match(/<input.*type="submit"/)
1144
- r.should match(/<input.*name="submit"/)
1145
- r.should match(/<input.*value="Done"/)
1146
- r.should match(/<label.*>LABEL<\/label>/)
1119
+ r.should have_selector("input[type=submit][name=submit][value=Done]")
1120
+ r.should have_selector("label:contains('LABEL')")
1147
1121
  end
1148
1122
 
1149
1123
  it "should be disabled if :disabled => true is passed in" do
1150
1124
  r = @c.render :disabled_submit
1151
- r.should match_tag(:input, :type => "submit", :value => "Done", :disabled => "disabled")
1125
+ r.should have_selector("input[type=submit][value=Done][disabled=disabled]")
1152
1126
  end
1153
1127
  end
1154
1128
 
@@ -1160,18 +1134,18 @@ describe "button" do
1160
1134
 
1161
1135
  it "should return a button based on the values passed in" do
1162
1136
  r = @c.render :button_with_values
1163
- r.should match_tag(:button, :type => "button", :name => "foo", :value => "bar", :content => "Click Me")
1137
+ r.should have_selector("button[type=button][name=foo][value=bar]:contains('Click Me')")
1164
1138
  end
1165
1139
 
1166
1140
  it "should provide an additional label tag if the :label option is passed in" do
1167
1141
  r = @c.render :button_with_label
1168
- r.should match(/<button.*value="foo"/)
1169
- r.should match(/<label.*>LABEL<\/label>/)
1142
+ r.should have_selector("button[value=foo]")
1143
+ r.should have_selector("label:contains('LABEL')")
1170
1144
  end
1171
1145
 
1172
1146
  it "should be disabled if :disabled => true is passed in" do
1173
1147
  r = @c.render :disabled_button
1174
- r.should match_tag(:button, :disabled => "true")
1148
+ r.should have_selector("button[disabled=true]")
1175
1149
  end
1176
1150
  end
1177
1151
 
@@ -1209,9 +1183,9 @@ describe "custom builder" do
1209
1183
 
1210
1184
  it "should let you override update_unbound_controls" do
1211
1185
  r = @c.render :everything
1212
- r.should match_tag(:button, :unbound => "button")
1213
- r.should match_tag(:input, :unbound => "submit")
1214
- r.should match_tag(:textarea, :unbound => "text_area")
1186
+ r.should have_selector("button[unbound=button]")
1187
+ r.should have_selector("input[unbound=submit]")
1188
+ r.should have_selector("textarea[unbound=text_area]")
1215
1189
  end
1216
1190
  end
1217
1191
 
@@ -1225,28 +1199,28 @@ describe 'delete_button' do
1225
1199
 
1226
1200
  it "should have a default submit button text" do
1227
1201
  result = @controller.render :simple_delete # <%= delete_button @obj %>
1228
- result.should match(/<input type=\"submit\" value="Delete"><\/input>/)
1202
+ result.should have_selector("input[type=submit][value=Delete]")
1229
1203
  end
1230
1204
 
1231
1205
  it 'should return a button inside of a form for the object' do
1232
1206
  result = @controller.render :simple_delete # <%= delete_button @obj %>
1233
- result.should match_tag(:form, :action => "/fake_models/fake_model", :method => "post")
1234
- result.should match_tag(:input, :type => "hidden", :value => "DELETE", :name => "_method")
1207
+ result.should have_selector("form[action='/fake_models/fake_model'][method=post]")
1208
+ result.should have_selector("input[type=hidden][value=DELETE][name=_method]")
1235
1209
  end
1236
1210
 
1237
1211
  it 'should allow you to modify the label' do
1238
1212
  result = @controller.render :delete_with_label # <%= delete_button(@obj, "Delete moi!") %>
1239
- result.should match(/<input type=\"submit\" value=\"Delete moi!\"><\/input>/)
1213
+ result.should have_selector("input[type=submit][value='Delete moi!']")
1240
1214
  end
1241
1215
 
1242
1216
  it "should allow you to pass some extra params like a class" do
1243
1217
  result = @controller.render :delete_with_extra_params
1244
- result.should match(/<input type=\"submit\" class=\"custom-class\" value=\"Delete\"><\/input>/)
1218
+ result.should have_selector("input.custom-class[type=submit][value=Delete]")
1245
1219
  end
1246
1220
 
1247
1221
  it "should allow to pass an explicit url as a string" do
1248
1222
  result = @controller.render :delete_with_explicit_url # <%= delete_button('/test/custom_url') %>
1249
- result.should match_tag(:form, :action => "/test/custom_url", :method => "post")
1223
+ result.should have_selector("form[action='/test/custom_url'][method=post]")
1250
1224
  end
1251
1225
 
1252
1226
  end
@@ -9,38 +9,32 @@ describe Merb::Helpers::Tag do
9
9
 
10
10
  describe "#tag" do
11
11
  it 'generates <div>content</div> from tag :div, "content"' do
12
- response = get "/tag_helper/tag_with_content"
12
+ response = request "/tag_helper/tag_with_content"
13
13
 
14
- response.body.should match_tag(:div)
15
- response.body.should include("Astral Projection ~ Dancing Galaxy")
14
+ response.should have_selector("div")
15
+ response.body.to_s.should include("Astral Projection ~ Dancing Galaxy")
16
16
  end
17
17
 
18
18
  it 'outputs content returned by the block when block is given' do
19
- response = get "/tag_helper/tag_with_content_in_the_block"
19
+ response = request "/tag_helper/tag_with_content_in_the_block"
20
20
 
21
- response.body.should match_tag(:div)
21
+ response.should have_selector("div")
22
22
  response.body.should include("Astral Projection ~ Trust in Trance 1")
23
23
  end
24
24
 
25
25
  it 'generates tag attributes for all of keys of last Hash' do
26
- response = get "/tag_helper/tag_with_attributes"
26
+ response = request "/tag_helper/tag_with_attributes"
27
27
 
28
- doc = Hpricot(response.body)
29
- (doc/"div.psy").size.should == 1
30
- (doc/"div#bands").size.should == 1
31
- (doc/"div[@invalid_attr='at least in html']").size.should == 1
28
+ response.should have_selector("div.psy")
29
+ response.should have_selector("div#bands")
30
+ response.should have_selector("div[invalid_attr='at least in html']")
32
31
  end
33
32
 
34
33
  it 'handles nesting of tags/blocks' do
35
- response = get "/tag_helper/nested_tags"
34
+ response = request "/tag_helper/nested_tags"
36
35
 
37
- doc = Hpricot(response.body)
38
- (doc/"div.discography").size.should == 1
39
- (doc/"div.discography"/"ul.albums").size.should == 1
40
- (doc/"div.discography"/"ul.albums"/"li.first").size.should == 1
41
-
42
- (doc/"#tit").size.should == 1
43
- (doc/"#tit").first.inner_html.should == "Trust in Trance 2"
36
+ response.should have_selector("div.discography ul.albums li.first")
37
+ response.should have_selector("#tit:contains('Trust in Trance 2')")
44
38
  end
45
39
  end
46
40
  end
data/spec/merb_test.log CHANGED
@@ -1,9 +0,0 @@
1
- ~ Compiling routes...
2
- ~ Params: {"format"=>"", "action"=>"tag_with_content", "id"=>"", "controller"=>"tag_helper"}
3
- ~ {:after_filters_time=>1.5e-05, :action_time=>0.000921, :before_filters_time=>1.4e-05}
4
- ~ Params: {"format"=>"", "action"=>"tag_with_content_in_the_block", "id"=>"", "controller"=>"tag_helper"}
5
- ~ {:after_filters_time=>7.0e-06, :action_time=>0.000907, :before_filters_time=>5.0e-06}
6
- ~ Params: {"format"=>"", "action"=>"tag_with_attributes", "id"=>"", "controller"=>"tag_helper"}
7
- ~ {:after_filters_time=>9.0e-06, :action_time=>0.000808, :before_filters_time=>6.0e-06}
8
- ~ Params: {"format"=>"", "action"=>"nested_tags", "id"=>"", "controller"=>"tag_helper"}
9
- ~ {:after_filters_time=>9.0e-06, :action_time=>0.000896, :before_filters_time=>7.0e-06}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: merb-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.12
4
+ version: 0.9.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael D. Ivey
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-10-29 00:00:00 -07:00
12
+ date: 2008-11-03 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 0.9.12
23
+ version: 0.9.13
24
24
  version:
25
25
  description: Helper support for Merb
26
26
  email: ivey@gweezlebur.com
@@ -305,7 +305,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
305
305
  requirements: []
306
306
 
307
307
  rubyforge_project: merb
308
- rubygems_version: 1.3.0
308
+ rubygems_version: 1.3.1
309
309
  signing_key:
310
310
  specification_version: 2
311
311
  summary: Helper support for Merb