merb-helpers 0.9.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. data/LICENSE +20 -0
  2. data/README +180 -0
  3. data/Rakefile +77 -0
  4. data/TODO +5 -0
  5. data/lib/merb-helpers.rb +38 -0
  6. data/lib/merb-helpers/core_ext.rb +57 -0
  7. data/lib/merb-helpers/core_ext/numeric.rb +388 -0
  8. data/lib/merb-helpers/date_time_formatting.rb +127 -0
  9. data/lib/merb-helpers/date_time_helpers.rb +190 -0
  10. data/lib/merb-helpers/form/builder.rb +410 -0
  11. data/lib/merb-helpers/form/helpers.rb +448 -0
  12. data/lib/merb-helpers/form_helpers.rb +24 -0
  13. data/lib/merb-helpers/tag_helpers.rb +61 -0
  14. data/lib/merb-helpers/text_helpers.rb +61 -0
  15. data/lib/merb-helpers/time_dsl.rb +59 -0
  16. data/spec/core_ext_spec.rb +19 -0
  17. data/spec/fixture/app/controllers/application.rb +4 -0
  18. data/spec/fixture/app/controllers/bound_check_box.rb +2 -0
  19. data/spec/fixture/app/controllers/bound_file_field.rb +2 -0
  20. data/spec/fixture/app/controllers/bound_hidden_field.rb +2 -0
  21. data/spec/fixture/app/controllers/bound_option_tag.rb +2 -0
  22. data/spec/fixture/app/controllers/bound_password_field.rb +2 -0
  23. data/spec/fixture/app/controllers/bound_radio_button.rb +2 -0
  24. data/spec/fixture/app/controllers/bound_radio_group.rb +2 -0
  25. data/spec/fixture/app/controllers/bound_select.rb +2 -0
  26. data/spec/fixture/app/controllers/bound_text_area.rb +2 -0
  27. data/spec/fixture/app/controllers/bound_text_field.rb +2 -0
  28. data/spec/fixture/app/controllers/button.rb +2 -0
  29. data/spec/fixture/app/controllers/check_box.rb +2 -0
  30. data/spec/fixture/app/controllers/custom_builder.rb +2 -0
  31. data/spec/fixture/app/controllers/delete_button.rb +2 -0
  32. data/spec/fixture/app/controllers/exceptions.rb +25 -0
  33. data/spec/fixture/app/controllers/field_set.rb +2 -0
  34. data/spec/fixture/app/controllers/fields_for.rb +3 -0
  35. data/spec/fixture/app/controllers/file_field.rb +2 -0
  36. data/spec/fixture/app/controllers/foo.rb +23 -0
  37. data/spec/fixture/app/controllers/form.rb +2 -0
  38. data/spec/fixture/app/controllers/form_for.rb +2 -0
  39. data/spec/fixture/app/controllers/hidden_field.rb +2 -0
  40. data/spec/fixture/app/controllers/label.rb +3 -0
  41. data/spec/fixture/app/controllers/numeric_ext.rb +3 -0
  42. data/spec/fixture/app/controllers/option_tag.rb +2 -0
  43. data/spec/fixture/app/controllers/password_field.rb +2 -0
  44. data/spec/fixture/app/controllers/radio_button.rb +2 -0
  45. data/spec/fixture/app/controllers/radio_group.rb +2 -0
  46. data/spec/fixture/app/controllers/select.rb +2 -0
  47. data/spec/fixture/app/controllers/specs_controller.rb +11 -0
  48. data/spec/fixture/app/controllers/submit.rb +2 -0
  49. data/spec/fixture/app/controllers/tag_helper.rb +21 -0
  50. data/spec/fixture/app/controllers/text_area.rb +2 -0
  51. data/spec/fixture/app/controllers/text_field.rb +3 -0
  52. data/spec/fixture/app/helpers/global_helpers.rb +8 -0
  53. data/spec/fixture/app/models/fake_dm_model.rb +25 -0
  54. data/spec/fixture/app/models/first_generic_fake_model.rb +57 -0
  55. data/spec/fixture/app/models/second_generic_fake_model.rb +18 -0
  56. data/spec/fixture/app/models/third_generic_fake_model.rb +3 -0
  57. data/spec/fixture/app/views/bound_check_box_specs/basic.html.erb +4 -0
  58. data/spec/fixture/app/views/bound_check_box_specs/checked.html.erb +4 -0
  59. data/spec/fixture/app/views/bound_check_box_specs/errors.html.erb +4 -0
  60. data/spec/fixture/app/views/bound_check_box_specs/label.html.erb +3 -0
  61. data/spec/fixture/app/views/bound_check_box_specs/on_and_off.html.erb +3 -0
  62. data/spec/fixture/app/views/bound_check_box_specs/raise_value_error.html.erb +3 -0
  63. data/spec/fixture/app/views/bound_file_field_specs/additional_attributes.html.erb +3 -0
  64. data/spec/fixture/app/views/bound_file_field_specs/takes_string.html.erb +3 -0
  65. data/spec/fixture/app/views/bound_file_field_specs/with_label.html.erb +3 -0
  66. data/spec/fixture/app/views/bound_hidden_field_specs/basic.html.erb +3 -0
  67. data/spec/fixture/app/views/bound_hidden_field_specs/errors.html.erb +3 -0
  68. data/spec/fixture/app/views/bound_hidden_field_specs/hidden_error.html.erb +3 -0
  69. data/spec/fixture/app/views/bound_hidden_field_specs/label.html.erb +3 -0
  70. data/spec/fixture/app/views/bound_option_tag_specs/grouped.html.erb +3 -0
  71. data/spec/fixture/app/views/bound_option_tag_specs/nested.html.erb +3 -0
  72. data/spec/fixture/app/views/bound_option_tag_specs/text_and_value.html.erb +4 -0
  73. data/spec/fixture/app/views/bound_password_field_specs/attributes.html.erb +3 -0
  74. data/spec/fixture/app/views/bound_password_field_specs/basic.html.erb +3 -0
  75. data/spec/fixture/app/views/bound_password_field_specs/label.html.erb +3 -0
  76. data/spec/fixture/app/views/bound_radio_button_specs/basic.html.erb +3 -0
  77. data/spec/fixture/app/views/bound_radio_group_specs/basic.html.erb +3 -0
  78. data/spec/fixture/app/views/bound_radio_group_specs/hashes.html.erb +3 -0
  79. data/spec/fixture/app/views/bound_radio_group_specs/mixed.html.erb +4 -0
  80. data/spec/fixture/app/views/bound_radio_group_specs/override_id.html.erb +3 -0
  81. data/spec/fixture/app/views/bound_select_specs/basic.html.erb +3 -0
  82. data/spec/fixture/app/views/bound_select_specs/blank.html.erb +3 -0
  83. data/spec/fixture/app/views/bound_select_specs/multiple.html.erb +3 -0
  84. data/spec/fixture/app/views/bound_select_specs/prompt.html.erb +3 -0
  85. data/spec/fixture/app/views/bound_select_specs/with_options.html.erb +3 -0
  86. data/spec/fixture/app/views/bound_select_specs/with_options_with_blank.html.erb +3 -0
  87. data/spec/fixture/app/views/bound_text_area_specs/basic.html.erb +3 -0
  88. data/spec/fixture/app/views/bound_text_field_specs/basic.html.erb +3 -0
  89. data/spec/fixture/app/views/button_specs/button_with_label.html.erb +1 -0
  90. data/spec/fixture/app/views/button_specs/button_with_values.html.erb +1 -0
  91. data/spec/fixture/app/views/button_specs/disabled_button.html.erb +1 -0
  92. data/spec/fixture/app/views/check_box_specs/basic.html.erb +1 -0
  93. data/spec/fixture/app/views/check_box_specs/boolean.html.erb +1 -0
  94. data/spec/fixture/app/views/check_box_specs/disabled.html.erb +1 -0
  95. data/spec/fixture/app/views/check_box_specs/label.html.erb +1 -0
  96. data/spec/fixture/app/views/check_box_specs/on_off_is_boolean.html.erb +1 -0
  97. data/spec/fixture/app/views/check_box_specs/raise_unless_both_on_and_off.html.erb +2 -0
  98. data/spec/fixture/app/views/check_box_specs/raises_error_if_not_boolean.html.erb +1 -0
  99. data/spec/fixture/app/views/check_box_specs/raises_error_if_on_off_and_boolean_false.html.erb +1 -0
  100. data/spec/fixture/app/views/check_box_specs/simple.html.erb +1 -0
  101. data/spec/fixture/app/views/check_box_specs/to_string.html.erb +8 -0
  102. data/spec/fixture/app/views/check_box_specs/unchecked.html.erb +2 -0
  103. data/spec/fixture/app/views/custom_builder_specs/everything.html.erb +10 -0
  104. data/spec/fixture/app/views/delete_button_specs/delete_with_explicit_url.html.erb +1 -0
  105. data/spec/fixture/app/views/delete_button_specs/delete_with_extra_params.html.erb +1 -0
  106. data/spec/fixture/app/views/delete_button_specs/delete_with_label.html.erb +1 -0
  107. data/spec/fixture/app/views/delete_button_specs/simple_delete.html.erb +1 -0
  108. data/spec/fixture/app/views/exeptions/client_error.html.erb +37 -0
  109. data/spec/fixture/app/views/exeptions/internal_server_error.html.erb +216 -0
  110. data/spec/fixture/app/views/exeptions/not_acceptable.html.erb +38 -0
  111. data/spec/fixture/app/views/exeptions/not_found.html.erb +40 -0
  112. data/spec/fixture/app/views/fields_for_specs/basic.html.erb +3 -0
  113. data/spec/fixture/app/views/fields_for_specs/midstream.html.erb +7 -0
  114. data/spec/fixture/app/views/fields_for_specs/nil.html.erb +3 -0
  115. data/spec/fixture/app/views/fieldset_specs/legend.html.erb +3 -0
  116. data/spec/fixture/app/views/file_field_specs/disabled.html.erb +1 -0
  117. data/spec/fixture/app/views/file_field_specs/makes_multipart.html.erb +3 -0
  118. data/spec/fixture/app/views/file_field_specs/with_label.html.erb +1 -0
  119. data/spec/fixture/app/views/file_field_specs/with_values.html.erb +1 -0
  120. data/spec/fixture/app/views/foo/bar.html.erb +0 -0
  121. data/spec/fixture/app/views/form_for_specs/basic.html.erb +3 -0
  122. data/spec/fixture/app/views/form_specs/create_a_form.html.erb +3 -0
  123. data/spec/fixture/app/views/form_specs/create_a_multipart_form.html.erb +3 -0
  124. data/spec/fixture/app/views/form_specs/fake_delete_if_set.html.erb +3 -0
  125. data/spec/fixture/app/views/form_specs/fake_put_if_set.html.erb +3 -0
  126. data/spec/fixture/app/views/form_specs/get_if_set.html.erb +3 -0
  127. data/spec/fixture/app/views/form_specs/post_by_default.html.erb +3 -0
  128. data/spec/fixture/app/views/form_specs/resourceful_form.html.erb +3 -0
  129. data/spec/fixture/app/views/hidden_field_specs/basic.html.erb +1 -0
  130. data/spec/fixture/app/views/hidden_field_specs/disabled.html.erb +1 -0
  131. data/spec/fixture/app/views/hidden_field_specs/label.html.erb +1 -0
  132. data/spec/fixture/app/views/label_specs/basic.html.erb +1 -0
  133. data/spec/fixture/app/views/layout/application.html.erb +11 -0
  134. data/spec/fixture/app/views/numeric_ext_specs/minutes_to_hours.html.erb +1 -0
  135. data/spec/fixture/app/views/numeric_ext_specs/to_concurrency_default.html.erb +1 -0
  136. data/spec/fixture/app/views/numeric_ext_specs/two_digits.html.erb +1 -0
  137. data/spec/fixture/app/views/option_tag_specs/array.html.erb +1 -0
  138. data/spec/fixture/app/views/option_tag_specs/clean.html.erb +1 -0
  139. data/spec/fixture/app/views/option_tag_specs/collection.html.erb +1 -0
  140. data/spec/fixture/app/views/option_tag_specs/multiple_selects.html.erb +1 -0
  141. data/spec/fixture/app/views/option_tag_specs/no_extra_attributes.html.erb +1 -0
  142. data/spec/fixture/app/views/option_tag_specs/optgroups.html.erb +1 -0
  143. data/spec/fixture/app/views/option_tag_specs/selected.html.erb +1 -0
  144. data/spec/fixture/app/views/option_tag_specs/with_blank.html.erb +1 -0
  145. data/spec/fixture/app/views/option_tag_specs/with_prompt.html.erb +1 -0
  146. data/spec/fixture/app/views/password_field_specs/basic.html.erb +1 -0
  147. data/spec/fixture/app/views/password_field_specs/disabled.html.erb +1 -0
  148. data/spec/fixture/app/views/radio_button_specs/basic.html.erb +1 -0
  149. data/spec/fixture/app/views/radio_button_specs/disabled.html.erb +1 -0
  150. data/spec/fixture/app/views/radio_button_specs/label.html.erb +1 -0
  151. data/spec/fixture/app/views/radio_group_specs/attributes.html.erb +1 -0
  152. data/spec/fixture/app/views/radio_group_specs/basic.html.erb +1 -0
  153. data/spec/fixture/app/views/radio_group_specs/hash.html.erb +1 -0
  154. data/spec/fixture/app/views/radio_group_specs/specific_attributes.html.erb +1 -0
  155. data/spec/fixture/app/views/select_specs/blank.html.erb +1 -0
  156. data/spec/fixture/app/views/select_specs/multiple.html.erb +1 -0
  157. data/spec/fixture/app/views/submit_specs/disabled_submit.html.erb +1 -0
  158. data/spec/fixture/app/views/submit_specs/submit_with_label.html.erb +1 -0
  159. data/spec/fixture/app/views/submit_specs/submit_with_values.html.erb +1 -0
  160. data/spec/fixture/app/views/tag_helper/nested_tags.html.erb +5 -0
  161. data/spec/fixture/app/views/tag_helper/tag_with_attributes.html.erb +1 -0
  162. data/spec/fixture/app/views/tag_helper/tag_with_content.html.erb +1 -0
  163. data/spec/fixture/app/views/tag_helper/tag_with_content_in_the_block.html.erb +3 -0
  164. data/spec/fixture/app/views/text_area_specs/basic.html.erb +1 -0
  165. data/spec/fixture/app/views/text_area_specs/disabled.html.erb +1 -0
  166. data/spec/fixture/app/views/text_area_specs/label.html.erb +1 -0
  167. data/spec/fixture/app/views/text_area_specs/nil.html.erb +1 -0
  168. data/spec/fixture/app/views/text_field_specs/basic.html.erb +1 -0
  169. data/spec/fixture/app/views/text_field_specs/class.html.erb +1 -0
  170. data/spec/fixture/app/views/text_field_specs/disabled.html.erb +1 -0
  171. data/spec/fixture/app/views/text_field_specs/label.html.erb +1 -0
  172. data/spec/fixture/config/environments/development.rb +6 -0
  173. data/spec/fixture/config/environments/production.rb +5 -0
  174. data/spec/fixture/config/environments/test.rb +6 -0
  175. data/spec/fixture/config/init.rb +46 -0
  176. data/spec/fixture/config/rack.rb +11 -0
  177. data/spec/fixture/config/router.rb +36 -0
  178. data/spec/fixture/log/merb.main.pid +1 -0
  179. data/spec/fixture/log/merb_test.log +624 -0
  180. data/spec/fixture/public/images/merb.jpg +0 -0
  181. data/spec/fixture/public/merb.fcgi +4 -0
  182. data/spec/fixture/public/stylesheets/master.css +119 -0
  183. data/spec/merb_helpers_config_spec.rb +82 -0
  184. data/spec/merb_helpers_date_time_spec.rb +257 -0
  185. data/spec/merb_helpers_form_spec.rb +1266 -0
  186. data/spec/merb_helpers_tag_helper_spec.rb +46 -0
  187. data/spec/merb_helpers_text_spec.rb +67 -0
  188. data/spec/numeric_extlib_spec.rb +135 -0
  189. data/spec/ordinalize_spec.rb +51 -0
  190. data/spec/spec_helper.rb +149 -0
  191. data/spec/time_dsl_spec.rb +43 -0
  192. metadata +303 -0
@@ -0,0 +1,61 @@
1
+ module Merb
2
+ module Helpers
3
+ module Tag
4
+ # Creates a generic HTML tag. You can invoke it a variety of ways.
5
+ #
6
+ # tag :div
7
+ # # <div></div>
8
+ #
9
+ # tag :div, 'content'
10
+ # # <div>content</div>
11
+ #
12
+ # tag :div, :class => 'class'
13
+ # # <div class="class"></div>
14
+ #
15
+ # tag :div, 'content', :class => 'class'
16
+ # # <div class="class">content</div>
17
+ #
18
+ # tag :div do
19
+ # 'content'
20
+ # end
21
+ # # <div>content</div>
22
+ #
23
+ # tag :div, :class => 'class' do
24
+ # 'content'
25
+ # end
26
+ # # <div class="class">content</div>
27
+ #
28
+ def tag(name, contents = nil, attrs = {}, &block)
29
+ attrs, contents = contents, nil if contents.is_a?(Hash)
30
+ contents = capture(&block) if block_given?
31
+ open_tag(name, attrs) + contents.to_s + close_tag(name)
32
+ end
33
+
34
+ # Creates the opening tag with attributes for the provided +name+
35
+ # attrs is a hash where all members will be mapped to key="value"
36
+ #
37
+ # Note: This tag will need to be closed
38
+ def open_tag(name, attrs = nil)
39
+ "<#{name}#{' ' + attrs.to_html_attributes unless attrs.blank?}>"
40
+ end
41
+
42
+ # Creates a closing tag
43
+ def close_tag(name)
44
+ "</#{name}>"
45
+ end
46
+
47
+ # Creates a self closing tag. Like <br/> or <img src="..."/>
48
+ #
49
+ # +name+ : the name of the tag to create
50
+ # +attrs+ : a hash where all members will be mapped to key="value"
51
+ def self_closing_tag(name, attrs = nil)
52
+ "<#{name}#{' ' + attrs.to_html_attributes if attrs && !attrs.empty?}/>"
53
+ end
54
+
55
+ end
56
+ end
57
+ end
58
+
59
+ class Merb::Controller
60
+ include Merb::Helpers::Tag
61
+ end
@@ -0,0 +1,61 @@
1
+ module Merb::Helpers::Text
2
+ # Allows you to cycle through elements in an array
3
+ #
4
+ # ==== Parameters
5
+ # values<Array>:: Array of objects to cycle through
6
+ # values<Hash>:: Last element of array can be a hash with the key of
7
+ # :name to specify the name of the cycle
8
+ #
9
+ # ==== Returns
10
+ # String
11
+ #
12
+ # ==== Notes
13
+ # * Default name is :default
14
+ #
15
+ # ==== Example
16
+ # <%= 5.times { cycle("odd! ","even! "} %>
17
+ #
18
+ # Generates:
19
+ #
20
+ # odd! even! odd! even! odd!
21
+ def cycle(*values)
22
+ options = extract_options_from_args!(values) || {}
23
+ key = (options[:name] || :default).to_sym
24
+ (@cycle_positions ||= {})[key] ||= {:position => -1, :values => values}
25
+ unless values == @cycle_positions[key][:values]
26
+ @cycle_positions[key] = {:position => -1, :values => values}
27
+ end
28
+ current = @cycle_positions[key][:position]
29
+ @cycle_positions[key][:position] = current + 1
30
+ values.at( (current + 1) % values.length).to_s
31
+ end
32
+
33
+ # Allows you to reset a cycle
34
+ #
35
+ # ==== Parameters
36
+ # name<Symbol|String>:: Name of the cycle
37
+ #
38
+ # ==== Returns
39
+ # True if successful, otherwise nil
40
+ #
41
+ # ==== Notes
42
+ # * Default name is :default
43
+ #
44
+ # ==== Example
45
+ # <%= cycle("odd! ","even! ","what comes after even?") %>
46
+ # <%= cycle("odd! ","even! ","what comes after even?") %>
47
+ # <% reset_cycle %>
48
+ # <%= cycle("odd! ","even! ","what comes after even?") %>
49
+ #
50
+ # Generates:
51
+ #
52
+ # odd! even! odd!
53
+ def reset_cycle(name = :default)
54
+ (@cycle_positions[name.to_sym] = nil) &&
55
+ true if @cycle_positions && @cycle_positions[name.to_sym]
56
+ end
57
+ end
58
+
59
+ class Merb::Controller
60
+ include Merb::Helpers::Text
61
+ end
@@ -0,0 +1,59 @@
1
+ # Provides a a simple way of calling time units and to see the elapsed time between 2 moments
2
+ # ==== Examples
3
+ # 142.minutes => returns a value in seconds
4
+ # 7.days => returns a value in seconds
5
+ # 1.week => returns a value in seconds
6
+ # 2.weeks.ago => returns a date
7
+ # 1.year.since(time) => returns a date
8
+ # 5.months.since(2.weeks.from_now) => returns a date
9
+ module TimeDSL
10
+
11
+ def second
12
+ self * 1
13
+ end
14
+ alias_method :seconds, :second
15
+
16
+ def minute
17
+ self * 60
18
+ end
19
+ alias_method :minutes, :minute
20
+
21
+ def hour
22
+ self * 3600
23
+ end
24
+ alias_method :hours, :hour
25
+
26
+ def day
27
+ self * 86400
28
+ end
29
+ alias_method :days, :day
30
+
31
+ def week
32
+ self * 604800
33
+ end
34
+ alias_method :weeks, :week
35
+
36
+ def month
37
+ self * 2592000
38
+ end
39
+ alias_method :months, :month
40
+
41
+ def year
42
+ self * 31471200
43
+ end
44
+ alias_method :years, :year
45
+
46
+ # Reads best without arguments: 10.minutes.ago
47
+ def ago(time = ::Time.now)
48
+ time - self
49
+ end
50
+ alias :until :ago
51
+
52
+ # Reads best with argument: 10.minutes.since(time)
53
+ def since(time = ::Time.now)
54
+ time + self
55
+ end
56
+ alias :from_now :since
57
+ end
58
+
59
+ Numeric.send :include, TimeDSL
@@ -0,0 +1,19 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe "String" do
4
+ before :each do
5
+ @str = "This is a fairly long string to test with!"
6
+ end
7
+
8
+ it "should default to appending ..." do
9
+ @str.truncate(5).should == "Th..."
10
+ end
11
+
12
+ it "should default to a length of 30" do
13
+ @str.truncate().should == "This is a fairly long strin..."
14
+ end
15
+
16
+ it "should truncate to a given length with a given suffix" do
17
+ @str.truncate(15, "--more").should == "This is a--more"
18
+ end
19
+ end
@@ -0,0 +1,4 @@
1
+
2
+
3
+ class Application < Merb::Controller
4
+ end
@@ -0,0 +1,2 @@
1
+ class BoundCheckBoxSpecs < SpecController
2
+ end
@@ -0,0 +1,2 @@
1
+ class BoundFileFieldSpecs < SpecController
2
+ end
@@ -0,0 +1,2 @@
1
+ class BoundHiddenFieldSpecs < SpecController
2
+ end
@@ -0,0 +1,2 @@
1
+ class BoundOptionTagSpecs < SpecController
2
+ end
@@ -0,0 +1,2 @@
1
+ class BoundPasswordFieldSpecs < SpecController
2
+ end
@@ -0,0 +1,2 @@
1
+ class BoundRadioButtonSpecs < SpecController
2
+ end
@@ -0,0 +1,2 @@
1
+ class BoundRadioGroupSpecs < SpecController
2
+ end
@@ -0,0 +1,2 @@
1
+ class BoundSelectSpecs < SpecController
2
+ end
@@ -0,0 +1,2 @@
1
+ class BoundTextAreaSpecs < SpecController
2
+ end
@@ -0,0 +1,2 @@
1
+ class BoundTextFieldSpecs < SpecController
2
+ end
@@ -0,0 +1,2 @@
1
+ class ButtonSpecs < SpecController
2
+ end
@@ -0,0 +1,2 @@
1
+ class CheckBoxSpecs < SpecController
2
+ end
@@ -0,0 +1,2 @@
1
+ class CustomBuilderSpecs < SpecController
2
+ end
@@ -0,0 +1,2 @@
1
+ class DeleteButtonSpecs < SpecController
2
+ end
@@ -0,0 +1,25 @@
1
+ class Exceptions < Application
2
+
3
+ attr_reader :handler
4
+
5
+ # handle NotFound exceptions (404)
6
+
7
+ def not_found
8
+ @handler = :not_found
9
+ render :format => :html
10
+ end
11
+
12
+ # handle NotAcceptable exceptions (406)
13
+
14
+ def not_acceptable
15
+ @handler = :not_acceptable
16
+ render "Handled by: not_acceptable"
17
+ end
18
+
19
+ # # Any client error (400 series)
20
+ def client_error
21
+ @handler = :client_error
22
+ render "Handled by: client_error"
23
+ end
24
+
25
+ end
@@ -0,0 +1,2 @@
1
+ class FieldsetSpecs < SpecController
2
+ end
@@ -0,0 +1,3 @@
1
+ class FieldsForSpecs < SpecController
2
+
3
+ end
@@ -0,0 +1,2 @@
1
+ class FileFieldSpecs < SpecController
2
+ end
@@ -0,0 +1,23 @@
1
+ class Foo < Application
2
+
3
+ def index
4
+ "index"
5
+ end
6
+
7
+ def bar
8
+ render
9
+ end
10
+
11
+ def renders_tag
12
+ render
13
+ end
14
+
15
+ def raise_conflict
16
+ raise Conflict
17
+ end
18
+
19
+ def raise_not_acceptable
20
+ raise NotAcceptable
21
+ end
22
+
23
+ end
@@ -0,0 +1,2 @@
1
+ class FormSpecs < SpecController
2
+ end
@@ -0,0 +1,2 @@
1
+ class FormForSpecs < SpecController
2
+ end
@@ -0,0 +1,2 @@
1
+ class HiddenFieldSpecs < SpecController
2
+ end
@@ -0,0 +1,3 @@
1
+ class LabelSpecs < SpecController
2
+
3
+ end
@@ -0,0 +1,3 @@
1
+ class NumericExtSpecs < SpecController
2
+
3
+ end
@@ -0,0 +1,2 @@
1
+ class OptionTagSpecs < SpecController
2
+ end
@@ -0,0 +1,2 @@
1
+ class PasswordFieldSpecs < SpecController
2
+ end
@@ -0,0 +1,2 @@
1
+ class RadioButtonSpecs < SpecController
2
+ end
@@ -0,0 +1,2 @@
1
+ class RadioGroupSpecs < SpecController
2
+ end
@@ -0,0 +1,2 @@
1
+ class SelectSpecs < SpecController
2
+ end
@@ -0,0 +1,11 @@
1
+ # Helpers are tested going through the full stack.
2
+ # to keep things isolated each helper has its own controller subclass
3
+ # if you are working on a new helper, please consider creating
4
+ # a new spec controller subclass
5
+ #
6
+ # Remember that your helper spec views
7
+ # will be located in a folder named after the controller you use
8
+
9
+ class SpecController < Merb::Controller
10
+ layout nil
11
+ end
@@ -0,0 +1,2 @@
1
+ class SubmitSpecs < SpecController
2
+ end
@@ -0,0 +1,21 @@
1
+ class TagHelper < Merb::Controller
2
+ def tag_with_content
3
+ @content = "Astral Projection ~ Dancing Galaxy"
4
+
5
+ render
6
+ end
7
+
8
+ def tag_with_content_in_the_block
9
+ render
10
+ end
11
+
12
+ def nested_tags
13
+ @content = "Astral Projection ~ In the Mix"
14
+
15
+ render
16
+ end
17
+
18
+ def tag_with_attributes
19
+ render
20
+ end
21
+ end
@@ -0,0 +1,2 @@
1
+ class TextAreaSpecs < SpecController
2
+ end
@@ -0,0 +1,3 @@
1
+ class TextFieldSpecs < SpecController
2
+
3
+ end
@@ -0,0 +1,8 @@
1
+
2
+
3
+ module Merb
4
+
5
+ module GlobalHelper
6
+ # helpers defined here available to all views.
7
+ end
8
+ end
@@ -0,0 +1,25 @@
1
+ class FakeDMModel
2
+ def self.properties
3
+ [FakeColumn.new(:baz, TrueClass),
4
+ FakeColumn.new(:bat, TrueClass)
5
+ ]
6
+ end
7
+
8
+ def new_record?
9
+ false
10
+ end
11
+
12
+ def errors
13
+ FakeErrors.new(self)
14
+ end
15
+
16
+ def baz?
17
+ true
18
+ end
19
+ alias baz baz?
20
+
21
+ def bat?
22
+ false
23
+ end
24
+ alias bat bat?
25
+ end