ea-address_lookup 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1b1345ea8c9c8d77175aebd9718ce3192468ba06
4
- data.tar.gz: a4533becc341a750aeea6bbe8bfc26a6f182e4b3
3
+ metadata.gz: 46eb65bbbbdc3bc0b13e0e369c5149c110f33139
4
+ data.tar.gz: de08abf8f39ac44d5412173567b0901305d58855
5
5
  SHA512:
6
- metadata.gz: 7835a2ebc748e58158d0356aef2e4b5d97a585daa9cbc32c64334b8b9ccf0f036f446feb4a2c2c03258c6b425e6c7ac61d27df978ceee259ac2243d0a0163c78
7
- data.tar.gz: a6a73fb95f5d28ca276ec27ea5c60015a0390b9798e92234d1c623939e5ca97f690d4b2f4c39096def4a2701130e6af88546d6a2a28f1bb64bf3aca834d8a860
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.
@@ -7,8 +7,8 @@ module EA
7
7
  @file_name = file_name.to_s.strip
8
8
  end
9
9
 
10
- def data_for(key)
11
- yaml[key.to_s]
10
+ def data_for(key, mod = {})
11
+ yaml[key.to_s].merge! mod
12
12
  end
13
13
 
14
14
  private
@@ -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
@@ -1,5 +1,5 @@
1
1
  module EA
2
2
  module AddressLookup
3
- VERSION = "0.3.2".freeze
3
+ VERSION = "0.3.3".freeze
4
4
  end
5
5
  end
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.2
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-05-29 00:00:00.000000000 Z
11
+ date: 2016-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport