Sha256: d5b8e41ca376a7d7b2062693334a2ee953842de936ff8c248f32f22300e5b1c2

Contents?: true

Size: 1.53 KB

Versions: 2

Compression:

Stored size: 1.53 KB

Contents

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

describe Strategies::IsEqual do
  let(:data) { %w{ a } }
  let(:keywords_overlap) { %w{ a } }
  let(:keywords_no_overlap) { %w{ d } }

  it "fails if keywords are empty" do
    sample = SampleDouble.new(data,[])
    comparator = Strategies::IsEqual.new(sample)
    expect(comparator.success?).to eq(false)
  end

  it "fails if data is empty" do
    sample = SampleDouble.new([],keywords_no_overlap)
    comparator = Strategies::IsEqual.new(sample)
    expect(comparator.success?).to eq(false)
  end

  it "is successfull if both keywords and data are empty" do
    sample = SampleDouble.new([],[])
    comparator = Strategies::IsEqual.new(sample)
    expect(comparator.success?).to eq(true)
  end

  it "is successfull if data and keywords are equal" do
    sample = SampleDouble.new(data,keywords_overlap)
    comparator = Strategies::IsEqual.new(sample)
    expect(comparator.success?).to eq(true)
  end

  it "fails if data and keywords are different" do
    sample = SampleDouble.new(data,keywords_no_overlap)
    comparator = Strategies::IsEqual.new(sample)
    expect(comparator.success?).to eq(false)
  end

  #tested at this point for all classes
  it "displays a warning if an exception is defined (is not supported by this strategy)" do
    needed_msg = "Exceptions are not supported by this strategy.\n" 
    sample = SampleDouble.new(data,keywords_no_overlap,%w{a})

    msg = capture(:stderr) do
      Strategies::IsEqual.new(sample)
    end

    expect(msg).to eq(needed_msg)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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