From 6f5fc14f596fd04c17e4f76d4b686534f0ad4137 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Mon, 3 Dec 2012 10:59:24 +0100 Subject: [PATCH] support regex in cuke tests --- features/step_definitions/routing.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/features/step_definitions/routing.rb b/features/step_definitions/routing.rb index efc214219..953c796ac 100644 --- a/features/step_definitions/routing.rb +++ b/features/step_definitions/routing.rb @@ -236,7 +236,7 @@ When /^I route I should get$/ do |table| ok = true row.keys.each do |key| - if row[key].match /(.*)\s+~(.+)%$/ + if row[key].match /(.*)\s+~(.+)%$/ #percentage range: 100 ~5% margin = 1 - $2.to_f*0.01 from = $1.to_f*margin to = $1.to_f/margin @@ -245,7 +245,7 @@ When /^I route I should get$/ do |table| else ok = false end - elsif row[key].match /(.*)\s+\+\-(.+)$/ + elsif row[key].match /(.*)\s+\+\-(.+)$/ #absolute range: 100 +-5 margin = $2.to_f from = $1.to_f-margin to = $1.to_f+margin @@ -254,6 +254,10 @@ When /^I route I should get$/ do |table| else ok = false end + elsif row[key] =~ /^\/(.*)\/$/ #regex: /a,b,.*/ + if got[key] =~ /#{$1}/ + got[key] = row[key] + end else ok = row[key] == got[key] end