hoverbird-ny-times-congress 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.mkdn +30 -11
- data/Rakefile +9 -6
- data/TODO +2 -0
- data/VERSION.yml +2 -2
- data/bin/setup.rb +2 -2
- data/lib/ny-times/congress/attribute_transformation.rb +3 -4
- data/lib/ny-times/congress/base.rb +6 -6
- data/lib/ny-times/congress/congress.rb +5 -5
- data/lib/ny-times/congress/legislator.rb +7 -4
- data/lib/ny-times/congress/position.rb +2 -5
- data/lib/ny-times/congress/roll_call_vote.rb +2 -1
- data/spec/base_spec.rb +3 -3
- data/spec/congress_spec.rb +6 -6
- data/spec/example_data/example_data.rb +59 -33
- data/spec/example_data/member.json +37 -12
- data/spec/example_data/members.json +1011 -2231
- data/spec/example_data/roll_call_votes.json +1 -1
- data/spec/legislator_spec.rb +55 -52
- data/spec/role_spec.rb +3 -3
- data/spec/roll_call_vote_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -1
- metadata +4 -2
data/spec/legislator_spec.rb
CHANGED
@@ -20,34 +20,34 @@ describe Legislator do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should return the Legislator's roles" do
|
23
|
-
joe.roles.size.should
|
23
|
+
joe.roles.size.should == 11
|
24
24
|
joe.roles.first.title.should == "Senator, 1st Class"
|
25
25
|
joe.roles.first.state.should == "CT"
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
describe "#initialize" do
|
30
|
-
before do
|
31
|
-
@parsed_data = JSON.parse(example_data)
|
32
|
-
@legislator = Legislator.new(parsed_data)
|
33
|
-
end
|
34
|
-
|
35
30
|
context "with limited params hash" do
|
36
31
|
def example_data
|
37
32
|
limited_legislator_attributes
|
38
33
|
end
|
39
|
-
|
34
|
+
|
35
|
+
before do
|
36
|
+
@parsed_data = JSON.parse(example_data)
|
37
|
+
@legislator = Legislator.new(parsed_data)
|
38
|
+
end
|
39
|
+
|
40
40
|
it "assigns attributes as expected" do
|
41
|
-
legislator.id.should
|
42
|
-
legislator.name.should
|
43
|
-
legislator.party.should
|
44
|
-
legislator.state.should
|
41
|
+
legislator.id.should == "L000304"
|
42
|
+
legislator.name.should == "Joseph I. Lieberman"
|
43
|
+
legislator.party.should == "ID"
|
44
|
+
legislator.state.should == "CT"
|
45
45
|
end
|
46
46
|
|
47
47
|
describe ":id and :member_id attributes" do
|
48
48
|
attr_reader :identifier
|
49
49
|
|
50
|
-
|
50
|
+
before do
|
51
51
|
@identifier = "H00HAA"
|
52
52
|
end
|
53
53
|
|
@@ -63,80 +63,83 @@ describe Legislator do
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
describe "
|
66
|
+
describe "with full bio and roles hash" do
|
67
|
+
|
67
68
|
def example_data
|
68
69
|
full_legislator_attributes
|
69
70
|
end
|
71
|
+
|
72
|
+
before do
|
73
|
+
@parsed_data = JSON.parse(example_data)['results'].first
|
74
|
+
@legislator = Legislator.new(parsed_data)
|
75
|
+
end
|
70
76
|
|
71
|
-
it "assigns attributes as expected" do
|
72
|
-
legislator.id.should
|
73
|
-
legislator.name.should
|
74
|
-
legislator.gender.should
|
75
|
-
legislator.govtrack_id.should
|
76
|
-
legislator.url.should
|
77
|
-
legislator.date_of_birth.should
|
78
|
-
legislator.district.should be_nil
|
77
|
+
it "assigns attributes as expected" do
|
78
|
+
legislator.id.should == "L000304"
|
79
|
+
legislator.name.should == "Joseph I. Lieberman"
|
80
|
+
legislator.gender.should == "M"
|
81
|
+
legislator.govtrack_id.should == 300067
|
82
|
+
legislator.url.should == "http://lieberman.senate.gov/"
|
83
|
+
legislator.date_of_birth.should == Date.parse("1942-02-24")
|
79
84
|
end
|
80
85
|
|
81
86
|
it "assigns a number of Roles to the Legislator" do
|
82
87
|
legislator.roles.size.should == 2
|
83
|
-
legislator.roles.each {|role| role.should be_kind_of
|
88
|
+
legislator.roles.each {|role| role.should be_kind_of(Role)}
|
84
89
|
end
|
85
90
|
end
|
86
91
|
end
|
87
92
|
|
88
93
|
describe "#positions" do
|
89
|
-
|
94
|
+
it "needs specs"
|
90
95
|
end
|
91
96
|
|
92
97
|
describe "#roles" do
|
98
|
+
def example_data
|
99
|
+
limited_legislator_attributes
|
100
|
+
end
|
93
101
|
|
94
102
|
before do
|
95
|
-
@parsed_data
|
96
|
-
@legislator
|
97
|
-
FakeWeb.clean_registry
|
103
|
+
@parsed_data = JSON.parse(example_data)
|
104
|
+
@legislator = Legislator.new(parsed_data)
|
98
105
|
end
|
99
106
|
|
100
|
-
context "when
|
101
|
-
def example_data
|
102
|
-
limited_legislator_attributes
|
103
|
-
end
|
107
|
+
context "when bio and roles haven't been populated" do
|
104
108
|
|
105
109
|
before do
|
106
|
-
legislator.
|
107
|
-
legislator.
|
108
|
-
legislator.
|
109
|
-
|
110
|
-
FakeWeb.register_uri(api_url_for('members/
|
110
|
+
legislator.attributes[:roles].should be_nil
|
111
|
+
legislator.attributes[:url].should be_nil
|
112
|
+
legislator.attributes[:birthdate].should be_nil
|
113
|
+
FakeWeb.clean_registry
|
114
|
+
FakeWeb.register_uri(api_url_for('members/L000304.json'), :string => member_response)
|
111
115
|
end
|
112
116
|
|
113
|
-
it "makes
|
117
|
+
it "makes second API request when one attempts to read those attributes" do
|
114
118
|
legislator.roles
|
115
|
-
roles = legislator.
|
116
|
-
|
117
|
-
|
118
|
-
legislator.date_of_birth.should == Date.parse("http://biden.senate.gov")
|
119
|
+
roles = legislator.attributes[:roles].should_not be_nil
|
120
|
+
legislator.date_of_birth.should == Date.parse("1942-02-24")
|
121
|
+
legislator.url.should =="http://lieberman.senate.gov/"
|
119
122
|
end
|
120
123
|
|
121
124
|
end
|
122
125
|
|
123
126
|
context "when bio and roles have already been loaded" do
|
124
|
-
|
127
|
+
def example_data
|
125
128
|
full_legislator_attributes
|
126
129
|
end
|
127
130
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
it "does not make another API request" do
|
134
|
-
legislator.roles
|
135
|
-
legislator.
|
136
|
-
legislator.
|
137
|
-
legislator.instance_variable_get("@birthdate").should be_nil
|
131
|
+
before do
|
132
|
+
@parsed_data = JSON.parse(example_data)['results'].first
|
133
|
+
@legislator = Legislator.new(parsed_data)
|
134
|
+
end
|
135
|
+
|
136
|
+
it "does not make another API request when accessing attributes" do
|
137
|
+
legislator.roles.should_not be_nil
|
138
|
+
legislator.url.should_not be_nil
|
139
|
+
legislator.date_of_birth.should_not be_nil
|
138
140
|
end
|
139
141
|
end
|
140
142
|
|
141
143
|
end
|
142
|
-
|
144
|
+
|
145
|
+
end
|
data/spec/role_spec.rb
CHANGED
@@ -9,7 +9,7 @@ describe NYTimes::Congress::Role do
|
|
9
9
|
|
10
10
|
context "initializing with params hash", :shared => true do
|
11
11
|
before do
|
12
|
-
@role = Role.new(JSON.parse
|
12
|
+
@role = Role.new(JSON.parse(example_data))
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should set String attributes" do
|
@@ -71,7 +71,7 @@ describe NYTimes::Congress::Role do
|
|
71
71
|
end
|
72
72
|
|
73
73
|
before do
|
74
|
-
@legislator = Legislator.new(JSON.parse
|
74
|
+
@legislator = Legislator.new(JSON.parse(example_data))
|
75
75
|
legislator.roles.should_not be_nil
|
76
76
|
@role = legislator.roles.sort_by{|r| r.congress}.first
|
77
77
|
end
|
@@ -97,7 +97,7 @@ describe NYTimes::Congress::Role do
|
|
97
97
|
end
|
98
98
|
|
99
99
|
it "can be found through the Legislator" do
|
100
|
-
legislator.roles.should include
|
100
|
+
legislator.roles.should include(role)
|
101
101
|
end
|
102
102
|
|
103
103
|
end
|
data/spec/roll_call_vote_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hoverbird-ny-times-congress
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Ewing
|
@@ -9,11 +9,12 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-02-
|
12
|
+
date: 2009-02-17 00:00:00 -08:00
|
13
13
|
default_executable: congresh
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|
17
|
+
type: :runtime
|
17
18
|
version_requirement:
|
18
19
|
version_requirements: !ruby/object:Gem::Requirement
|
19
20
|
requirements:
|
@@ -33,6 +34,7 @@ files:
|
|
33
34
|
- LICENSE
|
34
35
|
- Rakefile
|
35
36
|
- README.mkdn
|
37
|
+
- TODO
|
36
38
|
- VERSION.yml
|
37
39
|
- bin/congresh
|
38
40
|
- bin/setup.rb
|