douglas-ne-checks 0.0.1 → 0.1.0

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.
@@ -2,109 +2,219 @@ require 'spec_helper'
2
2
 
3
3
  describe Douglas::NE::Checks::File do
4
4
 
5
+ before(:all) do
6
+ @file6 = Douglas::NE::Checks::File.new(data_file('2013-06-04.htm'))
7
+ @file9 = Douglas::NE::Checks::File.new(data_file('2013-09-09.htm'))
8
+ end
9
+
5
10
  describe '#funds' do
6
11
 
12
+ context '2013-09-09.htm' do
13
+
14
+ subject { @file9.fund_names }
15
+
16
+ it { should be_a(Array) }
17
+
18
+ it { should have(12).entries }
19
+
20
+ end
21
+
22
+ end
23
+
24
+ describe '#fund_names' do
25
+
7
26
  context '2013-06-04.htm' do
8
27
 
9
- before(:all) do
10
- @file = Douglas::NE::Checks::File.new(data_file('2013-06-04.htm'))
11
- end
28
+ subject { @file6.fund_names }
29
+
30
+ it { should have(12).names }
31
+
32
+ end
33
+
34
+ context '2013-09-09.htm' do
35
+
36
+ subject { @file9.fund_names }
37
+
38
+ it { should have(12).names }
39
+
40
+ end
41
+
42
+ end
43
+
44
+ describe '#fund' do
45
+
46
+ context '2013-06-04.htm' do
12
47
 
13
- subject { @file.funds }
48
+ let(:file) { @file6 }
14
49
 
15
- it { should have(12).keys }
50
+ it 'should have known funds' do
51
+ expect(file.fund('11111 - GENERAL')).to_not be_nil
52
+ expect(file.fund('11111 - GENERAL')).to be_a(Hash)
53
+ end
16
54
 
17
55
  end
18
56
 
19
57
  context '2013-09-09.htm' do
20
58
 
21
- before(:all) do
22
- @file = Douglas::NE::Checks::File.new(data_file('2013-09-09.htm'))
59
+ let(:file) { @file9 }
60
+
61
+ it 'should have known funds' do
62
+ expect(file.fund('12535 - FEDERAL DRUG FORFEITURE')).to_not be_nil
63
+ expect(file.fund('12535 - FEDERAL DRUG FORFEITURE')).to be_a(Hash)
23
64
  end
24
65
 
25
- subject { @file.funds }
66
+ end
67
+
68
+ end
69
+
70
+ describe '#organizations' do
71
+
72
+ context '2013-09-09.htm' do
26
73
 
27
- it { should have(12).keys }
74
+ subject { @file9.organizations('11111 - GENERAL') }
28
75
 
29
- context '11111 - GENERAL' do
76
+ it { should be_a(Array) }
30
77
 
31
- subject { @file.funds['11111 - GENERAL'] }
78
+ it { should have(62).entries }
32
79
 
33
- it { should have(62).keys }
80
+ end
81
+
82
+ end
83
+
84
+ describe '#organization_names' do
85
+
86
+ context '2013-06-04.htm' do
87
+
88
+ subject { @file6.organization_names('11111 - GENERAL') }
89
+
90
+ it { should be_a(Array) }
91
+
92
+ it { should have(74).names }
93
+
94
+ end
95
+
96
+ end
97
+
98
+ describe '#organization' do
99
+
100
+ context '2013-06-04.htm' do
101
+
102
+ subject { @file6.organization('11111 - GENERAL', '582015 - NOXIOUS WEED CONTROL') }
103
+
104
+ it { should be_a(Hash) }
105
+
106
+ end
107
+
108
+ end
109
+
110
+ describe '#raw_data' do
111
+
112
+ context '2013-06-04.htm' do
113
+
114
+ let(:file) { @file6 }
115
+
116
+ subject { file.raw_data }
117
+
118
+ it_behaves_like 'raw data'
119
+
120
+ context '[:funds]' do
121
+
122
+ subject { file.raw_data[:funds] }
123
+
124
+ it_behaves_like 'raw data funds', 12
34
125
 
35
126
  end
36
127
 
37
- context '12532 - COUNTY ROAD' do
128
+ end
129
+
130
+ context '2013-09-09.htm' do
38
131
 
39
- subject { @file.funds['12532 - COUNTY ROAD'] }
132
+ let(:file) { @file9 }
40
133
 
41
- it { should have(3).keys }
134
+ subject { file.raw_data }
42
135
 
43
- its(:keys) { should include('670011 - DESIGN & SURVEY') }
44
- its(:keys) { should include('672011 - MAINTENANCE') }
45
- its(:keys) { should include('674011 - EQUIPMENT') }
136
+ it_behaves_like 'raw data'
46
137
 
47
- context '670011 - DESIGN & SURVEY' do
138
+ context '[:funds]' do
48
139
 
49
- subject { @file.funds['12532 - COUNTY ROAD']['670011 - DESIGN & SURVEY'] }
140
+ subject { file.raw_data[:funds] }
50
141
 
51
- it { should have(1).row }
142
+ it_behaves_like 'raw data funds', 12
52
143
 
53
- context 'row 0' do
144
+ context '11111 - GENERAL' do
54
145
 
55
- subject { @file.funds['12532 - COUNTY ROAD']['670011 - DESIGN & SURVEY'][0] }
146
+ it_behaves_like 'a raw data fund', 62
147
+
148
+ end
149
+
150
+ context '12532 - COUNTY ROAD' do
151
+
152
+ it_behaves_like 'a raw data fund', 3
153
+
154
+ context '670011 - DESIGN & SURVEY' do
155
+
156
+ it_behaves_like 'a raw data fund organization', 1
157
+
158
+ context 'entry 0' do
159
+
160
+ it_behaves_like 'a raw data fund organization entry', 0, {
161
+ supplier: 'METROPOLITAN AREA PLANNING AGENCY',
162
+ account: '42239 - PROFESSIONAL FEES - OTHER',
163
+ description: 'INV 2608 (NIROC FUNDING)',
164
+ invoice: '2603',
165
+ check_number: 363827,
166
+ check_date: Date.new(2013, 9, 10),
167
+ check_status: 'NEGOTIABLE',
168
+ amount: 25000.00
169
+ }
56
170
 
57
- it 'should have known values' do
58
- expect(subject[:supplier]).to eql('METROPOLITAN AREA PLANNING AGENCY')
59
- expect(subject[:account]).to eql('42239 - PROFESSIONAL FEES - OTHER')
60
- expect(subject[:description]).to eql('INV 2608 (NIROC FUNDING)')
61
- expect(subject[:invoice]).to eql('2603')
62
- expect(subject[:check_number]).to eql(363827)
63
- expect(subject[:check_date]).to eql(Date.new(2013, 9, 10))
64
- expect(subject[:check_status]).to eql('NEGOTIABLE')
65
- expect(subject[:amount]).to be_within(0.01).of(25000.00)
66
171
  end
67
172
 
68
173
  end
69
174
 
70
- end
175
+ context '672011 - MAINTENANCE' do
176
+
177
+ it_behaves_like 'a raw data fund organization', 30
178
+
179
+ end
71
180
 
72
- context '672011 - MAINTENANCE' do
181
+ context '674011 - EQUIPMENT' do
73
182
 
74
- subject { @file.funds['12532 - COUNTY ROAD']['672011 - MAINTENANCE'] }
183
+ it_behaves_like 'a raw data fund organization', 2
75
184
 
76
- it { should have(30).rows }
185
+ end
77
186
 
78
187
  end
79
188
 
80
- context '674011 - EQUIPMENT' do
189
+ context '12516 - VETERANS' do
81
190
 
82
- subject { @file.funds['12532 - COUNTY ROAD']['674011 - EQUIPMENT'] }
191
+ it_behaves_like 'a raw data fund', 1
83
192
 
84
- it { should have(2).rows }
193
+ context '656011 - VETERANS' do
85
194
 
86
- end
195
+ it_behaves_like 'a raw data fund organization', 1
87
196
 
88
- end
197
+ end
89
198
 
90
- context '12516 - VETERANS' do
199
+ end
91
200
 
92
- subject { @file.funds['12516 - VETERANS'] }
201
+ context '12582 - EMPLOYEE MEDICAL INS' do
93
202
 
94
- it { should have(1).keys }
203
+ it_behaves_like 'a raw data fund', 2
95
204
 
96
- its(:keys) { should include('656011 - VETERANS') }
205
+ context '695011 - MED INSURANCE' do
97
206
 
98
- end
207
+ it_behaves_like 'a raw data fund organization', 3
99
208
 
100
- context '12582 - EMPLOYEE MEDICAL INS' do
209
+ end
101
210
 
102
- subject { @file.funds['12582 - EMPLOYEE MEDICAL INS'] }
211
+ context '695012 - WELLNESS' do
103
212
 
104
- it { should have(2).keys }
213
+ it_behaves_like 'a raw data fund organization', 1
105
214
 
106
- its(:keys) { should include('695011 - MED INSURANCE') }
107
- its(:keys) { should include('695012 - WELLNESS') }
215
+ end
216
+
217
+ end
108
218
 
109
219
  end
110
220
 
@@ -8,6 +8,10 @@ require 'awesome_print'
8
8
  require 'pathname'
9
9
  require 'douglas/ne/checks'
10
10
 
11
+ # Requires supporting ruby files with custom matchers and macros, etc,
12
+ # in spec/support/ and its subdirectories.
13
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
14
+
11
15
  RSpec.configure do |config|
12
16
  config.treat_symbols_as_metadata_keys_with_true_values = true
13
17
  config.run_all_when_everything_filtered = true
@@ -0,0 +1,87 @@
1
+ require 'spec_helper'
2
+
3
+ shared_examples 'raw data' do
4
+
5
+ it { should be_a(Hash) }
6
+
7
+ it { should have(1).keys }
8
+
9
+ it { should have_key(:funds) }
10
+
11
+ end
12
+
13
+ shared_examples 'raw data funds' do |key_count|
14
+
15
+ it { should have(key_count).keys }
16
+
17
+ it { should be_a(Array) }
18
+
19
+ end
20
+
21
+ shared_examples 'a raw data fund' do |org_count|
22
+
23
+ let(:fund_name) { example.metadata[:example_group][:example_group][:description] }
24
+
25
+ subject { file.raw_data[:funds].find { |f| f[:name] == fund_name } }
26
+
27
+ it { should be_a(Hash) }
28
+
29
+ it { should have_key(:name) }
30
+
31
+ it { should have_key(:organizations) }
32
+
33
+ it 'should have a known quantity of organizations' do
34
+ expect(subject[:organizations]).to have(org_count).values
35
+ end
36
+
37
+ end
38
+
39
+ shared_examples 'a raw data fund organization' do |entry_count|
40
+
41
+ let(:fund_name) { example.metadata[:example_group][:example_group][:example_group][:description] }
42
+
43
+ let(:org_name) { example.metadata[:example_group][:example_group][:description] }
44
+
45
+ subject do
46
+ fund = file.raw_data[:funds].find { |f| f[:name] == fund_name }
47
+ fund[:organizations].find { |o| o[:name] == org_name }
48
+ end
49
+
50
+ it { should be_a(Hash) }
51
+
52
+ it { should have_key(:name) }
53
+
54
+ it { should have_key(:entries) }
55
+
56
+ it 'should have a known quantity of entries' do
57
+ expect(subject[:entries]).to have(entry_count).values
58
+ end
59
+
60
+ end
61
+
62
+ shared_examples 'a raw data fund organization entry' do |entry_index, values|
63
+
64
+ let(:fund_name) { example.metadata[:example_group][:example_group][:example_group][:example_group][:description] }
65
+
66
+ let(:org_name) { example.metadata[:example_group][:example_group][:example_group][:description] }
67
+
68
+ subject do
69
+ fund = file.raw_data[:funds].find { |f| f[:name] == fund_name }
70
+ org = fund[:organizations].find { |o| o[:name] == org_name }
71
+ org[:entries][entry_index]
72
+ end
73
+
74
+ it { should be_a(Hash) }
75
+
76
+ it 'should have known values' do
77
+ expect(subject[:supplier]).to eql(values[:supplier])
78
+ expect(subject[:account]).to eql(values[:account])
79
+ expect(subject[:description]).to eql(values[:description])
80
+ expect(subject[:invoice]).to eql(values[:invoice])
81
+ expect(subject[:check_number]).to eql(values[:check_number])
82
+ expect(subject[:check_date]).to eql(values[:check_date])
83
+ expect(subject[:check_status]).to eql(values[:check_status])
84
+ expect(subject[:amount]).to be_within(0.01).of(values[:amount])
85
+ end
86
+
87
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: douglas-ne-checks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Veys
@@ -158,6 +158,7 @@ files:
158
158
  - spec/data/2013-09-09.htm
159
159
  - spec/file_spec.rb
160
160
  - spec/spec_helper.rb
161
+ - spec/support/shared_examples_for_raw_data.rb
161
162
  homepage: ''
162
163
  licenses:
163
164
  - MIT
@@ -187,3 +188,4 @@ test_files:
187
188
  - spec/data/2013-09-09.htm
188
189
  - spec/file_spec.rb
189
190
  - spec/spec_helper.rb
191
+ - spec/support/shared_examples_for_raw_data.rb