Sha256: 9317a962bd3815089cae7f938201cad0875326d311f11d86c68dc4fc4e722f84

Contents?: true

Size: 824 Bytes

Versions: 12

Compression:

Stored size: 824 Bytes

Contents

require 'spec_helper'
module WLang
  describe Source, "template_content" do
    
    subject{ Source.new(source).template_content }

    context 'on a pure string' do
      let(:source){ "Hello world!" }
      it{ should eq(source) }
    end

    context 'on a Path' do
      let(:source){ hello_path }
      it{ should eq(hello_path.read) }
    end

    context 'on a File' do
      let(:source){ File.open(Path.here.to_s) }
      it{ should eq(File.read(__FILE__)) }
    end

    it 'also works on an IO' do
      hello_io do |io|
        Source.new(io).template_content.should eq(hello_path.read)
      end
    end

    it 'is aliased as to_s' do
      Source.new("raw text").to_s.should eq("raw text")
    end

    it 'is aliased as to_str' do
      Source.new("raw text").to_str.should eq("raw text")
    end

  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
wlang-2.3.1 spec/unit/source/test_template_content.rb
wlang-2.3.0 spec/unit/source/test_template_content.rb
wlang-2.2.4 spec/unit/source/test_template_content.rb
wlang-2.2.3 spec/unit/source/test_template_content.rb
wlang-2.2.2 spec/unit/source/test_template_content.rb
wlang-2.2.1 spec/unit/source/test_template_content.rb
wlang-2.2.0 spec/unit/source/test_template_content.rb
wlang-2.1.2 spec/unit/source/test_template_content.rb
wlang-2.1.1 spec/unit/source/test_template_content.rb
wlang-2.1.0 spec/unit/source/test_template_content.rb
wlang-2.0.1 spec/unit/source/test_template_content.rb
wlang-2.0.0 spec/unit/source/test_template_content.rb