viewaide 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.5.0
@@ -1,5 +1,4 @@
1
1
  require "viewaide/helpers/date_helper"
2
- require "viewaide/helpers/form_helper"
3
2
  require "viewaide/helpers/link_helper"
4
3
  require "viewaide/helpers/structure_helper"
5
4
  require "viewaide/helpers/table_helper"
@@ -11,7 +10,6 @@ require "viewaide/helpers/jquery_helper"
11
10
  module Viewaide
12
11
  module Helpers
13
12
  include DateHelper
14
- include FormHelper
15
13
  include LinkHelper
16
14
  include StructureHelper
17
15
  include TableHelper
@@ -23,7 +21,7 @@ module Viewaide
23
21
  protected
24
22
 
25
23
  def other_than_grid?(classes)
26
- (standardize_css_classes(classes).map {|s| s.to_s } -
24
+ (standardize_css_classes(classes).map {|css_class| css_class.to_s } -
27
25
  Viewaide::Helpers::GridHelper::MULTIPLE_FRACTIONS).any?
28
26
  end
29
27
 
@@ -31,26 +29,15 @@ module Viewaide
31
29
  css_classes = [] + standardize_css_classes(string_or_array)
32
30
 
33
31
  if replace.any?
34
- replace.keys.each do |k|
35
- if css_classes.include? k
36
- css_classes.delete(k)
37
- css_classes << replace[k]
38
- end
39
- end
32
+ replace_css_classes(css_classes, replace)
40
33
  end
41
34
 
42
35
  fractions = css_classes & Viewaide::Helpers::GridHelper::MULTIPLE_FRACTIONS
43
36
  if css_classes.any? && fractions.any?
44
- fractions.each do |fraction|
45
- css_classes.delete(fraction)
46
- css_classes << self.send(fraction)
47
- if fraction == "full" && @_viewaide_column_count != application_width
48
- css_classes << last_column
49
- end
50
- end
37
+ replace_fractions(css_classes, fractions)
51
38
  end
52
39
 
53
- css_classes.map {|s| s.strip }.reject {|s| s.blank? }.uniq.join(" ").strip
40
+ css_classes.map(&:strip).reject(&:blank?).uniq.join(" ").strip
54
41
  end
55
42
 
56
43
  private
@@ -59,6 +46,25 @@ module Viewaide
59
46
  [string_or_array].flatten.join(" ").split(/ /)
60
47
  end
61
48
 
49
+ def replace_css_classes(css_classes, replace)
50
+ replace.keys.each do |key|
51
+ if css_classes.include?(key)
52
+ css_classes.delete(key)
53
+ css_classes << replace[key]
54
+ end
55
+ end
56
+ end
57
+
58
+ def replace_fractions(css_classes, fractions)
59
+ fractions.each do |fraction|
60
+ css_classes.delete(fraction)
61
+ css_classes << self.send(fraction)
62
+ if fraction == "full" && @_viewaide_column_count != application_width
63
+ css_classes << last_column
64
+ end
65
+ end
66
+ end
67
+
62
68
  BLOCK_CALLED_FROM_ERB = 'defined? __in_erb_template'
63
69
 
64
70
  if RUBY_VERSION < '1.9.0'
@@ -2,31 +2,31 @@ module Viewaide
2
2
  module Helpers
3
3
  module GridHelper
4
4
  MULTIPLES = {
5
- :one_twentyfourth => (1/24.to_f),
6
- :one_twelfth => (1/12.to_f),
7
- :one_eigth => (1/8.to_f),
8
- :one_sixth => (1/6.to_f),
9
- :five_twentyfourths => (5/24.to_f),
10
- :one_fourth => (1/4.to_f),
11
- :seven_twentyfourths => (7/24.to_f),
12
- :one_third => (1/3.to_f),
13
- :three_eigths => (3/8.to_f),
14
- :five_twelfths => (5/12.to_f),
15
- :eleven_twentyfourths => (11/24.to_f),
16
- :one_half => (1/2.to_f),
17
- :half => (1/2.to_f),
18
- :thirteen_twentyfourths => (13/24.to_f),
19
- :seven_twelfths => (7/12.to_f),
20
- :five_eigths => (5/8.to_f),
21
- :two_thirds => (2/3.to_f),
22
- :seventeen_twentyfourths => (17/24.to_f),
23
- :three_fourths => (3/4.to_f),
24
- :nineteen_twentyfourths => (19/24.to_f),
25
- :five_sixths => (5/6.to_f),
26
- :seven_eigths => (7/8.to_f),
27
- :eleven_twelfths => (11/12.to_f),
28
- :twentythree_twentyfourths => (23/24.to_f),
29
- :full => (1.to_f)
5
+ :one_twentyfourth => (1/24.0),
6
+ :one_twelfth => (1/12.0),
7
+ :one_eigth => (1/8.0),
8
+ :one_sixth => (1/6.0),
9
+ :five_twentyfourths => (5/24.0),
10
+ :one_fourth => (1/4.0),
11
+ :seven_twentyfourths => (7/24.0),
12
+ :one_third => (1/3.0),
13
+ :three_eigths => (3/8.0),
14
+ :five_twelfths => (5/12.0),
15
+ :eleven_twentyfourths => (11/24.0),
16
+ :one_half => (1/2.0),
17
+ :half => (1/2.0),
18
+ :thirteen_twentyfourths => (13/24.0),
19
+ :seven_twelfths => (7/12.0),
20
+ :five_eigths => (5/8.0),
21
+ :two_thirds => (2/3.0),
22
+ :seventeen_twentyfourths => (17/24.0),
23
+ :three_fourths => (3/4.0),
24
+ :nineteen_twentyfourths => (19/24.0),
25
+ :five_sixths => (5/6.0),
26
+ :seven_eigths => (7/8.0),
27
+ :eleven_twelfths => (11/12.0),
28
+ :twentythree_twentyfourths => (23/24.0),
29
+ :full => (1.0)
30
30
  }.freeze
31
31
  MULTIPLE_FRACTIONS = MULTIPLES.keys.map {|key| key.to_s }.freeze
32
32
 
@@ -104,19 +104,17 @@ module Viewaide
104
104
  def clean_column(classes, &block)
105
105
  size = classes.scan(/#{column_prefix}-(\d+)/).flatten.last
106
106
 
107
+ executed_with_erb = block_given? && block_is_within_action_view?(block)
108
+
107
109
  if size.nil?
108
110
  html = capture(&block)
109
- if block_given? && block_is_within_action_view?(block)
110
- concat(html)
111
- else
112
- html
113
- end
111
+ executed_with_erb ? concat(html) : html
114
112
  else
115
113
  size = size.to_i
116
114
  increase_depth(size)
117
115
  html = capture(&block)
118
116
 
119
- if block_given? && block_is_within_action_view?(block)
117
+ if executed_with_erb
120
118
  concat(html)
121
119
  decrease_depth(size)
122
120
  else
@@ -17,23 +17,23 @@ module Viewaide
17
17
  def messages(messages, options = {})
18
18
  except_keys = [options[:except]].flatten.compact
19
19
  only_keys = [options[:only]].flatten.compact
20
+ all_keys = messages.keys
20
21
 
21
22
  if except_keys.any? && only_keys.any?
22
23
  raise ArgumentError, ":only and :except options conflict; use one"
23
24
  end
24
25
 
25
26
  keys = if except_keys.any?
26
- messages.keys - except_keys
27
+ all_keys - except_keys
27
28
  elsif only_keys.any?
28
- messages.keys & only_keys
29
+ all_keys & only_keys
29
30
  else
30
- messages.keys
31
+ all_keys
31
32
  end
32
33
 
33
34
  keys.map do |key|
34
35
  if messages[key].present?
35
- content_tag :p,
36
- messages[key],
36
+ content_tag :p, messages[key],
37
37
  :class => [key, "single-line"].join(" ")
38
38
  end
39
39
  end.join
@@ -46,30 +46,22 @@ class GridHelperTest < Viewaide::ViewTestCase
46
46
  should "properly assign classes for generic helpers" do
47
47
  template = %(
48
48
  <% column do %>
49
- <% fieldset :hform, :half do %>
50
- <% set :one_third do %>text<% end %>
51
- <% set :two_thirds, :last do %>more text<% end %>
52
- <% end %>
53
- <% recordset :half, :last do %>table<% end %>
49
+ <% recordset :simple, :half do %><% end %>
50
+ <% recordset :half, :last do %>table content<% end %>
54
51
  <% end %>
55
52
  )
56
53
 
57
54
  show_view template do
58
55
  assert_select "div.span-24" do
59
- assert_select "fieldset.hform.span-12" do
60
- assert_select "div.span-4", "text"
61
- assert_select "div.span-8.last", "more text"
62
- end
63
- assert_select "table.span-12.last", "table"
56
+ assert_select "table.simple.span-12"
57
+ assert_select "table.span-12.last", "table content"
64
58
  end
65
59
  end
66
60
  end
67
61
 
68
62
  should "properly assign classes for generic helpers without column wrappers" do
69
63
  template = %(
70
- <% fieldset :hform, :half do %>
71
- <% set :one_third do %>text<% end %>
72
- <% set :two_thirds, :last do %>more text<% end %>
64
+ <% recordset :hform, :half do %>
73
65
  <% column do %>
74
66
  <% column :one_third do %>one third<% end %>
75
67
  <% column :two_thirds, :last do %>
@@ -87,10 +79,7 @@ class GridHelperTest < Viewaide::ViewTestCase
87
79
  )
88
80
 
89
81
  show_view template do
90
- assert_select "fieldset.hform.span-12" do
91
- assert_select "div.span-4", "text"
92
- assert_select "div.span-8.last", "more text"
93
-
82
+ assert_select "table.hform.span-12" do
94
83
  assert_select "div.span-12.last" do
95
84
  assert_select "div.span-4", "one third"
96
85
  assert_select "div.span-8.last" do
@@ -112,16 +101,16 @@ class GridHelperTest < Viewaide::ViewTestCase
112
101
  template = %(
113
102
  <% container :full do %>
114
103
  <% column :half do %>
115
- <% fieldset :hform, :half do %>
116
- <% set :one_third do %>text<% end %>
117
- <% set :two_thirds, :last do %>more text<% end %>
104
+ <% recordset :hform, :half do %>
105
+ <% column :one_third do %>text<% end %>
106
+ <% column :two_thirds, :last do %>more text<% end %>
118
107
  <% end %>
119
108
  <% recordset :half, :last do %>table<% end %>
120
109
  <% end %>
121
110
  <% column :one_third do %>one third!<% end %>
122
111
  <% column :one_sixth, :last do %>
123
- <% fieldset :vform, :full do %>
124
- <% set do %>text<% end %>
112
+ <% recordset :vform, :full do %>
113
+ <% column do %>text<% end %>
125
114
  <% end %>
126
115
  <% end %>
127
116
  <% end %>
@@ -131,7 +120,7 @@ class GridHelperTest < Viewaide::ViewTestCase
131
120
  assert_select "div.container.span-24", 1
132
121
  assert_select "div.container" do
133
122
  assert_select "div.span-12" do
134
- assert_select "fieldset.hform.span-6" do
123
+ assert_select "table.hform.span-6" do
135
124
  assert_select "div.span-2", "text"
136
125
  assert_select "div.span-4.last", "more text"
137
126
  end
@@ -141,7 +130,7 @@ class GridHelperTest < Viewaide::ViewTestCase
141
130
  assert_select "div.span-8", "one third!"
142
131
 
143
132
  assert_select "div.span-4.last" do
144
- assert_select "fieldset.vform.span-4.last" do
133
+ assert_select "table.vform.span-4.last" do
145
134
  assert_select "div", "text"
146
135
  end
147
136
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{viewaide}
8
- s.version = "0.4.1"
8
+ s.version = "0.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Joshua Clayton"]
12
- s.date = %q{2010-02-08}
12
+ s.date = %q{2010-03-31}
13
13
  s.description = %q{Making your views easier}
14
14
  s.email = %q{joshua.clayton@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -25,7 +25,6 @@ Gem::Specification.new do |s|
25
25
  "lib/viewaide.rb",
26
26
  "lib/viewaide/helpers.rb",
27
27
  "lib/viewaide/helpers/date_helper.rb",
28
- "lib/viewaide/helpers/form_helper.rb",
29
28
  "lib/viewaide/helpers/grid_helper.rb",
30
29
  "lib/viewaide/helpers/jquery_helper.rb",
31
30
  "lib/viewaide/helpers/link_helper.rb",
@@ -37,7 +36,6 @@ Gem::Specification.new do |s|
37
36
  "rails/init.rb",
38
37
  "tasks/viewaide_tasks.rake",
39
38
  "test/date_helper_test.rb",
40
- "test/form_helper_test.rb",
41
39
  "test/grid_helper_test.rb",
42
40
  "test/jquery_helper_test.rb",
43
41
  "test/link_helper_test.rb",
@@ -51,11 +49,10 @@ Gem::Specification.new do |s|
51
49
  s.homepage = %q{http://github.com/joshuaclayton/viewaide}
52
50
  s.rdoc_options = ["--charset=UTF-8"]
53
51
  s.require_paths = ["lib"]
54
- s.rubygems_version = %q{1.3.5}
52
+ s.rubygems_version = %q{1.3.6}
55
53
  s.summary = %q{Making your views easier}
56
54
  s.test_files = [
57
55
  "test/date_helper_test.rb",
58
- "test/form_helper_test.rb",
59
56
  "test/grid_helper_test.rb",
60
57
  "test/jquery_helper_test.rb",
61
58
  "test/link_helper_test.rb",
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: viewaide
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 5
8
+ - 0
9
+ version: 0.5.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - Joshua Clayton
@@ -9,39 +14,51 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-02-08 00:00:00 -05:00
17
+ date: 2010-03-31 00:00:00 -04:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: actionpack
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 2
29
+ - 1
30
+ - 0
23
31
  version: 2.1.0
24
- version:
32
+ type: :runtime
33
+ version_requirements: *id001
25
34
  - !ruby/object:Gem::Dependency
26
35
  name: activesupport
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
30
38
  requirements:
31
39
  - - ">="
32
40
  - !ruby/object:Gem::Version
41
+ segments:
42
+ - 2
43
+ - 1
44
+ - 0
33
45
  version: 2.1.0
34
- version:
46
+ type: :runtime
47
+ version_requirements: *id002
35
48
  - !ruby/object:Gem::Dependency
36
49
  name: hpricot
37
- type: :runtime
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
40
52
  requirements:
41
53
  - - ">="
42
54
  - !ruby/object:Gem::Version
55
+ segments:
56
+ - 0
57
+ - 8
58
+ - 1
43
59
  version: 0.8.1
44
- version:
60
+ type: :runtime
61
+ version_requirements: *id003
45
62
  description: Making your views easier
46
63
  email: joshua.clayton@gmail.com
47
64
  executables: []
@@ -60,7 +77,6 @@ files:
60
77
  - lib/viewaide.rb
61
78
  - lib/viewaide/helpers.rb
62
79
  - lib/viewaide/helpers/date_helper.rb
63
- - lib/viewaide/helpers/form_helper.rb
64
80
  - lib/viewaide/helpers/grid_helper.rb
65
81
  - lib/viewaide/helpers/jquery_helper.rb
66
82
  - lib/viewaide/helpers/link_helper.rb
@@ -72,7 +88,6 @@ files:
72
88
  - rails/init.rb
73
89
  - tasks/viewaide_tasks.rake
74
90
  - test/date_helper_test.rb
75
- - test/form_helper_test.rb
76
91
  - test/grid_helper_test.rb
77
92
  - test/jquery_helper_test.rb
78
93
  - test/link_helper_test.rb
@@ -95,24 +110,25 @@ required_ruby_version: !ruby/object:Gem::Requirement
95
110
  requirements:
96
111
  - - ">="
97
112
  - !ruby/object:Gem::Version
113
+ segments:
114
+ - 0
98
115
  version: "0"
99
- version:
100
116
  required_rubygems_version: !ruby/object:Gem::Requirement
101
117
  requirements:
102
118
  - - ">="
103
119
  - !ruby/object:Gem::Version
120
+ segments:
121
+ - 0
104
122
  version: "0"
105
- version:
106
123
  requirements: []
107
124
 
108
125
  rubyforge_project:
109
- rubygems_version: 1.3.5
126
+ rubygems_version: 1.3.6
110
127
  signing_key:
111
128
  specification_version: 3
112
129
  summary: Making your views easier
113
130
  test_files:
114
131
  - test/date_helper_test.rb
115
- - test/form_helper_test.rb
116
132
  - test/grid_helper_test.rb
117
133
  - test/jquery_helper_test.rb
118
134
  - test/link_helper_test.rb
@@ -1,165 +0,0 @@
1
- module Viewaide
2
- module Helpers
3
- module FormHelper
4
-
5
- # Generates a submit button for forms
6
- #
7
- # @param [String] value the text for the button
8
- # @param [*Args]
9
- # @return [String]
10
- # @example
11
- # <%= submit_button "Create" %>
12
- # generates
13
- # <button class="btn" type="submit" value="Create">
14
- # <span>Create</span>
15
- # </button>
16
- #
17
- # @example
18
- # <%= submit_button "Create", :class1, :class2, "another-class" %>
19
- # generates
20
- # <button class="btn class1 class2 another-class" type="submit" value="Create">
21
- # <span>Create</span>
22
- # </button>
23
- #
24
- # @example
25
- # <%= submit_button "Create", :class1, :id => "custom", :type => "image" %>
26
- # generates
27
- # <button class="btn class1" type="image" id="custom" value="Create">
28
- # <span>Create</span>
29
- # </button>
30
- #
31
- # @example
32
- # <%= submit_button "Create", :class1, :value => "override" %>
33
- # generates
34
- # <button class="btn class1" type="submit" value="override">
35
- # <span>Create</span>
36
- # </button>
37
- def submit_button(value, *args)
38
- options = args.extract_options!
39
- css_classes = ["btn"] << options.delete(:class) << args
40
- css_classes = clean_css_classes(css_classes, {"last" => last_column})
41
-
42
- content_tag :button,
43
- "<span>#{value}</span>",
44
- { :value => value,
45
- :type => "submit",
46
- :class => css_classes
47
- }.merge(options)
48
- end
49
-
50
- # Generates a wrapper set for form inputs and labels
51
- #
52
- # @param [*Args]
53
- # @return [String]
54
- # @example
55
- # <% set do %>words<% end %>
56
- # generates
57
- # <div class="text">words</div>
58
- #
59
- # @example
60
- # <% set :checkbox do %>words<% end %>
61
- # generates
62
- # <div class="checkbox">words</div>
63
- #
64
- # @example
65
- # <% set :id => "custom-id" do %>words<% end %>
66
- # generates
67
- # <div class="text" id="custom-id">words</div>
68
- #
69
- # @example
70
- # <% set :half do %>words<% end %>
71
- # generates
72
- # <div class="text span-12">words</div>
73
- def set(*args, &block)
74
- options = args.extract_options!
75
- css_classes = [] << options.delete(:class) << args
76
-
77
- if !other_than_grid?(args.map(&:to_s) - ["error", "last", last_column.to_s])
78
- css_classes << "text"
79
- end
80
-
81
- if standardize_css_classes(css_classes).include?("textarea")
82
- css_classes << "text"
83
- end
84
-
85
- css_classes = clean_css_classes(css_classes, {"last" => last_column})
86
-
87
- html = clean_column(css_classes) do
88
- content_tag :div,
89
- capture(&block),
90
- options.merge(:class => css_classes)
91
- end
92
-
93
- concat(html)
94
- end
95
-
96
- # Generates a fieldset with legend
97
- #
98
- # @param [*Args]
99
- # @return [String]
100
- # @example
101
- # <% fieldset do %>words<% end %>
102
- # generates
103
- # <fieldset>words</fieldset>
104
- #
105
- # @example
106
- # <% fieldset "User Information" do %>words<% end %>
107
- # generates
108
- # <fieldset>
109
- # <h3 class="legend">User Information</h3>
110
- # </fieldset>
111
- #
112
- # @example
113
- # <% fieldset "User Information", :hform do %>words<% end %>
114
- # generates
115
- # <fieldset class="hform">
116
- # <h3 class="legend">User Information</h3>
117
- # </fieldset>
118
- #
119
- # @example
120
- # <% fieldset "User Information", :hform, :legend => {:class => "lgnd", :id => "legend-id"} do %>
121
- # words
122
- # <% end %>
123
- # generates
124
- # <fieldset class="hform">
125
- # <h3 class="legend lgnd" id="legend-id">User Information</h3>
126
- # words
127
- # </fieldset>
128
- #
129
- # @example
130
- # <% fieldset "User Information", :hform, :id => "user-info" do %>
131
- # words
132
- # <% end %>
133
- # generates
134
- # <fieldset class="hform" id="user-info">
135
- # <h3 class="legend">User Information</h3>
136
- # words
137
- # </fieldset>
138
- def fieldset(*args, &block)
139
- options = args.extract_options!
140
- css_classes = [] << options.delete(:class) << args
141
- title = args.shift if args.first.is_a?(String)
142
- legend = if title.blank?
143
- ""
144
- else
145
- legend_opts = options.delete(:legend) || {}
146
- legend_classes = clean_css_classes([legend_opts.delete(:class)] << "legend")
147
- content_tag :h3,
148
- title,
149
- {:class => legend_classes}.merge(legend_opts)
150
- end
151
-
152
- css_classes = clean_css_classes(css_classes, {"last" => last_column})
153
-
154
- html = clean_column(css_classes) do
155
- content_tag :fieldset,
156
- legend + capture(&block),
157
- options.merge(:class => css_classes)
158
- end
159
-
160
- concat(html)
161
- end
162
-
163
- end
164
- end
165
- end
@@ -1,135 +0,0 @@
1
- require "test_helper"
2
-
3
- class FormHelperTest < Viewaide::ViewTestCase
4
-
5
- context "submit_button" do
6
-
7
- should "default with the correct structure" do
8
- show_view "<%= submit_button 'Create' %>" do
9
- assert_select "button.btn[type=submit][value=Create]" do
10
- assert_select "span", "Create"
11
- end
12
- end
13
- end
14
-
15
- should "allow adding additional classes" do
16
- show_view "<%= submit_button 'Create', 'adtl-class', :dumb %>" do
17
- assert_select "button.btn.adtl-class.dumb[type=submit][value=Create]" do
18
- assert_select "span", "Create"
19
- end
20
- end
21
- end
22
-
23
- should "handle additional attributes set" do
24
- show_view "<%= submit_button 'Create', :kls, :id => 'my-id', :type => 'image' %>" do
25
- assert_select "button.btn.kls#my-id[type=image][value=Create]" do
26
- assert_select "span", "Create"
27
- end
28
- end
29
- end
30
-
31
- should "allow overriding of value" do
32
- show_view "<%= submit_button 'Create', :value => 'override' %>" do
33
- assert_select "button.btn[type=submit][value=override]" do
34
- assert_select "span", "Create"
35
- end
36
- end
37
- end
38
-
39
- end
40
-
41
- context "set" do
42
-
43
- should "default with the correct structure" do
44
- show_view "<% set do %>words<% end %>" do
45
- assert_select "div.text", "words"
46
- end
47
- end
48
-
49
- should "allow adding/overriding classes" do
50
- show_view "<% set :checkbox do %>words<% end %>" do
51
- assert_select "div.checkbox", "words"
52
- end
53
- end
54
-
55
- should "handle additional attributes set" do
56
- show_view "<% set :id => 'custom-id' do %>words<% end %>" do
57
- assert_select "div.text#custom-id", "words"
58
- end
59
- end
60
-
61
- should "assign default class if width class is passed as the only class" do
62
- show_view "<% set :half do %>words<% end %>" do
63
- assert_select "div.text.span-12", "words"
64
- end
65
- end
66
-
67
- should "assign default class if last class is passed as the only class" do
68
- show_view "<% set :half, :last do %>words<% end %>" do
69
- assert_select "div.span-12.text.last", "words"
70
- end
71
- end
72
-
73
- should "assign default class if error class is passed" do
74
- show_view "<% set :half, :last, :error do %>words<% end %>" do
75
- assert_select "div.span-12.text.last.error", "words"
76
- end
77
- end
78
-
79
- should "assign default class if the class textarea is present" do
80
- show_view "<% set :textarea do %>words<% end %>" do
81
- assert_select "div.textarea.text", "words"
82
- end
83
- end
84
-
85
- end
86
-
87
- context "fieldset" do
88
-
89
- should "default with the correct structure" do
90
- show_view "<% fieldset do %>words<% end %>" do
91
- assert_select "fieldset", "words"
92
- end
93
- end
94
-
95
- should "assign the first argument as the legend if it is a string" do
96
- show_view "<% fieldset 'User Information' do %>words<% end %>" do
97
- assert_select "fieldset", /words/ do
98
- assert_select "h3.legend", "User Information"
99
- end
100
- end
101
- end
102
-
103
- should "allow adding fieldset classes" do
104
- show_view "<% fieldset :hform, :last do %>words<% end %>" do
105
- assert_select "fieldset.hform.last", "words"
106
- end
107
- end
108
-
109
- should "allow adding fieldset classes and a legend" do
110
- show_view "<% fieldset 'User Information', :hform, :last do %>words<% end %>" do
111
- assert_select "fieldset.hform.last", /words/ do
112
- assert_select "h3.legend", "User Information"
113
- end
114
- end
115
- end
116
-
117
- should "allow assignment of legend attributes" do
118
- show_view "<% fieldset 'User Information', :hform, :legend => {:class => 'lgnd', :id => 'legend-id'} do %>words<% end %>" do
119
- assert_select "fieldset.hform", /words/ do
120
- assert_select "h3.legend.lgnd#legend-id", "User Information"
121
- end
122
- end
123
- end
124
-
125
- should "allow assignment of fieldset attributes" do
126
- show_view "<% fieldset 'User Information', :hform, :id => 'my-fieldset' do %>words<% end %>" do
127
- assert_select "fieldset.hform#my-fieldset", /words/ do
128
- assert_select "h3.legend", "User Information"
129
- end
130
- end
131
- end
132
-
133
- end
134
-
135
- end