Sha256: 0179eb8f2ca725ca579b01379d48c8ce99513f8ea92f811c93fae36b1ab0c06e

Contents?: true

Size: 1008 Bytes

Versions: 6

Compression:

Stored size: 1008 Bytes

Contents

require 'spec_helper'
require 'wordlist/operators/subtract'

describe Wordlist::Operators::Subtract do
  let(:left)  { %w[foo bar] }
  let(:right) { %w[bar baz] }

  subject { described_class.new(left,right) }

  describe "#each" do
    context "when given a block" do
      it "must yield the words which do not exist in other wordlists" do
        expect { |b|
          subject.each(&b)
        }.to yield_successive_args(*(left - right))
      end

      context "when the wordlists do not have any common words" do
        let(:left)  { %w[foo bar] }
        let(:right) { %w[baz qux] }

        it "must yield the left-hand operand's words" do
          expect { |b|
            subject.each(&b)
          }.to yield_successive_args(*left)
        end
      end
    end

    context "when not given a block" do
      it "must return an Enumerator for the #each" do
        expect(subject.each).to be_kind_of(Enumerator)
        expect(subject.each.to_a).to eq(left - right)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
wordlist-1.1.1 spec/operators/subtract_spec.rb
wordlist-1.1.0 spec/operators/subtract_spec.rb
wordlist-1.0.3 spec/operators/subtract_spec.rb
wordlist-1.0.2 spec/operators/subtract_spec.rb
wordlist-1.0.1 spec/operators/subtract_spec.rb
wordlist-1.0.0 spec/operators/subtract_spec.rb