gds-api-adapters 22.0.0 → 23.0.0

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: 30afe3107beb650860db70e91c9d42835c570de2
4
- data.tar.gz: d3b8c1636e24c02501718a1f6f1c319cd43c818c
3
+ metadata.gz: 5ea6ab5e0f8cd1e6568d3588d21b9918c7818a65
4
+ data.tar.gz: 57953905ccbcd5453f4acc5548248a02b57e1fa2
5
5
  SHA512:
6
- metadata.gz: 085750359ca93887f245ffe02241413cfd2d5532c4eee64265fc8605ddc04b50df7994b9f3a869b43b36eb1d1359f1da1c308deef366f1284db75fcc95970ee5
7
- data.tar.gz: 7b34634b10f4ba9c74c3bbe271d411681d831af8fa2405f78036f7856ade1c893af9ab8b7fdab2587f3b9388630fcc8df24dd6107021df67a486b027d70c3007
6
+ metadata.gz: fed21cbb734110e486fe6e390a4e8960b4f018d886643a76cd1d75c91ca076a87fd052103c5c982afc287b869c83336d60da7e6a60bcd66ca7f43f3ba6c6db32
7
+ data.tar.gz: e2f4fdf14f51fe5ece8d45ffd822b4c4f1fcbc393a3d601bf224a89a6c94bacea7ccf941f20b0e9b0ed8db0ddc045e255da3a0930e3740233c0f3e4947fca885
@@ -4,11 +4,6 @@ require 'rack/utils'
4
4
  module GdsApi
5
5
  class Rummager < Base
6
6
 
7
- def search(query, extra_params={})
8
- raise ArgumentError.new("Query cannot be blank") if query.nil? || query.strip.empty?
9
- get_json!(search_url(:search, query, extra_params))
10
- end
11
-
12
7
  def unified_search(args)
13
8
  request_url = "#{base_url}/unified_search.json?#{Rack::Utils.build_nested_query(args)}"
14
9
  get_json!(request_url)
@@ -43,15 +38,6 @@ module GdsApi
43
38
 
44
39
  private
45
40
 
46
- def search_url(type, query, extra_params={})
47
- request_path = "#{base_url}/#{type}?q=#{CGI.escape(query)}"
48
- if extra_params
49
- request_path << "&"
50
- request_path << Rack::Utils.build_query(extra_params)
51
- end
52
- request_path
53
- end
54
-
55
41
  def base_url
56
42
  endpoint
57
43
  end
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '22.0.0'
2
+ VERSION = '23.0.0'
3
3
  end
@@ -3,77 +3,10 @@ require "gds_api/rummager"
3
3
 
4
4
  describe GdsApi::Rummager do
5
5
  before(:each) do
6
- stub_request(:get, /example.com\/search/).to_return(body: "[]")
7
6
  stub_request(:get, /example.com\/advanced_search/).to_return(body: "[]")
8
7
  stub_request(:get, /example.com\/unified_search/).to_return(body: "[]")
9
8
  end
10
9
 
11
- it "should raise an exception if the service at the search URI returns a 500" do
12
- stub_request(:get, /example.com\/search/).to_return(status: [500, "Internal Server Error"])
13
- assert_raises(GdsApi::HTTPServerError) do
14
- GdsApi::Rummager.new("http://example.com").search("query")
15
- end
16
- end
17
-
18
- it "should raise an exception if the service at the search URI returns a 404" do
19
- stub_request(:get, /example.com\/search/).to_return(status: [404, "Not Found"])
20
- assert_raises(GdsApi::HTTPNotFound) do
21
- GdsApi::Rummager.new("http://example.com").search("query")
22
- end
23
- end
24
-
25
- it "should raise an exception if the service at the search URI times out" do
26
- stub_request(:get, /example.com\/search/).to_timeout
27
- assert_raises(GdsApi::TimedOutException) do
28
- GdsApi::Rummager.new("http://example.com").search("query")
29
- end
30
- end
31
-
32
- it "should return the search deserialized from json" do
33
- search_results = [{"title" => "document-title"}]
34
- stub_request(:get, /example.com\/search/).to_return(body: search_results.to_json)
35
- results = GdsApi::Rummager.new("http://example.com").search("query")
36
-
37
- assert_equal search_results, results.to_hash
38
- end
39
-
40
- it "should return an empty set of results without making request if query is empty" do
41
- assert_raises(ArgumentError) do
42
- GdsApi::Rummager.new("http://example.com").search("")
43
- end
44
- end
45
-
46
- it "should return an empty set of results without making request if query is nil" do
47
- assert_raises(ArgumentError) do
48
- GdsApi::Rummager.new("http://example.com").search(nil)
49
- end
50
- end
51
-
52
- it "should request the search results in JSON format" do
53
- GdsApi::Rummager.new("http://example.com").search("query")
54
-
55
- assert_requested :get, /.*/, headers: {"Accept" => "application/json"}
56
- end
57
-
58
- it "should issue a request for the search term specified" do
59
- GdsApi::Rummager.new("http://example.com").search "search-term"
60
-
61
- assert_requested :get, /\?q=search-term/
62
- end
63
-
64
- it "should escape characters that would otherwise be invalid in a URI" do
65
- GdsApi::Rummager.new("http://example.com").search "search term with spaces"
66
-
67
- #the actual request is "?q=search+term+with+spaces", but Webmock appears to be re-escaping.
68
- assert_requested :get, /\?q=search%20term%20with%20spaces/
69
- end
70
-
71
- it "should append arbitrary parameters when supplied" do
72
- GdsApi::Rummager.new("http://example.com").search("search-term", foo: "bar", zoo: "baz")
73
-
74
- assert_requested :get, /\?foo=bar&q=search-term&zoo=baz/
75
- end
76
-
77
10
  # tests for #organisations
78
11
 
79
12
  it "should request the list of organisations" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gds-api-adapters
3
3
  version: !ruby/object:Gem::Version
4
- version: 22.0.0
4
+ version: 23.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Stewart
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-28 00:00:00.000000000 Z
11
+ date: 2015-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: plek