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 CHANGED
@@ -2,4 +2,4 @@ lib/**/*.rb
2
2
  bin/*
3
3
  -
4
4
  features/**/*.feature
5
- LICENSE.txt
5
+ MIT-LICENSE
@@ -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, stable or refined.
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
1
+ 0.0.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{formative}
8
- s.version = "0.0.1"
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-17}
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)
@@ -7,47 +7,52 @@ describe Formative::FormBuilder do
7
7
  include FormativeSpecHelper
8
8
 
9
9
  let(:template) { mock_template }
10
- let(:model) { mock('model', :attribute => 'THE_VALUE') }
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
- :check_box => [],
21
- :submit => []
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
- unless builder_method == :submit
28
- it 'should output a default wrapper' do
29
- subject.send(*args).should =~ /^<p.*\/p>$/
30
- end
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
- it 'should output a given wrapper' do
33
- subject.send(*(args << {:wrapper => :div})).should =~ /^<div.*\/div>$/
34
- end
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
- it 'should add "field <method_name> <field_name>" as class of wrapper' do
37
- subject.send(*args).should =~ /^<p class="field #{builder_method.to_s.dasherize} attribute"/
38
- end
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
- it 'should output a proper label' do
41
- subject.send(*args).should =~ /<label for="model_attribute".*\/label>/
42
- end
46
+ it 'should output a proper label' do
47
+ subject.send(*args).should =~ /<label for="model_attribute".*\/label>/
48
+ end
43
49
 
44
- it 'should output a given unit' do
45
- subject.send(*(args << {:unit => 'the unit'})).should =~ /<span class="unit">the unit<\/span>/
46
- end
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
- it 'should output a given hint' do
49
- subject.send(*(args << {:hint => 'additional information'})).should =~ /<span class="hint">additional information<\/span>/
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
- - 1
9
- version: 0.0.1
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 00:00:00 +01:00
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: 4206223225746873947
143
+ hash: 1849876295290540993
144
144
  segments:
145
145
  - 0
146
146
  version: "0"