technicalpickles-daywalker 0.1.2 → 0.2.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.
- data/README.rdoc +1 -1
- data/VERSION.yml +2 -2
- data/lib/daywalker.rb +40 -2
- data/lib/daywalker/base.rb +5 -2
- data/lib/daywalker/district.rb +24 -10
- data/lib/daywalker/dynamic_finder_match.rb +2 -6
- data/lib/daywalker/geocoder.rb +18 -0
- data/lib/daywalker/legislator.rb +154 -57
- data/lib/daywalker/type_converter.rb +25 -4
- data/spec/daywalker/district_spec.rb +67 -45
- data/spec/daywalker/dynamic_finder_match_spec.rb +9 -9
- data/spec/daywalker/geocoder_spec.rb +46 -0
- data/spec/daywalker/legislator_spec.rb +258 -71
- data/spec/daywalker/type_converter_spec.rb +45 -9
- data/spec/fixtures/get_nonexistent_legislator.xml +9 -0
- data/spec/fixtures/rpi_location.yml +5 -0
- data/spec/spec_helper.rb +40 -6
- metadata +37 -4
@@ -53,6 +53,46 @@ describe Daywalker::TypeConverter do
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
+
describe 'district_to_sym_or_i' do
|
57
|
+
it 'should convert 5 to 5' do
|
58
|
+
Daywalker::TypeConverter.district_to_sym_or_i('5').should == 5
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should convert Junior Seat to :junior_seat' do
|
62
|
+
Daywalker::TypeConverter.district_to_sym_or_i('Junior Seat').should == :junior_seat
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should convert Senior Seat to :senior_seat' do
|
66
|
+
Daywalker::TypeConverter.district_to_sym_or_i('Senior Seat').should == :senior_seat
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should raise ArgumentError for bad input' do
|
70
|
+
lambda {
|
71
|
+
Daywalker::TypeConverter.district_to_sym_or_i('zomg')
|
72
|
+
}.should raise_error(ArgumentError)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe 'sym_or_i_to_district' do
|
77
|
+
it 'should convert :junior_seat to Junior Seat' do
|
78
|
+
Daywalker::TypeConverter.sym_or_i_to_district(:junior_seat).should == 'Junior Seat'
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should convert :senior_seat to Senior Seat' do
|
82
|
+
Daywalker::TypeConverter.sym_or_i_to_district(:senior_seat).should == 'Senior Seat'
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'should convert 5 to 5' do
|
86
|
+
Daywalker::TypeConverter.sym_or_i_to_district(5).should == '5'
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'should raise ArgumentError for everything else' do
|
90
|
+
lambda {
|
91
|
+
Daywalker::TypeConverter.sym_or_i_to_district(:zomg)
|
92
|
+
}.should raise_error(ArgumentError)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
56
96
|
describe 'sym_to_title_abbr' do
|
57
97
|
it 'should convert :senator to Sen' do
|
58
98
|
Daywalker::TypeConverter.sym_to_title_abbr(:senator).should == 'Sen'
|
@@ -119,7 +159,7 @@ describe Daywalker::TypeConverter do
|
|
119
159
|
before do
|
120
160
|
@conditions = {
|
121
161
|
:title => :senator,
|
122
|
-
:
|
162
|
+
:district => 5,
|
123
163
|
:official_rss_url => 'http://zomg.com/index.rss',
|
124
164
|
:party => :democrat,
|
125
165
|
:website_url => 'http://zomg.com',
|
@@ -132,19 +172,15 @@ describe Daywalker::TypeConverter do
|
|
132
172
|
}
|
133
173
|
end
|
134
174
|
|
175
|
+
it 'should convert district value' do
|
176
|
+
Daywalker::TypeConverter.should_receive(:sym_or_i_to_district).with(5)
|
177
|
+
Daywalker::TypeConverter.normalize_conditions(@conditions)
|
178
|
+
end
|
135
179
|
it 'should convert title value' do
|
136
180
|
Daywalker::TypeConverter.should_receive(:sym_to_title_abbr).with(:senator)
|
137
181
|
Daywalker::TypeConverter.normalize_conditions(@conditions)
|
138
182
|
end
|
139
183
|
|
140
|
-
it 'should copy district_number value to district' do
|
141
|
-
Daywalker::TypeConverter.normalize_conditions(@conditions)[:district].should == 5
|
142
|
-
end
|
143
|
-
|
144
|
-
it 'should remove district_number value' do
|
145
|
-
Daywalker::TypeConverter.normalize_conditions(@conditions).should_not have_key(:district_number)
|
146
|
-
end
|
147
|
-
|
148
184
|
it 'should copy official_rss_url value to official_rss' do
|
149
185
|
Daywalker::TypeConverter.normalize_conditions(@conditions)[:official_rss].should == 'http://zomg.com/index.rss'
|
150
186
|
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
HTTP/1.1 400 Bad Request
|
2
|
+
Date: Mon, 16 Feb 2009 10:28:34 GMT
|
3
|
+
Server: Apache/2.2.3 (Debian) mod_python/3.2.10 Python/2.4.4 PHP/5.2.0-8+etch11
|
4
|
+
Content-Type: text/html; charset=utf-8
|
5
|
+
Vary: Accept-Encoding
|
6
|
+
Connection: close
|
7
|
+
Transfer-Encoding: chunked
|
8
|
+
|
9
|
+
No Such Object Exists
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'spec'
|
3
|
+
require 'yaml'
|
3
4
|
require 'fake_web'
|
4
5
|
|
5
6
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
@@ -9,13 +10,46 @@ require 'daywalker'
|
|
9
10
|
|
10
11
|
FakeWeb.allow_net_connect = false
|
11
12
|
|
12
|
-
|
13
|
-
|
13
|
+
module Daywalker
|
14
|
+
module ExampleMethods
|
15
|
+
def fixture_path_for(response)
|
16
|
+
File.join File.dirname(__FILE__), 'fixtures', response
|
17
|
+
end
|
18
|
+
|
19
|
+
def register_uri_with_response(uri, response)
|
20
|
+
FakeWeb.register_uri("http://services.sunlightlabs.com/api/#{uri}", :response => fixture_path_for(response))
|
21
|
+
end
|
22
|
+
|
23
|
+
def yaml_fixture(name)
|
24
|
+
YAML::load_file File.join(File.dirname(__FILE__), 'fixtures', name)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
module ExampleGroupMethods
|
29
|
+
|
30
|
+
def specify_its_attributes(attributes)
|
31
|
+
attributes.each do |name, value|
|
32
|
+
specify { subject.send(name.to_sym).should == value }
|
33
|
+
end
|
34
|
+
end
|
14
35
|
|
15
|
-
|
16
|
-
File.join File.dirname(__FILE__), 'fixtures', response
|
36
|
+
end
|
17
37
|
end
|
18
38
|
|
19
|
-
|
20
|
-
|
39
|
+
Spec::Runner.configure do |config|
|
40
|
+
config.before :each do
|
41
|
+
FakeWeb.clean_registry
|
42
|
+
end
|
43
|
+
|
44
|
+
config.before :all do
|
45
|
+
Daywalker.api_key = 'redacted'
|
46
|
+
end
|
47
|
+
|
48
|
+
config.after :all do
|
49
|
+
Daywalker.api_key = nil
|
50
|
+
end
|
51
|
+
|
52
|
+
config.include Daywalker::ExampleMethods
|
53
|
+
config.extend Daywalker::ExampleGroupMethods
|
21
54
|
end
|
55
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: technicalpickles-daywalker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Nichols
|
@@ -9,10 +9,39 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-02-
|
12
|
+
date: 2009-02-16 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: happymapper
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.2.2
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: httparty
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.3.0
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: graticule
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.2.8
|
44
|
+
version:
|
16
45
|
description: TODO
|
17
46
|
email: josh@technicalpickles.com
|
18
47
|
executables: []
|
@@ -28,12 +57,14 @@ files:
|
|
28
57
|
- lib/daywalker/base.rb
|
29
58
|
- lib/daywalker/district.rb
|
30
59
|
- lib/daywalker/dynamic_finder_match.rb
|
60
|
+
- lib/daywalker/geocoder.rb
|
31
61
|
- lib/daywalker/legislator.rb
|
32
62
|
- lib/daywalker/type_converter.rb
|
33
63
|
- lib/daywalker.rb
|
34
64
|
- spec/daywalker
|
35
65
|
- spec/daywalker/district_spec.rb
|
36
66
|
- spec/daywalker/dynamic_finder_match_spec.rb
|
67
|
+
- spec/daywalker/geocoder_spec.rb
|
37
68
|
- spec/daywalker/legislator_spec.rb
|
38
69
|
- spec/daywalker/type_converter_spec.rb
|
39
70
|
- spec/daywalker_spec.rb
|
@@ -44,6 +75,7 @@ files:
|
|
44
75
|
- spec/fixtures/districts_by_zip.xml
|
45
76
|
- spec/fixtures/districts_by_zip_bad_api.xml
|
46
77
|
- spec/fixtures/districts_by_zip_missing_zip.xml
|
78
|
+
- spec/fixtures/get_nonexistent_legislator.xml
|
47
79
|
- spec/fixtures/legislators_by_zip.xml
|
48
80
|
- spec/fixtures/legislators_by_zip_bad_api.xml
|
49
81
|
- spec/fixtures/legislators_find_by_ny_district_4.xml
|
@@ -51,6 +83,7 @@ files:
|
|
51
83
|
- spec/fixtures/legislators_find_ny_senators.xml
|
52
84
|
- spec/fixtures/legislators_find_ny_senators_bad_api.xml
|
53
85
|
- spec/fixtures/legislators_find_one_by_ny_senators.xml
|
86
|
+
- spec/fixtures/rpi_location.yml
|
54
87
|
- spec/spec_helper.rb
|
55
88
|
has_rdoc: true
|
56
89
|
homepage: http://github.com/technicalpickles/daywalker
|