Sha256: de6a46f1b0901d3f9837139516924eb5b3be35c0a74712624a75890c2e3cce6c

Contents?: true

Size: 1.18 KB

Versions: 6

Compression:

Stored size: 1.18 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

6 entries across 6 versions & 1 rubygems

Version Path
troo-0.0.7 test/lib/troo/presentation/template_test.rb
troo-0.0.6 test/lib/troo/presentation/template_test.rb
troo-0.0.5 test/lib/troo/presentation/template_test.rb
troo-0.0.4 test/lib/troo/presentation/template_test.rb
troo-0.0.3 test/lib/troo/presentation/template_test.rb
troo-0.0.2 test/lib/troo/presentation/template_test.rb