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.
@@ -344,4 +344,4 @@
344
344
  "state": "NY" } ]
345
345
  }
346
346
  }
347
- }
347
+ }
@@ -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 be 11
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 eql "B000444"
42
- legislator.name.should eql "Joseph Biden"
43
- legislator.party.should eql "D"
44
- legislator.state.should eql "DE"
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
- setup do
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 "initializing with full bio and roles hash" do
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 eql "B000444"
73
- legislator.name.should eql "Joseph Biden"
74
- legislator.gender.should eql "M"
75
- legislator.govtrack_id.should eql 300008
76
- legislator.url.should eql "http://biden.senate.gov"
77
- legislator.date_of_birth.should eql Date.parse("1942-11-20")
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 Role}
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 = JSON.parse(example_data)
96
- @legislator = Legislator.new(parsed_data)
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 bio and roles haven't been populated"
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.instance_variable_get("@roles").should be_nil
107
- legislator.instance_variable_get("@url").should be_nil
108
- legislator.instance_variable_get("@birthdate").should be_nil
109
-
110
- FakeWeb.register_uri(api_url_for('members/B000444.json'), :string => full_legislator_attributes)
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 an API request for bio and roles fields" do
117
+ it "makes second API request when one attempts to read those attributes" do
114
118
  legislator.roles
115
- roles = legislator.instance_variable_get("@roles").should_not be_nil
116
-
117
- legislator.url.should eql Date.parse("1942-11-20")
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
- def example_data
127
+ def example_data
125
128
  full_legislator_attributes
126
129
  end
127
130
 
128
- before do
129
- legislator.instance_variable_get("@roles").should_not be_nil
130
- legislator.birthdate.should_not be_nil
131
- end
132
-
133
- it "does not make another API request" do
134
- legislator.roles
135
- legislator.instance_variable_get("@roles").should_not be_nil
136
- legislator.instance_variable_get("@url").should be_nil
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
@@ -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 example_data)
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 example_data)
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 role
100
+ legislator.roles.should include(role)
101
101
  end
102
102
 
103
103
  end
@@ -4,7 +4,7 @@ describe RollCallVote do
4
4
  attr_reader :congress, :vote
5
5
 
6
6
  def example_data
7
- File.read('example_data/roll_call_votes.json')
7
+ roll_call_votes_response
8
8
  end
9
9
 
10
10
  before do
@@ -1,8 +1,9 @@
1
1
  require File.dirname(__FILE__) + '/../lib/ny-times-congress'
2
+ require File.dirname(__FILE__) + '/example_data/example_data'
3
+
2
4
  require "rubygems"
3
5
  require "spec"
4
6
  require 'fake_web'
5
- require 'example_data/example_data'
6
7
 
7
8
  gem 'rr'
8
9
 
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.1.0
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-11 00:00:00 -08:00
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