Sha256: 5532929f9dd30575e9673a365357121ce73f184de960306f1626c593c790bda1

Contents?: true

Size: 1.63 KB

Versions: 6

Compression:

Stored size: 1.63 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper.rb'

RandomStrings = RandomText::RandomStrings
describe RandomStrings do
  before :each do
    @words = %w(Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua lol)
    @random_words = RandomStrings.new(@words)
  end

  it "should be equal to initialization array" do
    @random_words.should == @words
  end

  describe "with get" do
    it "should return word" do
      @random_words.get.should =~ /^\w+$/
    end
  end

  describe "with get(n)" do
    it "should return words" do
      @random_words.get(10).all?{ |w| w.should =~ /^\w+$/ }
    end

    it "should return n words" do
      @random_words.get(10).length.should == 10
    end
  end

  describe "with get(:all)" do
    it "should return words" do
      @random_words.get(:all).all?{ |w| w.should =~ /^\w+$/ }
    end

    it "should return all words" do
      @random_words.get(:all).sort.should == @words.sort
    end

    it "should return shuffled words" do
      @random_words.get(:all).should_not == @random_words.get(:all)
    end
  end

  describe "with uniq(n)" do
    it "should return words" do
      @random_words.uniq(10).all?{ |w| w.should =~ /^\w+$/ }
    end

    it "should return n words" do
      @random_words.uniq(10).length.should == 10
    end

    it "should return n uniq words" do
      @random_words.uniq(10).uniq.length.should == 10
    end
  end

  describe "with uniq(:all)" do
    it "should call get(:all)" do
      @random_words.should_receive(:get).with(:all).and_return(:uniq_words)
      @random_words.uniq(:all).should == :uniq_words
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
random_text-1.1.0 spec/random_text/random_string_spec.rb
random_text-1.0.2.2 spec/random_text/random_string_spec.rb
random_text-1.0.2.1 spec/random_text/random_string_spec.rb
random_text-1.0.2 spec/random_text/random_string_spec.rb
random_text-1.0.1 spec/random_text/random_string_spec.rb
random_text-1.0.0 spec/random_text/random_string_spec.rb