Sha256: 3271772627ef447b3af860e3a739430c6be96dcf30128e61ddcc1ededd8d04ed

Contents?: true

Size: 1.55 KB

Versions: 2

Compression:

Stored size: 1.55 KB

Contents

#enconding: utf-8
require 'spec_helper'
require 'strategies_helper'

describe Strategies::ContainsAllWithSubstringSearch do
  let(:data) { %w{ ab c e} }
  let(:exceptions) { %w{ b } }
  let(:keywords_overlap) { %w{ a } }
  let(:keywords_no_overlap) { %w{ d } }
  let(:multiple_keywords_with_one_no_overlap) { %w{ a b cd } }

  it "is successfull when there's a data overlap" do
    sample = SampleDouble.new(data,keywords_overlap)
    comparator = Strategies::ContainsAllWithSubstringSearch.new(sample)
    expect(comparator.success?).to eq(true)
  end

  it "doesn't find something if there's no overlap" do
    sample = SampleDouble.new(data,keywords_no_overlap)
    comparator = Strategies::ContainsAllWithSubstringSearch.new(sample)
    expect(comparator.success?).to eq(false)
  end

  it "doesn't find something if there's an exception defined" do
    sample = SampleDouble.new(data,keywords_overlap, exceptions)
    comparator = Strategies::ContainsAllWithSubstringSearch.new(sample)
    expect(comparator.success?).to eq(false)
  end

  it "doesn't find something if there's an exception defined" do
    sample = SampleDouble.new(data,multiple_keywords_with_one_no_overlap, exceptions)
    comparator = Strategies::ContainsAllWithSubstringSearch.new(sample)
    expect(comparator.success?).to eq(false)
  end

  it "fails if not all keywords can be found within the data" do
    sample = SampleDouble.new(data,multiple_keywords_with_one_no_overlap)
    comparator = Strategies::ContainsAllWithSubstringSearch.new(sample)
    expect(comparator.success?).to eq(false)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
the_array_comparator-0.2.0 spec/comparator/contains_all_with_substring_search_spec.rb
the_array_comparator-0.1.1 spec/comparator/contains_all_with_substring_search_spec.rb