cuke_modeler 0.4.0 → 0.4.1

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: 1b7765a28c904d7029be528292e466d45658e0d4
4
- data.tar.gz: e9348d536a8e54578858e3e3ba1604f62494069b
3
+ metadata.gz: 414503e25b096ba139b0585a57db358e5874c263
4
+ data.tar.gz: c982a0ae8247c086de6a8af77fef5552bc744184
5
5
  SHA512:
6
- metadata.gz: 43e9dafda2fd090bc707e3aa7af7b9522b9a2eb70e8769f00ed88c3b515724473dddcc7e881d31c62c2094ef4af9719faf2f2c5c79925b32647026a32fe5aa1d
7
- data.tar.gz: 921be93201b8a2bc6aa4a22a77ce4aa177de988017db9885a802a1c535b02ca5952c972ec874fbb20284251d8cfeb035eb4404b46dd38295f1ed859e0bcc1d2c
6
+ metadata.gz: e3e67445b91027baa77694302656394837fce4e384cc213c4f1ba8127b5826a5d6d6c6105998030b1e429c7c71a26522df26e5cae044f0a1f62cf089aeaa7b9a
7
+ data.tar.gz: 499a61bbd3f475f9ad9cfb0f3f00903eaec01895b68eed7496c89404e2a1c8c4ef7fb8eda54deeaff9b49e1c8e0acc11d335fd0b54ea55c56711f55a7be034e2
data/History.rdoc CHANGED
@@ -1,3 +1,9 @@
1
+ === Version 0.4.1 / 2016-05-12
2
+
3
+ * Increased the flexibility of input when adding rows to an Example object.
4
+ * Added some error checking around adding value rows to an Example object without adding a parameter row as well.
5
+
6
+
1
7
  === Version 0.4.0 / 2016-05-01
2
8
 
3
9
  * The path of a Directory object is now a changeable attribute instead of only being populated if the instance was
@@ -44,11 +44,22 @@ module CukeModeler
44
44
  # parameters and their corresponding values or as an Array of values which
45
45
  # will be assigned in order.
46
46
  def add_row(row)
47
+ raise('Cannot add a row. No parameters have been set.') if @parameters.empty?
48
+
49
+ # A quick 'deep clone' so that the input isn't modified
50
+ row = Marshal::load(Marshal.dump(row))
51
+
47
52
  case
48
53
  when row.is_a?(Array)
54
+ # 'stringify' input
55
+ row.collect! { |value| value.to_s }
56
+
49
57
  @rows << Hash[@parameters.zip(row.collect { |value| value.strip })]
50
58
  @row_elements << Row.new("|#{row.join('|')}|")
51
59
  when row.is_a?(Hash)
60
+ # 'stringify' input
61
+ row = row.inject({}) { |hash, (key, value)| hash[key.to_s] = value.to_s; hash }
62
+
52
63
  @rows << row.each_value { |value| value.strip! }
53
64
  @row_elements << Row.new("|#{ordered_row_values(row).join('|')}|")
54
65
  else
@@ -1,3 +1,3 @@
1
1
  module CukeModeler
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -173,7 +173,7 @@ describe 'Example, Unit' do
173
173
  clazz.new.should respond_to(:add_row)
174
174
  end
175
175
 
176
- it 'can add a new row as a hash' do
176
+ it 'can add a new row as a hash, string values' do
177
177
  source = "Examples:\n|param1|param2|\n|value1|value2|"
178
178
  example = clazz.new(source)
179
179
 
@@ -185,7 +185,19 @@ describe 'Example, Unit' do
185
185
  example.row_elements.collect { |row| row.cells }[1..example.row_elements.count].should == [['value1', 'value2'], ['value3', 'value4']]
186
186
  end
187
187
 
188
- it 'can add a new row as an array' do
188
+ it 'can add a new row as a hash, non-string values' do
189
+ source = "Examples:\n|param1|param2|\n|value1|value2|"
190
+ example = clazz.new(source)
191
+
192
+ new_row = {:param1 => 'value3', 'param2' => 4}
193
+ example.add_row(new_row)
194
+
195
+ #todo - remove once Hash rows are no longer supported
196
+ example.rows.should == [{'param1' => 'value1', 'param2' => 'value2'}, {'param1' => 'value3', 'param2' => '4'}]
197
+ example.row_elements.collect { |row| row.cells }[1..example.row_elements.count].should == [['value1', 'value2'], ['value3', '4']]
198
+ end
199
+
200
+ it 'can add a new row as an array, string values' do
189
201
  source = "Examples:\n|param1|param2|\n|value1|value2|"
190
202
  example = clazz.new(source)
191
203
 
@@ -197,7 +209,22 @@ describe 'Example, Unit' do
197
209
  example.row_elements.collect { |row| row.cells }[1..example.row_elements.count].should == [['value1', 'value2'], ['value3', 'value4']]
198
210
  end
199
211
 
212
+ it 'can add a new row as an array, non-string values' do
213
+ source = "Examples:\n|param1|param2|param3|\n|value1|value2|value3|"
214
+ example = clazz.new(source)
215
+
216
+ new_row = [:value4, 5, 'value6']
217
+ example.add_row(new_row)
218
+
219
+ #todo - remove once Hash rows are no longer supported
220
+ example.rows.should == [{'param1' => 'value1', 'param2' => 'value2', 'param3' => 'value3'}, {'param1' => 'value4', 'param2' => '5', 'param3' => 'value6'}]
221
+ example.row_elements.collect { |row| row.cells }[1..example.row_elements.count].should == [['value1', 'value2', 'value3'], ['value4', '5', 'value6']]
222
+ end
223
+
200
224
  it 'can only use a Hash or an Array to add a new row' do
225
+ source = "Examples:\n|param|\n|value|"
226
+ example = clazz.new(source)
227
+
201
228
  expect { example.add_row({}) }.to_not raise_error
202
229
  expect { example.add_row([]) }.to_not raise_error
203
230
  expect { example.add_row(:a_row) }.to raise_error(ArgumentError)
@@ -216,6 +243,31 @@ describe 'Example, Unit' do
216
243
  example.rows.should == [{'param1' => 'value1', 'param2' => 'value2'}, {'param1' => 'value3', 'param2' => 'value4'}, {'param1' => 'value5', 'param2' => 'value6'}]
217
244
  example.row_elements.collect { |row| row.cells }[1..example.row_elements.count].should == [['value1', 'value2'], ['value3', 'value4'], ['value5', 'value6']]
218
245
  end
246
+
247
+ #todo - remove once Hash rows are no longer supported
248
+ it 'will complain if a row is added and no parameters have been set' do
249
+ example = clazz.new
250
+ example.parameters = []
251
+
252
+ new_row = ['value1', 'value2']
253
+ expect { example.add_row(new_row) }.to raise_error('Cannot add a row. No parameters have been set.')
254
+
255
+ new_row = {'param1' => 'value1', 'param2' => 'value2'}
256
+ expect { example.add_row(new_row) }.to raise_error('Cannot add a row. No parameters have been set.')
257
+ end
258
+
259
+ #todo - remove once Hash rows are no longer supported
260
+ it 'does not modify its row input' do
261
+ source = "Examples:\n|param1|param2|\n|value1|value2|"
262
+ example = clazz.new(source)
263
+
264
+ new_row = ['value1'.freeze, 'value2'.freeze].freeze
265
+ expect { example.add_row(new_row) }.to_not raise_error
266
+
267
+ new_row = {'param1'.freeze => 'value1'.freeze, 'param2'.freeze => 'value2'.freeze}.freeze
268
+ expect { example.add_row(new_row) }.to_not raise_error
269
+ end
270
+
219
271
  end
220
272
 
221
273
  describe '#remove_row' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cuke_modeler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Kessler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-02 00:00:00.000000000 Z
11
+ date: 2016-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gherkin