Sha256: bcc2e9ce946998020b433f2d9f7a727fd91e63ba50e9dddef4c29488f5b3f85c

Contents?: true

Size: 1.72 KB

Versions: 2

Compression:

Stored size: 1.72 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'

describe "Object" do
  it "should respond to to_os" do
    Object.new.respond_to?(:to_os).should == true
  end
  describe "methodable object" do
    before(:each) do
      @obj.stub!(:run).and_return "true"
    end
    it "should run the method :run because it exists" do
      @obj.send_if_method(:run).should == "true"
    end
    it "should not run the method :bah because it doesn't exist" do
      @obj.send_if_method("bah").should == "bah"
    end
    it "should not run the method if it is sent nil" do
      @obj.send_if_method(nil).should == nil
    end
    it "should not run an empty string method" do
      @obj.send_if_method("").should == ""
    end
    it "should not run a method that is an integer" do
      @obj.send_if_method(2).should == 2
    end
  end
  describe "with_options" do
    before(:each) do
      @obj = Class.new
    end
    it "should respond to with_options" do
      @obj.respond_to?(:with_options).should == true
    end
    it "should set the options on the parent" do
      allow_message_expectations_on_nil
      @a.should_receive(:clone).and_return @a
      @a.stub!(:options).and_return({})
      with_options({:nick => "name"}, @a) do
      end
    end
    
    describe "running" do
      before(:each) do
        Class.stub!(:default_options).and_return({})
        Class.send :include, Configurable
        Class.send :include, MethodMissingSugar
        @a = Class.new        
        @b = Class.new
        
        with_options({:nick => "name", :b => @b}, @a) do
          b.dude "totally"
        end
        
      end
      it "should set the options on the child in the instance eval" do
        @b.dude.should == "totally"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
auser-poolparty-0.2.20 spec/poolparty/core/object_spec.rb
auser-poolparty-0.2.21 spec/poolparty/core/object_spec.rb