easel_helpers 0.3.0
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/MIT-LICENSE +20 -0
- data/Manifest +31 -0
- data/README.textile +3 -0
- data/Rakefile +18 -0
- data/easel_helpers.gemspec +41 -0
- data/lib/easel_helpers.rb +3 -0
- data/lib/easel_helpers/helpers.rb +81 -0
- data/lib/easel_helpers/helpers/date_helper.rb +15 -0
- data/lib/easel_helpers/helpers/form_helper.rb +68 -0
- data/lib/easel_helpers/helpers/grid_helper.rb +178 -0
- data/lib/easel_helpers/helpers/jquery_helper.rb +21 -0
- data/lib/easel_helpers/helpers/link_helper.rb +21 -0
- data/lib/easel_helpers/helpers/message_helper.rb +32 -0
- data/lib/easel_helpers/helpers/navigation_helper.rb +29 -0
- data/lib/easel_helpers/helpers/rjs_helper.rb +20 -0
- data/lib/easel_helpers/helpers/structure_helper.rb +43 -0
- data/lib/easel_helpers/helpers/table_helper.rb +61 -0
- data/lib/easel_helpers/rails_partial_caching.rb +40 -0
- data/rails/init.rb +4 -0
- data/tasks/easel_helpers_tasks.rake +4 -0
- data/test/date_helper_test.rb +59 -0
- data/test/form_helper_test.rb +135 -0
- data/test/grid_helper_test.rb +226 -0
- data/test/jquery_helper_test.rb +30 -0
- data/test/link_helper_test.rb +44 -0
- data/test/message_helper_test.rb +50 -0
- data/test/navigation_helper_test.rb +130 -0
- data/test/rjs_helper_test.rb +47 -0
- data/test/structure_helper_test.rb +54 -0
- data/test/table_helper_test.rb +112 -0
- data/test/test_helper.rb +34 -0
- metadata +152 -0
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RjsHelperTest < ActiveSupport::TestCase
|
4
|
+
include EaselHelpers::Helpers::RjsHelper
|
5
|
+
include EaselHelpers::Helpers::MessageHelper
|
6
|
+
|
7
|
+
context "inline_flash" do
|
8
|
+
setup do
|
9
|
+
@page = Object.new
|
10
|
+
@flash_hash = {:notice => "Test!"}
|
11
|
+
self.expects(:messages).with({:notice => "Test!"}).returns("string")
|
12
|
+
end
|
13
|
+
|
14
|
+
context "without keeping flash" do
|
15
|
+
setup do
|
16
|
+
@flash_hash.expects(:discard).returns(true)
|
17
|
+
end
|
18
|
+
|
19
|
+
should "default to inserting flash within div#flash-container" do
|
20
|
+
@page.expects(:insert_html).with(:top, "flash-container", "string")
|
21
|
+
inline_flash(@page, @flash_hash)
|
22
|
+
end
|
23
|
+
|
24
|
+
should "allow assignment of container id" do
|
25
|
+
@page.expects(:insert_html).with(:top, "my-custom-id", "string")
|
26
|
+
inline_flash(@page, @flash_hash, {:container => "my-custom-id"})
|
27
|
+
end
|
28
|
+
|
29
|
+
should "allow replacement of current flash container's HTML" do
|
30
|
+
@page.expects(:replace_html).with("flash-container", "string")
|
31
|
+
inline_flash(@page, @flash_hash, {:replace => true})
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "when keeping flash" do
|
36
|
+
setup do
|
37
|
+
@flash_hash.expects(:discard).never
|
38
|
+
end
|
39
|
+
|
40
|
+
should "default to inserting flash within div#flash-container" do
|
41
|
+
@page.expects(:insert_html).with(:top, "flash-container", "string")
|
42
|
+
inline_flash(@page, @flash_hash, :keep_flash => true)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class StructureHelperTest < EaselHelpers::ViewTestCase
|
4
|
+
|
5
|
+
context "blockquote" do
|
6
|
+
|
7
|
+
should "default with the correct structure" do
|
8
|
+
show_view "<% blockquote do %>My quoted text<% end %>" do
|
9
|
+
assert_select "blockquote", "My quoted text"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
should "default with the correct structure when an author is set" do
|
14
|
+
show_view "<% blockquote :author => 'W. Shakespeare' do %>All the world's a stage<% end %>" do
|
15
|
+
assert_select "div.quote-cited" do
|
16
|
+
assert_select "blockquote", "All the world's a stage"
|
17
|
+
assert_select "cite", "W. Shakespeare"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
context "body" do
|
25
|
+
|
26
|
+
should "allow passing a block structure" do
|
27
|
+
show_view %(
|
28
|
+
<% body do %>body goes here<% end %>
|
29
|
+
) do
|
30
|
+
assert_select "body", "body goes here"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
should "allow passing arguments" do
|
35
|
+
show_view %(
|
36
|
+
<% body :home, 'home-index', 'logged-in', :id => 'application' do %>body goes here<% end %>
|
37
|
+
) do
|
38
|
+
assert_select "body#application.home.home-index.logged-in", "body goes here"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
should "allow multiple body definitions that set attributes" do
|
43
|
+
show_view %(
|
44
|
+
<% body :home, 'logged-in' %>
|
45
|
+
<% body :id => 'application' %>
|
46
|
+
<% body 'home-index', :id => 'application-override' do %>body goes here<% end %>
|
47
|
+
) do
|
48
|
+
assert_select "body#application-override.home.home-index.logged-in", "body goes here"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TableHelperTest < EaselHelpers::ViewTestCase
|
4
|
+
|
5
|
+
context "zebra_row" do
|
6
|
+
|
7
|
+
should "default with the correct structure" do
|
8
|
+
show_view "<table><% zebra_row do %>no class<% end %><% zebra_row do %>alt class<% end %></table>" do
|
9
|
+
assert_select "tr:first-child", "no class"
|
10
|
+
assert_select "tr.alt:last-child", "alt class"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
should "allow override of the cycle list" do
|
15
|
+
show_view %(
|
16
|
+
<table>
|
17
|
+
<% (colors = %w(red white blue)).each do |color| %>
|
18
|
+
<% zebra_row :cycle_list => colors do %>the color <%= color %><% end %>
|
19
|
+
<% end %>
|
20
|
+
</table>
|
21
|
+
) do
|
22
|
+
assert_select "tr.red:first-child", "the color red"
|
23
|
+
assert_select "tr.white", "the color white"
|
24
|
+
assert_select "tr.blue:last-child", "the color blue"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
should "allow option assignment" do
|
29
|
+
show_view "<% zebra_row :id => 'my-id', :class => 'custom-class' do %>user 1<% end %>" do
|
30
|
+
assert_select "tr#my-id.custom-class", "user 1"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
context "recordset" do
|
37
|
+
|
38
|
+
should "default with the correct structure" do
|
39
|
+
show_view %(<% recordset do %>rows<% end %>) do
|
40
|
+
assert_select "table.recordset[cellspacing=0]", "rows"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
should "allow headers be set" do
|
45
|
+
show_view %(<% recordset :headers => ["Header 1", "Header 2", "Header 3"] do %><tbody>rows</tbody><% end %>) do
|
46
|
+
assert_select "table.recordset[cellspacing=0]" do
|
47
|
+
assert_select "thead" do
|
48
|
+
assert_select "tr" do
|
49
|
+
assert_select "th.first", "Header 1"
|
50
|
+
assert_select "th", "Header 2"
|
51
|
+
assert_select "th.last", "Header 3"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
assert_select "tbody", "rows"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
should "allow headers to have attributes set" do
|
60
|
+
show_view %(
|
61
|
+
<% recordset :headers => [["Header 1", {:class => "mine", :id => "over"}]] do %>
|
62
|
+
<tbody>rows</tbody>
|
63
|
+
<% end %>
|
64
|
+
) do
|
65
|
+
assert_select "table.recordset[cellspacing=0]" do
|
66
|
+
assert_select "thead" do
|
67
|
+
assert_select "tr" do
|
68
|
+
assert_select "th#over.first.mine", "Header 1"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
assert_select "tbody", "rows"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
should "allow classes be assigned in a comma-delimited manner" do
|
77
|
+
show_view %(<% recordset "my-recordset", "car-list" do %><% end %>) do
|
78
|
+
assert_select "table.recordset.my-recordset.car-list[cellspacing=0]"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
should "allow additional attributes be set on the recordset" do
|
83
|
+
show_view %(<% recordset :headers => %w(One Two Three), :table => {:id => "my-id", :class => "my-recordset"} do %><% end %>) do
|
84
|
+
assert_select "table#my-id.recordset.my-recordset[cellspacing=0]" do
|
85
|
+
assert_select "thead" do
|
86
|
+
assert_select "tr" do
|
87
|
+
assert_select "th", "One"
|
88
|
+
assert_select "th", "Two"
|
89
|
+
assert_select "th", "Three"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
should "reset cycles for zebra_rows" do
|
97
|
+
show_view %(
|
98
|
+
<% recordset do %>
|
99
|
+
<% zebra_row do %>text<% end %>
|
100
|
+
<% end %>
|
101
|
+
<% recordset do %>
|
102
|
+
<% zebra_row do %>text<% end %>
|
103
|
+
<% end %>
|
104
|
+
) do
|
105
|
+
assert_select "table.recordset" do
|
106
|
+
assert_select "tr.alt", 0
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'active_support'
|
4
|
+
require 'active_support/test_case'
|
5
|
+
|
6
|
+
require 'shoulda/rails'
|
7
|
+
require 'action_controller'
|
8
|
+
require 'action_controller/test_process'
|
9
|
+
|
10
|
+
require "easel_helpers"
|
11
|
+
|
12
|
+
ActionView::Base.send :include, EaselHelpers::Helpers
|
13
|
+
ActionController::Base.send :include, EaselHelpers::PartialCaching
|
14
|
+
|
15
|
+
class EaselHelpers::ViewTestCase < ActiveSupport::TestCase
|
16
|
+
include ActionController::Assertions::SelectorAssertions
|
17
|
+
|
18
|
+
def setup
|
19
|
+
super
|
20
|
+
@view = ActionView::Base.new
|
21
|
+
end
|
22
|
+
|
23
|
+
protected
|
24
|
+
|
25
|
+
def show_view(template)
|
26
|
+
@html_result = ActionView::InlineTemplate.new(template).render(@view, {})
|
27
|
+
@html_document = HTML::Document.new(@html_result, true, false)
|
28
|
+
yield if block_given?
|
29
|
+
end
|
30
|
+
|
31
|
+
def response_from_page_or_rjs
|
32
|
+
@html_document.root
|
33
|
+
end
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: easel_helpers
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joshua Clayton
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-08-21 00:00:00 -04:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: actionview
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
- - "="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.1.0
|
27
|
+
version:
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: activesupport
|
30
|
+
type: :development
|
31
|
+
version_requirement:
|
32
|
+
version_requirements: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: "0"
|
37
|
+
- - "="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 2.1.0
|
40
|
+
version:
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: hpricot
|
43
|
+
type: :development
|
44
|
+
version_requirement:
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: "0"
|
50
|
+
- - "="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 0.8.1
|
53
|
+
version:
|
54
|
+
description: Fusionary Rails View Helpers
|
55
|
+
email: joshua.clayton@gmail.com
|
56
|
+
executables: []
|
57
|
+
|
58
|
+
extensions: []
|
59
|
+
|
60
|
+
extra_rdoc_files:
|
61
|
+
- lib/easel_helpers/helpers/date_helper.rb
|
62
|
+
- lib/easel_helpers/helpers/form_helper.rb
|
63
|
+
- lib/easel_helpers/helpers/grid_helper.rb
|
64
|
+
- lib/easel_helpers/helpers/jquery_helper.rb
|
65
|
+
- lib/easel_helpers/helpers/link_helper.rb
|
66
|
+
- lib/easel_helpers/helpers/message_helper.rb
|
67
|
+
- lib/easel_helpers/helpers/navigation_helper.rb
|
68
|
+
- lib/easel_helpers/helpers/rjs_helper.rb
|
69
|
+
- lib/easel_helpers/helpers/structure_helper.rb
|
70
|
+
- lib/easel_helpers/helpers/table_helper.rb
|
71
|
+
- lib/easel_helpers/helpers.rb
|
72
|
+
- lib/easel_helpers/rails_partial_caching.rb
|
73
|
+
- lib/easel_helpers.rb
|
74
|
+
- README.textile
|
75
|
+
- tasks/easel_helpers_tasks.rake
|
76
|
+
files:
|
77
|
+
- easel_helpers.gemspec
|
78
|
+
- lib/easel_helpers/helpers/date_helper.rb
|
79
|
+
- lib/easel_helpers/helpers/form_helper.rb
|
80
|
+
- lib/easel_helpers/helpers/grid_helper.rb
|
81
|
+
- lib/easel_helpers/helpers/jquery_helper.rb
|
82
|
+
- lib/easel_helpers/helpers/link_helper.rb
|
83
|
+
- lib/easel_helpers/helpers/message_helper.rb
|
84
|
+
- lib/easel_helpers/helpers/navigation_helper.rb
|
85
|
+
- lib/easel_helpers/helpers/rjs_helper.rb
|
86
|
+
- lib/easel_helpers/helpers/structure_helper.rb
|
87
|
+
- lib/easel_helpers/helpers/table_helper.rb
|
88
|
+
- lib/easel_helpers/helpers.rb
|
89
|
+
- lib/easel_helpers/rails_partial_caching.rb
|
90
|
+
- lib/easel_helpers.rb
|
91
|
+
- Manifest
|
92
|
+
- MIT-LICENSE
|
93
|
+
- rails/init.rb
|
94
|
+
- Rakefile
|
95
|
+
- README.textile
|
96
|
+
- tasks/easel_helpers_tasks.rake
|
97
|
+
- test/date_helper_test.rb
|
98
|
+
- test/form_helper_test.rb
|
99
|
+
- test/grid_helper_test.rb
|
100
|
+
- test/jquery_helper_test.rb
|
101
|
+
- test/link_helper_test.rb
|
102
|
+
- test/message_helper_test.rb
|
103
|
+
- test/navigation_helper_test.rb
|
104
|
+
- test/rjs_helper_test.rb
|
105
|
+
- test/structure_helper_test.rb
|
106
|
+
- test/table_helper_test.rb
|
107
|
+
- test/test_helper.rb
|
108
|
+
has_rdoc: true
|
109
|
+
homepage: http://github.com/fusionary/easel_helpers
|
110
|
+
licenses: []
|
111
|
+
|
112
|
+
post_install_message:
|
113
|
+
rdoc_options:
|
114
|
+
- --line-numbers
|
115
|
+
- --inline-source
|
116
|
+
- --title
|
117
|
+
- Easel_helpers
|
118
|
+
- --main
|
119
|
+
- README.textile
|
120
|
+
require_paths:
|
121
|
+
- lib
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: "0"
|
127
|
+
version:
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: "1.2"
|
133
|
+
version:
|
134
|
+
requirements: []
|
135
|
+
|
136
|
+
rubyforge_project: easel_helpers
|
137
|
+
rubygems_version: 1.3.2
|
138
|
+
signing_key:
|
139
|
+
specification_version: 3
|
140
|
+
summary: Fusionary Rails View Helpers
|
141
|
+
test_files:
|
142
|
+
- test/date_helper_test.rb
|
143
|
+
- test/form_helper_test.rb
|
144
|
+
- test/grid_helper_test.rb
|
145
|
+
- test/jquery_helper_test.rb
|
146
|
+
- test/link_helper_test.rb
|
147
|
+
- test/message_helper_test.rb
|
148
|
+
- test/navigation_helper_test.rb
|
149
|
+
- test/rjs_helper_test.rb
|
150
|
+
- test/structure_helper_test.rb
|
151
|
+
- test/table_helper_test.rb
|
152
|
+
- test/test_helper.rb
|