Sha256: 930dd5e89caafcee801bc36b84cc6ec668d31ee39f7da9a4464b85aaa6bd0c00

Contents?: true

Size: 1.51 KB

Versions: 2

Compression:

Stored size: 1.51 KB

Contents

require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
require 'benchmark'
require 'active_support' # for Symbol#to_proc

module DependencySpec
  describe Erector::Dependency do
    it "can be constructed with type and text" do
      x = Erector::Dependency.new(:foo, "abc")
      x.type.should == :foo
      x.text.should == "abc"
      x.options.should == {}
    end

    it "can be constructed with type, text, and options" do
      x = Erector::Dependency.new(:foo, "abc", {:bar => 7})
      x.options.should == {:bar => 7}
    end

    it "can be constructed with a file" do
      file = File.new("#{File.dirname(__FILE__)}/sample-file.txt")
      x = Erector::Dependency.new(:foo, file)
      x.text.should == "sample file contents, 2 + 2 = \#{2 + 2}\n"
    end

    it "can be constructed with a file and interpolate the text" do
      file = File.new("#{File.dirname(__FILE__)}/sample-file.txt")
      x = Erector::Dependency.new(:foo, file, :interpolate => true)
      x.text.should == "sample file contents, 2 + 2 = 4\n"
    end

    it "is equal to an identical external" do
      x = Erector::Dependency.new(:foo, "abc", {:bar => 7})
      y = Erector::Dependency.new(:foo, "abc", {:bar => 7})
      x.should == y
      [x].should include(y)
    end

    it "is not equal to an otherwise identical external with different options" do
      x = Erector::Dependency.new(:foo, "abc")
      y = Erector::Dependency.new(:foo, "abc", {:bar => 7})
      x.should_not == y
      [x].should_not include(y)
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
erector-0.8.1 spec/erector/dependency_spec.rb
erector-0.8.0 spec/erector/dependency_spec.rb