ea-address_lookup 0.3.2 → 0.3.3
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46eb65bbbbdc3bc0b13e0e369c5149c110f33139
|
4
|
+
data.tar.gz: de08abf8f39ac44d5412173567b0901305d58855
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5dfbb57cda573e56090e39042a8fc6ab0db9357856486bb9640e5dc806bdcb41e4813426d1c9063ed06fc18e94ee659dafde355c8edd41fd137b1e65aebdf461
|
7
|
+
data.tar.gz: 07a950f80cd47e6de1d09f329e420d1af3f5d427645e4c2dbe67eae479875fe2dc07e31df9065e583ab1063457765b11923d90f1f9944fbaa09bcbcb90b12f0c
|
data/README.md
CHANGED
@@ -91,6 +91,35 @@ describe "postcode lookup" do
|
|
91
91
|
end
|
92
92
|
```
|
93
93
|
|
94
|
+
Note, that you can also pass output modifications into the mock methods:
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
describe "postcode lookup" do
|
98
|
+
let(:address_one) do
|
99
|
+
{
|
100
|
+
"uprn" => 340116
|
101
|
+
....
|
102
|
+
"source_data_type" => dpa
|
103
|
+
}
|
104
|
+
end
|
105
|
+
let(:address_two) { address_one.merge("postcode" => "XX7 8XX" }
|
106
|
+
let(:addresses) { [address_one, address_two] }
|
107
|
+
|
108
|
+
before do
|
109
|
+
mock_ea_address_lookup_find_by_postcode("results" => addresses)
|
110
|
+
end
|
111
|
+
|
112
|
+
it "some tests that use data returned by a postcode lookup" do
|
113
|
+
address_data = EA::AddressLookup.find_by_uprn("77138")
|
114
|
+
expect(address_data["results"]).to eq(addresses)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
```
|
118
|
+
|
119
|
+
The modifications are merged into the output, so must match the correct data
|
120
|
+
structure. Note that in the example above `address_data["results"]` returns
|
121
|
+
an array of address data hashes.
|
122
|
+
|
94
123
|
## Contributing to this project
|
95
124
|
|
96
125
|
If you have an idea you'd like to contribute please log an issue.
|
@@ -5,10 +5,10 @@ module EA
|
|
5
5
|
# Uses data from address_lookup.yml to mock calls to EA::AddressLookup methods
|
6
6
|
module RspecMocks
|
7
7
|
|
8
|
-
def mock_ea_address_lookup_find_by_uprn
|
8
|
+
def mock_ea_address_lookup_find_by_uprn(mod = {})
|
9
9
|
allow(EA::AddressLookup)
|
10
10
|
.to receive(:find_by_uprn)
|
11
|
-
.and_return(mock_data.data_for(:uprn_lookup))
|
11
|
+
.and_return(mock_data.data_for(:uprn_lookup, mod))
|
12
12
|
end
|
13
13
|
|
14
14
|
def mock_failure_of_ea_address_lookup_find_by_uprn
|
@@ -17,10 +17,10 @@ module EA
|
|
17
17
|
.and_raise(AddressServiceUnavailableError, "Whoops")
|
18
18
|
end
|
19
19
|
|
20
|
-
def mock_ea_address_lookup_find_by_postcode
|
20
|
+
def mock_ea_address_lookup_find_by_postcode(mod = {})
|
21
21
|
allow(EA::AddressLookup)
|
22
22
|
.to receive(:find_by_postcode)
|
23
|
-
.and_return(mock_data.data_for(:postcode_lookup))
|
23
|
+
.and_return(mock_data.data_for(:postcode_lookup, mod))
|
24
24
|
end
|
25
25
|
|
26
26
|
def mock_failure_of_ea_address_lookup_find_by_postcode
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ea-address_lookup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Digital Services Team, EnvironmentAgency
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|