kosher 0.1.10 → 0.1.11
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/lib/kosher/condition.rb +15 -12
- data/lib/kosher/version.rb +1 -1
- data/spec/fabricators/condition_fabricator.rb +2 -2
- data/spec/kosher/offer_spec.rb +2 -2
- metadata +1 -1
data/lib/kosher/condition.rb
CHANGED
@@ -1,22 +1,25 @@
|
|
1
1
|
module Kosher
|
2
|
-
class Condition < Struct.new(:
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
2
|
+
class Condition < Struct.new(:grade)
|
3
|
+
|
4
|
+
alias_method :to_i, :grade
|
5
|
+
|
6
|
+
CONDITIONS = {
|
7
|
+
'new' => 1,
|
8
|
+
'mint' => 2,
|
9
|
+
'verygood' => 3,
|
10
|
+
'good' => 4,
|
11
|
+
'acceptable' => 5 }
|
12
|
+
|
13
|
+
def initialize(string = '')
|
14
|
+
self.grade = CONDITIONS[string] || 6
|
12
15
|
end
|
13
16
|
|
14
17
|
def kosher?
|
15
|
-
|
18
|
+
grade <= 4
|
16
19
|
end
|
17
20
|
|
18
21
|
def new?
|
19
|
-
|
22
|
+
grade == 1
|
20
23
|
end
|
21
24
|
|
22
25
|
def used?
|
data/lib/kosher/version.rb
CHANGED
data/spec/kosher/offer_spec.rb
CHANGED
@@ -49,7 +49,7 @@ module Kosher
|
|
49
49
|
describe "#kosher?" do
|
50
50
|
context "when condition is kosher" do
|
51
51
|
before do
|
52
|
-
offer.condition = Fabricate(:kosher_condition, :
|
52
|
+
offer.condition = Fabricate(:kosher_condition, :grade => 1)
|
53
53
|
end
|
54
54
|
|
55
55
|
context "when seller is kosher" do
|
@@ -99,7 +99,7 @@ module Kosher
|
|
99
99
|
|
100
100
|
context "when condition is not kosher" do
|
101
101
|
before do
|
102
|
-
offer.condition = Fabricate(:kosher_condition, :
|
102
|
+
offer.condition = Fabricate(:kosher_condition, :grade => 5)
|
103
103
|
end
|
104
104
|
|
105
105
|
it "returns false" do
|