Sha256: 01ccd4e99cf0ceceba07bcbc82d84a0ac5ad0c2250c3a7ff76bce3899c347727

Contents?: true

Size: 1018 Bytes

Versions: 2

Compression:

Stored size: 1018 Bytes

Contents

require 'rails_helper'

module Ecm::Tags
  describe TagSearch do
    context 'instance' do
      subject { Ecm::Tags::TagSearch.new }

      it { expect(subject).to be_a(Ecm::Tags::TagSearch) }
    end

    context 'simple search' do
      subject do
        @post = create(:post)
        @post.tag_list.add('foo')
        @post.save!
        Ecm::Tags::TagSearch.new(tag_list: 'foo').do_work
      end

      it 'should return a hash' do
        expect(subject).to be_a(Hash)
      end

      it { expect(subject.keys).to include('Post') }
      it { expect(subject['Post'].size).to eq(1) }
    end

    context 'fuzzy search' do
      subject do
        @post = create(:post)
        @post.tag_list.add('foo')
        @post.save!
        Ecm::Tags::TagSearch.new(tag_list: 'f', fuzzy: true).do_work
      end

      it 'should return a hash' do
        expect(subject).to be_a(Hash)
      end

      it { expect(subject.keys).to include('Post') }
      it { expect(subject['Post'].size).to eq(1) }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ecm_tags-2.2.1 spec/models/ecm/tags/tag_search_spec.rb
ecm_tags-2.2.0 spec/models/ecm/tags/tag_search_spec.rb