Sha256: ae5c78f09199b74f76437d8a6e238f05132d99bb1827ebde1cecaa4fbb95c962

Contents?: true

Size: 891 Bytes

Versions: 6

Compression:

Stored size: 891 Bytes

Contents

require 'spec_helper'
require 'wordlist/modifiers/mutate'

describe Wordlist::Modifiers::Mutate do
  let(:wordlist) { %w[foo bar] }

  let(:pattern) { /[oa]/ }
  let(:replace) { {'o' => '0', 'a' => '@'} }

  subject { described_class.new(wordlist,pattern,replace) }

  describe "#each" do
    let(:expected_words) do
      %w[
        foo
        f0o
        fo0
        f00
        bar
        b@r
      ]
    end

    context "when given a block" do
      it "must enumerate through every possible string substitution combination" 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 object for #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/modifiers/mutate_spec.rb
wordlist-1.1.0 spec/modifiers/mutate_spec.rb
wordlist-1.0.3 spec/modifiers/mutate_spec.rb
wordlist-1.0.2 spec/modifiers/mutate_spec.rb
wordlist-1.0.1 spec/modifiers/mutate_spec.rb
wordlist-1.0.0 spec/modifiers/mutate_spec.rb