Sha256: 6ba2e4ae2e382d3c33529b301229a1da19bb55dd8aae6235def8b5c97f89afcf

Contents?: true

Size: 1.34 KB

Versions: 4

Compression:

Stored size: 1.34 KB

Contents

require 'spec_helper'

describe "CallbackDefinitionContainer" do

  it "should successfully load the :simple_before_call example" do
    example = Example.new(:simple_before_call)
    theatre = Theatre::Theatre.new
    example.register_namespaces_on theatre

    flexmock(theatre.namespace_manager).should_receive(:register_callback_at_namespace).
        with([:asterisk, :before_call], Proc).once

    loader  = Theatre::CallbackDefinitionLoader.new(theatre)
    loader.load_events_file example.file
  end

  it "should let you override the recorder method name" do
    theatre = Theatre::Theatre.new
    theatre.namespace_manager.register_namespace_name "/foo/bar/qaz"
    flexmock(theatre.namespace_manager).should_receive(:register_callback_at_namespace).
        with([:foo, :bar, :qaz], Proc).once

    loader = Theatre::CallbackDefinitionLoader.new(theatre, :roflcopter)
    loader.roflcopter.foo.bar.qaz.each {}
  end

end

# High level specs to test the entire library.

describe "Misuses of the Theatre" do

  it "should not allow callbacks to be registered for namespaces which have not been registered" do
    theatre = Theatre::Theatre.new
    example = Example.new(:simple_before_call)

    loader = Theatre::CallbackDefinitionLoader.new(theatre)
    lambda do
      loader.events.foo.each {}
    end.should raise_error(Theatre::NamespaceNotFound)
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
adhearsion-1.1.1 theatre-spec/dsl_spec.rb
adhearsion-1.1.0 theatre-spec/dsl_spec.rb
adhearsion-1.0.3 theatre-spec/dsl_spec.rb
adhearsion-1.0.2 theatre-spec/dsl_spec.rb