Sha256: ec9bb7cb31892321663d78df1fcc5077a564811fe55b1f1b64225805bcc2563c

Contents?: true

Size: 733 Bytes

Versions: 2

Compression:

Stored size: 733 Bytes

Contents

require 'spec_helper'
require 'eff/template'

describe Eff::Template do
  before(:each) do
    @src      = '<%= "#{@name}, I am your father." %>'
    @erb_vars = { name: "Luke" }
  end

  let(:template) { Eff::Template.new @src, @erb_vars }

  describe '#erb_vars=' do
    it 'converts keys to instance variable keys' do
      template.instance_variable_get(:@erb_vars).should eq({ :@name => "Luke"})
    end
  end

  describe '#result' do
    it 'correctly creates the result' do
      template.result.should eq("Luke, I am your father.")
    end

    it 'handles multiple vars' do
      @src = '<%= "#{@name} - #{@age}" %>'
      @erb_vars = { name: "Luke", age: 21 }
      template.result.should eq("Luke - 21")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
eff-0.0.2 spec/eff/template_spec.rb
eff-0.0.1 spec/template_spec.rb