Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9001885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:29:46+00:00 2026-06-16T00:29:46+00:00

Starting to use rspec assertions with cucumber and I’ve got the doubt about which

  • 0

Starting to use rspec assertions with cucumber and I’ve got the doubt about which way to make string comparisons. I’ve tried the following 4 methods and all of them seem to produce the same result, so I was wondering if one of the methods is better over the others?

And, is it easy to explain the difference between the 4 methods? Maybe with an example?

page.first('div#navigation a').text.should == 'Radio')
page.first('div#navigation a').text.should eq('Radio')
page.first('div#navigation a').text.should match('Radio')
page.first('div#navigation a').text.should (be 'Radio')

Many thanks!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:29:47+00:00Added an answer on June 16, 2026 at 12:29 am

    For the string comparison you are doing, == , eq and (be .) are basically the same.

    The match is pattern matching and will match partials, so would match bRadiosity which would not be true for the other methods if that was the whole text in the a anchor tag

    e.g.

    1.9.3-p194 :001 > a="text with radio"
     => "text with radio" 
    1.9.3-p194 :002 > a.=='radio'
     => false 
    

    and

    1.9.3-p194 :013 > b="radioz"
     => "radioz" 
    1.9.3-p194 :014 > b.=="radio"
     => false 
    1.9.3-p194 :015 > b.match "radio"
     => #<MatchData "radio"> 
    

    Note:

    == is ruby (which also has .eql? available though not shown here).
    .eq is an rspec helper as is the (be .) construct
    

    Personally I like == the best for string comparison. Other folks prefer .eql because it differs more from = (stands out more, less confusion). I may like == more as it sems a bit more portable across languages.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am starting to use some Java code which was written by someone else.
I'm starting to use AutoMapper and some doubts arose. Where is the correct way
I am starting to use cucumber for high level testing. I have this defined
I am starting to use AndEngine and trying to load a texture to make
I'm just starting to use JScrollPane, which seems to work flawlessly with 1 exception.
We are starting to use the Telerik MVC controls and had a question about
i am just starting to use cucumber and like it so far however there
I'm starting to use Composer in a project, in which I historically had all
I'm just starting to use Hibernate and I was wondering how to insert a
I am starting to use mongodb for data storage. In mysql I save a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.