formative 0.0.1 → 0.0.2
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/.document +1 -1
- data/README.rdoc +2 -2
- data/VERSION +1 -1
- data/formative.gemspec +2 -2
- data/lib/formative/form_builder.rb +0 -5
- data/spec/form_builder_spec.rb +28 -23
- metadata +4 -4
data/.document
CHANGED
data/README.rdoc
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Formative is an extraction of the custom form builder I used in my last couple of Rails projects. It is the simplest thing that could possibly work for me. YMMV.
|
4
4
|
|
5
|
-
I am packaging this as a gem mainly for my personal use. So do not expect this to be any of well-documented,
|
5
|
+
I am packaging this as a gem mainly for my personal use. So do not expect this to be any of well-documented, complete or refined.
|
6
6
|
|
7
7
|
== Usage
|
8
8
|
|
@@ -23,7 +23,7 @@ Then just use `Formative::FormBuilder` as your builder -- here is an example for
|
|
23
23
|
%fieldset
|
24
24
|
%legend Request Form
|
25
25
|
|
26
|
-
= f.text_field :bananas, :unit => 'kg'
|
26
|
+
= f.text_field :bananas, :unit => 'kg',
|
27
27
|
:hint => 'Enter the amount of bananas in kg you would like to eat right now'
|
28
28
|
|
29
29
|
.controls
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/formative.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{formative}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Martin Rehfeld"]
|
12
|
-
s.date = %q{2011-02-
|
12
|
+
s.date = %q{2011-02-18}
|
13
13
|
s.description = %q{Formative is an extraction of the custom form builder I used in my last couple of Rails projects. It is the simplest thing that could possibly work for me. YMMV.}
|
14
14
|
s.email = %q{martin.rehfeld@glnetworks.de}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -13,11 +13,6 @@ module Formative
|
|
13
13
|
content_tag(wrapper(options), super + field_label(field_name, options) + unit(options) + hint(options).html_safe, :class => wrapper_class('check_box', field_name))
|
14
14
|
end
|
15
15
|
|
16
|
-
def submit(*args)
|
17
|
-
options = filter_custom_options(args.extract_options!)
|
18
|
-
super(args, options)
|
19
|
-
end
|
20
|
-
|
21
16
|
private
|
22
17
|
|
23
18
|
def content_tag(tag, content, *args)
|
data/spec/form_builder_spec.rb
CHANGED
@@ -7,47 +7,52 @@ describe Formative::FormBuilder do
|
|
7
7
|
include FormativeSpecHelper
|
8
8
|
|
9
9
|
let(:template) { mock_template }
|
10
|
-
let(:
|
10
|
+
let(:date_attribute) { mock('attribute', :day => 1, :month => 1, :year => 2000) }
|
11
|
+
let(:text_attribute) { 'THE_VALUE' }
|
12
|
+
let(:model) { mock('model', :attribute => attribute) }
|
11
13
|
|
12
14
|
subject { Formative::FormBuilder.new(:model, model, template, {}, Proc.new {}) }
|
13
15
|
|
14
16
|
{
|
15
|
-
:select => [ [] ],
|
16
17
|
:text_field => [],
|
18
|
+
:select => [ [] ],
|
17
19
|
:collection_select => [ [Struct.new(:value, :text).new], :value, :text ],
|
18
20
|
:password_field => [],
|
19
21
|
:text_area => [],
|
20
|
-
:
|
21
|
-
:
|
22
|
+
:date_select => [],
|
23
|
+
:check_box => []
|
22
24
|
}.each_pair do |builder_method, additional_args|
|
23
25
|
|
24
26
|
describe "##{builder_method}" do
|
27
|
+
let(:attribute) { builder_method == :date_select ? date_attribute : text_attribute }
|
25
28
|
let(:args) { [builder_method, :attribute].concat additional_args }
|
26
29
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
30
|
+
it 'should output a default wrapper' do
|
31
|
+
tag = subject.send(*args)
|
32
|
+
tag.should =~ /^<p/
|
33
|
+
tag.should =~ /<\/p\>$/
|
34
|
+
end
|
31
35
|
|
32
|
-
|
33
|
-
|
34
|
-
|
36
|
+
it 'should output a given wrapper' do
|
37
|
+
tag = subject.send(*(args << {:wrapper => :div}))
|
38
|
+
tag.should =~ /^<div/
|
39
|
+
tag.should =~ /<\/div\>$/
|
40
|
+
end
|
35
41
|
|
36
|
-
|
37
|
-
|
38
|
-
|
42
|
+
it 'should add "field <method_name> <field_name>" as class of wrapper' do
|
43
|
+
subject.send(*args).should =~ /^<p class="field #{builder_method.to_s.dasherize} attribute"/
|
44
|
+
end
|
39
45
|
|
40
|
-
|
41
|
-
|
42
|
-
|
46
|
+
it 'should output a proper label' do
|
47
|
+
subject.send(*args).should =~ /<label for="model_attribute".*\/label>/
|
48
|
+
end
|
43
49
|
|
44
|
-
|
45
|
-
|
46
|
-
|
50
|
+
it 'should output a given unit' do
|
51
|
+
subject.send(*(args << {:unit => 'the unit'})).should =~ /<span class="unit">the unit<\/span>/
|
52
|
+
end
|
47
53
|
|
48
|
-
|
49
|
-
|
50
|
-
end
|
54
|
+
it 'should output a given hint' do
|
55
|
+
subject.send(*(args << {:hint => 'additional information'})).should =~ /<span class="hint">additional information<\/span>/
|
51
56
|
end
|
52
57
|
|
53
58
|
context ":wrapper => false" do
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Martin Rehfeld
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-02-
|
17
|
+
date: 2011-02-18 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -140,7 +140,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
140
140
|
requirements:
|
141
141
|
- - ">="
|
142
142
|
- !ruby/object:Gem::Version
|
143
|
-
hash:
|
143
|
+
hash: 1849876295290540993
|
144
144
|
segments:
|
145
145
|
- 0
|
146
146
|
version: "0"
|