We’re trying to verify XML REST API’s and would like to write Cucumber
specs of the following type:
Scenario: Create a phrase
Given I have an authenticated session for user with login “steve”
When I send a POST to /phrases with parameters: locale=ca and post
body
“<?xml version="1.0" encoding="UTF-8"?>
060e985b-0307-4c8f-b43f-c16f0e45196d
Fake Catalan Source
<source_language>ca</source_language>
”
Then I get a 201 (created) status result
And I a phrase object with UUID=060e985b-0307-4c8f-b43f-c16f0e45196d
exists on the server
When /^I send a (GET|POST|PUT|DELETE) to ([/\w]+)(?: with parameters:
)?(.) and post body (.)$/m do |method, path, params, body|
send(method.downcase.to_sym, path, params)
end
The error:
$ cucumber features/phrases_xml.feature -n
/usr/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/…/lib/cucumber/parser/treetop_ext.rb:42:in parse_or_fail': features/phrases_xml.feature:9:6: Parse error, expected one of "|", "\n", "\r", "\"\"\"", "#", "Given", "When", "Then", "And", "But", "@", "Scenario", "Scenario Outline". (Cucumber::Parser::SyntaxError) from /usr/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/parser/treetop_ext.rb:28:in parse_file’
from
/usr/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/…/lib/cucumber/parser/treetop_ext.rb:33:in open' from /usr/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/parser/treetop_ext.rb:33:in parse_file’
from
/usr/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/…/lib/cucumber/cli/main.rb:55:in load_plain_text_features' from /usr/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/cli/main.rb:54:in each’
from
/usr/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/…/lib/cucumber/cli/main.rb:54:in load_plain_text_features' from /usr/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/../lib/cucumber/cli/main.rb:37:in execute!’
from
/usr/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/…/lib/cucumber/cli/main.rb:20:in execute' from /usr/lib/ruby/gems/1.8/gems/cucumber-0.2.3/bin/cucumber:6 from /usr/bin/cucumber:19:in load’
from /usr/bin/cucumber:19
Given I want to have multiple lines
“”"
I can pass them
in with three quotes…
“”"
How does that parse into a step definition? Would it be:
Given /^I want to have multiple lines\n(.*)$/m do |text|
…or would it be something else? Is the newline character necessary?
Are the quotes included? And does this imply that multiline text
must always be separated from from steps in lines of its own?
Sorry if I’m asking dumb questions, but I was trying to look this up a
few weeks ago myself to represent some example Markdown data, and
eventually gave up. This isn’t documented anywhere that I could find.
I’ve also never heard of pystring syntax – I just tried to Google
that too, but all I got were references to Java libraries and no
simple syntax reference.
On Tue, Apr 14, 2009 at 10:37 PM, Stephen E. [email protected] wrote:
Sorry if I’m asking dumb questions, but I was trying to look this up a
few weeks ago myself to represent some example Markdown data, and
eventually gave up. This isn’t documented anywhere that I could find.
I’ve also never heard of pystring syntax – I just tried to Google
that too, but all I got were references to Java libraries and no
simple syntax reference.
All right, never mind. Having been given enough clues that the
feature exists and what it generally might look like, I prowled
through Cucumber’s specs and examples until I got a clearer picture.
Then, to keep my ‘There ain’t no documentation!’ whining privileges, I
went and added what I learned to the wiki:
I’d call it my minor good deed for the day, but really I was using it
to procrastinate on my podcasting work for another half hour, so
overall it was morally neutral.
All right, never mind. Having been given enough clues that the
lol… Sorry for not explaining the syntax better… What you wrote on
the wiki is great and doesn’t really need further explanation by Ben
Mabey or anyone else IMO.
I’ll go ahead and elaborate on it though. Thanks for adding the page.