Sha256: f19cdbb96853c4fce7f01135305be6dca11991e8e20c4a6feb6e498beb8a3aa7

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

require "spec_helper"

describe Machined::Helpers::LocalsHelpers do
  describe "#locals=" do
    it "sets psuedo local variables" do
      with_context do |context, output|
        context.locals = { :title => "Hello World", :body => nil }
        context.title.should == "Hello World"
        context.body.should be_nil
      end
    end
    
    it "responds_to the local variable name" do
      with_context do |context, output|
        context.locals = { :title => "Hello World", :body => nil }
        context.respond_to?(:title).should be_true
        context.respond_to?(:body).should be_true
      end
    end
    
    it "still raises errors if the method doesn't exist" do
      with_context do |context, output|
        expect { context.not_a_local }.to raise_error(NoMethodError)
        context.respond_to?(:not_a_local).should be_false
      end
    end
    
    it "clears local variables when set to nil" do
      with_context do |context, output|
        context.locals = { :title => "Hello World" }
        context.locals = nil
        expect { context.title }.to raise_error(NoMethodError)
        context.respond_to?(:title).should be_false
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
machined-0.1.0 spec/machined/helpers/locals_helper_spec.rb