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