cucumber-blendle-steps 0.7.3 → 0.8.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: de3e9cfc94a3dabc6c1231b540bcc52d81f8af72
4
- data.tar.gz: f1a47e6a62cc96ed0497f86e0b840c58bbe17e29
3
+ metadata.gz: 709d07946974f2672901a9f966855630ac3ca27d
4
+ data.tar.gz: 847de1e801ab0b818e998d7e604ba9cdd135679c
5
5
  SHA512:
6
- metadata.gz: af26b7397df3af869b0c8a56521b99bcfb7566e8c87fbde7fba9e13b91d9029ba6197c4b996402c1493863a4cbaa0f9924b854c08f70b4aee9fb945daf94a341
7
- data.tar.gz: 41d661138ad6c1d9ab680c9b8853169d420d825e7ab216123bdab13e73e0cf0d621331077272ac33ac903db065af5811dc4ef6224a22fa08c379a34aff6c38c7
6
+ metadata.gz: 73bf43623319113a56267672962ea94350ce57b06c48ea1ce32af0e2ab5bc74e4bcccb4356783bca3529cadac4de9553c0de1cd7fd25041f8d2ba1c0ae48c229
7
+ data.tar.gz: 7e2c63b5da5e5a6b30d920896d55e8b3c7375f2f29be55047180d4ffeb28763b5fd510aedf5b0f4c447a251c5deaa47eca6039e2f781e721e07b2ffae9736bdf
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## [v0.7.3](https://github.com/blendle/cucumber-blendle-steps/tree/v0.7.3) (2016-04-24)
4
+ [Full Changelog](https://github.com/blendle/cucumber-blendle-steps/compare/v0.7.2...v0.7.3)
5
+
3
6
  ## [v0.7.2](https://github.com/blendle/cucumber-blendle-steps/tree/v0.7.2) (2016-04-05)
4
7
  [Full Changelog](https://github.com/blendle/cucumber-blendle-steps/compare/v0.7.1...v0.7.2)
5
8
 
@@ -48,10 +48,11 @@ end
48
48
  # * Then the item with uid "hello" should not exist
49
49
  #
50
50
  Then(/^the (\S+) with (\S+) "([^"]*)" should( not)? exist$/) do |object, attribute, value, negate|
51
- hash = parse_row({ attribute => value }, object)
52
51
  assertion = negate ? 'blank?' : 'present?'
52
+ hash = parse_row({ attribute => value }, object)
53
+ klass = object.tr(' ', '_').singularize.classify
53
54
 
54
- assert eval("#{object.tr(' ', '_').singularize.classify}.first(hash).#{assertion}"),
55
+ assert eval("row_finder(klass, hash).#{assertion}"),
55
56
  %(#{object.capitalize} not found \(#{attribute}: #{value}\))
56
57
  end
57
58
 
@@ -67,7 +68,7 @@ Then(/^the following (.+)? should( not)? exist:$/) do |object, negate, table|
67
68
  hash = parse_row(row, object)
68
69
  klass = object.tr(' ', '_').singularize.classify
69
70
 
70
- assert eval("#{klass}.first(hash).#{assertion}"),
71
+ assert eval("row_finder(klass, hash).#{assertion}"),
71
72
  "Could not find requested #{object}:\n\n" \
72
73
  "- #{hash}\n" \
73
74
  "+ #{Object.const_get(klass).all.map(&:values).join("\n+ ")}"
@@ -83,9 +84,10 @@ end
83
84
  # @param [String] object_name to be parsed
84
85
  # @return [Hash] hash representation of key/values in table
85
86
  #
87
+ # rubocop:disable Metrics/AbcSize
86
88
  # rubocop:disable Metrics/CyclomaticComplexity
87
89
  # rubocop:disable Metrics/MethodLength
88
- # rubocop:disable Metrics/AbcSize
90
+ # rubocop:disable Metrics/PerceivedComplexity
89
91
  #
90
92
  def parse_row(row, object_name)
91
93
  table = object_name.tr(' ', '_')
@@ -108,6 +110,8 @@ def parse_row(row, object_name)
108
110
  value.to_s.casecmp('true').zero?
109
111
  when :string_array, :varchar_array, :bigint_array
110
112
  Sequel.pg_array(eval(value))
113
+ when :jsonb
114
+ Sequel.pg_jsonb(eval(value))
111
115
  else
112
116
  value
113
117
  end
@@ -117,3 +121,16 @@ def parse_row(row, object_name)
117
121
 
118
122
  Hash[hash]
119
123
  end
124
+
125
+ def row_finder(klass, hash)
126
+ ext = 'where'
127
+ query = hash.each_with_object({}) do |(key, value), q|
128
+ if value.is_a?(Sequel::Postgres::JSONBHash)
129
+ ext = "where { Sequel.pg_jsonb(:#{key}).contains(#{value}) }"
130
+ else
131
+ q[key] = value
132
+ end
133
+ end
134
+
135
+ eval "#{klass}.#{ext}.first(query)"
136
+ end
@@ -6,6 +6,6 @@ module Cucumber
6
6
  # This module defines default steps used by all of Blendle Ruby projects.
7
7
  #
8
8
  module BlendleSteps
9
- VERSION = '0.7.3'.freeze
9
+ VERSION = '0.8.0'.freeze
10
10
  end
11
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber-blendle-steps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Mertz