Sha256: f3999c77de1605a8df08f3dc1f11e4ab2f39eeca1dab7e7dfd2e1575fb027d3a

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

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

module RandomText
  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)
      @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 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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
random_text-0.0.5 spec/random_text/random_string_spec.rb
random_text-0.0.3 spec/random_text/random_string_spec.rb