Sha256: 15b9067d357c433a585af3f1df79386845e463bf7448c685e305d63f23b043c2

Contents?: true

Size: 1.43 KB

Versions: 31

Compression:

Stored size: 1.43 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper'
require 'cucumber/ast/py_string'

module Cucumber
  module Ast
    describe PyString do
      it "should handle unindented" do
        ps = PyString.new(10, 13, "4.1\n4.2\n", 0)
        ps.to_s.should == "4.1\n4.2\n"
      end

      it "should handle indented" do
        #                    """
        ps = PyString.new(10, 13, "     4.1\n   4.2\n", 2)
        ps.to_s.should == "   4.1\n 4.2\n"
      end
      
      describe "replacing arguments" do

        before(:each) do
          @ps = PyString.new(10, 13, "<book>\n<qty>\n", 0)
        end
      
        it "should return a new py_string with arguments replaced with values" do
          py_string_with_replaced_arg = @ps.arguments_replaced({'<book>' => 'Life is elsewhere', '<qty>' => '5'})
                
          py_string_with_replaced_arg.to_s.should == "Life is elsewhere\n5\n"
        end
        
        it "should not change the original py_string" do
          py_string_with_replaced_arg = @ps.arguments_replaced({'<book>' => 'Life is elsewhere'})
          
          @ps.to_s.should_not include("Life is elsewhere")
        end

        it "should replaced nil with empty string" do
          ps = PyString.new(10, 13, "'<book>'", 0)
          py_string_with_replaced_arg = ps.arguments_replaced({'<book>' => nil}) 
          
          py_string_with_replaced_arg.to_s.should == "''"
        end

      end
      
    end
  end
end

Version data entries

31 entries across 31 versions & 5 rubygems

Version Path
aslakhellesoy-cucumber-0.1.100.4 spec/cucumber/ast/py_string_spec.rb
aslakhellesoy-cucumber-0.1.100.5 spec/cucumber/ast/py_string_spec.rb
aslakhellesoy-cucumber-0.2.0.1 spec/cucumber/ast/py_string_spec.rb
aslakhellesoy-cucumber-0.2.0.2 spec/cucumber/ast/py_string_spec.rb
aslakhellesoy-cucumber-0.2.0.3 spec/cucumber/ast/py_string_spec.rb
aslakhellesoy-cucumber-0.2.0.4 spec/cucumber/ast/py_string_spec.rb
aslakhellesoy-cucumber-0.2.0 spec/cucumber/ast/py_string_spec.rb
aslakhellesoy-cucumber-0.2.1 spec/cucumber/ast/py_string_spec.rb
aslakhellesoy-cucumber-0.2.2.1 spec/cucumber/ast/py_string_spec.rb
aslakhellesoy-cucumber-0.2.2.2 spec/cucumber/ast/py_string_spec.rb
aslakhellesoy-cucumber-0.2.2 spec/cucumber/ast/py_string_spec.rb
aslakhellesoy-cucumber-0.2.3.1 specs/cucumber/ast/py_string_spec.rb
aslakhellesoy-cucumber-0.2.3.2 spec/cucumber/ast/py_string_spec.rb
aslakhellesoy-cucumber-0.2.3.3 spec/cucumber/ast/py_string_spec.rb
aslakhellesoy-cucumber-0.2.3.4 spec/cucumber/ast/py_string_spec.rb
aslakhellesoy-cucumber-0.2.3 specs/cucumber/ast/py_string_spec.rb
aslakhellesoy-cucumber-0.3.0.1 spec/cucumber/ast/py_string_spec.rb
aslakhellesoy-cucumber-0.3.0 spec/cucumber/ast/py_string_spec.rb
cavalle-cucumber-0.2.3.3.1 spec/cucumber/ast/py_string_spec.rb
cavalle-cucumber-0.2.3.3.2 spec/cucumber/ast/py_string_spec.rb