Skip to content

Commit

Permalink
define subscriptions before other files are required
Browse files Browse the repository at this point in the history
  • Loading branch information
dchelimsky committed Jun 20, 2010
1 parent ea9c049 commit a918526
Showing 1 changed file with 54 additions and 56 deletions.
110 changes: 54 additions & 56 deletions lib/rspec/core.rb
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
require 'rspec/core/kernel_extensions'
require 'rspec/core/object_extensions'
require 'rspec/core/load_path'
require 'rspec/core/deprecation'
require 'rspec/core/formatters'
module RSpec
class << self
def subscriptions
@subscriptions ||= Hash.new {|h,k| h[k] = []}
end

require 'rspec/core/hooks'
require 'rspec/core/subject'
require 'rspec/core/let'
require 'rspec/core/metadata'
require 'rspec/core/pending'
# Supported events:
# example_group_started
# example_started
# example_initialized
# example_executed
# example_finished
def subscribe(event, &callback)
subscriptions[event] << callback
end

require 'rspec/core/around_proxy'
require 'rspec/core/world'
require 'rspec/core/notifier'
require 'rspec/core/configuration'
require 'rspec/core/option_parser'
require 'rspec/core/configuration_options'
require 'rspec/core/command_line'
require 'rspec/core/drb_command_line'
require 'rspec/core/runner'
require 'rspec/core/example'
require 'rspec/core/shared_example_group'
require 'rspec/core/example_group'
require 'rspec/core/version'
require 'rspec/core/errors'
def publish(event, *args)
subscriptions[event].each {|callback| callback.call(*args)}
end
def world
@world ||= RSpec::Core::World.new
end

module RSpec
module Core
def configuration
@configuration ||= RSpec::Core::Configuration.new
end

def configure
yield configuration if block_given?
end
end

module Core
def self.install_directory
@install_directory ||= File.expand_path(File.dirname(__FILE__))
end
Expand All @@ -46,40 +49,35 @@ def self.world
RSpec.deprecate('RSpec::Core.world', 'RSpec.world', '2.0.0')
RSpec.world
end

end

def self.world
@world ||= RSpec::Core::World.new
end

def self.configuration
@configuration ||= RSpec::Core::Configuration.new
end

def self.configure
yield configuration if block_given?
end

def self.subscriptions
@subscriptions ||= Hash.new {|h,k| h[k] = []}
end
end

# Supported events:
# example_group_started
# example_started
# example_initialized
# example_executed
# example_finished
def self.subscribe(event, &callback)
subscriptions[event] << callback
end
require 'rspec/core/kernel_extensions'
require 'rspec/core/object_extensions'
require 'rspec/core/load_path'
require 'rspec/core/deprecation'
require 'rspec/core/formatters'

def self.publish(event, *args)
subscriptions[event].each {|callback| callback.call(*args)}
end
end
require 'rspec/core/hooks'
require 'rspec/core/subject'
require 'rspec/core/let'
require 'rspec/core/metadata'
require 'rspec/core/pending'

require 'rspec/core/around_proxy'
require 'rspec/core/world'
require 'rspec/core/notifier'
require 'rspec/core/configuration'
require 'rspec/core/option_parser'
require 'rspec/core/configuration_options'
require 'rspec/core/command_line'
require 'rspec/core/drb_command_line'
require 'rspec/core/runner'
require 'rspec/core/example'
require 'rspec/core/shared_example_group'
require 'rspec/core/example_group'
require 'rspec/core/version'
require 'rspec/core/errors'
require 'rspec/core/backward_compatibility'

# TODO - make this configurable with default 'on'
Expand Down

0 comments on commit a918526

Please sign in to comment.