Sha256: b35bfab01570ed6065577cf1aa51b71c1caee9fbe02a3a6c0295992e995fc583

Contents?: true

Size: 1.18 KB

Versions: 14

Compression:

Stored size: 1.18 KB

Contents

require 'spec_helper'

describe RubyReportable::Sandbox do

  context "a sandbox" do
    before do
      @sandbox = RubyReportable::Sandbox.new(:source => [1, 2])
    end

    it "should create new methods based on options" do
      RubyReportable::Sandbox.new.respond_to?(:source).should == false
      @sandbox.respond_to?(:source).should == true
    end

    it "should store the value of a defined call" do
      @sandbox.source.should == [1, 2]
      @sandbox[:source].should == [1, 2]
    end

    it "should not call a method when trying to retrieve the stored value directly" do
      @sandbox[:source].should == nil
    end

    it "should be able to define a new method with value dynamically" do
      @sandbox.define(:arbitrary, proc { Time.now })
      @sandbox.respond_to?(:arbitrary).should == true
    end

    it "should not override a stored value with a method call" do
      @sandbox[:source] = [3, 4]
      @sandbox.source.should == [3, 4]
    end

    it "should allow you to build up a stored value" do
      @sandbox[:source] = [1, 2, 3, 4, 5, 6, 7, 8, 9]
      @sandbox.build(:source, proc { source.select(&:odd?) })

      @sandbox[:source].should == [1, 3, 5, 7, 9]
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
ruby_reportable-0.5.1 spec/sandbox_spec.rb
ruby_reportable-0.5.0 spec/sandbox_spec.rb
ruby_reportable-0.4.3 spec/sandbox_spec.rb
ruby_reportable-0.4.2 spec/sandbox_spec.rb
ruby_reportable-0.4.1 spec/sandbox_spec.rb
ruby_reportable-0.4.0 spec/sandbox_spec.rb
ruby_reportable-0.3.1 spec/sandbox_spec.rb
ruby_reportable-0.3.0 spec/sandbox_spec.rb
ruby_reportable-0.2.0 spec/sandbox_spec.rb
ruby_reportable-0.1.3.1 spec/sandbox_spec.rb
ruby_reportable-0.1.3 spec/sandbox_spec.rb
ruby_reportable-0.1.2 spec/sandbox_spec.rb
ruby_reportable-0.1.1 spec/sandbox_spec.rb
ruby_reportable-0.1.0 spec/sandbox_spec.rb