Sha256: 25cbc335c3615ff6aa7789ef1b5522eceaea86ac38996900d385642da94771ed

Contents?: true

Size: 1.47 KB

Versions: 11

Compression:

Stored size: 1.47 KB

Contents

# frozen_string_literal: true

require 'test_helper'

module Vedeu

  module Templating

    describe Template do

      let(:described) { Vedeu::Templating::Template }
      let(:instance)  { described.new(object, path) }
      let(:object)    {}
      let(:path)      {}

      describe '#initialize' do
        it { instance.must_be_instance_of(described) }
        it { instance.instance_variable_get('@object').must_equal(object) }
        it { instance.instance_variable_get('@path').must_equal('') }
      end

      describe '.parse' do
        subject { described.parse(object, path) }

        context 'when the path is empty' do
          let(:path) { '' }

          it { proc { subject }.must_raise(Vedeu::Error::MissingRequired) }
        end

        context 'when the path is does not exist' do
          let(:path) { Dir.tmpdir + '/vedeu_does_not_exist' }

          before { File.stubs(:exist?).returns(false) }

          it { proc { subject }.must_raise(Vedeu::Error::MissingRequired) }
        end

        context 'when the path exists' do
          let(:path) { Dir.tmpdir + '/vedeu_exists' }
          let(:expected) { "This is a test.\n" }

          before do
            File.stubs(:exist?).returns(true)
            File.stubs(:read).returns(expected)
          end

          it { subject.must_equal(expected) }
        end
      end

      describe '#parse' do
        it { instance.must_respond_to(:parse) }
      end

    end # Templating

  end # Template

end # Vedeu

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
vedeu-0.8.32 test/lib/vedeu/templating/template_test.rb
vedeu-0.8.31 test/lib/vedeu/templating/template_test.rb
vedeu-0.8.30 test/lib/vedeu/templating/template_test.rb
vedeu-0.8.29 test/lib/vedeu/templating/template_test.rb
vedeu-0.8.28 test/lib/vedeu/templating/template_test.rb
vedeu-0.8.27 test/lib/vedeu/templating/template_test.rb
vedeu-0.8.26 test/lib/vedeu/templating/template_test.rb
vedeu-0.8.25 test/lib/vedeu/templating/template_test.rb
vedeu-0.8.24 test/lib/vedeu/templating/template_test.rb
vedeu-0.8.23 test/lib/vedeu/templating/template_test.rb
vedeu-0.8.22 test/lib/vedeu/templating/template_test.rb