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 8345705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:46:06+00:00 2026-06-09T06:46:06+00:00

Consider the following RSpec snippet: it should match do {:a => 1, :b =>

  • 0

Consider the following RSpec snippet:

it "should match" do
  {:a => 1, :b => 2}.should =~ {"a" => 1, "b" => 2}
end

This test fails because one hash uses symbols for keys and the other uses strings for keys. In my case, one hash is a parsed JSON object, the other is the hash that created the object. I’d like them to compare as equal.

Before I go writing my own matcher or coercing both hashes to have string keys, is there a matcher or technique that handles this (common) case?

  • 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-09T06:46:07+00:00Added an answer on June 9, 2026 at 6:46 am

    You could do:

    it "should match" do
        {:a => 1, :b => 2}.stringify_keys.should =~ {"a" => 1, "b" => 2}
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

consider following: 1st APPROACH: public void f3() { f2(); f1(); } and this ...
Consider following class class test { public: test(int x){ cout<< test \n; } };
I have a question regarding exception handling. Consider following Java code snippet. try{ //code
Consider following two examples: Example 1: <xs:import namespace=http://example.com/ns schemaLocation=test.xsd/> Example2: <sample:Data Test=true xsi:schemaLocation=http://example.com/test.xsd> How
consider following scenario input string = WIPR.NS i have to replace this with WIPR2.NS
Consider the following two trivial models: class Iq def score #Some Irrelevant Code end
Please consider I have the following CoffeeScript code: class Foobar test: (path) -> fs
Consider following code: Dim S1 As String = a 'this is the string in
Please consider following snippet: <div class=row> <div class=span12> <div class=control-group> <label class=control-label>Person Name</label> <div
Consider following make: all: a b a: echo a exit 1 b: echo b

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.