Sha256: a59136d590254118f7baa73a91e004d4b249465ae3a87a71d6d81f16063028b6

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

require 'spec_helper'

describe Jamnagar::Utilities::DuplicateDetector do
  it 'should ask the store for duplicates' do
    store = Jamnagar::SpecHelpers::SimpleItemStore.new
    sut = Jamnagar::Utilities::DuplicateDetector.new(store)
    expect(store).to receive(:find_first).with({"final_url" => "http://example.com"})
    sut.detect("http://example.com")
  end
  context 'When Duplicates Exist' do
    it 'should return duplicate details' do
      store = double(Jamnagar::SpecHelpers::SimpleItemStore.new)
      allow(store).to receive(:find_first).and_return({"_id" => 456})
      sut = Jamnagar::Utilities::DuplicateDetector.new(store)
      expect(sut.detect("http://example.com")).to eq({"_id" => 456})
    end
  end
  context 'When No Duplicates Exist' do
    it 'should not return duplicate details' do
      store = double(Jamnagar::SpecHelpers::SimpleItemStore.new)
      allow(store).to receive(:find_first).and_return(nil)
      sut = Jamnagar::Utilities::DuplicateDetector.new(store)
      expect(sut.detect("http://example.com")).to eq(nil)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jamnagar-1.3.9.1 spec/duplicate_detector_spec.rb
jamnagar-1.3.9 spec/duplicate_detector_spec.rb
jamnagar-1.3.8 spec/duplicate_detector_spec.rb