fma_realestate 0.1.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,32 @@
1
+ {
2
+ "address_type": "S",
3
+ "census_block": "3015",
4
+ "census_tract": "012204",
5
+ "city": "Boulder",
6
+ "county_name": "Boulder",
7
+ "county_number": "013",
8
+ "dpbc": "25",
9
+ "dpv_confirmation_indicator": "Y",
10
+ "fips": "08013",
11
+ "in_city": "Boulder",
12
+ "in_state": "CO",
13
+ "in_street_address": "1325 Pearl Street",
14
+ "in_zip": "80302",
15
+ "latitude": 40.01831,
16
+ "longitude": -105.278027,
17
+ "post_directional": "",
18
+ "pre_directional": "",
19
+ "return_code": "1",
20
+ "search_key": "80302524725",
21
+ "state": "CO",
22
+ "state_number": "08",
23
+ "street_address": "1325 Pearl St",
24
+ "street_name": "PEARL",
25
+ "street_number": "1325",
26
+ "street_suffix": "ST",
27
+ "unit_number": "",
28
+ "unit_type": "",
29
+ "zip_4": "5247",
30
+ "zip_5": "80302",
31
+ "zip_9": "80302-5247"
32
+ }
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe FmaRealestate::Cass do
4
+ let(:authenticated_client) { described_class.new(:access_token => 'test', :raise_errors => true) }
5
+ let(:anonymous_client) { described_class.new(:raise_errors => true) }
6
+
7
+ describe "#tiger" do
8
+ context "with :raise_errors => false" do
9
+ let(:authenticated_client) { described_class.new(:access_token => 'test', :raise_errors => false) }
10
+
11
+ it_behaves_like "handles error suppression" do
12
+ let(:action) { authenticated_client.tiger }
13
+ end
14
+ end
15
+
16
+ context "with :raise_errors => true" do
17
+
18
+ it_behaves_like "requires valid authentication" do
19
+ let(:action) { anonymous_client.tiger }
20
+ end
21
+
22
+ it_behaves_like "handles 404 response" do
23
+ let(:action) { authenticated_client.tiger }
24
+ end
25
+
26
+ it_behaves_like "handles 400 response" do
27
+ let(:action) { authenticated_client.tiger }
28
+ end
29
+
30
+ it_behaves_like "handles 400 response" do
31
+ let(:action) { authenticated_client.tiger }
32
+ end
33
+ end
34
+
35
+ context "with valid access_token" do
36
+ let(:fixture) { request_fixture('tiger') }
37
+ it "should get response" do
38
+ Excon.stub({ :method => :get, :path => '/api/cass/tiger', :headers => { 'Authorization' => "Token token=test" }}, {:status => 200, :body => fixture })
39
+ params = {:street_address => "1325 Pearl Street", :city => "Boulder", :state => "CO", :zip => "80302"}
40
+ response = authenticated_client.tiger(params)
41
+ expect(response.keys.count).to eq(30)
42
+ expect(response['return_code']).to eq('1')
43
+ expect(response['dpv_confirmation_indicator']).to eq('Y')
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,184 @@
1
+ require 'spec_helper'
2
+
3
+ describe FmaRealestate::PublicRecord do
4
+ let(:authenticated_client) { described_class.new(:access_token => 'test', :raise_errors => true) }
5
+ let(:anonymous_client) { described_class.new(:raise_errors => true) }
6
+
7
+ describe "#search_by_address" do
8
+ context "with :raise_errors => false" do
9
+ let(:authenticated_client) { described_class.new(:access_token => 'test', :raise_errors => false) }
10
+
11
+ it_behaves_like "handles error suppression" do
12
+ let(:action) { authenticated_client.search_by_address }
13
+ end
14
+ end
15
+
16
+ context "with :raise_errors => true" do
17
+
18
+ it_behaves_like "requires valid authentication" do
19
+ let(:action) { anonymous_client.search_by_address }
20
+ end
21
+
22
+ it_behaves_like "handles 404 response" do
23
+ let(:action) { authenticated_client.search_by_address }
24
+ end
25
+
26
+ it_behaves_like "handles 400 response" do
27
+ let(:action) { authenticated_client.search_by_address }
28
+ end
29
+
30
+ it_behaves_like "handles 400 response" do
31
+ let(:action) { authenticated_client.search_by_address }
32
+ end
33
+ end
34
+
35
+ context "with valid access_token" do
36
+ let(:fixture) { request_fixture('search_by_address') }
37
+
38
+ it "should get response" do
39
+ Excon.stub({ :method => :get, :path => '/api/public_records/search_by_address', :headers => { 'Authorization' => "Token token=test" }}, {:status => 200, :body => fixture })
40
+ params = {:street_address => "1325 Pearl Street", :city => "Boulder", :state => "CO", :zip => "80302"}
41
+ response = authenticated_client.search_by_address(params)
42
+ expect(response["cass"]).to be_a Hash
43
+ expect(response["count"]).to be_a Integer
44
+ expect(response["results"]).to be_a Array
45
+ expect(response["results"].count).to eq(1)
46
+ expect(response["results"].first).to be_a Hash
47
+ end
48
+ end
49
+ end
50
+
51
+ describe "#search_by_advanced" do
52
+ context "with :raise_errors => false" do
53
+ let(:authenticated_client) { described_class.new(:access_token => 'test', :raise_errors => false) }
54
+
55
+ it_behaves_like "handles error suppression" do
56
+ let(:action) { authenticated_client.search_by_advanced }
57
+ end
58
+ end
59
+
60
+ context "with :raise_errors => true" do
61
+
62
+ it_behaves_like "requires valid authentication" do
63
+ let(:action) { anonymous_client.search_by_advanced }
64
+ end
65
+
66
+ it_behaves_like "handles 404 response" do
67
+ let(:action) { authenticated_client.search_by_advanced }
68
+ end
69
+
70
+ it_behaves_like "handles 400 response" do
71
+ let(:action) { authenticated_client.search_by_advanced }
72
+ end
73
+
74
+ it_behaves_like "handles 400 response" do
75
+ let(:action) { authenticated_client.search_by_advanced }
76
+ end
77
+ end
78
+
79
+ context "with valid access_token" do
80
+ let(:fixture) { request_fixture('search_by_advanced') }
81
+
82
+ it "should get response" do
83
+ Excon.stub({ :method => :get, :path => '/api/public_records/search_by_advanced', :headers => { 'Authorization' => "Token token=test" }}, {:status => 200, :body => fixture })
84
+ params = {:street_address => "1325 Pearl Street", :city => "Boulder", :state => "CO", :zip => "80302"}
85
+ response = authenticated_client.search_by_advanced(params)
86
+ expect(response["count"]).to be_a Integer
87
+ expect(response["results"]).to be_a Array
88
+ expect(response["results"].count).to eq(1)
89
+ expect(response["results"].first).to be_a Hash
90
+ expect(response["results"][0]["result"]).to be_a Hash
91
+ expect(response["results"][0]["weight"]).to be_a Integer
92
+ end
93
+ end
94
+ end
95
+
96
+ describe "#search_by_address_advanced" do
97
+ context "with :raise_errors => false" do
98
+ let(:authenticated_client) { described_class.new(:access_token => 'test', :raise_errors => false) }
99
+
100
+ it_behaves_like "handles error suppression" do
101
+ let(:action) { authenticated_client.search_by_address_advanced }
102
+ end
103
+ end
104
+
105
+ context "with :raise_errors => true" do
106
+
107
+ it_behaves_like "requires valid authentication" do
108
+ let(:action) { anonymous_client.search_by_address_advanced }
109
+ end
110
+
111
+ it_behaves_like "handles 404 response" do
112
+ let(:action) { authenticated_client.search_by_address_advanced }
113
+ end
114
+
115
+ it_behaves_like "handles 400 response" do
116
+ let(:action) { authenticated_client.search_by_address_advanced }
117
+ end
118
+
119
+ it_behaves_like "handles 400 response" do
120
+ let(:action) { authenticated_client.search_by_address_advanced }
121
+ end
122
+ end
123
+
124
+ context "with valid access_token" do
125
+ let(:fixture) { request_fixture('search_by_address_advanced') }
126
+
127
+ it "should get response" do
128
+ Excon.stub({ :method => :get, :path => '/api/public_records/search_by_address_advanced', :headers => { 'Authorization' => "Token token=test" }}, {:status => 200, :body => fixture })
129
+ params = {:street_address => "1325 Pearl Street", :city => "Boulder", :state => "CO", :zip => "80302"}
130
+ response = authenticated_client.search_by_address_advanced(params)
131
+ expect(response["cass"]).to be_a Hash
132
+ expect(response["count"]).to be_a Integer
133
+ expect(response["results"]).to be_a Array
134
+ expect(response["results"].count).to eq(1)
135
+ expect(response["results"].first).to be_a Hash
136
+ end
137
+ end
138
+ end
139
+
140
+ describe "#search_by_global" do
141
+ context "with :raise_errors => false" do
142
+ let(:authenticated_client) { described_class.new(:access_token => 'test', :raise_errors => false) }
143
+
144
+ it_behaves_like "handles error suppression" do
145
+ let(:action) { authenticated_client.search_by_global }
146
+ end
147
+ end
148
+
149
+ context "with :raise_errors => true" do
150
+
151
+ it_behaves_like "requires valid authentication" do
152
+ let(:action) { anonymous_client.search_by_global }
153
+ end
154
+
155
+ it_behaves_like "handles 404 response" do
156
+ let(:action) { authenticated_client.search_by_global }
157
+ end
158
+
159
+ it_behaves_like "handles 400 response" do
160
+ let(:action) { authenticated_client.search_by_global }
161
+ end
162
+
163
+ it_behaves_like "handles 400 response" do
164
+ let(:action) { authenticated_client.search_by_global }
165
+ end
166
+ end
167
+
168
+ context "with valid access_token" do
169
+ let(:fixture) { request_fixture('search_by_global') }
170
+
171
+ it "should get response" do
172
+ Excon.stub({ :method => :get, :path => '/api/public_records/search_by_global', :headers => { 'Authorization' => "Token token=test" }}, {:status => 200, :body => fixture })
173
+ params = {:q => "1325 Pearl Street"}
174
+ response = authenticated_client.search_by_global(params)
175
+ expect(response["count"]).to be_a Integer
176
+ expect(response["results"]).to be_a Array
177
+ expect(response["results"].count).to eq(20)
178
+ expect(response["results"].first).to be_a Hash
179
+ expect(response["results"][0]["result"]).to be_a Hash
180
+ expect(response["results"][0]["weight"]).to be_a Integer
181
+ end
182
+ end
183
+ end
184
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe FmaRealestate do
4
+ it 'has a version number' do
5
+ expect(FmaRealestate::VERSION).not_to be nil
6
+ end
7
+
8
+ describe ".configure" do
9
+ it 'should set the access_token' do
10
+ FmaRealestate.configure do |config|
11
+ config.access_token = "some_token"
12
+ end
13
+ expect(FmaRealestate.access_token).to eq("some_token")
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'rspec'
3
+ require 'fma_realestate'
4
+
5
+ Dir["./spec/support/**/*.rb"].sort.each { |f| require f }
6
+
7
+ RSpec.configure do |config|
8
+ config.include RequestFixturesHelper
9
+
10
+ config.before(:all) do
11
+ Excon.defaults[:mock] = true
12
+ end
13
+
14
+ config.after(:each) do
15
+ Excon.stubs.clear
16
+ end
17
+ end
@@ -0,0 +1,5 @@
1
+ module RequestFixturesHelper
2
+ def request_fixture(name)
3
+ File.read("spec/fixtures/#{name}.json")
4
+ end
5
+ end
@@ -0,0 +1,50 @@
1
+ shared_examples "requires valid authentication" do
2
+ it "raises authentication error" do
3
+ Excon.stub({}, {:status => 401 })
4
+ expect {action}.to raise_error(FmaRealestate::AuthenticationError)
5
+ end
6
+ end
7
+
8
+ shared_examples "handles 404 response" do
9
+ it "raises not found error" do
10
+ Excon.stub({}, {:status => 404 })
11
+ expect {action}.to raise_error(FmaRealestate::ResourceNotFound)
12
+ end
13
+ end
14
+
15
+ shared_examples "handles 400 response" do
16
+ it "raises not found error" do
17
+ Excon.stub({}, {:status => 400 })
18
+ expect {action}.to raise_error(FmaRealestate::BadRequest)
19
+ end
20
+ end
21
+
22
+ shared_examples "handles unexpected response" do
23
+ it "raises not found error" do
24
+ Excon.stub({}, {:status => 403 })
25
+ expect {action}.to raise_error(FmaRealestate::HTTPError)
26
+ end
27
+ end
28
+
29
+ shared_examples "handles error suppression" do
30
+ it 'suppresses request error' do
31
+ connection = double("connection")
32
+ allow(connection).to receive(:request) { raise FmaRealestate::RequestError }
33
+ authenticated_client.instance_variable_set(:@connection, connection)
34
+ expect {action}.to_not raise_error
35
+ end
36
+
37
+ it 'returns false when request error is suppressed' do
38
+ connection = double("connection")
39
+ allow(connection).to receive(:request) { raise FmaRealestate::RequestError }
40
+ authenticated_client.instance_variable_set(:@connection, connection)
41
+ expect(action).to be false
42
+ end
43
+
44
+ it "doesn't suppress non request errors" do
45
+ connection = double("connection")
46
+ allow(connection).to receive(:request) { raise StandardError }
47
+ authenticated_client.instance_variable_set(:@connection, connection)
48
+ expect {action}.to raise_error
49
+ end
50
+ end
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fma_realestate
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Blaine Johnson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: excon
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.37'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.37'
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.5'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description:
84
+ email:
85
+ - customer.service@firstmoversadvantage.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - Gemfile
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - fma_realestate.gemspec
96
+ - lib/fma_realestate.rb
97
+ - lib/fma_realestate/cass.rb
98
+ - lib/fma_realestate/client.rb
99
+ - lib/fma_realestate/exceptions.rb
100
+ - lib/fma_realestate/public_record.rb
101
+ - lib/fma_realestate/version.rb
102
+ - spec/fixtures/search_by_address.json
103
+ - spec/fixtures/search_by_address_advanced.json
104
+ - spec/fixtures/search_by_advanced.json
105
+ - spec/fixtures/search_by_global.json
106
+ - spec/fixtures/tiger.json
107
+ - spec/fma_realestate/cass_spec.rb
108
+ - spec/fma_realestate/public_record_spec.rb
109
+ - spec/fma_realestate_spec.rb
110
+ - spec/spec_helper.rb
111
+ - spec/support/request_fixture_helper.rb
112
+ - spec/support/shared_examples.rb
113
+ homepage: http://realestate.firstmoversadvantage.com/
114
+ licenses:
115
+ - MIT
116
+ metadata: {}
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ requirements: []
132
+ rubyforge_project:
133
+ rubygems_version: 2.2.2
134
+ signing_key:
135
+ specification_version: 4
136
+ summary: FMA Real Estate and CASS Ruby Client
137
+ test_files:
138
+ - spec/fixtures/search_by_address.json
139
+ - spec/fixtures/search_by_address_advanced.json
140
+ - spec/fixtures/search_by_advanced.json
141
+ - spec/fixtures/search_by_global.json
142
+ - spec/fixtures/tiger.json
143
+ - spec/fma_realestate/cass_spec.rb
144
+ - spec/fma_realestate/public_record_spec.rb
145
+ - spec/fma_realestate_spec.rb
146
+ - spec/spec_helper.rb
147
+ - spec/support/request_fixture_helper.rb
148
+ - spec/support/shared_examples.rb