frequency 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{frequency}
8
- s.version = "0.1.4"
8
+ s.version = "0.1.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["David James"]
@@ -73,12 +73,16 @@ class Frequency
73
73
 
74
74
  def per_decade
75
75
  value = FREQUENCIES[plain_text]
76
- value ? value[0] : nil
76
+ return nil unless value
77
+ return nil unless value[0]
78
+ value[0]
77
79
  end
78
80
 
79
81
  def per_year
80
82
  value = FREQUENCIES[plain_text]
81
- value ? (value[0] / 10.0) : nil
83
+ return nil unless value
84
+ return nil unless value[0]
85
+ value[0] / 10.0
82
86
  end
83
87
 
84
88
  def valid?
@@ -124,6 +124,58 @@ describe "Frequency" do
124
124
  end
125
125
  end
126
126
 
127
+ describe "other" do
128
+ before do
129
+ @freq = Frequency.new("other")
130
+ end
131
+
132
+ it "should be valid" do
133
+ @freq.plain_text.should == "other"
134
+ end
135
+
136
+ it "should be valid" do
137
+ @freq.valid?.should be_true
138
+ end
139
+
140
+ it "#per_year should be correct" do
141
+ @freq.per_year.should == nil
142
+ end
143
+
144
+ it "#per_decade should be correct" do
145
+ @freq.per_decade.should == nil
146
+ end
147
+
148
+ it "< should be undefined" do
149
+ lambda {
150
+ @freq.should < Frequency.new('monthly')
151
+ }.should raise_error(Frequency::Undefined)
152
+ end
153
+
154
+ it "<= should be undefined" do
155
+ lambda {
156
+ @freq.should <= Frequency.new('monthly')
157
+ }.should raise_error(Frequency::Undefined)
158
+ end
159
+
160
+ it "== should be undefined" do
161
+ lambda {
162
+ @freq.should == Frequency.new('monthly')
163
+ }.should raise_error(Frequency::Undefined)
164
+ end
165
+
166
+ it ">= should be undefined" do
167
+ lambda {
168
+ @freq.should >= Frequency.new('monthly')
169
+ }.should raise_error(Frequency::Undefined)
170
+ end
171
+
172
+ it "> should be undefined" do
173
+ lambda {
174
+ @freq.should > Frequency.new('monthly')
175
+ }.should raise_error(Frequency::Undefined)
176
+ end
177
+ end
178
+
127
179
  # ---
128
180
 
129
181
  describe "list" do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 4
9
- version: 0.1.4
8
+ - 5
9
+ version: 0.1.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - David James