Sha256: dbea6590b34e0c0e442e5c6165e1184c8b0c4e4e337e8d7d0fc36e185304db26

Contents?: true

Size: 873 Bytes

Versions: 6

Compression:

Stored size: 873 Bytes

Contents

require 'spec_helper'
require 'wordlist/operators/product'

describe Wordlist::Operators::Product do
  let(:left)  { %w[foo bar baz qux] }
  let(:right) { %w[abc xyz] }

  subject { described_class.new(left,right) }

  let(:expected_words) do
    %w[
        fooabc
        fooxyz
        barabc
        barxyz
        bazabc
        bazxyz
        quxabc
        quxxyz
    ]
  end

  describe "#each" do
    context "when given a block" do
      it "must yield words from the left-hand wordlist with the right-hand" do
        expect { |b|
          subject.each(&b)
        }.to yield_successive_args(*expected_words)
      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(expected_words)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

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