semanticgap_date_time_form 0.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -30,10 +30,10 @@ module SemanticGap
30
30
  validate :validate_date
31
31
 
32
32
  def month
33
- if @month.kind_of? Symbol
34
- @month
35
- elsif @month
33
+ if @month.kind_of?(String) && @month =~ /\d+/
36
34
  @month.to_i
35
+ else
36
+ @month
37
37
  end
38
38
  end
39
39
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "semanticgap_date_time_form"
3
- s.version = "0.1"
3
+ s.version = "0.1.2"
4
4
 
5
5
  s.authors = ["SemanticGap"]
6
6
  s.date = "2010-05-08"
@@ -94,5 +94,18 @@ describe SemanticGap::DateTimeForm::FormBuilderMixin do
94
94
  end
95
95
  end
96
96
  end
97
+
98
+ [ 2, '2' ].each do |month|
99
+ context "when month is #{month.inspect}" do
100
+ before(:each) do
101
+ @fields.month = month
102
+ @result = subject.datetime_form(:published_at)
103
+ end
104
+
105
+ it "has an option for the selected month" do
106
+ @result.should have_tag('option[value=?][selected=selected]', month)
107
+ end
108
+ end
109
+ end
97
110
  end
98
111
  end
@@ -580,4 +580,22 @@ describe SemanticGap::DateTimeForm::Form do
580
580
  end
581
581
  end
582
582
  end
583
+
584
+ describe '#month' do
585
+ { 1 => 1,
586
+ '1' => 1,
587
+ 'aaa' => 'aaa',
588
+ :hello => :hello
589
+ }.each do |value, expecting|
590
+ context 'when month is set to #{value.inspect}' do
591
+ before(:each) do
592
+ subject.month = value
593
+ end
594
+
595
+ it "returns #{expecting}" do
596
+ subject.month.should == expecting
597
+ end
598
+ end
599
+ end
600
+ end
583
601
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semanticgap_date_time_form
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.1"
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - SemanticGap