Sha256: ebd6b4f397ecd236bd0d4dfa2646d8f14d720ad2c5ce8bf966d4e4730752bacb

Contents?: true

Size: 1.35 KB

Versions: 5

Compression:

Stored size: 1.35 KB

Contents

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

describe SearchingStrategies::ContainsAnyWithSubstringSearch do
  let(:data) { %w{ ab c e} }
  let(:exceptions) { %w{ b} }
  let(:keywords_overlap) { %w{ a } }
  let(:multiple_overlap) { %w{ a c d} }
  let(:keywords_no_overlap) { %w{ d } }

  it "is successfull when there's a data overlap (at least one element)" do
    sample = SampleDouble.new(data,keywords_overlap)
    comparator = SearchingStrategies::ContainsAnyWithSubstringSearch.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 = SearchingStrategies::ContainsAnyWithSubstringSearch.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 = SearchingStrategies::ContainsAnyWithSubstringSearch.new(sample)
    expect(comparator.success?).to eq(false)
  end

  it "is successfull, if there's a least one match (second match 'c' -> exception -> no match) " do
    sample = SampleDouble.new(data,multiple_overlap, exceptions)
    comparator = SearchingStrategies::ContainsAnyWithSubstringSearch.new(sample)
    expect(comparator.success?).to eq(true)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
the_array_comparator-0.5.0 spec/comparator/contains_any_with_substring_search_spec.rb
the_array_comparator-0.4.0 spec/comparator/contains_any_with_substring_search_spec.rb
the_array_comparator-0.3.4 spec/comparator/contains_any_with_substring_search_spec.rb
the_array_comparator-0.3.1 spec/comparator/contains_any_with_substring_search_spec.rb
the_array_comparator-0.3.0 spec/comparator/contains_any_with_substring_search_spec.rb