rails_errors2html 1.3.0 → 1.4.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/lib/rails_errors2html.rb +9 -1
- data/rails_errors2html.gemspec +1 -1
- data/test/rails_errors2html_test.rb +27 -0
- metadata +2 -2
data/lib/rails_errors2html.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Errors2Html
|
2
|
-
VERSION = '1.
|
2
|
+
VERSION = '1.4.0'
|
3
3
|
|
4
4
|
def Errors2Html.version
|
5
5
|
Errors2Html::VERSION
|
@@ -25,6 +25,14 @@ module Errors2Html
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def Errors2Html.to_html(*args)
|
28
|
+
if args.size == 1
|
29
|
+
case args.first
|
30
|
+
when Array, String, Symbol
|
31
|
+
messages = Array(args.first)
|
32
|
+
args = [{:base => messages}]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
28
36
|
args.flatten!
|
29
37
|
args.compact!
|
30
38
|
|
data/rails_errors2html.gemspec
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
Gem::Specification::new do |spec|
|
5
5
|
spec.name = "rails_errors2html"
|
6
|
-
spec.version = "1.
|
6
|
+
spec.version = "1.4.0"
|
7
7
|
spec.platform = Gem::Platform::RUBY
|
8
8
|
spec.summary = "rails_errors2html"
|
9
9
|
spec.description = "<%= form_for @post do %> <%= @post.errors.to_html %>"
|
@@ -88,6 +88,33 @@ Testing Errors2Html do
|
|
88
88
|
assert{ compress(errors) == compress(expected) }
|
89
89
|
end
|
90
90
|
|
91
|
+
##
|
92
|
+
#
|
93
|
+
testing 'array-y errors' do
|
94
|
+
errors = %w( fu bar )
|
95
|
+
|
96
|
+
expected = <<-__
|
97
|
+
<div class="errors2html errors-summary">
|
98
|
+
<h4 class="errors-caption">Sorry, we encountered some errors:</h4>
|
99
|
+
|
100
|
+
|
101
|
+
<ul class="errors-global-list">
|
102
|
+
<li class="errors-message">
|
103
|
+
fu
|
104
|
+
</li>
|
105
|
+
<li class="errors-message">
|
106
|
+
bar
|
107
|
+
</li>
|
108
|
+
</ul>
|
109
|
+
|
110
|
+
</div>
|
111
|
+
__
|
112
|
+
|
113
|
+
actual = Errors2Html.to_html(errors)
|
114
|
+
|
115
|
+
assert{ compress(actual) == compress(expected) }
|
116
|
+
end
|
117
|
+
|
91
118
|
protected
|
92
119
|
def compress(*strings)
|
93
120
|
strings.flatten.compact.join.gsub(/\s+/, '')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_errors2html
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fattr
|