Sha256: 010e614729c739ccbeca0f3ad5c85866ff977193619a7db86d54cef75758c60a

Contents?: true

Size: 1.49 KB

Versions: 2

Compression:

Stored size: 1.49 KB

Contents

require_relative '../spec_helper'
require 'tailor/ruler'

describe Tailor::Ruler do
  before { subject.stub(:log) }

  describe "#add_child_ruler" do
    it "adds new rulers to @child_rulers" do
      ruler = double "Ruler"
      subject.add_child_ruler(ruler)
      subject.instance_variable_get(:@child_rulers).first.should == ruler
    end
  end

  describe "#problems" do
    context "no child_rulers" do
      context "@problems is empty" do
        specify { subject.problems.should be_empty }
      end

      context "@problems.size is 1" do
        before do
          problem = double "Problem"
          problem.should_receive(:[]).with :line
          subject.instance_variable_set(:@problems, [problem])
        end

        specify { subject.problems.size.should == 1 }
      end
    end

    context "child_rulers have problems" do
      before do
        problem = double "Problem"
        problem.should_receive(:[]).with :line
        child_ruler = double "Ruler"
        child_ruler.stub(:problems).and_return([problem])
        subject.instance_variable_set(:@child_rulers, [child_ruler])
      end

      context "@problems is empty" do
        specify { subject.problems.size.should == 1 }
      end

      context "@problems.size is 1" do
        before do
          problem = double "Problem"
          problem.should_receive(:[]).with :line
          subject.instance_variable_set(:@problems, [problem])
        end

        specify { subject.problems.size.should == 2 }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tailor-1.0.0.alpha2 spec/tailor/ruler_spec.rb
tailor-1.0.0.alpha spec/tailor/ruler_spec.rb