Sha256: 3f5746d2cc629fafcd9539c2c13d5ee790e6ebae3410d2b38ce2a3ebb14ddaa4

Contents?: true

Size: 1009 Bytes

Versions: 21

Compression:

Stored size: 1009 Bytes

Contents

require 'test_helper'
include StoryGenerator

class StoryGeneratorTest < ActiveSupport::TestCase
  
  context "The Story Generator" do
    setup do
      d = 'A product called "onion chutney"'
      @pc = Precondition.make(:description => d)
    end
    
    context "regexp method" do
      should "replace any quoted string with a regular expression" do
        assert_equal "/^A product called \"([^\\\"]*)\"$/", regexp('A product called "onion chutney"')
      end
    end
    
    context "variables method" do
      
      setup do
        @string = Precondition.make.description
        @longer_string = Precondition.make(:longer).description
      end
      
      should "build an array of variables" do
        assert_equal ['onion chutney'], variables("And a product \"onion chutney\"")
      end
      
      should "know how many variables it has in quotes" do
        assert_equal 1, variables(@string).size
        assert_equal 2, variables(@longer_string).size
      end
    end
  end
  
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
branston-0.6.6 lib/branston/test/unit/story_generator_test.rb
branston-0.6.5 lib/branston/test/unit/story_generator_test.rb
branston-0.6.4 lib/branston/test/unit/story_generator_test.rb
branston-0.6.3 lib/branston/test/unit/story_generator_test.rb
branston-0.6.2 lib/branston/test/unit/story_generator_test.rb
branston-0.6.1 lib/branston/test/unit/story_generator_test.rb
branston-0.6.0 lib/branston/test/unit/story_generator_test.rb
branston-0.5.2 lib/branston/test/unit/story_generator_test.rb
branston-0.5.1 lib/branston/test/unit/story_generator_test.rb
branston-0.5.0 lib/branston/test/unit/story_generator_test.rb
branston-0.4.6 lib/branston/test/unit/story_generator_test.rb
branston-0.4.5 lib/branston/test/unit/story_generator_test.rb
branston-0.4.4 lib/branston/test/unit/story_generator_test.rb
branston-0.4.3 lib/branston/test/unit/story_generator_test.rb
branston-0.4.2 lib/branston/test/unit/story_generator_test.rb
branston-0.4.1 lib/branston/test/unit/story_generator_test.rb
branston-0.4.0 lib/branston/test/unit/story_generator_test.rb
branston-0.3.6 lib/branston/test/unit/story_generator_test.rb
branston-0.3.4 lib/branston/test/unit/story_generator_test.rb
branston-0.3.3 lib/branston/test/unit/story_generator_test.rb