Sha256: a5ae67e39638115f93695960d6f40816d7dd261abda75ebce52f2824535e341c

Contents?: true

Size: 1.43 KB

Versions: 2

Compression:

Stored size: 1.43 KB

Contents

require 'spec_helper'

describe Werd::ProjectWordCounter do
  let(:name) { 'Story, story!' }
  let(:description) { 'Some words! Some: word' }
  let(:stories) { [instance_double(TrackerApi::Resources::Story,
                                  name: name,
                                  description: description,
                                 )] }
  let(:project) { instance_double(TrackerApi::Resources::Project, stories: stories) }
  let(:client) { instance_double(TrackerApi::Client, project: project) }
  let(:word_counter) { Werd::ProjectWordCounter.new('token', 'project-id') }

  before do
    allow(word_counter).
      to receive(:client).
      and_return(verify_contracted_instance_method(Werd::ProjectWordCounter, :client, client))
  end

  let(:document_expectation) { [name, description].join("\n") }
  describe '#document' do
    subject { word_counter.document }
    it { is_expected.to eq document_expectation }
  end

  let(:words_expectation) { [
    ['story' , 2],
    ['some'  , 2],
    ['words' , 1],
    ['word'  , 1],
  ] }
  describe '#words' do
    before do
      allow(word_counter).
        to receive(:document).
        and_return(verify_contracted_instance_method(Werd::ProjectWordCounter, :document, document_expectation))
    end
    subject { word_counter.words }
    it { is_expected.to eq words_expectation }
  end

  describe '#project' do
    subject { word_counter.project }
    it { is_expected.to eq project }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
werd-0.0.2 spec/lib/werd/project_word_counter_spec.rb
werd-0.0.1 spec/lib/werd/project_word_counter_spec.rb