Merge pull request #1455 from Project-OSRM/fix/cucumber2.0
upgrade to cucumber 2.0
This commit is contained in:
commit
337bed8176
27
Gemfile.lock
27
Gemfile.lock
@ -2,22 +2,27 @@ GEM
|
||||
remote: http://rubygems.org/
|
||||
specs:
|
||||
builder (3.2.2)
|
||||
cucumber (1.3.8)
|
||||
cucumber (2.0.0)
|
||||
builder (>= 2.1.2)
|
||||
cucumber-core (~> 1.1.3)
|
||||
diff-lcs (>= 1.1.3)
|
||||
gherkin (~> 2.12.1)
|
||||
gherkin (~> 2.12)
|
||||
multi_json (>= 1.7.5, < 2.0)
|
||||
multi_test (>= 0.0.2)
|
||||
diff-lcs (1.2.4)
|
||||
gherkin (2.12.1)
|
||||
multi_test (>= 0.1.2)
|
||||
cucumber-core (1.1.3)
|
||||
gherkin (~> 2.12.0)
|
||||
diff-lcs (1.2.5)
|
||||
gherkin (2.12.2)
|
||||
multi_json (~> 1.3)
|
||||
multi_json (1.8.0)
|
||||
multi_test (0.0.2)
|
||||
multi_json (1.11.0)
|
||||
multi_test (0.1.2)
|
||||
osmlib-base (0.1.4)
|
||||
rake (10.1.0)
|
||||
rspec-expectations (2.14.3)
|
||||
diff-lcs (>= 1.1.3, < 2.0)
|
||||
sys-proctable (0.9.3)
|
||||
rake (10.4.2)
|
||||
rspec-expectations (3.2.1)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.2.0)
|
||||
rspec-support (3.2.2)
|
||||
sys-proctable (0.9.8)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
@ -52,5 +52,5 @@ When /^I request a travel time matrix I should get$/ do |table|
|
||||
actual << r
|
||||
end
|
||||
end
|
||||
table.routing_diff! actual
|
||||
table.diff! actual
|
||||
end
|
||||
|
@ -39,7 +39,7 @@ When /^I request locate I should get$/ do |table|
|
||||
actual << got
|
||||
end
|
||||
end
|
||||
table.routing_diff! actual
|
||||
table.diff! actual
|
||||
end
|
||||
|
||||
When /^I request locate (\d+) times I should get$/ do |n,table|
|
||||
|
@ -91,6 +91,6 @@ When /^I match I should get$/ do |table|
|
||||
actual << got
|
||||
end
|
||||
end
|
||||
table.routing_diff! actual
|
||||
table.diff! actual
|
||||
end
|
||||
|
||||
|
@ -39,7 +39,7 @@ When /^I request nearest I should get$/ do |table|
|
||||
actual << got
|
||||
end
|
||||
end
|
||||
table.routing_diff! actual
|
||||
table.diff! actual
|
||||
end
|
||||
|
||||
When /^I request nearest (\d+) times I should get$/ do |n,table|
|
||||
|
@ -74,5 +74,5 @@ Then /^routability should be$/ do |table|
|
||||
actual << output_row
|
||||
end
|
||||
end
|
||||
table.routing_diff! actual
|
||||
table.diff! actual
|
||||
end
|
||||
|
@ -140,7 +140,7 @@ When /^I route I should get$/ do |table|
|
||||
actual << got
|
||||
end
|
||||
end
|
||||
table.routing_diff! actual
|
||||
table.diff! actual
|
||||
end
|
||||
|
||||
When /^I route (\d+) times I should get$/ do |n,table|
|
||||
|
@ -1,76 +0,0 @@
|
||||
#monkey patch cucumber table class to reorder output.
|
||||
#we always want failed rows to be shown right below the expected row.
|
||||
|
||||
class Cucumber::Ast::Table
|
||||
def routing_diff!(other_table, options={})
|
||||
options = {:missing_row => true, :surplus_row => true, :missing_col => true, :surplus_col => false}.merge(options)
|
||||
|
||||
other_table = ensure_table(other_table)
|
||||
other_table.convert_headers!
|
||||
other_table.convert_columns!
|
||||
ensure_green!
|
||||
|
||||
convert_headers!
|
||||
convert_columns!
|
||||
|
||||
original_width = cell_matrix[0].length
|
||||
other_table_cell_matrix = pad!(other_table.cell_matrix)
|
||||
padded_width = cell_matrix[0].length
|
||||
|
||||
missing_col = cell_matrix[0].detect{|cell| cell.status == :undefined}
|
||||
surplus_col = padded_width > original_width
|
||||
|
||||
require_diff_lcs
|
||||
cell_matrix.extend(Diff::LCS)
|
||||
changes = cell_matrix.diff(other_table_cell_matrix).flatten
|
||||
|
||||
inserted = 0
|
||||
missing = 0
|
||||
|
||||
row_indices = Array.new(other_table_cell_matrix.length) {|n| n}
|
||||
|
||||
last_change = nil
|
||||
missing_row_pos = nil
|
||||
insert_row_pos = nil
|
||||
|
||||
changes.each do |change|
|
||||
if(change.action == '-')
|
||||
missing_row_pos = change.position + inserted
|
||||
cell_matrix[missing_row_pos].each{|cell| cell.status = :undefined}
|
||||
row_indices.insert(missing_row_pos, nil)
|
||||
missing += 1
|
||||
else # '+'
|
||||
#change index so we interleave instead
|
||||
insert_row_pos = change.position + inserted + 1
|
||||
#insert_row_pos = change.position + missing #original
|
||||
|
||||
inserted_row = change.element
|
||||
inserted_row.each{|cell| cell.status = :comment}
|
||||
cell_matrix.insert(insert_row_pos, inserted_row)
|
||||
row_indices[insert_row_pos] = nil
|
||||
inspect_rows(cell_matrix[missing_row_pos], inserted_row) if last_change && last_change.action == '-'
|
||||
inserted += 1
|
||||
end
|
||||
last_change = change
|
||||
end
|
||||
|
||||
other_table_cell_matrix.each_with_index do |other_row, i|
|
||||
row_index = row_indices.index(i)
|
||||
row = cell_matrix[row_index] if row_index
|
||||
if row
|
||||
(original_width..padded_width).each do |col_index|
|
||||
surplus_cell = other_row[col_index]
|
||||
row[col_index].value = surplus_cell.value if row[col_index]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
clear_cache!
|
||||
should_raise =
|
||||
missing_row_pos && options[:missing_row] ||
|
||||
insert_row_pos && options[:surplus_row] ||
|
||||
missing_col && options[:missing_col] ||
|
||||
surplus_col && options[:surplus_col]
|
||||
raise Different.new(self) if should_raise
|
||||
end
|
||||
end
|
@ -4,19 +4,13 @@ STRESS_TIMEOUT = 300
|
||||
|
||||
Before do |scenario|
|
||||
|
||||
# feature name
|
||||
# fetch scenario and feature name, so we can use it in log files if needed
|
||||
case scenario
|
||||
when Cucumber::Ast::Scenario
|
||||
when Cucumber::RunningTestCase::Scenario
|
||||
@feature_name = scenario.feature.name
|
||||
when Cucumber::Ast::OutlineTable::ExampleRow
|
||||
@feature_name = scenario.scenario_outline.feature.name
|
||||
end
|
||||
|
||||
# scenario name
|
||||
case scenario
|
||||
when Cucumber::Ast::Scenario
|
||||
@scenario_title = scenario.name
|
||||
when Cucumber::Ast::OutlineTable::ExampleRow
|
||||
when Cucumber::RunningTestCase::ExampleRow
|
||||
@feature_name = scenario.scenario_outline.feature.name
|
||||
@scenario_title = scenario.scenario_outline.name
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user