Sha256: afd4b18841184f074ecd98418a8ea0bc6695e6a7acc139335b9e0165413d80ad

Contents?: true

Size: 885 Bytes

Versions: 3

Compression:

Stored size: 885 Bytes

Contents

require 'spec_helper'

describe SlowLoadableComponent do

  it "does nothing if component is already loaded" do
    SlowlyDetonatingComponent.new.get.should be_instance_of(SlowlyDetonatingComponent)
  end

  it "calls #load if the component is not already loaded" do
    component = SlowLoading.new.get
    component.should be_instance_of(SlowLoading)

    component.load_called.should be_true
  end

  it "calls the load method once if the component takes a long time to load" do
    OnlyOneLoad.new.get
  end

  it "should throw an error if calling load does not cause the component to load before timeout" do
    lambda { BasicSlowLoader.new(1).get }.should raise_error(LoadableComponent::UnableToLoadComponent, /after 1 seconds/)
  end

  it "should cancel loading if an error is detected" do
    lambda { HasError.new(1).get }.should raise_error(HasError::CustomError)
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
loadable_component-0.1.1 spec/slow_loadable_component_spec.rb
loadable_component-0.1.0 spec/slow_loadable_component_spec.rb
loadable_component-0.0.3 spec/slow_loadable_component_spec.rb