minimodel 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/minimodel.rb +2 -2
- data/minimodel.gemspec +1 -1
- data/spec/colour_spec.rb +2 -2
- data/spec/currency_spec.rb +39 -44
- data/spec/dutch_education_spec.rb +18 -44
- metadata +6 -6
data/lib/minimodel.rb
CHANGED
data/minimodel.gemspec
CHANGED
data/spec/colour_spec.rb
CHANGED
@@ -9,8 +9,8 @@ class Colour < MiniModel
|
|
9
9
|
insert name: 'Green', hexdigits: '00FF00'
|
10
10
|
end
|
11
11
|
|
12
|
-
describe Colour do
|
12
|
+
describe 'Colour' do
|
13
13
|
it 'should assign auto incrementing id values' do
|
14
|
-
Colour.all.map(&:id).must_equal
|
14
|
+
Colour.all.map(&:id).must_equal([1, 2, 3])
|
15
15
|
end
|
16
16
|
end
|
data/spec/currency_spec.rb
CHANGED
@@ -17,92 +17,87 @@ describe 'A currency object' do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'should respond_to?(:code) and respond_to?(:name)' do
|
20
|
-
@euro.respond_to?(:code).must_equal
|
21
|
-
@euro.respond_to?(:name).must_equal
|
20
|
+
@euro.respond_to?(:code).must_equal(true)
|
21
|
+
@euro.respond_to?(:name).must_equal(true)
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'should have attribute reader methods' do
|
25
|
-
@euro.code.must_equal
|
26
|
-
@euro.name.must_equal
|
25
|
+
@euro.code.must_equal('EUR')
|
26
|
+
@euro.name.must_equal('Euro')
|
27
27
|
end
|
28
28
|
|
29
|
-
describe '
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
@euro.eql?(Currency.new(code: 'EUR', name: 'Euro')).must_equal true
|
34
|
-
end
|
29
|
+
describe 'eql query method' do
|
30
|
+
it 'should return true when passed a currency object with the same attributes' do
|
31
|
+
@euro.eql?(@euro).must_equal(true)
|
32
|
+
@euro.eql?(Currency.new(code: 'EUR', name: 'Euro')).must_equal(true)
|
35
33
|
end
|
36
34
|
|
37
|
-
|
38
|
-
|
39
|
-
@euro.eql?(Currency.new(code: 'GBP', name: 'Pound sterling')).must_equal false
|
40
|
-
end
|
35
|
+
it 'should return false when given a currency object with a different code' do
|
36
|
+
@euro.eql?(Currency.new(code: 'GBP', name: 'Pound sterling')).must_equal(false)
|
41
37
|
end
|
42
38
|
end
|
43
39
|
|
44
|
-
describe '
|
40
|
+
describe 'to_hash method' do
|
45
41
|
it 'should return a hash containing the object attributes' do
|
46
|
-
@euro.to_hash.
|
47
|
-
@euro.to_hash.must_equal code: 'EUR', name: 'Euro'
|
42
|
+
@euro.to_hash.must_equal({code: 'EUR', name: 'Euro'})
|
48
43
|
end
|
49
44
|
end
|
50
45
|
|
51
|
-
describe '
|
46
|
+
describe 'to_json method' do
|
52
47
|
it 'should return a string containing a JSON object' do
|
53
|
-
@euro.to_json.must_equal
|
48
|
+
@euro.to_json.must_equal('{"code":"EUR","name":"Euro"}')
|
54
49
|
end
|
55
50
|
end
|
56
51
|
|
57
|
-
describe '
|
52
|
+
describe 'read_attribute method' do
|
58
53
|
it 'should return the value corresponding to the given attribute name' do
|
59
|
-
@euro.read_attribute(:code).must_equal
|
60
|
-
@euro.read_attribute(:name).must_equal
|
54
|
+
@euro.read_attribute(:code).must_equal('EUR')
|
55
|
+
@euro.read_attribute(:name).must_equal('Euro')
|
61
56
|
end
|
62
57
|
end
|
63
58
|
end
|
64
59
|
|
65
|
-
describe Currency do
|
66
|
-
describe '
|
60
|
+
describe 'Currency' do
|
61
|
+
describe 'all class method' do
|
67
62
|
it 'should return an array containing currency objects' do
|
68
|
-
Currency.all.must_be_kind_of
|
69
|
-
Currency.all.
|
63
|
+
Currency.all.must_be_kind_of(Array)
|
64
|
+
Currency.all.each { |object| object.must_be_kind_of(Currency) }
|
70
65
|
end
|
71
66
|
end
|
72
67
|
|
73
|
-
describe '
|
68
|
+
describe 'primary_key class method' do
|
74
69
|
it 'should return the primary key specified using #indexed_by' do
|
75
|
-
Currency.primary_key.must_equal
|
70
|
+
Currency.primary_key.must_equal(:code)
|
76
71
|
end
|
77
72
|
end
|
78
73
|
|
79
|
-
describe '
|
74
|
+
describe 'count class method' do
|
80
75
|
it 'should return the total number of currencies defined' do
|
81
|
-
Currency.count.must_equal
|
76
|
+
Currency.count.must_equal(5)
|
82
77
|
end
|
83
78
|
end
|
84
79
|
|
85
|
-
describe '
|
86
|
-
|
87
|
-
|
88
|
-
currency = Currency.find('EUR')
|
80
|
+
describe 'find class method' do
|
81
|
+
it 'should return the correct currency object' do
|
82
|
+
currency = Currency.find('EUR')
|
89
83
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
end
|
84
|
+
currency.must_be_kind_of(Currency)
|
85
|
+
currency.code.must_equal('EUR')
|
86
|
+
currency.name.must_equal('Euro')
|
94
87
|
end
|
95
88
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
89
|
+
it 'should raise an error if the currency cannot be found' do
|
90
|
+
proc { Currency.find('FOO') }.must_raise(KeyError)
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'should yield if the currency cannot be found and the caller supplies a block' do
|
94
|
+
Currency.find('FOO') { nil }.must_be_nil
|
100
95
|
end
|
101
96
|
end
|
102
97
|
|
103
|
-
describe '
|
98
|
+
describe 'insert class method' do
|
104
99
|
it 'should raise an error when passed a key that already exists' do
|
105
|
-
proc { Currency.insert(code: 'EUR', name: 'Euro') }.must_raise
|
100
|
+
proc { Currency.insert(code: 'EUR', name: 'Euro') }.must_raise(MiniModel::DuplicateKeyError)
|
106
101
|
end
|
107
102
|
end
|
108
103
|
end
|
@@ -65,47 +65,21 @@ describe 'A level object' do
|
|
65
65
|
@course_names = %w( VMBO-T/Duits VMBO-T/Engels VMBO-T/Nederlands )
|
66
66
|
end
|
67
67
|
|
68
|
-
describe '
|
69
|
-
it 'should
|
70
|
-
@level.profiles
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
describe '#size' do
|
75
|
-
it 'should return the number of profiles linked to this level' do
|
76
|
-
@level.profiles.size.must_equal 4
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe '#to_a' do
|
81
|
-
it 'should return an array containing the correct profile objects' do
|
82
|
-
profiles = @level.profiles.to_a
|
83
|
-
|
84
|
-
profiles.must_be_kind_of Array
|
85
|
-
profiles.map(&:name).sort.must_equal @profile_names
|
86
|
-
end
|
68
|
+
describe 'profiles method' do
|
69
|
+
it 'should return an enumerable object with the correct size' do
|
70
|
+
profiles = @level.profiles
|
71
|
+
profiles.must_respond_to(:each)
|
72
|
+
profiles.class.ancestors.must_include(Enumerable)
|
73
|
+
profiles.size.must_equal(4)
|
87
74
|
end
|
88
75
|
end
|
89
76
|
|
90
|
-
describe '
|
91
|
-
it 'should
|
92
|
-
@level.courses
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
describe '#size' do
|
97
|
-
it 'should return the number of courses linked to this level' do
|
98
|
-
@level.courses.size.must_equal 3
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
describe '#to_a' do
|
103
|
-
it 'should return an array containing the correct course objects' do
|
104
|
-
courses = @level.courses.to_a
|
105
|
-
|
106
|
-
courses.must_be_kind_of Array
|
107
|
-
courses.map(&:name).sort.must_equal @course_names
|
108
|
-
end
|
77
|
+
describe 'courses method' do
|
78
|
+
it 'should return an enumerable object with the correct size' do
|
79
|
+
courses = @level.courses
|
80
|
+
courses.must_respond_to(:each)
|
81
|
+
courses.class.ancestors.must_include(Enumerable)
|
82
|
+
courses.size.must_equal(3)
|
109
83
|
end
|
110
84
|
end
|
111
85
|
end
|
@@ -115,10 +89,10 @@ describe 'A profile object' do
|
|
115
89
|
@profile = Profile.find(8)
|
116
90
|
end
|
117
91
|
|
118
|
-
describe '
|
92
|
+
describe 'level method' do
|
119
93
|
it 'should return the correct level object' do
|
120
|
-
@profile.level.must_be_kind_of
|
121
|
-
@profile.level.name.must_equal
|
94
|
+
@profile.level.must_be_kind_of(Level)
|
95
|
+
@profile.level.name.must_equal('HAVO')
|
122
96
|
end
|
123
97
|
end
|
124
98
|
end
|
@@ -128,10 +102,10 @@ describe 'A course object' do
|
|
128
102
|
@course = Course.find_by_name('VWO/Engels')
|
129
103
|
end
|
130
104
|
|
131
|
-
describe '
|
105
|
+
describe 'level method' do
|
132
106
|
it 'should return the correct level object' do
|
133
|
-
@course.level.must_be_kind_of
|
134
|
-
@course.level.name.must_equal
|
107
|
+
@course.level.must_be_kind_of(Level)
|
108
|
+
@course.level.name.must_equal('VWO')
|
135
109
|
end
|
136
110
|
end
|
137
111
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minimodel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-01-31 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &10440420 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.0.3
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *10440420
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activerecord
|
27
|
-
requirement: &
|
27
|
+
requirement: &10440150 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: 3.0.3
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *10440150
|
36
36
|
description: A little library for defining little models
|
37
37
|
email:
|
38
38
|
- mail@timcraft.com
|