cucumber-rest-api 0.2 → 0.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: 4a3fa8e3d3f088998463154ab371d40b9b6719be
4
- data.tar.gz: d8ad2eed12586feb88d878cab626c12a42e1eccf
3
+ metadata.gz: a32a1ee616f1dd147b4bfe21bd4f9b5a6066d302
4
+ data.tar.gz: 1c1374d166553597b6aff9e42428d2fbc06b1a87
5
5
  SHA512:
6
- metadata.gz: ebb5e478362dbfc9f6c55f6fe2e74280bc1c8821ab627e74835088c68a1dbd05a4cf12635cb6593e5f4afd5d8ce91cddc2b5e150bf71a22fd1618ba7dc03c6cd
7
- data.tar.gz: 4b85cc347b607e1e8d8f9127b9aab59587785324ea3a6ebd8cdedd9862d38c642046b10032ff0ba41a79e6cb714ab3f96893c63316ec65033f7d1f8b13d90c90
6
+ metadata.gz: b2fb1a43239d31df072a4f5ea61a2719e14e9b28bb9b43b1d6ec34c52e7cd68c013c94919b08d3b9a148215ac108a1737de0c9f0164c99fd475dff500a651c36
7
+ data.tar.gz: e2648890c0a653c36420e67633e252f42f7c0b3a752285757f733ee177e06ef2db2af1ecabe39779a2c58c314ae3e6cd670f0784c6e5696c52ccb5e680e64593
@@ -123,15 +123,23 @@ Then /^the XML response should (not)?\s?have "([^"]*)"$/ do |negative, xpath|
123
123
  end
124
124
  end
125
125
 
126
- Then /^the XML response should have "([^"]*)" with the text "([^"]*)"$/ do |xpath, text|
126
+ Then /^the XML response should (not)?\s?have "([^"]*)" with the text "([^"]*)"$/ do |negative, xpath, text|
127
127
  parsed_response = Nokogiri::XML(last_response.body)
128
128
  elements = parsed_response.xpath(xpath)
129
- if self.respond_to?(:should)
130
- elements.should_not be_empty, "could not find #{xpath} in:\n#{last_response.body}"
131
- elements.find { |e| e.text == text }.should_not be_nil, "found elements but could not find #{text} in:\n#{elements.inspect}"
129
+ if negative.present?
130
+ if self.respond_to?(:should)
131
+ elements.find { |e| e.text == text }.should be_nil, "found elements with #{text} in:\n#{elements.inspect}"
132
+ else
133
+ assert !elements.find { |e| e.text == text }, "found elements with #{text} in:\n#{elements.inspect}"
134
+ end
132
135
  else
133
- assert !elements.empty?, "could not find #{xpath} in:\n#{last_response.body}"
134
- assert elements.find { |e| e.text == text }, "found elements but could not find #{text} in:\n#{elements.inspect}"
136
+ if self.respond_to?(:should)
137
+ elements.should_not be_empty, "could not find #{xpath} in:\n#{last_response.body}"
138
+ elements.find { |e| e.text == text }.should_not be_nil, "found elements but could not find #{text} in:\n#{elements.inspect}"
139
+ else
140
+ assert !elements.empty?, "could not find #{xpath} in:\n#{last_response.body}"
141
+ assert elements.find { |e| e.text == text }, "found elements but could not find #{text} in:\n#{elements.inspect}"
142
+ end
135
143
  end
136
144
  end
137
145
 
@@ -1,4 +1,5 @@
1
1
  require "net/http"
2
+ require "net/https"
2
3
  require "uri"
3
4
  require 'json'
4
5
 
@@ -29,12 +30,13 @@ class Object
29
30
  def request path,request_opts
30
31
  req = "#{$SERVER_PATH}" + path
31
32
  uri = URI.parse(req)
32
- http = Net::HTTP.new(uri.host, uri.port)
33
-
33
+
34
+ http = Net::HTTP.new(uri.host, uri.port)
35
+
34
36
  if request_opts[:method] == :post
35
37
  request, body = send_post_request(uri, request_opts)
36
38
  elsif request_opts[:method] == :put
37
- request, body = perform_put_request(uri, request_opts)
39
+ request, body = perform_put_request(uri, request_opts)
38
40
  elsif request_opts[:method] == :get
39
41
  request = send_get_request(uri, request_opts)
40
42
  elsif request_opts[:method] == :delete
@@ -46,7 +48,15 @@ class Object
46
48
  @headers.each { |k,v| request.add_field(k, v) }
47
49
  @headers = nil
48
50
  end
49
- @response = http.request(request,body)
51
+
52
+ if req.include? "https"
53
+ http.use_ssl = true
54
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
55
+ @response = http.request(request,body)
56
+ else
57
+ http = Net::HTTP.new(uri.host, uri.port)
58
+ @response = http.request(request,body)
59
+ end
50
60
  end
51
61
 
52
62
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber-rest-api
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anupama Vijaykumar,Nic Jackson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-06 00:00:00.000000000 Z
11
+ date: 2014-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jsonpath
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  version: '0'
96
96
  requirements: []
97
97
  rubyforge_project:
98
- rubygems_version: 2.1.11
98
+ rubygems_version: 2.2.1
99
99
  signing_key:
100
100
  specification_version: 4
101
101
  summary: Cucumber steps to easily test REST-based XML and JSON APIs