[Cucumber] How to feed Special Characters with Capybara?

1,373 views
Skip to first unread message

andruis

unread,
Jan 19, 2011, 5:41:20 PM1/19/11
to Cukes
I'm trying to get Cucumber to understand special characters(trademark
symbol and registered symbol) in my test statements and im getting
errors.

I have tried: Wordhere™

but it doesn't seem to recognize the symbol when doing cucumber in the
command prompt.

Am I missing some syntax? How do I feed it the special character in
the .feature file?

Thanks for any help!
Andrew

Mike Sassak

unread,
Jan 19, 2011, 10:20:39 PM1/19/11
to cu...@googlegroups.com

I'm a little confused about what you're seeing here. Can you gist the
.feature file containing the special character? Features are parsed as
UTF-8, so multibyte characters in that encoding should be fine.

Mike

> Thanks for any help!
> Andrew
>

> --
> You received this message because you are subscribed to the Google Groups "Cukes" group.
> To post to this group, send email to cu...@googlegroups.com.
> To unsubscribe from this group, send email to cukes+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/cukes?hl=en.
>
>

andruis

unread,
Jan 19, 2011, 10:51:46 PM1/19/11
to Cukes
Sorry kinda new at this testing part, see if I can explain alittle
better

So we have a .feature file which has the test cases in it

then we use rake cucumber in the console to run the tests.

In the tests,we pass fields so like:

somethinghere | somethinghere | somethinghere etc for about 12 fields.

in some of the fields we have trademark symbol and register symbol.

It shows up on the html correctly but when I run cucumber is seems to
fail on it.

so for instance we have &#0153 for the ™ (Alt + 0153) but keeps
failing since the ID/name/label doesnt match.

we use capybara as a gem also which helps with tests.


How do you feed special characters for the tests? is that the right
syntax for it?

Thanks.
> > For more options, visit this group athttp://groups.google.com/group/cukes?hl=en.- Hide quoted text -
>
> - Show quoted text -

Mike Sassak

unread,
Jan 19, 2011, 11:04:33 PM1/19/11
to cu...@googlegroups.com
On Wed, Jan 19, 2011 at 9:51 PM, andruis <agr...@comcast.net> wrote:
> Sorry kinda new at this testing part, see if I can explain alittle
> better
>
> So we have a .feature file which has the test cases in it
>
> then we use rake cucumber in the console to run the tests.
>
> In the tests,we pass fields so like:
>
> somethinghere | somethinghere | somethinghere etc for about 12 fields.
>
> in some of the fields we have trademark symbol and register symbol.
>
> It shows up on the html correctly but when I run cucumber is seems to
> fail on it.
>
> so for instance we have &#0153 for the ™ (Alt + 0153) but keeps
> failing since the ID/name/label doesnt match.
>
> we use capybara as a gem also which helps with tests.
>
>
> How do you feed special characters for the tests? is that the right
> syntax for it?

It'll be easier to see what you're doing if you gist or post your
feature (or a similar example) someplace, but from what you've
described it sounds like you're putting the escape codes into the
feature file itself. Cucumber passes the content of the tables
straight to the test code, so try copying in the literal character
rather than an escaped representation of it, i.e. use ™ in the feature
rather than &#0153.

Mike

andruis

unread,
Jan 20, 2011, 5:40:24 PM1/20/11
to Cukes
Feature: https://docs.google.com/leaf?id=0ByitC8naGXxWZTIzMzc3ZTMtYzIwNC00MmFhLWE3MDItNjA5YTYyOTJiOTY3&hl=en

Error: https://docs.google.com/leaf?id=0ByitC8naGXxWOGJjMzA0ZTktODQ5OS00MTRiLTkzYWUtM2M3NjBjOGFkMGEx&hl=en


I have tried single quote, double quotes, no quotes even.

Thanks,
> >> > For more options, visit this group athttp://groups.google.com/group/cukes?hl=en.-Hide quoted text -
>
> >> - Show quoted text -
>
> > --
> > You received this message because you are subscribed to the Google Groups "Cukes" group.
> > To post to this group, send email to cu...@googlegroups.com.
> > To unsubscribe from this group, send email to cukes+un...@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/cukes?hl=en.- Hide quoted text -
>
> - Show quoted text -- Hide quoted text -

Mike Sassak

unread,
Jan 22, 2011, 6:10:36 PM1/22/11
to cu...@googlegroups.com

Thanks for posting these! From the looks of the error message from
Capybara, I think you are including single quotes around the item that
you're searching for. That should be unnecessary, unless those single
quotes are in the HTML itself. You can take a look at this gist to see
what I would expect to see in that table:
https://gist.github.com/791595.

If you have tried that and still are having no luck, maybe the page
itself doesn't contain what you expect it to. The cucumber-rails steps
contain a step "Then show me the page" which will open up the current
page that Cucumber is visiting in a browser. (I think you'll need to
install the launchy gem for it to work.)

Also, if you're interested, you might want to check out these links
about writing Cucumber scenarios:

* http://benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories.html
* http://cuke4ninja.com/chp_feature_files.html

I notice that you're using a very low-level and imperative style. This
has it's place, but you might find you end up writing clearer
scenarios (and with a more maintainable suite of features), if you
focus on expressing things at a slightly higher level.

Mike

Reply all
Reply to author
Forward
0 new messages