sinatra_more 0.3.9 → 0.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +24 -8
- data/TODO +3 -2
- data/VERSION +1 -1
- data/lib/sinatra_more/markup_plugin/asset_tag_helpers.rb +10 -0
- data/lib/sinatra_more/markup_plugin/form_builder/abstract_form_builder.rb +2 -2
- data/lib/sinatra_more/markup_plugin/form_helpers.rb +18 -0
- data/lib/sinatra_more/support_lite.rb +3 -37
- data/sinatra_more.gemspec +6 -2
- data/test/fixtures/markup_app/app.rb +6 -0
- data/test/fixtures/markup_app/views/fields_for.erb +8 -0
- data/test/fixtures/markup_app/views/fields_for.haml +6 -0
- data/test/fixtures/markup_app/views/form_tag.erb +1 -0
- data/test/fixtures/markup_app/views/form_tag.haml +1 -0
- data/test/fixtures/markup_app/views/mail_to.erb +3 -0
- data/test/fixtures/markup_app/views/mail_to.haml +3 -0
- data/test/fixtures/warden_app/app.rb +5 -0
- data/test/markup_plugin/test_asset_tag_helpers.rb +32 -0
- data/test/markup_plugin/test_form_builder.rb +49 -5
- data/test/markup_plugin/test_form_helpers.rb +17 -0
- metadata +6 -2
data/README.rdoc
CHANGED
@@ -134,6 +134,10 @@ methods should be very familiar to anyone who has used rails view helpers.
|
|
134
134
|
* Creates a link element with given name, url and options
|
135
135
|
* <tt>link_to 'click me', '/dashboard', :class => 'linky'</tt>
|
136
136
|
* <tt>link_to('/dashboard', :class => 'blocky') { ...content... }</tt>
|
137
|
+
* <tt>mail_to(email, caption=nil, mail_options={})</tt>
|
138
|
+
* Creates a mailto link tag to the specified email_address
|
139
|
+
* <tt>mail_to "me@demo.com"</tt> # => <a href="mailto:me@demo.com">me@demo.com</a>
|
140
|
+
* <tt>mail_to "me@demo.com", "My Email"</tt> # => <a href="mailto:me@demo.com">My Email</a>
|
137
141
|
* <tt>image_tag(url, options={})</tt>
|
138
142
|
* Creates an image element with given url and options
|
139
143
|
* <tt>image_tag('icons/avatar.png')</tt>
|
@@ -190,6 +194,9 @@ methods should be very familiar to anyone who has used rails view helpers.
|
|
190
194
|
* <tt>submit_tag(caption, options={})</tt>
|
191
195
|
* Constructs a submit button from the given options
|
192
196
|
* <tt>submit_tag "Create", :class => 'success'</tt>
|
197
|
+
* <tt>button_tag(caption, options={})</tt>
|
198
|
+
* Constructs an input (type => 'button') from the given options
|
199
|
+
* <tt>button_tag "Cancel", :class => 'clear'</tt>
|
193
200
|
* <tt>image_submit_tag(source, options={})</tt>
|
194
201
|
* Constructs an image submit button from the given options
|
195
202
|
* <tt>image_submit_tag "submit.png", :class => 'success'</tt>
|
@@ -221,8 +228,13 @@ A form_tag might look like:
|
|
221
228
|
* Defaults to StandardFormBuilder but you can easily create your own!
|
222
229
|
* <tt>form_for(@user, '/register', :id => 'register') { |f| ...field-elements... }</tt>
|
223
230
|
* <tt>form_for(:user, '/register', :id => 'register') { |f| ...field-elements... }</tt>
|
231
|
+
* <tt>fields_for(object, settings={}, &block)</tt>
|
232
|
+
* Constructs fields for a given object for use in an existing form
|
233
|
+
* Defaults to StandardFormBuilder but you can easily create your own!
|
234
|
+
* <tt>fields_for @user.assignment do |assignment| ... end</tt>
|
235
|
+
* <tt>fields_for :assignment do |assigment| ... end</tt>
|
224
236
|
|
225
|
-
The following are fields provided by AbstractFormBuilder that can be used within a form_for:
|
237
|
+
The following are fields provided by AbstractFormBuilder that can be used within a form_for or fields_for:
|
226
238
|
|
227
239
|
* <tt>error_messages(options={})</tt>
|
228
240
|
* Displays list html for the errors on form object
|
@@ -269,9 +281,13 @@ A form_for using these basic fields might look like:
|
|
269
281
|
%p
|
270
282
|
= f.label :is_admin, :caption => "Admin User?"
|
271
283
|
= f.check_box :is_admin
|
272
|
-
|
284
|
+
%p
|
273
285
|
= f.label :color, :caption => "Favorite Color?"
|
274
286
|
= f.select :color, :options => ['red', 'black']
|
287
|
+
%p
|
288
|
+
- fields_for @user.location do |location|
|
289
|
+
= location.text_field :street
|
290
|
+
= location.text_field :city
|
275
291
|
%p
|
276
292
|
= f.submit "Create", :class => 'button'
|
277
293
|
|
@@ -454,12 +470,6 @@ In addition, the strategy used expects that you have an <tt>authenticate</tt> me
|
|
454
470
|
|
455
471
|
Using this plugin you also do need to define your own routes for managing warden sessions. An example is below:
|
456
472
|
|
457
|
-
get '/unauthenticated/?' do
|
458
|
-
flash[:notice] = "That username and password are not correct!"
|
459
|
-
status 401
|
460
|
-
haml_template 'session/login'
|
461
|
-
end
|
462
|
-
|
463
473
|
get '/login/?' do
|
464
474
|
haml_template 'session/login'
|
465
475
|
end
|
@@ -468,6 +478,12 @@ Using this plugin you also do need to define your own routes for managing warden
|
|
468
478
|
authenticate_user!
|
469
479
|
redirect "/dashboard"
|
470
480
|
end
|
481
|
+
|
482
|
+
post '/unauthenticated/?' do
|
483
|
+
flash[:notice] = "That username and password are not correct!"
|
484
|
+
status 401
|
485
|
+
haml_template 'session/login'
|
486
|
+
end
|
471
487
|
|
472
488
|
get '/logout/?' do
|
473
489
|
logout_user!
|
data/TODO
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
= UNFINISHED
|
2
2
|
|
3
3
|
* Add support for model, routes, migration generator types based on components
|
4
|
-
* Add support for fields_for
|
5
|
-
* Add support for button tag method, mail_to helper
|
4
|
+
* Add support for form.fields_for (one-to-one, nested and many associations like in rails)
|
6
5
|
* Add support for check_box_group, radio_button_group which create a set of checkboxes or radio buttons
|
7
6
|
* Become total warden solution (basically just require warden gem installed, do everything else)
|
8
7
|
* Look into removing overlapping methods and simply leverage sinatra_warden
|
@@ -19,6 +18,8 @@
|
|
19
18
|
|
20
19
|
= COMPLETED
|
21
20
|
|
21
|
+
* Add support for button tag method, mail_to helper
|
22
|
+
* Add support for simple fields_for tag helper
|
22
23
|
* Add content_for / yield tags similar to rails
|
23
24
|
* Created application generator using thor
|
24
25
|
* Add support for a MailerPlugin which will make sending emails a breeze (http://github.com/hiroshi/pony)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.10
|
@@ -28,6 +28,16 @@ module SinatraMore
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
+
# Creates a mail link element with given name and caption
|
32
|
+
# mail_to "me@demo.com" => <a href="mailto:me@demo.com">me@demo.com</a>
|
33
|
+
# mail_to "me@demo.com", "My Email" => <a href="mailto:me@demo.com">My Email</a>
|
34
|
+
def mail_to(email, caption=nil, mail_options={})
|
35
|
+
html_options = mail_options.slice!(:cc, :bcc, :subject, :body)
|
36
|
+
mail_query = Rack::Utils.build_query(mail_options).gsub(/\+/, '%20').gsub('%40', '@')
|
37
|
+
mail_href = "mailto:#{email}"; mail_href << "?#{mail_query}" if mail_query.present?
|
38
|
+
link_to (caption || email), mail_href, html_options
|
39
|
+
end
|
40
|
+
|
31
41
|
# Creates an image element with given url and options
|
32
42
|
# image_tag('icons/avatar.png')
|
33
43
|
def image_tag(url, options={})
|
@@ -53,7 +53,7 @@ class AbstractFormBuilder
|
|
53
53
|
# f.check_box :remember_me, :value => 'true', :uncheck_value => '0'
|
54
54
|
def check_box(field, options={})
|
55
55
|
unchecked_value = options.delete(:uncheck_value) || '0'
|
56
|
-
options.reverse_merge!(:id => field_id(field))
|
56
|
+
options.reverse_merge!(:id => field_id(field), :value => '1')
|
57
57
|
options.merge!(:checked => true) if values_matches_field?(field, options[:value])
|
58
58
|
html = @template.check_box_tag field_name(field), options
|
59
59
|
html << hidden_field(field, :value => unchecked_value, :id => nil)
|
@@ -98,7 +98,7 @@ class AbstractFormBuilder
|
|
98
98
|
# Returns true if the value matches the value in the field
|
99
99
|
# field_has_value?(:gender, 'male')
|
100
100
|
def values_matches_field?(field, value)
|
101
|
-
value.present? && field_value(field).to_s == value.to_s
|
101
|
+
value.present? && (field_value(field).to_s == value.to_s || field_value(field).to_s == 'true')
|
102
102
|
end
|
103
103
|
|
104
104
|
# Returns the value for the object's field
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module SinatraMore
|
2
2
|
module FormHelpers
|
3
3
|
# Constructs a form for object using given or default form_builder
|
4
|
+
# form_for :user, '/register' do |f| ... end
|
4
5
|
# form_for @user, '/register', :id => 'register' do |f| ... end
|
5
6
|
def form_for(object, url, settings={}, &block)
|
6
7
|
builder_class = configured_form_builder_class(settings[:builder])
|
@@ -8,6 +9,16 @@ module SinatraMore
|
|
8
9
|
form_tag(url, settings) { form_html }
|
9
10
|
end
|
10
11
|
|
12
|
+
# Constructs form fields for an object using given or default form_builder
|
13
|
+
# Used within an existing form to allow alternate objects within one form
|
14
|
+
# fields_for @user.assignment do |assignment| ... end
|
15
|
+
# fields_for :assignment do |assigment| ... end
|
16
|
+
def fields_for(object, settings={}, &block)
|
17
|
+
builder_class = configured_form_builder_class(settings[:builder])
|
18
|
+
fields_html = capture_html(builder_class.new(self, object), &block)
|
19
|
+
concat_content fields_html
|
20
|
+
end
|
21
|
+
|
11
22
|
# Constructs a form without object based on options
|
12
23
|
# form_tag '/register' do ... end
|
13
24
|
def form_tag(url, options={}, &block)
|
@@ -125,6 +136,13 @@ module SinatraMore
|
|
125
136
|
input_tag(:submit, options)
|
126
137
|
end
|
127
138
|
|
139
|
+
# Constructs a button input from the given options
|
140
|
+
# button_tag "Cancel", :class => 'clear'
|
141
|
+
def button_tag(caption, options = {})
|
142
|
+
options.reverse_merge!(:value => caption)
|
143
|
+
input_tag(:button, options)
|
144
|
+
end
|
145
|
+
|
128
146
|
# Constructs a submit button from the given options
|
129
147
|
# submit_tag "Create", :class => 'success'
|
130
148
|
def image_submit_tag(source, options={})
|
@@ -1,43 +1,9 @@
|
|
1
1
|
# This is for adding specific methods that are required by sinatra_more if activesupport isn't required
|
2
2
|
|
3
|
-
unless String.method_defined?(:titleize)
|
3
|
+
unless String.method_defined?(:titleize) && Hash.method_defined?(:slice)
|
4
4
|
require 'active_support/inflector'
|
5
5
|
require 'active_support/core_ext/blank'
|
6
6
|
require 'active_support/core_ext/class/attribute_accessors'
|
7
|
+
require 'active_support/core_ext/hash'
|
8
|
+
require 'active_support/core_ext/array'
|
7
9
|
end
|
8
|
-
|
9
|
-
unless Hash.method_defined?(:reverse_merge!)
|
10
|
-
module HashExtensions
|
11
|
-
def reverse_merge(other_hash)
|
12
|
-
other_hash.merge(self)
|
13
|
-
end
|
14
|
-
def reverse_merge!(other_hash)
|
15
|
-
replace(reverse_merge(other_hash))
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
unless Hash.method_defined?(:symbolize_keys!)
|
21
|
-
module HashExtensions
|
22
|
-
def symbolize_keys
|
23
|
-
inject({}) do |options, (key, value)|
|
24
|
-
options[(key.to_sym rescue key) || key] = value
|
25
|
-
options
|
26
|
-
end
|
27
|
-
end
|
28
|
-
def symbolize_keys!
|
29
|
-
self.replace(self.symbolize_keys)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
unless Array.method_defined?(:extract_options!)
|
35
|
-
module ArrayExtensions
|
36
|
-
def extract_options!
|
37
|
-
last.is_a?(::Hash) ? pop : {}
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
Hash.send(:include, HashExtensions) if defined?(HashExtensions)
|
43
|
-
Array.send(:include, ArrayExtensions) if defined?(ArrayExtensions)
|
data/sinatra_more.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{sinatra_more}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.10"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Nathan Esquenazi"]
|
12
|
-
s.date = %q{2009-11-
|
12
|
+
s.date = %q{2009-11-11}
|
13
13
|
s.default_executable = %q{sinatra_gen}
|
14
14
|
s.description = %q{Expands sinatra with standard helpers and tools to allow for complex applications}
|
15
15
|
s.email = %q{nesquena@gmail.com}
|
@@ -98,12 +98,16 @@ Gem::Specification.new do |s|
|
|
98
98
|
"test/fixtures/markup_app/views/content_for.haml",
|
99
99
|
"test/fixtures/markup_app/views/content_tag.erb",
|
100
100
|
"test/fixtures/markup_app/views/content_tag.haml",
|
101
|
+
"test/fixtures/markup_app/views/fields_for.erb",
|
102
|
+
"test/fixtures/markup_app/views/fields_for.haml",
|
101
103
|
"test/fixtures/markup_app/views/form_for.erb",
|
102
104
|
"test/fixtures/markup_app/views/form_for.haml",
|
103
105
|
"test/fixtures/markup_app/views/form_tag.erb",
|
104
106
|
"test/fixtures/markup_app/views/form_tag.haml",
|
105
107
|
"test/fixtures/markup_app/views/link_to.erb",
|
106
108
|
"test/fixtures/markup_app/views/link_to.haml",
|
109
|
+
"test/fixtures/markup_app/views/mail_to.erb",
|
110
|
+
"test/fixtures/markup_app/views/mail_to.haml",
|
107
111
|
"test/fixtures/render_app/app.rb",
|
108
112
|
"test/fixtures/render_app/views/erb/test.erb",
|
109
113
|
"test/fixtures/render_app/views/haml/test.haml",
|
@@ -46,6 +46,12 @@ class MarkupUser
|
|
46
46
|
def session_id; 45; end
|
47
47
|
def gender; 'male'; end
|
48
48
|
def remember_me; '1'; end
|
49
|
+
def permission; Permission.new; end
|
50
|
+
end
|
51
|
+
|
52
|
+
class Permission
|
53
|
+
def can_edit; true; end
|
54
|
+
def can_delete; false; end
|
49
55
|
end
|
50
56
|
|
51
57
|
class Errors < Array
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<% @user = MarkupUser.new %>
|
2
|
+
<% form_for @user , '/demo1', :id => 'demo-fields-for' do |f| %>
|
3
|
+
<%= f.text_field :gender %>
|
4
|
+
<% fields_for @user.permission do |permission| %>
|
5
|
+
<%= permission.check_box :can_edit %>
|
6
|
+
<%= permission.check_box :can_delete %>
|
7
|
+
<% end %>
|
8
|
+
<% end %>
|
@@ -46,6 +46,38 @@ class TestAssetTagHelpers < Test::Unit::TestCase
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
+
context 'for #mail_to method' do
|
50
|
+
should "display link element for mail to no caption" do
|
51
|
+
actual_html = mail_to('test@demo.com')
|
52
|
+
assert_has_tag(:a, :href => "mailto:test@demo.com", :content => 'test@demo.com') { actual_html }
|
53
|
+
end
|
54
|
+
|
55
|
+
should "display link element for mail to with caption" do
|
56
|
+
actual_html = mail_to('test@demo.com', "My Email", :class => 'demo')
|
57
|
+
assert_has_tag(:a, :href => "mailto:test@demo.com", :content => 'My Email', :class => 'demo') { actual_html }
|
58
|
+
end
|
59
|
+
|
60
|
+
should "display link element for mail to with caption and mail options" do
|
61
|
+
actual_html = mail_to('test@demo.com', "My Email", :subject => 'demo test', :class => 'demo', :cc => 'foo@test.com')
|
62
|
+
assert_has_tag(:a, :class => 'demo') { actual_html }
|
63
|
+
assert_match /mailto\:test\@demo.com\?/, actual_html
|
64
|
+
assert_match /cc=foo\@test\.com/, actual_html
|
65
|
+
assert_match /subject\=demo\%20test/, actual_html
|
66
|
+
end
|
67
|
+
|
68
|
+
should "display mail link element in haml" do
|
69
|
+
visit '/haml/mail_to'
|
70
|
+
assert_have_selector 'p.simple a', :href => 'mailto:test@demo.com', :content => 'test@demo.com'
|
71
|
+
assert_have_selector 'p.captioned a', :href => 'mailto:test@demo.com', :content => 'Click my Email'
|
72
|
+
end
|
73
|
+
|
74
|
+
should "display mail link element in erb" do
|
75
|
+
visit '/erb/mail_to'
|
76
|
+
assert_have_selector 'p.simple a', :href => 'mailto:test@demo.com', :content => 'test@demo.com'
|
77
|
+
assert_have_selector 'p.captioned a', :href => 'mailto:test@demo.com', :content => 'Click my Email'
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
49
81
|
context 'for #image_tag method' do
|
50
82
|
should "display image tag absolute link with no options" do
|
51
83
|
assert_has_tag('img', :src => "/absolute/pic.gif") { image_tag('/absolute/pic.gif') }
|
@@ -34,7 +34,7 @@ class TestFormBuilder < Test::Unit::TestCase
|
|
34
34
|
assert_has_tag('form input[type=hidden]', :name => '_method', :count => 0) { actual_html } # no method action field
|
35
35
|
end
|
36
36
|
|
37
|
-
should "display correct form html with method :
|
37
|
+
should "display correct form html with method :put" do
|
38
38
|
actual_html = form_for(@user, '/update', :method => 'put') { "Demo" }
|
39
39
|
assert_has_tag('form', :action => '/update', :method => 'post') { actual_html }
|
40
40
|
assert_has_tag('form input', :type => 'hidden', :name => "_method", :value => 'put') { actual_html }
|
@@ -61,7 +61,7 @@ class TestFormBuilder < Test::Unit::TestCase
|
|
61
61
|
assert_has_tag('form p input[type=text]') { actual_html }
|
62
62
|
end
|
63
63
|
|
64
|
-
should "display fail for form with
|
64
|
+
should "display fail for form with nil object" do
|
65
65
|
assert_raises(RuntimeError) { form_for(@not_real, '/register', :id => 'register', :method => 'post') { "Demo" } }
|
66
66
|
end
|
67
67
|
|
@@ -80,6 +80,38 @@ class TestFormBuilder < Test::Unit::TestCase
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
+
context 'for #fields_for method' do
|
84
|
+
should 'display correct fields html' do
|
85
|
+
actual_html = fields_for(@user) { |f| f.text_field(:first_name) }
|
86
|
+
assert_has_tag(:input, :type => 'text', :name => 'user[first_name]', :id => 'user_first_name') { actual_html }
|
87
|
+
end
|
88
|
+
|
89
|
+
should 'display correct fields html with symbol object' do
|
90
|
+
actual_html = fields_for(:markup_user) { |f| f.text_field(:first_name) }
|
91
|
+
assert_has_tag(:input, :type => 'text', :name => 'markup_user[first_name]', :id => 'markup_user_first_name') { actual_html }
|
92
|
+
end
|
93
|
+
|
94
|
+
should "display fail for nil object" do
|
95
|
+
assert_raises(RuntimeError) { fields_for(@not_real) { |f| "Demo" } }
|
96
|
+
end
|
97
|
+
|
98
|
+
should 'display correct simple fields in haml' do
|
99
|
+
visit '/haml/fields_for'
|
100
|
+
assert_have_selector :form, :action => '/demo1', :id => 'demo-fields-for'
|
101
|
+
assert_have_selector '#demo-fields-for input', :type => 'text', :name => 'markup_user[gender]', :value => 'male'
|
102
|
+
assert_have_selector '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_edit]', :value => '1', :checked => 'checked'
|
103
|
+
assert_have_selector '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_delete]'
|
104
|
+
end
|
105
|
+
|
106
|
+
should "display correct simple fields in erb" do
|
107
|
+
visit '/erb/fields_for'
|
108
|
+
assert_have_selector :form, :action => '/demo1', :id => 'demo-fields-for'
|
109
|
+
assert_have_selector '#demo-fields-for input', :type => 'text', :name => 'markup_user[gender]', :value => 'male'
|
110
|
+
assert_have_selector '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_edit]', :value => '1', :checked => 'checked'
|
111
|
+
assert_have_selector '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_delete]'
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
83
115
|
# ===========================
|
84
116
|
# AbstractFormBuilder
|
85
117
|
# ===========================
|
@@ -186,14 +218,26 @@ class TestFormBuilder < Test::Unit::TestCase
|
|
186
218
|
end
|
187
219
|
|
188
220
|
should "display correct checkbox html as checked when object value matches" do
|
189
|
-
@user.stubs(:show_favorites => '
|
221
|
+
@user.stubs(:show_favorites => 'human')
|
222
|
+
actual_html = standard_builder.check_box(:show_favorites, :value => 'human')
|
223
|
+
assert_has_tag('input[type=checkbox]', :checked => 'checked', :name => 'user[show_favorites]') { actual_html }
|
224
|
+
end
|
225
|
+
|
226
|
+
should "display correct checkbox html as checked when object value is true" do
|
227
|
+
@user.stubs(:show_favorites => true)
|
190
228
|
actual_html = standard_builder.check_box(:show_favorites, :value => '1')
|
191
229
|
assert_has_tag('input[type=checkbox]', :checked => 'checked', :name => 'user[show_favorites]') { actual_html }
|
192
230
|
end
|
193
231
|
|
194
232
|
should "display correct checkbox html as unchecked when object value doesn't match" do
|
195
|
-
@user.stubs(:
|
196
|
-
actual_html = standard_builder.check_box(:show_favorites, :value => '
|
233
|
+
@user.stubs(:show_favorites => 'alien')
|
234
|
+
actual_html = standard_builder.check_box(:show_favorites, :value => 'human')
|
235
|
+
assert_has_no_tag('input[type=checkbox]', :checked => 'checked') { actual_html }
|
236
|
+
end
|
237
|
+
|
238
|
+
should "display correct checkbox html as unchecked when object value is false" do
|
239
|
+
@user.stubs(:show_favorites => false)
|
240
|
+
actual_html = standard_builder.check_box(:show_favorites, :value => '1')
|
197
241
|
assert_has_no_tag('input[type=checkbox]', :checked => 'checked') { actual_html }
|
198
242
|
end
|
199
243
|
|
@@ -364,6 +364,23 @@ class TestFormHelpers < Test::Unit::TestCase
|
|
364
364
|
end
|
365
365
|
end
|
366
366
|
|
367
|
+
context 'for #button_tag method' do
|
368
|
+
should "display submit tag in ruby" do
|
369
|
+
actual_html = button_tag("Cancel", :class => 'clear')
|
370
|
+
assert_has_tag(:input, :type => 'button', :class => "clear", :value => 'Cancel') { actual_html }
|
371
|
+
end
|
372
|
+
|
373
|
+
should "display submit tag in erb" do
|
374
|
+
visit '/erb/form_tag'
|
375
|
+
assert_have_selector 'form.advanced-form input[type=button]', :count => 1, :value => "Cancel"
|
376
|
+
end
|
377
|
+
|
378
|
+
should "display submit tag in haml" do
|
379
|
+
visit '/haml/form_tag'
|
380
|
+
assert_have_selector 'form.advanced-form input[type=button]', :count => 1, :value => "Cancel"
|
381
|
+
end
|
382
|
+
end
|
383
|
+
|
367
384
|
context 'for #image_submit_tag method' do
|
368
385
|
should "display image submit tag in ruby with relative path" do
|
369
386
|
actual_html = image_submit_tag('buttons/ok.png', :class => 'success')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra_more
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Esquenazi
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-11 00:00:00 -08:00
|
13
13
|
default_executable: sinatra_gen
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -191,12 +191,16 @@ files:
|
|
191
191
|
- test/fixtures/markup_app/views/content_for.haml
|
192
192
|
- test/fixtures/markup_app/views/content_tag.erb
|
193
193
|
- test/fixtures/markup_app/views/content_tag.haml
|
194
|
+
- test/fixtures/markup_app/views/fields_for.erb
|
195
|
+
- test/fixtures/markup_app/views/fields_for.haml
|
194
196
|
- test/fixtures/markup_app/views/form_for.erb
|
195
197
|
- test/fixtures/markup_app/views/form_for.haml
|
196
198
|
- test/fixtures/markup_app/views/form_tag.erb
|
197
199
|
- test/fixtures/markup_app/views/form_tag.haml
|
198
200
|
- test/fixtures/markup_app/views/link_to.erb
|
199
201
|
- test/fixtures/markup_app/views/link_to.haml
|
202
|
+
- test/fixtures/markup_app/views/mail_to.erb
|
203
|
+
- test/fixtures/markup_app/views/mail_to.haml
|
200
204
|
- test/fixtures/render_app/app.rb
|
201
205
|
- test/fixtures/render_app/views/erb/test.erb
|
202
206
|
- test/fixtures/render_app/views/haml/test.haml
|