Skip to content

Using expect got equal error #2068

@motizukilucas

Description

@motizukilucas

Ruby version: ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
Rails version: Rails 5.0.7
Rspec version: RSpec 3.8

  • rspec-core 3.8.0
  • rspec-expectations 3.8.1
  • rspec-mocks 3.8.0
  • rspec-rails 3.8.0
  • rspec-support 3.8.0

Observed behaviour

Getting equal error when using expect

Expected behaviour

Should be passing the test, according to the error description, or getting another error mesage

Code:

  RSpec.describe Api::V1::Profiles::ProfilesController, type: :api do
        describe 'POST /api/v1/profiles/profiles' do
              it 'Cadastro convencional de usuário (sem o facebook)' do
                    cpf = BRDocuments::CPF.generate(false)
                    post '/api/v1/profiles/profiles', :profile => {
                          :full_name => Faker::Name.name,
                          :email => Faker::Internet.email,
                          :password => "123456",
                          # :[lat] => '', 
                          # :[lng] => '', 
                          # :[fb_access_token] => '', 
                          :telephone => "2199919#{Random.rand(2520...4350)}", 
                          :cpf => cpf 
                          # :[photo] => '', 
                          # :[remote_photo_url] => ''
                    }
                    expect(last_response.status).to be(200)
                    expect(Profile.last.cpf.to_s).to be (cpf.to_s)
                  end
            end
      end

Result:

  1) Api::V1::Profiles::ProfilesController POST /api/v1/profiles/profiles Cadastro convencional de usuário (sem o facebook)
 Failure/Error: expect(Profile.last.cpf.to_s).to be (cpf.to_s)
 
   expected #<String:47388415357700> => "60307377407"
        got #<String:47388434347480> => "60307377407"
 
   Compared using equal?, which compares object identity,
   but expected and actual are not the same object. Use
   `expect(actual).to eq(expected)` if you don't care about
   object identity in this example.
  # ./spec/api/v1/profiles/profiles_controller_spec.rb:20:in `block (3 levels) in <top (required)>'

  Finished in 15.1 seconds (files took 6.72 seconds to load)
  1 example, 1 failure

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions