cucumber-api-steps icon indicating copy to clipboard operation
cucumber-api-steps copied to clipboard

XML response should have - text comparison with number input

Open sytzek opened this issue 9 years ago • 2 comments

Using from api_step.rb the step: the XML response should have "field" with the text "1234"

The string "1234" enters the body of the step as the argument named 'text'. In the body the 'text' has class 'Fixnum' in stead of 'String.

The comparison between the element found and the text argument fails because the classes dont match.

Simple fix is to transform text explicitly to class String with the method 'to_s'

sytzek avatar Aug 19 '15 11:08 sytzek

Hmm. the to_s method does not work with a string "0123" (it becomes "123")

sytzek avatar Aug 19 '15 12:08 sytzek

This seems to work:

Add this step

Transform /^text "[^"]"$/ do |step_arg| /text "([^"])"/.match(step_arg)[1] end

And Change api_step to:

Then /^my XML response should have "([^"])" with the (text "[^"]")$/ do |xpath, text| ... end

sytzek avatar Aug 19 '15 13:08 sytzek