iraq_unrest 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +114 -0
- data/Rakefile +7 -0
- data/examples/example_01.png +0 -0
- data/examples/example_02.png +0 -0
- data/examples/example_03.png +0 -0
- data/examples/iraq_government_casualty_figure.csv +95 -0
- data/examples/iraq_government_casualty_figure.html +126 -0
- data/examples/iraqi_casualties_comparison.csv +119 -0
- data/examples/iraqi_casualties_comparison.html +105 -0
- data/iraq_unrest.gemspec +33 -0
- data/lib/iraq_unrest/concerns/serializable.rb +37 -0
- data/lib/iraq_unrest/concerns/validatable.rb +18 -0
- data/lib/iraq_unrest/config.rb +8 -0
- data/lib/iraq_unrest/data/Iraq_Government_Casualty_Figure.csv +116 -0
- data/lib/iraq_unrest/data_set.rb +41 -0
- data/lib/iraq_unrest/erb/header.html.erb +32 -0
- data/lib/iraq_unrest/erb/iraq_government_casualty_figure.html.erb +94 -0
- data/lib/iraq_unrest/erb/iraqi_casualties_comparison.html.erb +73 -0
- data/lib/iraq_unrest/format.rb +103 -0
- data/lib/iraq_unrest/google_doc.rb +31 -0
- data/lib/iraq_unrest/iraq_government_casualty_figure.rb +53 -0
- data/lib/iraq_unrest/iraq_unrest_record.rb +74 -0
- data/lib/iraq_unrest/iraqi_casualties_comparison.rb +46 -0
- data/lib/iraq_unrest/serializers.rb +46 -0
- data/lib/iraq_unrest/version.rb +3 -0
- data/lib/iraq_unrest.rb +50 -0
- data/test/fixtures/vcr_cassettes/iraq_government_casualty_figure.yml +161 -0
- data/test/fixtures/vcr_cassettes/iraqi_casualties_comparison.yml +184 -0
- data/test/google_doc_test.rb +56 -0
- data/test/iraq_government_casualty_figure_test.rb +253 -0
- data/test/iraqi_casualties_comparison_test.rb +246 -0
- data/test/test_helper.rb +17 -0
- data/test/validatable_test.rb +34 -0
- metadata +242 -0
@@ -0,0 +1,184 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://docs.google.com/spreadsheet/pub?gid=9&hl=en_US&key=0Aia6y6NymliRdEZESktBSWVqNWM1dkZOSGNIVmtFZEE&output=csv
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
Content-Type:
|
16
|
+
- text/csv
|
17
|
+
X-Robots-Tag:
|
18
|
+
- noindex, nofollow, nosnippet
|
19
|
+
Content-Disposition:
|
20
|
+
- attachment; filename="Iraq Unrest.csv"
|
21
|
+
Set-Cookie:
|
22
|
+
- NID=67=dJclmwa8iaDNZ4CB0RxHEiP_3spkVXQxeKZpER9-lmcnWKK0luvNaqQXJhyKQg9u8-S1oJIq99n0uwyHao4h1KPz4NSZVy-3wqI8RSumVbTWz4lKwuNEnitFFPOsiD1k;Domain=.google.com;Path=/;Expires=Wed,
|
23
|
+
14-May-2014 16:29:13 GMT;HttpOnly
|
24
|
+
P3p:
|
25
|
+
- CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657
|
26
|
+
for more info."
|
27
|
+
Date:
|
28
|
+
- Tue, 12 Nov 2013 16:29:13 GMT
|
29
|
+
Expires:
|
30
|
+
- Tue, 12 Nov 2013 16:29:13 GMT
|
31
|
+
Cache-Control:
|
32
|
+
- private, max-age=0
|
33
|
+
X-Content-Type-Options:
|
34
|
+
- nosniff
|
35
|
+
X-Xss-Protection:
|
36
|
+
- 1; mode=block
|
37
|
+
Server:
|
38
|
+
- GSE
|
39
|
+
Alternate-Protocol:
|
40
|
+
- 443:quic
|
41
|
+
Transfer-Encoding:
|
42
|
+
- chunked
|
43
|
+
body:
|
44
|
+
encoding: ASCII-8BIT
|
45
|
+
string: |-
|
46
|
+
Iraqi Casualties: A Comparison,,,
|
47
|
+
,,,
|
48
|
+
"This sheet provides a comparison between data compiled by AFP, based on reports from security and medical officials, data compiled by the Iraqi ministries of health, interior and defence, and data compiled by Britain-based NGO Iraq Body Count",,,
|
49
|
+
,,,
|
50
|
+
,KILLED,,
|
51
|
+
,Iraq Government,Iraq Body Count,AFP
|
52
|
+
Dec-2013,0,,
|
53
|
+
Nov-2013,0,,139
|
54
|
+
Oct-2013,964,,743
|
55
|
+
Sep-2013,885,,880
|
56
|
+
Aug-2013,356,,693
|
57
|
+
Jul-2013,921,,875
|
58
|
+
Jun-2013,240,,452
|
59
|
+
May-2013,630,887,614
|
60
|
+
Apr-2013,205,544,461
|
61
|
+
Mar-2013,163,395,271
|
62
|
+
Feb-2013,136,358,220
|
63
|
+
Jan-2013,177,357,246
|
64
|
+
2013,4677,2541,5594
|
65
|
+
Dec-2012,208,275,144
|
66
|
+
Nov-2012,166,240,160
|
67
|
+
Oct-2012,144,290,136
|
68
|
+
Sep-2012,365,396,253
|
69
|
+
Aug-2012,164,422,278
|
70
|
+
Jul-2012,325,469,278
|
71
|
+
Jun-2012,131,529,282
|
72
|
+
May-2012,132,304,
|
73
|
+
Apr-2012,126,392,
|
74
|
+
Mar-2012,112,377,
|
75
|
+
Feb-2012,150,356,
|
76
|
+
Jan-2012,151,524,
|
77
|
+
2012,2174,4574,1531
|
78
|
+
Dec-2011,155,388,
|
79
|
+
Nov-2011,187,279,
|
80
|
+
Oct-2011,258,366,
|
81
|
+
Sep-2011,185,397,
|
82
|
+
Aug-2011,239,401,
|
83
|
+
Jul-2011,259,308,
|
84
|
+
Jun-2011,271,386,
|
85
|
+
May-2011,177,381,
|
86
|
+
Apr-2011,211,289,
|
87
|
+
Mar-2011,247,311,
|
88
|
+
Feb-2011,197,252,
|
89
|
+
Jan-2011,259,389,
|
90
|
+
2011,2645,4147,
|
91
|
+
Dec-2010,151,217,
|
92
|
+
Nov-2010,171,307,
|
93
|
+
Oct-2010,185,312,
|
94
|
+
Sep-2010,273,254,
|
95
|
+
Aug-2010,426,516,
|
96
|
+
Jul-2010,535,443,
|
97
|
+
Jun-2010,284,385,
|
98
|
+
May-2010,337,387,
|
99
|
+
Apr-2010,328,385,
|
100
|
+
Mar-2010,367,336,
|
101
|
+
Feb-2010,352,304,
|
102
|
+
Jan-2010,196,263,
|
103
|
+
2010,3605,4109,
|
104
|
+
Dec-2009,367,475,
|
105
|
+
Nov-2009,122,226,
|
106
|
+
Oct-2009,410,435,
|
107
|
+
Sep-2009,203,332,
|
108
|
+
Aug-2009,456,618,
|
109
|
+
Jul-2009,275,407,
|
110
|
+
Jun-2009,437,498,
|
111
|
+
May-2009,155,387,
|
112
|
+
Apr-2009,355,565,
|
113
|
+
Mar-2009,252,426,
|
114
|
+
Feb-2009,258,402,
|
115
|
+
Jan-2009,191,366,
|
116
|
+
2009,3481,5137,
|
117
|
+
Dec-2008,316,576,
|
118
|
+
Nov-2008,340,521,
|
119
|
+
Oct-2008,317,575,
|
120
|
+
Sep-2008,440,584,
|
121
|
+
Aug-2008,431,627,
|
122
|
+
Jul-2008,465,623,
|
123
|
+
Jun-2008,509,747,
|
124
|
+
May-2008,563,886,
|
125
|
+
Apr-2008,1073,1272,
|
126
|
+
Mar-2008,1082,1623,
|
127
|
+
Feb-2008,721,1049,
|
128
|
+
Jan-2008,541,844,
|
129
|
+
2008,6798,9927,
|
130
|
+
Dec-2007,568,982,
|
131
|
+
Nov-2007,606,1095,
|
132
|
+
Oct-2007,887,1286,
|
133
|
+
Sep-2007,917,1360,
|
134
|
+
Aug-2007,1856,2457,
|
135
|
+
Jul-2007,1875,2671,
|
136
|
+
Jun-2007,1463,2180,
|
137
|
+
May-2007,2124,2809,
|
138
|
+
Apr-2007,1689,2495,
|
139
|
+
Mar-2007,2078,2682,
|
140
|
+
Feb-2007,1806,2607,
|
141
|
+
Jan-2007,2087,2948,
|
142
|
+
2007,17956,25572,
|
143
|
+
Dec-2006,0,2886,
|
144
|
+
Nov-2006,1975,3064,
|
145
|
+
Oct-2006,1427,2977,
|
146
|
+
Sep-2006,0,2556,
|
147
|
+
Aug-2006,0,2835,
|
148
|
+
Jul-2006,1850,3279,
|
149
|
+
Jun-2006,1009,2553,
|
150
|
+
May-2006,1055,2251,
|
151
|
+
Apr-2006,0,1792,
|
152
|
+
Mar-2006,0,1940,
|
153
|
+
Feb-2006,0,1569,
|
154
|
+
Jan-2006,0,1543,
|
155
|
+
2006,7316,29245,
|
156
|
+
Dec-2005,,1135,
|
157
|
+
Nov-2005,,1465,
|
158
|
+
Oct-2005,,1298,
|
159
|
+
Sep-2005,,1415,
|
160
|
+
Aug-2005,,2266,
|
161
|
+
Jul-2005,,1528,
|
162
|
+
Jun-2005,,1299,
|
163
|
+
May-2005,,1336,
|
164
|
+
Apr-2005,,1119,
|
165
|
+
Mar-2005,,871,
|
166
|
+
Feb-2005,,1266,
|
167
|
+
Jan-2005,,1188,
|
168
|
+
2005,,16186,
|
169
|
+
Dec-2004,,1106,
|
170
|
+
Nov-2004,,1653,
|
171
|
+
Oct-2004,,1011,
|
172
|
+
Sep-2004,,1031,
|
173
|
+
Aug-2004,,868,
|
174
|
+
Jul-2004,,818,
|
175
|
+
Jun-2004,,900,
|
176
|
+
May-2004,,656,
|
177
|
+
Apr-2004,,1304,
|
178
|
+
Mar-2004,,1001,
|
179
|
+
Feb-2004,,660,
|
180
|
+
Jan-2004,,609,
|
181
|
+
2004,,11617,
|
182
|
+
http_version:
|
183
|
+
recorded_at: Tue, 12 Nov 2013 16:29:13 GMT
|
184
|
+
recorded_with: VCR 2.6.0
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module IraqUnrest
|
4
|
+
|
5
|
+
describe GoogleDoc do
|
6
|
+
|
7
|
+
before do
|
8
|
+
VCR.insert_cassette 'iraq_government_casualty_figure', :re_record_interval => 86400
|
9
|
+
@doc = GoogleDoc.new
|
10
|
+
end
|
11
|
+
|
12
|
+
after { VCR.eject_cassette }
|
13
|
+
|
14
|
+
describe "when asked for a spreadsheet by name" do
|
15
|
+
|
16
|
+
it "must return a String object" do
|
17
|
+
spreadsheet = @doc.spreadsheet(:iraq_government_casualty_figure)
|
18
|
+
spreadsheet.must_be_kind_of String
|
19
|
+
end
|
20
|
+
|
21
|
+
it "must return an ArgumentError when the name is invalid" do
|
22
|
+
proc {@doc.spreadsheet(:foobaz)}.must_raise ArgumentError
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "when there are network problems" do
|
28
|
+
|
29
|
+
before do
|
30
|
+
WebMock.disable_net_connect!
|
31
|
+
@doc = GoogleDoc.new
|
32
|
+
end
|
33
|
+
after { WebMock.allow_net_connect! }
|
34
|
+
|
35
|
+
it "must raise a TimeoutError with a custom message for long requests" do
|
36
|
+
stub_request(:get,
|
37
|
+
"https://docs.google.com/spreadsheet/pub?gid=4&hl=en_US&key=0Aia6y6NymliRdEZESktBSWVqNWM1dkZOSGNIVmtFZEE&output=csv").
|
38
|
+
to_timeout
|
39
|
+
err = proc {@doc.spreadsheet(:iraq_government_casualty_figure)}.must_raise Curl::Err::TimeoutError
|
40
|
+
err.message.must_match /^Could not connect to Google Docs in a timely manner Curl::Err::TimeoutError$/
|
41
|
+
end
|
42
|
+
|
43
|
+
it "must raise an Exception with a custom message when the response code when not 200" do
|
44
|
+
stub_request(:get,
|
45
|
+
"https://docs.google.com/spreadsheet/pub?gid=4&hl=en_US&key=0Aia6y6NymliRdEZESktBSWVqNWM1dkZOSGNIVmtFZEE&output=csv").
|
46
|
+
to_return(:status => 500, :body => "", :headers => {})
|
47
|
+
|
48
|
+
err = proc {@doc.spreadsheet(:iraq_government_casualty_figure)}.must_raise Exception
|
49
|
+
err.message.must_match /^Did not receive a successfull response from Google Docs$/
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,253 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module IraqUnrest
|
4
|
+
|
5
|
+
describe IraqGovernmentCasualtyFigure do
|
6
|
+
|
7
|
+
before { VCR.insert_cassette 'iraq_government_casualty_figure', :re_record_interval => 86400 }
|
8
|
+
after { VCR.eject_cassette }
|
9
|
+
|
10
|
+
describe "an instance" do
|
11
|
+
|
12
|
+
before { @object = IraqiCasualtiesComparison.new(:date => "Sep-2013") }
|
13
|
+
|
14
|
+
describe "when asked as_json" do
|
15
|
+
it "must be a Hash" do
|
16
|
+
@object.as_json.must_be_instance_of Hash
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "when asked to_json" do
|
21
|
+
it "must be a String" do
|
22
|
+
@object.to_json.must_be_instance_of String
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "the data set" do
|
29
|
+
|
30
|
+
it "must return 88 when asked for the number of Iraqi Civilians Killed in Feb-2013" do
|
31
|
+
IraqGovernmentCasualtyFigure.all.find {|item| item.date == "Feb-2013" }.civilian_killed.must_equal "88"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "must return 58 when asked for the number of Iraqi Police Killed in Dec-2008" do
|
35
|
+
IraqGovernmentCasualtyFigure.all.find {|item| item.date == "Dec-2008" }.police_killed.must_equal "58"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "must return 25 when asked for the number of Iraqi Army Killed in Nov-2006" do
|
39
|
+
IraqGovernmentCasualtyFigure.all.find {|item| item.date == "Nov-2006" }.army_killed.must_equal "25"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "must return 1745 when asked for the number of Iraqi Civilian Wounded in Apr-2008" do
|
43
|
+
IraqGovernmentCasualtyFigure.all.find {|item| item.date == "Apr-2008" }.civilian_wounded.must_equal "1745"
|
44
|
+
end
|
45
|
+
|
46
|
+
it "must return when asked for the number of Iraqi Police Wounded in Oct-2006" do
|
47
|
+
IraqGovernmentCasualtyFigure.all.find {|item| item.date == "Oct-2006" }.police_wounded.must_equal "184"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "must return 89 when asked for the number of Iraqi Army Wounded in Juy-2013" do
|
51
|
+
IraqGovernmentCasualtyFigure.all.find {|item| item.date == "Jul-2013" }.army_wounded.must_equal "89"
|
52
|
+
end
|
53
|
+
|
54
|
+
it "must return 54 when asked for the number of Insurgents Killed in Jan-2010" do
|
55
|
+
IraqGovernmentCasualtyFigure.all.find {|item| item.date == "Jan-2010" }.insurg_killed.must_equal "54"
|
56
|
+
end
|
57
|
+
|
58
|
+
it "must return 949 when asked for the number of Insurgents Arrested in Jun-2008" do
|
59
|
+
IraqGovernmentCasualtyFigure.all.find {|item| item.date == "Jun-2008" }.insurg_arrested.must_equal "949"
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "class methods" do
|
65
|
+
|
66
|
+
describe "when asked for a raw csv" do
|
67
|
+
it "must return a String" do
|
68
|
+
IraqGovernmentCasualtyFigure.raw_csv.must_be_kind_of String
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "when asked for a CSV" do
|
73
|
+
|
74
|
+
before { @csv = IraqGovernmentCasualtyFigure.to_csv }
|
75
|
+
|
76
|
+
it "must return a CSV String" do
|
77
|
+
@csv.must_be_kind_of String
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "Parsring the String into a CSV object" do
|
81
|
+
|
82
|
+
before do
|
83
|
+
@csv_object = CSV.parse(@csv, :headers => true,
|
84
|
+
:header_converters => :symbol)
|
85
|
+
end
|
86
|
+
|
87
|
+
it "must have the correct headers" do
|
88
|
+
@csv_object.headers.must_equal IraqGovernmentCasualtyFigure::ATTRIBUTES
|
89
|
+
end
|
90
|
+
|
91
|
+
it "must have a dates in the format of mmm-YYYY in the first colum" do
|
92
|
+
@csv_object.values_at(:date).flatten.map {|date| Date::strptime(date,"%b-%Y") }
|
93
|
+
end
|
94
|
+
|
95
|
+
it "must have at least 90 rows" do
|
96
|
+
@csv_object.size.must_be :>=, 90
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
describe "when asked to generate a CSV" do
|
104
|
+
|
105
|
+
before { @file = IraqGovernmentCasualtyFigure.to_csv! }
|
106
|
+
|
107
|
+
it "must return a File object" do
|
108
|
+
@file.must_be_kind_of File
|
109
|
+
end
|
110
|
+
|
111
|
+
it "must create a file" do
|
112
|
+
@file.path.must_equal IraqGovernmentCasualtyFigure.file_name + ".csv"
|
113
|
+
(File.exists? @file.path).must_equal true
|
114
|
+
end
|
115
|
+
|
116
|
+
describe "CSV file" do
|
117
|
+
|
118
|
+
before do
|
119
|
+
@csv = CSV.table(@file.path, :skip_lines => /#/)
|
120
|
+
end
|
121
|
+
|
122
|
+
it "must have the correct headers" do
|
123
|
+
@csv.headers.must_equal IraqGovernmentCasualtyFigure::ATTRIBUTES
|
124
|
+
end
|
125
|
+
|
126
|
+
it "wont be empty" do
|
127
|
+
@csv.empty?.must_equal false
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
describe "when asked as_json#to_json" do
|
135
|
+
|
136
|
+
before do
|
137
|
+
@json = IraqUnrest::IraqGovernmentCasualtyFigure.as_json.to_json
|
138
|
+
end
|
139
|
+
|
140
|
+
it "must return a JSON string of all objects" do
|
141
|
+
@json.wont_be_nil
|
142
|
+
@json.must_be_kind_of String
|
143
|
+
@parsed = JSON.parse(@json)
|
144
|
+
@parsed.must_be_kind_of Array
|
145
|
+
@parsed.first.empty?.must_equal false
|
146
|
+
end
|
147
|
+
|
148
|
+
end
|
149
|
+
|
150
|
+
describe "when asked as_json" do
|
151
|
+
|
152
|
+
before do
|
153
|
+
@json = IraqUnrest::IraqGovernmentCasualtyFigure.as_json
|
154
|
+
end
|
155
|
+
|
156
|
+
it "must return an Array" do
|
157
|
+
@json.wont_be_nil
|
158
|
+
@json.must_be_kind_of Array
|
159
|
+
@generated = JSON.generate(@json)
|
160
|
+
@generated.must_be_kind_of String
|
161
|
+
end
|
162
|
+
|
163
|
+
end
|
164
|
+
|
165
|
+
describe "when asked to generate a rickshaw data structure" do
|
166
|
+
before do
|
167
|
+
@data = IraqGovernmentCasualtyFigure.as_rickshaw
|
168
|
+
@attr = [:civilian_killed, :police_killed, :army_killed, :civilian_wounded, :police_wounded, :army_wounded, :insurg_killed, :insurg_arrested]
|
169
|
+
end
|
170
|
+
|
171
|
+
it "must have all keys except a date" do
|
172
|
+
@data.keys.must_equal @attr
|
173
|
+
end
|
174
|
+
|
175
|
+
it "must contain formatted array of hashes for each attribute" do
|
176
|
+
@attr.each do |attr|
|
177
|
+
@data[attr].each do |data_point|
|
178
|
+
data_point.keys.must_equal [:x, :y]
|
179
|
+
Date.strptime(data_point[:x].to_s, "%s").must_be_instance_of Date
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
end
|
185
|
+
|
186
|
+
describe "when asked for HTML" do
|
187
|
+
|
188
|
+
before do
|
189
|
+
@html = IraqGovernmentCasualtyFigure.to_html
|
190
|
+
end
|
191
|
+
|
192
|
+
it "must return a String" do
|
193
|
+
@html.must_be_kind_of String
|
194
|
+
end
|
195
|
+
|
196
|
+
end
|
197
|
+
|
198
|
+
describe "when asked to generate HTML" do
|
199
|
+
|
200
|
+
before { @file = IraqGovernmentCasualtyFigure.to_html! }
|
201
|
+
|
202
|
+
it "must return a File object" do
|
203
|
+
@file.must_be_kind_of File
|
204
|
+
end
|
205
|
+
|
206
|
+
it "must create a file" do
|
207
|
+
@file.path.must_equal IraqGovernmentCasualtyFigure.file_name + ".html"
|
208
|
+
(File.exists? @file.path).must_equal true
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
212
|
+
|
213
|
+
describe "when asked to visualize all records" do
|
214
|
+
|
215
|
+
before { @file = IraqGovernmentCasualtyFigure.visualize! }
|
216
|
+
|
217
|
+
it "must return a File object" do
|
218
|
+
@file.must_be_kind_of File
|
219
|
+
end
|
220
|
+
|
221
|
+
it "must create a file" do
|
222
|
+
@file.path.must_equal IraqGovernmentCasualtyFigure.file_name + ".html"
|
223
|
+
(File.exists? @file.path).must_equal true
|
224
|
+
end
|
225
|
+
|
226
|
+
end
|
227
|
+
|
228
|
+
describe "when asked for all records" do
|
229
|
+
it "must return a collection of IraqGovernmentCasualtyFigure objects" do
|
230
|
+
data = IraqGovernmentCasualtyFigure.all
|
231
|
+
data.must_be_kind_of Enumerable
|
232
|
+
data.size.must_be :>, 90
|
233
|
+
data.first.must_be_kind_of IraqGovernmentCasualtyFigure
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
describe "when asked for a file name" do
|
238
|
+
it "must respond with a properly formatted file name" do
|
239
|
+
IraqGovernmentCasualtyFigure.file_name.must_equal 'iraq_government_casualty_figure'
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
describe "when asked to parse raw data" do
|
244
|
+
it "must raise an Exception if it cannot find a title" do
|
245
|
+
err = proc {IraqGovernmentCasualtyFigure.parse("Foo,Bar,Baz,\n")}.must_raise Exception
|
246
|
+
err.message.must_match /^Could not find a valid title in data source$/
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
end
|
251
|
+
|
252
|
+
end
|
253
|
+
end
|