Sha256: e209256aa5eecf697706ac365c858f1f1eef736ab7471f6dace8fd58a15ac10a

Contents?: true

Size: 954 Bytes

Versions: 4

Compression:

Stored size: 954 Bytes

Contents

require 'hashery'
require 'awestruct/handlers/string_handler'
require 'awestruct/handlers/interpolation_handler'

describe Awestruct::Handlers::InterpolationHandler do

  before :all do
    @site = Hashery::OpenCascade[ { :encoding=>false } ]
  end

  it "should interpolate content when rendered" do 
    handler = build_handler( 'This is #{cheese}' )

    context = Hashery::OpenCascade[ { :cheese=>'swiss' } ] 
    content = handler.rendered_content( context )
    content.should == 'This is swiss'
  end

  it "should correctly interpolate complicated stuff that includes regular expressions [Issue #139]" do
    input = %q(url = url.replace(/\/?#$/, '');)
    handler = build_handler( input )
    content = handler.rendered_content( Hashery::OpenCascade[] )
    content.should == input
  end

  def build_handler( input )
    Awestruct::Handlers::InterpolationHandler.new( @site, Awestruct::Handlers::StringHandler.new( @site, input ) )
  end
end


Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
awestruct-0.5.4.rc3 spec/interpolation_handler_spec.rb
awestruct-0.5.4.rc2 spec/interpolation_handler_spec.rb
awestruct-0.5.4.rc spec/interpolation_handler_spec.rb
awestruct-0.5.4.beta1 spec/interpolation_handler_spec.rb