bcardarella-deepthroat 0.3.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.
@@ -0,0 +1,181 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class TestContributions < Test::Unit::TestCase
4
+
5
+ def setup
6
+ shared_attributes
7
+ DeepThroat.api_key = "validApiKey"
8
+ web_faker(:contributions, :cid => @cid, :cycle => @cycle, :apikey => DeepThroat.api_key)
9
+ end
10
+
11
+ context "Finding all contributions for Hilary Clinton in 2006" do
12
+ setup { @contributions = DeepThroat::Contributions.find(:cid => @cid, :cycle => @cycle) }
13
+
14
+ should "map #cid" do
15
+ assert_equal @cid, @contributions.cid
16
+ end
17
+
18
+ should "map #cycle" do
19
+ assert_equal @cycle, @contributions.cycle
20
+ end
21
+
22
+ should "map #name" do
23
+ assert_equal @contributions.name, @contributions.name
24
+ end
25
+
26
+ should "map #origin" do
27
+ assert_equal @contributions.origin, @contributions.origin
28
+ end
29
+
30
+ should "map #source" do
31
+ assert_equal @contributions.source, @contributions.source
32
+ end
33
+
34
+ should_eventually "map #contributors" do
35
+ assert_kind_of Array, @contributions.contributors
36
+ end
37
+ end
38
+
39
+ context "Finding all contributions for Hillary Clinton with no cycle defined" do
40
+ setup do
41
+ web_faker(:contributions, :cid => @cid, :apikey => DeepThroat.api_key)
42
+ end
43
+
44
+ should "not raise any errors" do
45
+ assert_nothing_raised do
46
+ @contributions = DeepThroat::Contributions.find(:cid => @cid)
47
+ end
48
+ end
49
+ end
50
+
51
+ context "A new instance with missing attributes" do
52
+ should "raise a 'DeepThroat::NoCIDError' when not given a cid" do
53
+ assert_raise DeepThroat::NoCIDError do
54
+ DeepThroat::Contributions.find(:cycle => @cycle)
55
+ end
56
+ end
57
+ end
58
+
59
+ context "Obtaining the XML" do
60
+ setup { @xml_response = DeepThroat::Contributions.get_xml(:cid => @cid, :cycle => @cycle, :method => "candContrib") }
61
+
62
+ should "return an XML feed" do
63
+ assert_equal @test_xml, @xml_response
64
+ end
65
+ end
66
+
67
+ context "Parsing the XML" do
68
+ setup { @contributions = DeepThroat::Contributions.parse(@test_xml)[0] }
69
+
70
+ should "the return a 'DeepThroat::Contributions::Details' object" do
71
+ assert_kind_of DeepThroat::Contributions, @contributions
72
+ end
73
+
74
+ should "assign :name" do
75
+ assert_equal @name, @contributions.name
76
+ assert_kind_of String, @contributions.name
77
+ end
78
+
79
+ should "assign :origin" do
80
+ assert_equal @origin, @contributions.origin
81
+ assert_kind_of String, @contributions.origin
82
+ end
83
+
84
+ should "assign :source" do
85
+ assert_equal @source, @contributions.source
86
+ assert_kind_of String, @contributions.source
87
+ end
88
+
89
+ should "assign :contributors" do
90
+ assert_kind_of Array, @contributions.contributors
91
+ end
92
+ end
93
+
94
+
95
+ context "Sad Paths" do
96
+ setup do
97
+ # invalid ApiKey
98
+ web_faker(:contributions_bad_api_key, :cid => @cid, :cycle => @cycle, :apikey => "badApiKey")
99
+ # blank ApiKey
100
+ web_faker(:contributions_bad_api_key, :cid => @cid, :cycle => @cycle, :apikey => "")
101
+ # no ApiKey
102
+ web_faker(:contributions_bad_api_key, :cid => @cid, :cycle => @cycle)
103
+
104
+ # invalid CID
105
+ web_faker(:contributions_bad_cid, :cid => "badCID", :cycle => @cycle, :apikey => @api_key)
106
+ end
107
+
108
+ context "ApiKey" do
109
+ should "raise 'DeepThroat::InvalidOrMissing::ApiKeyError' when given a bad ApiKey" do
110
+ DeepThroat.api_key = "badApiKey"
111
+ assert_raise DeepThroat::InvalidOrMissing::ApiKeyError do
112
+ DeepThroat::Contributions.find(:cid => @cid, :cycle => @cycle)
113
+ end
114
+ end
115
+
116
+ should "raise 'DeepThroat::InvalidOrMissing::ApiKeyError' when given a blank ApiKey" do
117
+ DeepThroat.api_key = ""
118
+ assert_raise DeepThroat::InvalidOrMissing::ApiKeyError do
119
+ DeepThroat::Contributions.find(:cid => @cid, :cycle => @cycle)
120
+ end
121
+ end
122
+
123
+ should "raise 'DeepThroat::InvalidOrMissing::ApiKeyError' when given no ApiKey" do
124
+ DeepThroat.api_key = nil
125
+ assert_raise DeepThroat::InvalidOrMissing::ApiKeyError do
126
+ DeepThroat::Contributions.find(:cid => @cid, :cycle => @cycle)
127
+ end
128
+ end
129
+ end
130
+
131
+ context "CID" do
132
+ should "raise 'DeepThroat::InvalidOrMissing::CIDError' when given a bad CID" do
133
+ @bad_cid = "badCID"
134
+ assert_raise DeepThroat::InvalidOrMissing::CIDError do
135
+ DeepThroat::Contributions.find(:cid => @bad_cid, :cycle => @cycle)
136
+ end
137
+ end
138
+ end
139
+
140
+ context "Cycle" do
141
+ should "raise 'DeepThroat::InvalidOrMissing::CycleError' when given a bad Cycle" do
142
+ @bad_cycle = 2000
143
+ assert_raise DeepThroat::InvalidOrMissing::CycleError do
144
+ DeepThroat::Contributions.find(:cid => @cid, :cycle => @bad_cycle)
145
+ end
146
+ end
147
+ end
148
+
149
+ end
150
+
151
+ context "CONSTANTS" do
152
+ should "have CYCLES defined as an Array" do
153
+ assert_kind_of Array, DeepThroat::Contributions::CYCLES
154
+ end
155
+
156
+ context "CYCLES" do
157
+ should "include the year 2006" do
158
+ assert DeepThroat::Contributions::CYCLES.include?(2006)
159
+ end
160
+
161
+ should "include the year 2008" do
162
+ assert DeepThroat::Contributions::CYCLES.include?(2008)
163
+ end
164
+ end
165
+ end
166
+
167
+
168
+ private
169
+
170
+ def shared_attributes
171
+ @cid = "N00000019"
172
+ @cycle = 2006
173
+ @api_key = DeepThroat.api_key
174
+
175
+ @test_xml = contributions_xml.match(/<response>.*/)[0]
176
+
177
+ @name = "Hillary Clinton (D)"
178
+ @origin = "Center for Responsive Politics"
179
+ @source = "http://www.opensecrets.org/politicians/contrib.php?cid=N00000019&cycle=2006"
180
+ end
181
+ end
@@ -0,0 +1,38 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class TestContributionsContributor < Test::Unit::TestCase
4
+ def setup
5
+ shared_attributes
6
+ DeepThroat.api_key = "fakeapi_key"
7
+ web_faker(:contributions, :cid => @cid, :cycle => @cycle, :api_key => DeepThroat.api_key)
8
+ end
9
+
10
+ context "Parsing the XML" do
11
+ setup { @contributor = DeepThroat::Contributions::Contributor.parse(@test_xml) }
12
+
13
+ should "the return a 'DeepThroat::Contributions::Contributor' object" do
14
+ assert_kind_of DeepThroat::Contributions::Contributor, @contributor
15
+ end
16
+
17
+ should "assign :organization" do
18
+ assert_equal @organization, @contributor.organization
19
+ assert_kind_of String, @contributor.organization
20
+ end
21
+
22
+ should "assign :total" do
23
+ assert_equal @total, @contributor.total
24
+ assert_kind_of Integer, @contributor.total
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def shared_attributes
31
+ @cid = "N00000019"
32
+ @cycle = 2006
33
+
34
+ @test_xml = "<contributor org_name=\"Goldman Sachs\" total=\"193570\" />"
35
+ @organization = "Goldman Sachs"
36
+ @total = 193570
37
+ end
38
+ end
@@ -0,0 +1,181 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class TestIndustries < Test::Unit::TestCase
4
+
5
+ def setup
6
+ shared_attributes
7
+ DeepThroat.api_key = "validApiKey"
8
+ web_faker(:industries, :cid => @cid, :cycle => @cycle, :apikey => DeepThroat.api_key)
9
+ end
10
+
11
+ context "Finding all contributions by industries for Hilary Clinton in 2006" do
12
+ setup { @industries = DeepThroat::Industries.find(:cid => @cid, :cycle => @cycle) }
13
+
14
+ should "map #cid" do
15
+ assert_equal @cid, @industries.cid
16
+ end
17
+
18
+ should "map #cycle" do
19
+ assert_equal @cycle, @industries.cycle
20
+ end
21
+
22
+ should "map #name" do
23
+ assert_equal @industries.name, @industries.name
24
+ end
25
+
26
+ should "map #origin" do
27
+ assert_equal @industries.origin, @industries.origin
28
+ end
29
+
30
+ should "map #source" do
31
+ assert_equal @industries.source, @industries.source
32
+ end
33
+
34
+ should_eventually "map #industries" do
35
+ assert_kind_of Array, @industries.industries
36
+ end
37
+ end
38
+
39
+ context "Finding all industries for Hillary Clinton with no cycle defined" do
40
+ setup do
41
+ web_faker(:industries, :cid => @cid, :apikey => DeepThroat.api_key)
42
+ end
43
+
44
+ should "not raise any errors" do
45
+ assert_nothing_raised do
46
+ @industries = DeepThroat::Industries.find(:cid => @cid)
47
+ end
48
+ end
49
+ end
50
+
51
+ context "A new instance with missing attributes" do
52
+ should "raise a 'DeepThroat::NoCIDError' when not given a cid" do
53
+ assert_raise DeepThroat::NoCIDError do
54
+ DeepThroat::Industries.find(:cycle => @cycle)
55
+ end
56
+ end
57
+ end
58
+
59
+ context "Obtaining the XML" do
60
+ setup { @xml_response = DeepThroat::Industries.get_xml(:cid => @cid, :cycle => @cycle, :method => "candIndustry") }
61
+
62
+ should "return an XML feed" do
63
+ assert_equal @test_xml, @xml_response
64
+ end
65
+ end
66
+
67
+ context "Parsing the XML" do
68
+ setup { @industries = DeepThroat::Industries.parse(@test_xml)[0] }
69
+
70
+ should "the return a 'DeepThroat::Industries::Details' object" do
71
+ assert_kind_of DeepThroat::Industries, @industries
72
+ end
73
+
74
+ should "assign :name" do
75
+ assert_equal @name, @industries.name
76
+ assert_kind_of String, @industries.name
77
+ end
78
+
79
+ should "assign :origin" do
80
+ assert_equal @origin, @industries.origin
81
+ assert_kind_of String, @industries.origin
82
+ end
83
+
84
+ should "assign :source" do
85
+ assert_equal @source, @industries.source
86
+ assert_kind_of String, @industries.source
87
+ end
88
+
89
+ should "assign :industries" do
90
+ assert_kind_of Array, @industries.industries
91
+ end
92
+ end
93
+
94
+
95
+ context "Sad Paths" do
96
+ setup do
97
+ # invalid ApiKey
98
+ web_faker(:industries_bad_api_key, :cid => @cid, :cycle => @cycle, :apikey => "badApiKey")
99
+ # blank ApiKey
100
+ web_faker(:industries_bad_api_key, :cid => @cid, :cycle => @cycle, :apikey => "")
101
+ # no ApiKey
102
+ web_faker(:industries_bad_api_key, :cid => @cid, :cycle => @cycle)
103
+
104
+ # invalid CID
105
+ web_faker(:industries_bad_cid, :cid => "badCID", :cycle => @cycle, :apikey => @api_key)
106
+ end
107
+
108
+ context "ApiKey" do
109
+ should "raise 'DeepThroat::InvalidOrMissing::ApiKeyError' when given a bad ApiKey" do
110
+ DeepThroat.api_key = "badApiKey"
111
+ assert_raise DeepThroat::InvalidOrMissing::ApiKeyError do
112
+ DeepThroat::Industries.find(:cid => @cid, :cycle => @cycle)
113
+ end
114
+ end
115
+
116
+ should "raise 'DeepThroat::InvalidOrMissing::ApiKeyError' when given a blank ApiKey" do
117
+ DeepThroat.api_key = ""
118
+ assert_raise DeepThroat::InvalidOrMissing::ApiKeyError do
119
+ DeepThroat::Industries.find(:cid => @cid, :cycle => @cycle)
120
+ end
121
+ end
122
+
123
+ should "raise 'DeepThroat::InvalidOrMissing::ApiKeyError' when given no ApiKey" do
124
+ DeepThroat.api_key = nil
125
+ assert_raise DeepThroat::InvalidOrMissing::ApiKeyError do
126
+ DeepThroat::Industries.find(:cid => @cid, :cycle => @cycle)
127
+ end
128
+ end
129
+ end
130
+
131
+ context "CID" do
132
+ should "raise 'DeepThroat::InvalidOrMissing::CIDError' when given a bad CID" do
133
+ @bad_cid = "badCID"
134
+ assert_raise DeepThroat::InvalidOrMissing::CIDError do
135
+ DeepThroat::Industries.find(:cid => @bad_cid, :cycle => @cycle)
136
+ end
137
+ end
138
+ end
139
+
140
+ context "Cycle" do
141
+ should "raise 'DeepThroat::InvalidOrMissing::CycleError' when given a bad Cycle" do
142
+ @bad_cycle = 2000
143
+ assert_raise DeepThroat::InvalidOrMissing::CycleError do
144
+ DeepThroat::Industries.find(:cid => @cid, :cycle => @bad_cycle)
145
+ end
146
+ end
147
+ end
148
+
149
+ end
150
+
151
+ context "CONSTANTS" do
152
+ should "have CYCLES defined as an Array" do
153
+ assert_kind_of Array, DeepThroat::Industries::CYCLES
154
+ end
155
+
156
+ context "CYCLES" do
157
+ should "include the year 2006" do
158
+ assert DeepThroat::Industries::CYCLES.include?(2006)
159
+ end
160
+
161
+ should "include the year 2008" do
162
+ assert DeepThroat::Industries::CYCLES.include?(2008)
163
+ end
164
+ end
165
+ end
166
+
167
+
168
+ private
169
+
170
+ def shared_attributes
171
+ @cid = "N00000019"
172
+ @cycle = 2006
173
+ @api_key = DeepThroat.api_key
174
+
175
+ @test_xml = industries_xml.match(/<response>.*/)[0]
176
+
177
+ @name = "Hillary Clinton (D)"
178
+ @origin = "Center for Responsive Politics"
179
+ @source = "http://www.opensecrets.org/politicians/industries.php?cid=N00000019&cycle=2006"
180
+ end
181
+ end
@@ -0,0 +1,50 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class TestIndustriesIndustry < Test::Unit::TestCase
4
+ def setup
5
+ shared_attributes
6
+ DeepThroat.api_key = "fakeapi_key"
7
+ web_faker(:industries, :cid => @cid, :cycle => @cycle, :api_key => DeepThroat.api_key)
8
+ end
9
+
10
+ context "Parsing the XML" do
11
+ setup { @industry = DeepThroat::Industries::Industry.parse(@test_xml) }
12
+
13
+ should "the return a 'DeepThroat::Industries::Industry' object" do
14
+ assert_kind_of DeepThroat::Industries::Industry, @industry
15
+ end
16
+
17
+ should "assign :industry" do
18
+ assert_equal @industry_name, @industry.industry
19
+ assert_kind_of String, @industry.industry
20
+ end
21
+
22
+ should "assign :indivs" do
23
+ assert_equal @indivs, @industry.indivs
24
+ assert_kind_of Integer, @industry.indivs
25
+ end
26
+
27
+ should "assign :pacs" do
28
+ assert_equal @pacs, @industry.pacs
29
+ assert_kind_of Integer, @industry.pacs
30
+ end
31
+
32
+ should "assign :total" do
33
+ assert_equal @total, @industry.total
34
+ assert_kind_of Integer, @industry.total
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ def shared_attributes
41
+ @cid = "N00000019"
42
+ @cycle = 2006
43
+
44
+ @test_xml = "<industry industry_name=\"Education\" indivs=\"713124\" pacs=\"7000\" total=\"720124\" />"
45
+ @industry_name = "Education"
46
+ @indivs = 713124
47
+ @pacs = 7000
48
+ @total = 720124
49
+ end
50
+ end
@@ -0,0 +1,243 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class TestIndustry < Test::Unit::TestCase
4
+
5
+ def setup
6
+ shared_attributes
7
+ DeepThroat.api_key = "validApiKey"
8
+ web_faker(:industry, :cid => @cid, :cycle => @cycle, :apikey => DeepThroat.api_key, :ind => "A01")
9
+ end
10
+
11
+ context "Finding all contributions by industry for Hilary Clinton in 2006" do
12
+ setup { @industry = DeepThroat::Industry.find(:cid => @cid, :cycle => @cycle, :ind => "A01") }
13
+
14
+ should "map #cid" do
15
+ assert_equal @cid, @industry.cid
16
+ end
17
+
18
+ should "map #cycle" do
19
+ assert_equal @cycle, @industry.cycle
20
+ end
21
+
22
+ should "map #name" do
23
+ assert_equal @industry.name, @industry.name
24
+ end
25
+
26
+ should "map #state" do
27
+ assert_equal @industry.state, @industry.state
28
+ end
29
+
30
+ should "map #party" do
31
+ assert_equal @industry.party, @industry.party
32
+ end
33
+
34
+ should "map #chamber" do
35
+ assert_equal @industry.chamber, @industry.chamber
36
+ end
37
+
38
+ should "map #origin" do
39
+ assert_equal @industry.origin, @industry.origin
40
+ end
41
+
42
+ should "map #source" do
43
+ assert_equal @industry.source, @industry.source
44
+ end
45
+ end
46
+
47
+ context "Finding all industry for Hillary Clinton with no cycle defined" do
48
+ setup do
49
+ web_faker(:industry, :cid => @cid, :apikey => DeepThroat.api_key, :ind => "A01")
50
+ end
51
+
52
+ should "not raise any errors" do
53
+ assert_nothing_raised do
54
+ @industry = DeepThroat::Industry.find(:cid => @cid, :ind => "A01")
55
+ end
56
+ end
57
+ end
58
+
59
+ context "A new instance with missing attributes" do
60
+ should "raise a 'DeepThroat::NoCIDError' when not given a :cid" do
61
+ assert_raise DeepThroat::NoCIDError do
62
+ DeepThroat::Industry.find(:cycle => @cycle, :ind => "A01")
63
+ end
64
+ end
65
+
66
+ should "raise 'DeepThroat::InvalidOrMissing::IndustryCodeError' when not given a :ind" do
67
+ assert_raise DeepThroat::InvalidOrMissing::IndustryCodeError do
68
+ DeepThroat::Industry.find(:cid => @cid, :cycle => @cycle)
69
+ end
70
+ end
71
+
72
+ end
73
+
74
+ context "Obtaining the XML" do
75
+ setup { @xml_response = DeepThroat::Industry.get_xml(:cid => @cid, :cycle => @cycle, :method => "CandIndByInd", :ind => "A01") }
76
+
77
+ should "return an XML feed" do
78
+ assert_equal @test_xml, @xml_response
79
+ end
80
+ end
81
+
82
+ context "Parsing the XML" do
83
+ setup { @industry = DeepThroat::Industry.parse(@test_xml)[0] }
84
+
85
+ should "the return a 'DeepThroat::Industry::Details' object" do
86
+ assert_kind_of DeepThroat::Industry, @industry
87
+ end
88
+
89
+ should "assign :name" do
90
+ assert_equal @name, @industry.name
91
+ assert_kind_of String, @industry.name
92
+ end
93
+
94
+ should "assign :origin" do
95
+ assert_equal @origin, @industry.origin
96
+ assert_kind_of String, @industry.origin
97
+ end
98
+
99
+ should "assign :source" do
100
+ assert_equal @source, @industry.source
101
+ assert_kind_of String, @industry.source
102
+ end
103
+
104
+ should "assign :industry" do
105
+ assert_equal @industry_name, @industry.industry
106
+ assert_kind_of String, @industry.industry
107
+ end
108
+
109
+ should "assign :chamber" do
110
+ assert_equal @chamber, @industry.chamber
111
+ assert_kind_of String, @industry.chamber
112
+ end
113
+
114
+ should "assign :party" do
115
+ assert_equal @party, @industry.party
116
+ assert_kind_of String, @industry.party
117
+ end
118
+
119
+ should "assign :state" do
120
+ assert_equal @state, @industry.state
121
+ assert_kind_of String, @industry.state
122
+ end
123
+
124
+ should "assign :total" do
125
+ assert_equal @total, @industry.total
126
+ assert_kind_of Integer, @industry.total
127
+ end
128
+
129
+ should "assign :indivs" do
130
+ assert_equal @indivs, @industry.indivs
131
+ assert_kind_of Integer, @industry.indivs
132
+ end
133
+
134
+ should "assign :pacs" do
135
+ assert_equal @pacs, @industry.pacs
136
+ assert_kind_of Integer, @industry.pacs
137
+ end
138
+
139
+ should "assign :rank" do
140
+ assert_equal @rank, @industry.rank
141
+ assert_kind_of Integer, @industry.rank
142
+ end
143
+ end
144
+
145
+ context "Sad Paths" do
146
+ setup do
147
+ # invalid ApiKey
148
+ web_faker(:industry_bad_api_key, :cid => @cid, :cycle => @cycle, :apikey => "badApiKey", :ind => "A01")
149
+ # blank ApiKey
150
+ web_faker(:industry_bad_api_key, :cid => @cid, :cycle => @cycle, :apikey => "", :ind => "A01")
151
+ # no ApiKey
152
+ web_faker(:industry_bad_api_key, :cid => @cid, :cycle => @cycle, :ind => "A01")
153
+
154
+ # invalid CID
155
+ web_faker(:industry_bad_cid, :cid => "badCID", :cycle => @cycle, :apikey => @api_key, :ind => "A01")
156
+
157
+ # no Industry Code
158
+ # Not certain how to handle yet
159
+ # web_faker(:industry_bad_indcode, :cid => @cid, :cycle => @cycle, :apikey => DeepThroat.api_key)
160
+ end
161
+
162
+ context "ApiKey" do
163
+ should "raise 'DeepThroat::InvalidOrMissing::ApiKeyError' when given a bad ApiKey" do
164
+ DeepThroat.api_key = "badApiKey"
165
+ assert_raise DeepThroat::InvalidOrMissing::ApiKeyError do
166
+ DeepThroat::Industry.find(:cid => @cid, :cycle => @cycle, :ind => "A01")
167
+ end
168
+ end
169
+
170
+ should "raise 'DeepThroat::InvalidOrMissing::ApiKeyError' when given a blank ApiKey" do
171
+ DeepThroat.api_key = ""
172
+ assert_raise DeepThroat::InvalidOrMissing::ApiKeyError do
173
+ DeepThroat::Industry.find(:cid => @cid, :cycle => @cycle, :ind => "A01")
174
+ end
175
+ end
176
+
177
+ should "raise 'DeepThroat::InvalidOrMissing::ApiKeyError' when given no ApiKey" do
178
+ DeepThroat.api_key = nil
179
+ assert_raise DeepThroat::InvalidOrMissing::ApiKeyError do
180
+ DeepThroat::Industry.find(:cid => @cid, :cycle => @cycle, :ind => "A01")
181
+ end
182
+ end
183
+ end
184
+
185
+ context "CID" do
186
+ should "raise 'DeepThroat::InvalidOrMissing::CIDError' when given a bad CID" do
187
+ @bad_cid = "badCID"
188
+ assert_raise DeepThroat::InvalidOrMissing::CIDError do
189
+ DeepThroat::Industry.find(:cid => @bad_cid, :cycle => @cycle, :ind => "A01")
190
+ end
191
+ end
192
+ end
193
+
194
+ context "Cycle" do
195
+ should "raise 'DeepThroat::InvalidOrMissing::CycleError' when given a bad Cycle" do
196
+ @bad_cycle = 2000
197
+ assert_raise DeepThroat::InvalidOrMissing::CycleError do
198
+ DeepThroat::Industry.find(:cid => @cid, :cycle => @bad_cycle, :ind => "A01")
199
+ end
200
+ end
201
+ end
202
+ end
203
+
204
+ context "CONSTANTS" do
205
+ should "have CYCLES defined as an Array" do
206
+ assert_kind_of Array, DeepThroat::Industry::CYCLES
207
+ end
208
+
209
+ context "CYCLES" do
210
+ should "include the year 2006" do
211
+ assert DeepThroat::Industry::CYCLES.include?(2006)
212
+ end
213
+
214
+ should "include the year 2008" do
215
+ assert DeepThroat::Industry::CYCLES.include?(2008)
216
+ end
217
+ end
218
+ end
219
+
220
+
221
+ private
222
+
223
+ def shared_attributes
224
+ @cid = "N00000019"
225
+ @cycle = 2008
226
+ @api_key = DeepThroat.api_key
227
+
228
+ @test_xml = industry_xml.match(/<response>.*/)[0]
229
+
230
+ @name = "Clinton, Hillary"
231
+ @origin = "Center for Responsive Politics"
232
+ @source = "http://www.opensecrets.org/industries/recips.php?Ind=A01&cycle=2008&recipdetail=S&Mem=Y&sortorder=U"
233
+
234
+ @industry_name = "Crop Production "
235
+ @chamber = "S"
236
+ @party = "D"
237
+ @state = "New York "
238
+ @total = 218291
239
+ @indivs = 211491
240
+ @pacs = 6800
241
+ @rank = 4
242
+ end
243
+ end