soaspec 0.0.35 → 0.0.36

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: 4c7df2a27ca4097085513de2d9afa7d45e8eb9ff
4
- data.tar.gz: 691d473c89b69df0dbb5fcb21ffdfe13c67dd236
3
+ metadata.gz: '0877db6205f535e6fe2c1999d6fd43efc7c8c968'
4
+ data.tar.gz: cd409d133b72f33a343dcd2c6dae74e23bda9c00
5
5
  SHA512:
6
- metadata.gz: 2a5a1e6b75df8eca6e4b03ac1e654e0d649c92dcbb72af84852115f5cdf3b8427697fdaf8a1aff779398c9d993e8734eeb4b0b2340a7e59e2956b15fd1178935
7
- data.tar.gz: 38e3753dfaf0f7eeb859601777a3158019fa84cb5e0e1497b03cccc3143f6fd8b3f2b09ad0cce493c52fc46ff120d60ec0c319077747ec08e938d8e90a8fe4e4
6
+ metadata.gz: 0cf6f5d024199e9a4518bb86054927f768e096ae34c9f9686b8c58a5d79163fe979dbb3fc01448c90c89a2d057399e00f0ac0ff012e7ac3564e27f9d45a5ecd4
7
+ data.tar.gz: 630e900ca4727d7f17bec11c0d947c12e1378f57acadbe67cfae4442425f69807ca2abdf1dede554d7cbf477861b97002a543f1283d3f6bb64cd66068f64fed6
@@ -0,0 +1,10 @@
1
+ before_script:
2
+ - apt-get update -qq && apt-get install -y -qq sqlite3 libsqlite3-dev nodejs
3
+ - ruby -v
4
+ - which ruby
5
+ - gem install bundler rake --no-ri --no-rdoc
6
+ - bundle install --jobs $(nproc) "${FLAGS[@]}"
7
+
8
+ rspec:
9
+ script:
10
+ - bundle exec rake spec
data/ChangeLog CHANGED
@@ -1,3 +1,12 @@
1
+ Version 0.0.36 / 2018-3-15
2
+ * Bug fix
3
+ * Make test name log in correct place
4
+ * Enhancements
5
+ * Made accessor 'mandatory_json_values' to make it easier to share mandatory json path - value pairs
6
+ * Created 'store' method for handler through which one can store a value and use it later on it in the same context
7
+ * Deprecated
8
+ * Removed old 'mandatory_elements', 'mandatory_xpath_values' overridden way of handling data for favor of new way of it setting 'expected_mandatory_elements'
9
+
1
10
  Version 0.0.35 / 2018-3-13
2
11
  * Enhancements
3
12
  * Handle array of JSON hashes starting with '['
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- soaspec (0.0.35)
4
+ soaspec (0.0.36)
5
5
  jsonpath
6
6
  rest-client (>= 2.0)
7
7
  rspec (~> 3.0)
data/Rakefile CHANGED
@@ -3,9 +3,10 @@ require 'rspec/core/rake_task'
3
3
  require 'rake/clean'
4
4
 
5
5
  ENV['folder'] ||= ''
6
+ ENV['test'] ||= ''
6
7
 
7
8
  RSpec::Core::RakeTask.new(:run_spec) do |t|
8
- t.pattern = "spec/*/#{ENV['folder']}*/*_spec.rb"
9
+ t.pattern = "spec/*/#{ENV['folder']}*/#{ENV['test']}*_spec.rb"
9
10
  end
10
11
 
11
12
  desc 'Prepare log files'
@@ -3,7 +3,7 @@ japan:
3
3
  country_name: 'Japan'
4
4
 
5
5
  pet:
6
- id: '1'
6
+ id: '1122334400'
7
7
  category:
8
8
  id: '1'
9
9
  name: 'string'
@@ -14,3 +14,42 @@ pet:
14
14
  - id: '1'
15
15
  name: 'string'
16
16
  status: sold
17
+
18
+ pet1:
19
+ id: '123987'
20
+ category:
21
+ id: '1'
22
+ name: 'string'
23
+ name: 'new_puppy'
24
+ photoUrls:
25
+ - 'string'
26
+ tags:
27
+ - id: '1'
28
+ name: 'string'
29
+ status: available
30
+
31
+ pet2:
32
+ id: '9998772'
33
+ category:
34
+ id: '1'
35
+ name: 'string'
36
+ name: 'new_puppy'
37
+ photoUrls:
38
+ - 'string'
39
+ tags:
40
+ - id: '1'
41
+ name: 'string'
42
+ status: available
43
+
44
+ pet3:
45
+ id: '554678'
46
+ category:
47
+ id: '1'
48
+ name: 'string'
49
+ name: 'new_puppy'
50
+ photoUrls:
51
+ - 'string'
52
+ tags:
53
+ - id: '1'
54
+ name: 'string'
55
+ status: available
@@ -3,11 +3,12 @@ module Soaspec
3
3
  # Some are included in 'success scenarios' and to configure the request sent
4
4
  module Accessors
5
5
 
6
- # Defines expected_mandatory_elements method used in 'success_scenarios' shared examples
6
+ # Defines expected_mandatory_elements method used in 'success_scenario' shared examples
7
7
  # to indicate certain elements must be present
8
- # @param [Array] elements Array of symbols specifying expected element names for 'success_scearios' in snakecase
8
+ # @param [Array] elements Array of symbols specifying expected element names for 'success scenario' in snakecase
9
9
  def mandatory_elements(elements)
10
10
  define_method('expected_mandatory_elements') do
11
+ return [elements] if elements.is_a?(String) || elements.is_a?(Symbol)
11
12
  elements
12
13
  end
13
14
  end
@@ -29,5 +30,22 @@ module Soaspec
29
30
  end
30
31
  end
31
32
 
33
+ # Defines mandatory json path value pairs to be included in 'success scenario' shared example
34
+ #
35
+ # @example Inside class
36
+ # mandatory_json_values '$..GetWeatherResult' => 'Found'
37
+ #
38
+ # In test
39
+ # describe Exchange(:name) do
40
+ # it_behaves_like 'success scenario' # Includes json pair validation
41
+ # end
42
+ #
43
+ def mandatory_json_values(json_value_pairs)
44
+ raise ArgumentError('Hash of {jsonpath => expected values} expected ') unless json_value_pairs.is_a? Hash
45
+ define_method('expected_mandatory_json_values') do
46
+ json_value_pairs
47
+ end
48
+ end
49
+
32
50
  end
33
51
  end
@@ -5,6 +5,8 @@ class Exchange
5
5
 
6
6
  attr_reader :api_class
7
7
 
8
+ # @param [Symbol, String] name Name shown in RSpec run
9
+ # @param [Hash] override_parameters Parameters to override for default params
8
10
  def initialize(name, override_parameters = {})
9
11
  @test_name = name.to_s
10
12
  @api_class = Soaspec::Environment.api_handler
@@ -13,6 +15,7 @@ class Exchange
13
15
 
14
16
  # Make request to handler with parameters defined
15
17
  def make_request
18
+ Soaspec::SpecLogger.add_to 'Example ' + @test_name
16
19
  @api_class.make_request(@override_parameters)
17
20
  end
18
21
 
@@ -20,7 +23,6 @@ class Exchange
20
23
  # This will make the request and store the response
21
24
  # @return [String] Name given when initializing
22
25
  def to_s
23
- Soaspec::SpecLogger.add_to 'Example ' + @test_name
24
26
  @test_name
25
27
  end
26
28
 
@@ -35,7 +37,7 @@ class Exchange
35
37
  # Get status code from api class. This is http response for Web Api
36
38
  # @return [Integer] Status code from api class
37
39
  def status_code
38
- @api_class.status_code_for(self.response)
40
+ @api_class.status_code_for(response)
39
41
  end
40
42
 
41
43
  # Extract value from path api class
@@ -35,21 +35,27 @@ module Soaspec
35
35
  []
36
36
  end
37
37
 
38
- # Use this to set 'expected_mandatory_elements' see 'accessors'
39
- def mandatory_elements
40
- []
38
+ # Change this through 'mandatory_xpath_values' method to specify xpath results that must be present in the response
39
+ # Will be used in 'success_scenarios' shared examples
40
+ # @return [Hash] Hash of 'xpath' => 'expected value' pairs
41
+ def expected_mandatory_xpath_values
42
+ {}
41
43
  end
42
44
 
43
- # Override this to specify xpath results that must be present in the response
45
+ # Change this through 'mandatory_json_values' method to specify json results that must be present in the response
44
46
  # Will be used in 'success_scenarios' shared examples
45
47
  # @return [Hash] Hash of 'xpath' => 'expected value' pairs
46
- def expected_mandatory_xpath_values
48
+ def expected_mandatory_json_values
47
49
  {}
48
50
  end
49
51
 
50
- # Use this to set 'expected_mandatory_xpath_values' see 'accessors'
51
- def mandatory_xpath_values
52
- []
52
+ # Stores a value in a method that can be accessed by the provided name
53
+ # @param [Symbol] name Name of method to use to access this value within handler
54
+ # @param [String] value Value to store
55
+ def store(name, value)
56
+ define_singleton_method(name.to_s) do
57
+ value
58
+ end
53
59
  end
54
60
 
55
61
  end
@@ -10,24 +10,17 @@ shared_examples_for 'success scenario' do
10
10
  expect(described_class).to contain_key mandatory_element
11
11
  end
12
12
  end
13
- # TODO: Remove this. Handle deprecated method temporarily
14
- described_class.api_class.mandatory_elements.each do |mandatory_element|
15
- puts "Overriding 'mandatory_elements' deprecated. Use new 'expected_mandatory_elements' instead of overriding this method"
16
- it mandatory_element do
17
- expect(described_class).to contain_key mandatory_element
18
- end
19
- end
20
13
  end
21
14
  described_class.api_class.expected_mandatory_xpath_values.each do |xpath, value|
22
15
  it "has xpath '#{xpath}' equal to '#{value}'" do
23
16
  expect(described_class).to have_xpath_value(xpath => value)
24
17
  end
25
18
  end
26
- # TODO: Remove deprecated method
27
- described_class.api_class.mandatory_xpath_values.each do |xpath, value|
28
- puts "Overriding 'mandatory_elements' deprecated. Use new 'expected_mandatory_elements' instead of overriding this method"
19
+ described_class.api_class.expected_mandatory_json_values.each do |xpath, value|
29
20
  it "has xpath '#{xpath}' equal to '#{value}'" do
30
21
  expect(described_class).to have_xpath_value(xpath => value)
31
22
  end
32
23
  end
24
+
25
+
33
26
  end
@@ -1,3 +1,3 @@
1
1
  module Soaspec
2
- VERSION = '0.0.35'
2
+ VERSION = '0.0.36'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soaspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.35
4
+ version: 0.0.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - SamuelGarrattIQA
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-12 00:00:00.000000000 Z
11
+ date: 2018-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -148,6 +148,7 @@ extensions: []
148
148
  extra_rdoc_files: []
149
149
  files:
150
150
  - ".gitignore"
151
+ - ".gitlab-ci.yml"
151
152
  - ".rspec"
152
153
  - ".rubocop.yml"
153
154
  - ".travis.yml"