Sha256: 9ef41d9f4075487dbad5e7bd27d9624f9854c9500bb76a53099121885173db31

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

require 'spec_helper'

describe Jamnagar::Refiners::ContributorDetail do
  it 'accepts a store' do
    store = {}
    Jamnagar::Refiners::ContributorDetail.new(store: store)
  end
  it 'should look for the user in the contributor store' do
    @raw   = {"user" => {"id" => 43550495}}
    @item  = Jamnagar::Materials::Twitter::Item.new({"raw" => @raw})
    @store = double(Jamnagar::Storage::ContributorStore)
    @sut   = Jamnagar::Refiners::ContributorDetail.new(store: @store)

    expect(@store).to receive(:find_contributor).with(@item, @raw["user"])
    @sut.refine(@item)
  end
  it 'should return the details of the contributor' do
    @raw   = {"user" => {"id" => 43550495}}
    @item  = Jamnagar::Materials::Twitter::Item.new({"raw" => @raw})
    @store = double(Jamnagar::Storage::ContributorStore)
    @sut   = Jamnagar::Refiners::ContributorDetail.new(store: @store)
    allow(@store).to receive(:find_contributor).and_return({"_id" => 999})

    expect(@sut.refine(@item).to_h).to eq({"raw" => {"user" => {"id" => 43550495}}, "contributor" => {"_id" => 999}})
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jamnagar-1.3.9.1 spec/contributor_detail_refinment_spec.rb
jamnagar-1.3.9 spec/contributor_detail_refinment_spec.rb