Sha256: b6e965b394bdc6a606e89241b24ce606f9c3ade5380f4af583094c21592038c2

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

require_relative '../../../test_helper'

module Troo
  describe Template do
    let(:described_class) { Template }
    let(:object) { OpenStruct.new(value: 'Hello from variable!') }
    let(:template_path) { '/../../../test/support/template.erb' }

    describe '#initialize' do
      subject { described_class.new(object, template_path) }

      it 'assigns the object to an instance variable' do
        subject.instance_variable_get('@object').must_equal(object)
      end

      it 'assigns the template_path to an instance variable' do
        subject.instance_variable_get('@template_path')
          .must_equal(template_path)
      end
    end

    describe '#parse' do
      subject { described_class.new(object, template_path).parse }

      context 'when the template file can be found' do
        it 'parses the template' do
          subject.must_match(/This is the test template/)
          subject.must_match(/Hello from variable!/)
        end
      end

      context 'when the template file cannot be found' do
        let(:template_path) { '/some/wrong/path/template.erb' }

        it 'raises an exception' do
          proc { subject }.must_raise(Errno::ENOENT)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
troo-0.0.8 test/lib/troo/presentation/template_test.rb