Sha256: 1a09344d59dd094678c5e700dcb3ed03eebcee34d2360f9a463f8d693ac6504b

Contents?: true

Size: 1010 Bytes

Versions: 6

Compression:

Stored size: 1010 Bytes

Contents

require 'spec_helper'
require 'wordlist/operators/union'

describe Wordlist::Operators::Union 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 from both wordlists, without duplicates" 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 words from both wordlists" do
          expect { |b|
            subject.each(&b)
          }.to yield_successive_args(*(left + right))
        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/union_spec.rb
wordlist-1.1.0 spec/operators/union_spec.rb
wordlist-1.0.3 spec/operators/union_spec.rb
wordlist-1.0.2 spec/operators/union_spec.rb
wordlist-1.0.1 spec/operators/union_spec.rb
wordlist-1.0.0 spec/operators/union_spec.rb