squcumber-postgres 0.0.6 → 0.0.8

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
  SHA256:
3
- metadata.gz: 0c7e23adc852f610e1dccd53a19444e6be0bf6707c7a4243ef475ccce0abdb6e
4
- data.tar.gz: 437eac476560aa4fb9b5187a5e05c8e08c11f16954c74d0c0084808011dcd668
3
+ metadata.gz: a32490ebd1135e0fbd4e527a37216e807a9092f137adb94fdead577c493930f3
4
+ data.tar.gz: ce7dfe1d4a27fc6329a8dcdb8b866084725650acb65b0f5f3aa847cce58ba2de
5
5
  SHA512:
6
- metadata.gz: 2759e739f71e4d8f51f019b4cad5bbf0933f6ef032f348494baa9fc5bcf374b7df601893ead9bfa47a7db0a7d95243399a1c013e322e030a6f5ad8f157e571d3
7
- data.tar.gz: 551a53568da31c1f83e9cb91b496aea019960830a6b4151fb535d45ad13f36174ec3d8c553f7f35e6b5012dd90df3fa5a6cce6be3b81a5841e2da5b01a9c734e
6
+ metadata.gz: f4f385979a30214331d054dfc1b0e1cbc5a0c52b75f1991cc772949118762cbd3a85f658916fb5a1cdf3bd876eb7c41fd8f320b7dab8948907b9d4ad899dc67b
7
+ data.tar.gz: da362eb89ce0980d6a8beaeec97e1a46aac976543ecd67a3cba3bbeff04d7252365b304f8a3ad09e1ce7e6dd67aec21a575d471899c375f936cfdd990892e19e
@@ -82,13 +82,17 @@ end
82
82
 
83
83
  When(/^the given SQL files are executed$/) do
84
84
  silence_streams(STDERR) do
85
- @sql_files_to_execute.each { |file| TESTING_DATABASE.exec_file(file) }
85
+ @sql_files_to_execute.each do |file|
86
+ # This overwrites the result if multiple files are executed
87
+ @result = TESTING_DATABASE.exec_file(file).map { |e| e }
88
+ end
86
89
  end
87
90
  end
88
91
 
89
92
  When(/^the SQL file "?([^\s"]+)"? is executed/) do |file|
90
93
  silence_streams(STDERR) do
91
- TESTING_DATABASE.exec_file("#{@sql_file_path}/#{file}")
94
+ # This overwrites the result if multiple files are executed
95
+ @result = TESTING_DATABASE.exec_file("#{@sql_file_path}/#{file}").map { |e| e }
92
96
  end
93
97
  end
94
98
 
@@ -97,6 +101,13 @@ When(/^the resulting table "?([^\s"]*)"? is queried(?:, ordered by "?([^"]*)"?)?
97
101
  @result = TESTING_DATABASE.query("select * from #{table} #{sort_statement};").map { |e| e }
98
102
  end
99
103
 
104
+ When(/^the result is ordered by "?([^"]+)"?/) do |sort_columns_string|
105
+ sort_columns = sort_columns_string.split(',').map { |sort_column| sort_column.strip }
106
+ @result = @result.sort_by do |row|
107
+ sort_columns.map { |sort_column| row[sort_column] }
108
+ end
109
+ end
110
+
100
111
  Then(/^the result( with date placeholders)? starts with.*$/) do |placeholder, data|
101
112
  actual = @result[0..(data.hashes.length - 1)] || []
102
113
  expected = data.hashes || []
@@ -0,0 +1,3 @@
1
+ require_relative 'matchers'
2
+
3
+ World(MatcherHelpers)
@@ -34,10 +34,10 @@ module MatcherHelpers
34
34
  # 2 years ago (as year)
35
35
  # => '2015'
36
36
  #
37
- # beginning of last month
37
+ # beginning of month last month
38
38
  # => '2017-06-01'
39
39
  #
40
- # end of last year
40
+ # end of month last year
41
41
  # => '2016-12-31'
42
42
  #
43
43
  # today (as custom '%Y-%m')
@@ -126,7 +126,6 @@ module MatcherHelpers
126
126
 
127
127
  formatted_new_value = case format
128
128
  when nil
129
- puts "NO FORMAT"
130
129
  modified_new_value.to_s
131
130
  when 'day', 'month', 'year'
132
131
  modified_new_value.send(format.to_sym)
@@ -137,13 +136,9 @@ module MatcherHelpers
137
136
  raise "Invalid date format provided: #{format}"
138
137
  end
139
138
 
140
- formatted_new_value
139
+ formatted_new_value.to_s
141
140
  else
142
- new_value
141
+ new_value.to_s
143
142
  end
144
143
  end
145
144
  end
146
-
147
- if defined?(World)
148
- World(MatcherHelpers)
149
- end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: squcumber-postgres
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefanie Grunwald
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-23 00:00:00.000000000 Z
11
+ date: 2018-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -142,6 +142,7 @@ files:
142
142
  - lib/squcumber-postgres/rake/task.rb
143
143
  - lib/squcumber-postgres/step_definitions/common_steps.rb
144
144
  - lib/squcumber-postgres/support/database.rb
145
+ - lib/squcumber-postgres/support/helpers.rb
145
146
  - lib/squcumber-postgres/support/matchers.rb
146
147
  - lib/squcumber-postgres/support/output.rb
147
148
  - spec/spec_helper.rb