trenni-formatters 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b94680567298f92a104b915eb9394dbcbba604a
4
- data.tar.gz: e63108af3f7dd07993a4b299bad3bc596e5138a8
3
+ metadata.gz: aa50c8010c607b2a6ba876ae66c8e82f89aa4035
4
+ data.tar.gz: d623ed6dc7f3b3d63b66352c084f63ee424b72d3
5
5
  SHA512:
6
- metadata.gz: 70478b6fe86057a00dd1a497c78ebd037dc09966dd2ce29f7a61ac8e05c14cc7cb4ece5d2442378889b7f9ce4a33012a6b6bb6e8ab4aa3f719d62d5ac723b0fe
7
- data.tar.gz: 10030cb89fa77e24efa96bec0aa21517076dd49bdfad29560cbec0c7fe3779d15116d90c7aa7ade3e3d8afad85753a13b4d36cada63b7216001445fa2dfc47af
6
+ metadata.gz: 8694ad8a47b4023b168f5dd4dedb423a03c2070c4f53aa5b5051adce68495deb909b19c0096bd832d1aaa8c8d1aa363ecd28baf3912bb109a971dfd78f2d6757
7
+ data.tar.gz: b34050e3251ad1842122c0c2cd05d6d310cfe0c271fa35aaa557920b95094cbab49e4b0af3cd38fb93ec149da50ff76d783f04822ffb898433245a0200ef1e7a
@@ -70,7 +70,11 @@ module Trenni
70
70
  :value => value_for(options),
71
71
  :required => options[:required] ? true : false,
72
72
  :pattern => pattern_for(options),
73
- :placeholder => placeholder_for(options)
73
+ :placeholder => placeholder_for(options),
74
+ # for <input type="range|number">
75
+ :min => options[:min],
76
+ :max => options[:max],
77
+ :step => options[:step],
74
78
  }
75
79
 
76
80
  if explicit_attributes = options[:attributes]
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Trenni
22
22
  module Formatters
23
- VERSION = "0.3.2"
23
+ VERSION = "0.3.3"
24
24
  end
25
25
  end
@@ -25,29 +25,43 @@ require 'trenni/formatters/html/definition_list_form'
25
25
  require 'trenni/formatters/html/option_select'
26
26
  require 'trenni/formatters/html/table_select'
27
27
 
28
- module Trenni
29
- module Formatters
30
- module FormFormattersSpec
31
- class FormFormatter < Trenni::Formatters::Formatter
32
- include Trenni::Formatters::HTML::DefinitionListForm
33
- end
28
+ module Trenni::Formatters::FormFormatterSpec
29
+ class FormFormatter < Trenni::Formatters::Formatter
30
+ include Trenni::Formatters::HTML::DefinitionListForm
31
+ end
32
+
33
+ describe Trenni::Formatters do
34
+ it "should generate form" do
35
+ object = double(:bar => 10)
36
+
37
+ formatter = FormFormatter.new(:object => object)
38
+
39
+ output_tag = formatter.input(:field => :bar)
40
+ expect(output_tag).to be == %Q{<dt>Bar</dt>\n<dd><input name="bar" value="10"/></dd>}
41
+ end
42
+
43
+ it "should have default value" do
44
+ formatter = FormFormatter.new
45
+
46
+ expect(formatter.value_for(:value => 10)).to be == "10"
47
+ expect(formatter.value_for(:value => nil, :default => 10)).to be == "10"
48
+ end
49
+ end
50
+
51
+ describe "<input>" do
52
+ it "should support support min, max and step" do
53
+ object = double(:bar => 10)
54
+
55
+ formatter = FormFormatter.new(:object => object)
56
+
57
+ attributes = formatter.input_attributes_for(:min => 10, :max => 20, :step => 2)
58
+
59
+ expect(attributes[:min]).to be == 10
60
+ expect(attributes[:max]).to be == 20
61
+ expect(attributes[:step]).to be == 2
34
62
 
35
- describe Formatters do
36
- it "should generate form" do
37
- object = double(:bar => 10)
38
-
39
- formatter = FormFormatter.new(:object => object)
40
-
41
- expect(formatter.input(:field => :bar)).to be == %Q{<dt>Bar</dt>\n<dd><input name="bar" value="10"/></dd>}
42
- end
43
-
44
- it "should have default value" do
45
- formatter = FormFormatter.new
46
-
47
- expect(formatter.value_for(:value => 10)).to be == "10"
48
- expect(formatter.value_for(:value => nil, :default => 10)).to be == "10"
49
- end
50
- end
63
+ output_tag = formatter.input(:field => :bar, :min => 10)
64
+ expect(output_tag).to be == %Q{<dt>Bar</dt>\n<dd><input name="bar" value="10" min="10"/></dd>}
51
65
  end
52
66
  end
53
67
  end
@@ -22,30 +22,26 @@
22
22
 
23
23
  require 'trenni/formatters'
24
24
 
25
- module Trenni
26
- module Formatters
27
- module FormattersSpec
28
- describe Formatters do
29
- before do
30
- @count = 0
31
- @formatter = Trenni::Formatters::Formatter.new
32
-
33
- @formatter.for(String) do |value, options|
34
- @count += 1
35
- "String: #{value}"
36
- end
37
- end
38
-
39
- it "should format string" do
40
- expect(@formatter.format("foobar")).to be == "String: foobar"
41
- expect(@count).to be == 1
42
- end
43
-
44
- it "should format numbers" do
45
- expect(@formatter.format(10)).to be == "10"
46
- expect(@count).to be == 0
47
- end
25
+ module Trenni::FormattersSpec
26
+ describe Trenni::Formatters do
27
+ before do
28
+ @count = 0
29
+ @formatter = Trenni::Formatters::Formatter.new
30
+
31
+ @formatter.for(String) do |value, options|
32
+ @count += 1
33
+ "String: #{value}"
48
34
  end
49
35
  end
36
+
37
+ it "should format string" do
38
+ expect(@formatter.format("foobar")).to be == "String: foobar"
39
+ expect(@count).to be == 1
40
+ end
41
+
42
+ it "should format numbers" do
43
+ expect(@formatter.format(10)).to be == "10"
44
+ expect(@count).to be == 0
45
+ end
50
46
  end
51
47
  end
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
25
25
  spec.require_paths = ["lib"]
26
26
 
27
- spec.add_dependency "trenni", "~> 1.2.0"
27
+ spec.add_dependency "trenni", "~> 1.3.0"
28
28
 
29
29
  spec.add_development_dependency "bundler", "~> 1.3"
30
30
  spec.add_development_dependency "rspec", "~> 3.0.0.rc1"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trenni-formatters
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-26 00:00:00.000000000 Z
11
+ date: 2014-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trenni
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.2.0
19
+ version: 1.3.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.2.0
26
+ version: 1.3.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -88,8 +88,8 @@ files:
88
88
  - lib/trenni/formatters/html/option_select.rb
89
89
  - lib/trenni/formatters/html/table_select.rb
90
90
  - lib/trenni/formatters/version.rb
91
+ - spec/trenni/formatters/form_formatter_spec.rb
91
92
  - spec/trenni/formatters/formatters_spec.rb
92
- - spec/trenni/formatters/test_forms_formatter.rb
93
93
  - trenni-formatters.gemspec
94
94
  homepage: https://github.com/ioquatix/trenni-formatters
95
95
  licenses: []
@@ -115,5 +115,5 @@ signing_key:
115
115
  specification_version: 4
116
116
  summary: Formatters for Trenni, to assist with typical views and form based interfaces.
117
117
  test_files:
118
+ - spec/trenni/formatters/form_formatter_spec.rb
118
119
  - spec/trenni/formatters/formatters_spec.rb
119
- - spec/trenni/formatters/test_forms_formatter.rb