Sha256: 13ee2dbba35c6348fb49403d91af04c042d416eb6f8ef481fb30cc18c9d0dce9

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 KB

Contents

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

describe Strategies::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 = Strategies::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 = Strategies::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 = Strategies::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 = Strategies::ContainsAnyWithSubstringSearch.new(sample)
    expect(comparator.success?).to eq(true)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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