pairwise 0.1.1 → 0.1.2

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.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 1
2
+ :patch: 2
3
3
  :major: 0
4
4
  :minor: 1
@@ -0,0 +1,9 @@
1
+ Feature: Bad yml
2
+
3
+ Scenario: Empty yml
4
+ Given I have the yaml file "inputs.yml" containing:
5
+ """
6
+
7
+ """
8
+ When I run pairwise inputs.yml
9
+ Then it should not show any errors
@@ -13,3 +13,7 @@ end
13
13
  Then /^I should see in the output$/ do |string|
14
14
  last_stdout.should include(string)
15
15
  end
16
+
17
+ Then /^it should not show any errors$/ do
18
+ last_stderr.should == ""
19
+ end
@@ -85,7 +85,7 @@ module Pairwise
85
85
  def replace_wild_cards(input_combinations)
86
86
  map_each_input_value(input_combinations) do |input_value, index|
87
87
  if input_value == WILD_CARD
88
- pick_random_value(@inputs[index])
88
+ pick_random_value(@list_of_input_values[index])
89
89
  else
90
90
  input_value
91
91
  end
@@ -101,7 +101,7 @@ module Pairwise
101
101
  end
102
102
 
103
103
  def pick_random_value(input_combination)
104
- input_combination[rand(input_combination.size)]
104
+ input_combination[Kernel.rand(input_combination.size)]
105
105
  end
106
106
 
107
107
  def generate_pairs_between(parameter_i, input_lists, p_index)
data/lib/pairwise/cli.rb CHANGED
@@ -39,11 +39,15 @@ module Pairwise
39
39
  def execute!
40
40
  parse!
41
41
  exit_with_help if @input_file.nil? || @input_file.empty?
42
- input_data, input_labels = *load_and_parse_input_file!
43
42
 
44
- builder = Pairwise::Builder.new(input_data, @options)
43
+ inputs = YAML.load_file(@input_file)
44
+ if inputs
45
+ input_data, input_labels = *parse_input_data!(inputs)
46
+
47
+ builder = Pairwise::Builder.new(input_data, @options)
45
48
 
46
- @formatter.display(builder.build, input_labels)
49
+ @formatter.display(builder.build, input_labels)
50
+ end
47
51
  end
48
52
 
49
53
  private
@@ -56,8 +60,7 @@ module Pairwise
56
60
  Kernel.exit(0)
57
61
  end
58
62
 
59
- def load_and_parse_input_file!
60
- inputs = YAML.load_file(@input_file)
63
+ def parse_input_data!(inputs)
61
64
  inputs = hash_inputs_to_list(inputs) if inputs.is_a?(Hash)
62
65
 
63
66
  raw_inputs = inputs.map {|input| input.values[0]}
@@ -51,7 +51,7 @@ describe Pairwise do
51
51
  end
52
52
  end
53
53
 
54
- context "which are unequal lenghts" do
54
+ context "which are unequal lengths" do
55
55
  it "should generate all pairs for 3 parameters of 1,1,2 values" do
56
56
  data = [[:A1], [:B1], [:C1, :C2]]
57
57
 
@@ -107,7 +107,7 @@ describe Pairwise do
107
107
  #:A2, :B1, :C1, :D2
108
108
  end
109
109
 
110
- it "should generate pairs for three paramters" do
110
+ it "should generate pairs for three parameters" do
111
111
  data = [[:A1, :A2],
112
112
  [:B1, :B2],
113
113
  [:C1 , :C2 , :C3 ]]
@@ -119,7 +119,23 @@ describe Pairwise do
119
119
  [:A2, :B1, :C2],
120
120
  [:A1, :B2, :C3]]
121
121
  end
122
+
123
+ describe "replacing wildcards which could have more than one option" do
124
+ it "should generate pairs for 2 parameters of 3,2,3 values" do
125
+ Pairwise.combinations([:A1, :A2, :A3],
126
+ [:B1, :B2],
127
+ [:C1, :C2, :C3]).should == [[:A1, :B1, :C1],
128
+ [:A1, :B2, :C2],
129
+ [:A2, :B1, :C3],
130
+ [:A2, :B2, :C1],
131
+ [:A3, :B1, :C2],
132
+ [:A3, :B2, :C3],
133
+ [:A3, :B1, :C1], #B1 is a wildcard replacement
134
+ [:A2, :B1, :C2], #B1 is a wildcard replacement
135
+ [:A1, :B1, :C3]] #B1 is a wildcard replacement
136
+ end
137
+ end
122
138
  end
123
- end
124
139
 
140
+ end
125
141
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pairwise
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph Wilk
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-07 00:00:00 +00:00
12
+ date: 2010-01-08 00:00:00 +00:00
13
13
  default_executable: pairwise
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -48,6 +48,7 @@ files:
48
48
  - Rakefile
49
49
  - VERSION.yml
50
50
  - bin/pairwise
51
+ - features/bugs/bad_yml.feature
51
52
  - features/generating_pairwise_data.feature
52
53
  - features/step_definitions/pairwise_data_steps.rb
53
54
  - features/support/env.rb