← 输入框|github.com|刷新
Skip to content

Included NullDB but when running RSpec still got ActiveRecord::ConnectionNotEstablished #121

Open

Description

@thenordicwaters

I have installed in my gemfile:

group :test do
  gem 'activerecord-nulldb-adapter'
end

In one of my spec.rb file, I alr included

require 'nulldb_rspec'
require './spec/support/null_db.rb'

describe DemandPrediction::Jobs::DailyItemPopulator, type: :job do
  include NullDB::RSpec::NullifiedDatabase

  before do
    allow_any_instance_of(DemandPrediction::Models::Item).to receive(:last).and_return(nil)
    allow_any_instance_of(DemandPrediction::Models::Item).to receive(:import)
  end

  context 'xxx' do

  end
end

But when I run the rspec
I still got the following err

ActiveRecord::ConnectionNotEstablished: connection to server on socket "/tmp/.s.PGSQL.5432" failed

Any issue ?

Activity

  1. cabello commented on Oct 16, 2023

    @cabello

    From the error it appears that your code is still attempting to connect to the real Postgres database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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