Sha256: ff1860733cd18e179e8ed1ca77e32b3a982c8d2ffe0950d90a10fea6dc57a839

Contents?: true

Size: 972 Bytes

Versions: 29

Compression:

Stored size: 972 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, interpolate: true } ]
  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

29 entries across 29 versions & 1 rubygems

Version Path
awestruct-0.6.7 spec/awestruct/handlers/interpolation_handler_spec.rb
awestruct-0.6.6 spec/awestruct/handlers/interpolation_handler_spec.rb
awestruct-0.6.5 spec/awestruct/handlers/interpolation_handler_spec.rb
awestruct-0.6.4 spec/awestruct/handlers/interpolation_handler_spec.rb
awestruct-0.6.3 spec/awestruct/handlers/interpolation_handler_spec.rb
awestruct-0.6.2 spec/awestruct/handlers/interpolation_handler_spec.rb
awestruct-0.6.1 spec/awestruct/handlers/interpolation_handler_spec.rb
awestruct-0.6.0 spec/awestruct/handlers/interpolation_handler_spec.rb
awestruct-0.6.0.RC1 spec/awestruct/handlers/interpolation_handler_spec.rb
awestruct-0.6.0.alpha4 spec/awestruct/handlers/interpolation_handler_spec.rb
awestruct-0.6.0.alpha3 spec/awestruct/handlers/interpolation_handler_spec.rb
awestruct-0.6.0.alpha1 spec/awestruct/handlers/interpolation_handler_spec.rb
awestruct-0.5.7 spec/awestruct/handlers/interpolation_handler_spec.rb
awestruct-0.5.7.RC2 spec/awestruct/handlers/interpolation_handler_spec.rb
awestruct-0.5.7.RC1 spec/awestruct/handlers/interpolation_handler_spec.rb
awestruct-0.5.6 spec/awestruct/handlers/interpolation_handler_spec.rb
awestruct-0.5.6.beta9 spec/awestruct/handlers/interpolation_handler_spec.rb
awestruct-0.5.6.beta8 spec/awestruct/handlers/interpolation_handler_spec.rb
awestruct-0.5.6.beta7 spec/awestruct/handlers/interpolation_handler_spec.rb
awestruct-0.5.6.beta6 spec/awestruct/handlers/interpolation_handler_spec.rb