Sha256: 9ef68fe89ea27eb108e316e2d485aaf5995b32b69cd2602efd77853f4a6c772d

Contents?: true

Size: 1.54 KB

Versions: 19

Compression:

Stored size: 1.54 KB

Contents

require 'spec_helper'
require 'ronin/templates/template'

require 'templates/classes/example_template'
require 'templates/helpers/data'

describe Templates::Template do
  let(:example_template) { File.join(Helpers::TEMPLATE_DIR,'templates','example.erb') }
  let(:relative_template) { File.join(Helpers::TEMPLATE_DIR,'includes','_relative.erb') }

  subject { ExampleTemplate.new }

  it "should return the result of the block when entering a template" do
    subject.enter_example_template { |path|
      'result'
    }.should == 'result'
  end

  it "should be able to find templates relative to the current one" do
    subject.enter_example_template do |path|
      path.should == example_template
    end
  end

  it "should be able to find static templates" do
    subject.enter_relative_template do |path|
      path.should == relative_template
    end
  end

  it "should raise a RuntimeError when entering an unknown template" do
    lambda {
      subject.enter_missing_template { |path| }
    }.should raise_error(RuntimeError)
  end

  it "should be able to read templates relative to the current one" do
    subject.read_example_template do |contents|
      contents.should == File.read(example_template)
    end
  end

  it "should be able to find static templates" do
    subject.read_relative_template do |contents|
      contents.should == File.read(relative_template)
    end
  end

  it "should raise a RuntimeError when entering an unknown template" do
    lambda {
      subject.read_missing_template { |path| }
    }.should raise_error(RuntimeError)
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
ronin-support-0.5.1 spec/templates/template_spec.rb
ronin-support-0.5.0 spec/templates/template_spec.rb
ronin-support-0.5.0.rc2 spec/templates/template_spec.rb
ronin-support-0.5.0.rc1 spec/templates/template_spec.rb
ronin-support-0.4.1 spec/templates/template_spec.rb
ronin-support-0.4.0 spec/templates/template_spec.rb
ronin-support-0.4.0.rc2 spec/templates/template_spec.rb
ronin-support-0.4.0.rc1 spec/templates/template_spec.rb
ronin-support-0.3.0 spec/templates/template_spec.rb
ronin-support-0.2.0 spec/templates/template_spec.rb
ronin-support-0.2.0.rc2 spec/templates/template_spec.rb
ronin-support-0.2.0.rc1 spec/templates/template_spec.rb
ronin-support-0.1.0 spec/templates/template_spec.rb
ronin-support-0.1.0.rc3 spec/templates/template_spec.rb
ronin-support-0.1.0.rc2 spec/templates/template_spec.rb
ronin-support-0.1.0.rc1 spec/templates/template_spec.rb
ronin-support-0.1.0.pre3 spec/templates/template_spec.rb
ronin-support-0.1.0.pre2 spec/templates/template_spec.rb
ronin-support-0.1.0.pre1 spec/templates/template_spec.rb