cucumber-blendle-steps 0.7.3 → 0.8.0
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 +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/cucumber/blendle/steps/model_steps.rb +21 -4
- data/lib/cucumber/blendle/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 709d07946974f2672901a9f966855630ac3ca27d
|
4
|
+
data.tar.gz: 847de1e801ab0b818e998d7e604ba9cdd135679c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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("
|
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("
|
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/
|
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
|