Sha256: 772bbab7bdffe0308775340267b05d76b88012a07bb840f4cd9931c81d2aa19c

Contents?: true

Size: 1.05 KB

Versions: 10

Compression:

Stored size: 1.05 KB

Contents

RSpec.describe ActiveTracker do
  before do
    ActiveTracker.reset_connection
  end

  it "has a version number" do
    expect(ActiveTracker::VERSION).not_to be nil
  end

  it "creates a new connection to redis" do
    ActiveTracker::Configuration.redis_url = "foo"
    expect(Redis).to receive(:new).with(url: "foo")
    ActiveTracker.connection
  end

  it "pings and returns an existing connection to redis" do
    connection = double("Redis")
    expect(Redis).to receive(:new).with(url: "foo").and_return(connection)
    ActiveTracker.connection

    expect(Redis).to_not receive(:new)
    expect(connection).to receive(:ping).and_return("PONG")
    ActiveTracker.connection
  end

  it "re-connects to Redis if a ping fails" do
    ActiveTracker::Configuration.redis_url = "foo"
    connection = double("Redis")
    allow(Redis).to receive(:new).with(url: "foo").and_return(connection)
    ActiveTracker.connection

    expect(connection).to receive(:ping).and_raise(StandardError.new("Down"))
    expect(Redis).to receive(:new)
    ActiveTracker.connection
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
activetracker-0.4.9 spec/activetracker_spec.rb
activetracker-0.4.8 spec/activetracker_spec.rb
activetracker-0.4.7 spec/activetracker_spec.rb
activetracker-0.4.6 spec/activetracker_spec.rb
activetracker-0.4.5 spec/activetracker_spec.rb
activetracker-0.4.4 spec/activetracker_spec.rb
activetracker-0.4.3 spec/activetracker_spec.rb
activetracker-0.4.2 spec/activetracker_spec.rb
activetracker-0.4.1 spec/activetracker_spec.rb
activetracker-0.4.0 spec/activetracker_spec.rb