Skip to content

Commit

Permalink
more rdoc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dchelimsky committed Nov 6, 2011
1 parent ef11f68 commit 1959d05
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 28 deletions.
1 change: 1 addition & 0 deletions lib/rspec/core/example.rb
Expand Up @@ -132,6 +132,7 @@ def fail_with_exception(reporter, exception)
finish(reporter)
end

# @api private
def any_apply?(filters)
metadata.any_apply?(filters)
end
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/core/example_group.rb
Expand Up @@ -309,10 +309,12 @@ def self.run_examples(reporter)
end.all?
end

# @api private
def self.any_apply?(filters)
metadata.any_apply?(filters)
end

# @api private
def self.all_apply?(filters)
metadata.all_apply?(filters)
end
Expand Down
1 change: 1 addition & 0 deletions lib/rspec/core/let.rb
Expand Up @@ -86,6 +86,7 @@ def let!(name, &block)
end

module InstanceMethods
private
def __memoized
@__memoized ||= {}
end
Expand Down
23 changes: 20 additions & 3 deletions lib/rspec/core/metadata.rb
Expand Up @@ -2,9 +2,11 @@ module RSpec
module Core
class Metadata < Hash

# Used to extend metadata Hashes to support lazy evaluation of locations
# and descriptions.
module MetadataHash

# Supports lazy evaluation of some values. Extended by
# ExampleMetadataHash and GroupMetadataHash, which get mixed in to
# Metadata for ExampleGroups and Examples (respectively).
def [](key)
return super if has_key?(key)
case key
Expand Down Expand Up @@ -58,9 +60,19 @@ def build_description_from(*parts)
end
end

# Mixed in to Metadata for an Example (extends MetadataHash) to support
# lazy evaluation of some values.
module ExampleMetadataHash
include MetadataHash
end

# Mixed in to Metadata for an ExampleGroup (extends MetadataHash) to
# support lazy evaluation of some values.
module GroupMetadataHash
include MetadataHash

private

def described_class_for(*)
ancestors.each do |g|
return g[:describes] if g.has_key?(:describes)
Expand Down Expand Up @@ -105,6 +117,7 @@ def initialize(parent_group_metadata=nil)
yield self if block_given?
end

# @api private
def process(*args)
user_metadata = args.last.is_a?(Hash) ? args.pop : {}
ensure_valid_keys(user_metadata)
Expand All @@ -115,18 +128,22 @@ def process(*args)
update(user_metadata)
end

# @api private
def for_example(description, user_metadata)
dup.extend(MetadataHash).configure_for_example(description, user_metadata)
dup.extend(ExampleMetadataHash).configure_for_example(description, user_metadata)
end

# @api private
def any_apply?(filters)
filters.any? {|k,v| filter_applies?(k,v)}
end

# @api private
def all_apply?(filters)
filters.all? {|k,v| filter_applies?(k,v)}
end

# @api private
def filter_applies?(key, value, metadata=self)
case value
when Hash
Expand Down
34 changes: 9 additions & 25 deletions lib/rspec/core/rake_task.rb
Expand Up @@ -20,39 +20,26 @@ class RakeTask < ::Rake::TaskLib
# 'spec/**/*_spec.rb'
attr_accessor :pattern

# Deprecated and has no effect. The rake task now checks
# ENV['BUNDLE_GEMFILE'] instead.
#
# By default, if there is a Gemfile, the generated command will include
# 'bundle exec'. Set this to true to ignore the presence of a Gemfile, and
# not add 'bundle exec' to the command.
#
# default:
# false
# @deprecated
# Has no effect. The rake task now checks ENV['BUNDLE_GEMFILE'] instead.
def skip_bundler=(*)
RSpec.deprecate("RSpec::Core::RakeTask#skip_bundler=")
end

# Deprecated and has no effect. The rake task now checks
# ENV['BUNDLE_GEMFILE'] instead.
#
# Name of Gemfile to use.
#
# default:
# Gemfile
# @deprecated
# Has no effect. The rake task now checks ENV['BUNDLE_GEMFILE'] instead.
def gemfile=(*)
RSpec.deprecate("RSpec::Core::RakeTask#gemfile=", 'ENV["BUNDLE_GEMFILE"]')
end

# Deprecated. Use ruby_opts="-w" instead.
# @deprecated
# Use ruby_opts="-w" instead.
#
# When true, requests that the specs be run with the warning flag set.
# e.g. "ruby -w"
#
# default:
# false
attr_reader :warning

def warning=(true_or_false)
RSpec.deprecate("RSpec::Core::RakeTask#warning=", 'ruby_opts="-w"')
@warning = true_or_false
Expand Down Expand Up @@ -110,7 +97,8 @@ def warning=(true_or_false)
# nil
attr_accessor :rspec_opts

# Deprecated. Use rspec_opts instead.
# @deprecated
# Use rspec_opts instead.
#
# Command line options to pass to rspec.
#
Expand Down Expand Up @@ -167,7 +155,7 @@ def spec_command
cmd_parts = []
cmd_parts << RUBY
cmd_parts << ruby_opts
cmd_parts << "-w" if warning?
cmd_parts << "-w" if @warning
cmd_parts << "-S"
cmd_parts << runner
if rcov
Expand All @@ -189,10 +177,6 @@ def runner
rcov ? rcov_path : rspec_path
end

def warning?
warning
end

def blank
lambda {|s| s == ""}
end
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/core/shared_context.rb
Expand Up @@ -21,6 +21,8 @@ def describe(name, *args, &block)

alias_method :context, :describe

private

def _nested_group_declarations
@_nested_group_declarations ||= []
end
Expand Down

0 comments on commit 1959d05

Please sign in to comment.