Hash
# File lib/rspec/core/metadata.rb, line 5 def initialize(superclass_metadata=nil) @superclass_metadata = superclass_metadata if @superclass_metadata update(@superclass_metadata) example_group = {:example_group => @superclass_metadata[:example_group]} end store(:example_group, example_group || {}) yield self if block_given? end
# File lib/rspec/core/metadata.rb, line 76 def all_apply?(filters) filters.all? do |key, value| apply_condition(key, value) end end
# File lib/rspec/core/metadata.rb, line 91 def apply_condition(key, value, metadata=nil) metadata ||= self case value when Hash value.all? { |k, v| apply_condition(k, v, metadata[key]) } when Regexp metadata[key] =~ value when Proc value.call(metadata[key]) rescue false when Fixnum if key == :line_number relevant_line_numbers(metadata).include?(world.preceding_declaration_line(value)) else metadata[key] == value end else metadata[key] == value end end
# File lib/rspec/core/metadata.rb, line 67 def configure_for_example(description, options) store(:description, description.to_s) store(:full_description, "#{self[:example_group][:full_description]} #{self[:description]}") store(:execution_result, {}) self[:file_path], self[:line_number] = file_and_line_number_from(caller) self[:location] = location_from(self) update(options) end
# File lib/rspec/core/metadata.rb, line 41 def ensure_valid_keys(user_metadata) RESERVED_KEYS.each do |key| if user_metadata.keys.include?(key) raise #{"*"*50}:#{key} is not allowedRSpec reserves some hash keys for its own internal use,including :#{key}, which is used on: #{caller(0)[4]}.Here are all of RSpec's reserved hash keys: #{RESERVED_KEYS.join("\n ")}#{"*"*50} raise ":#{key} is not allowed" end end end
# File lib/rspec/core/metadata.rb, line 63 def for_example(description, options) dup.configure_for_example(description,options) end
# File lib/rspec/core/metadata.rb, line 26 def process(*args) user_metadata = args.last.is_a?(Hash) ? args.pop : {} ensure_valid_keys(user_metadata) self[:example_group][:describes] = described_class_from(*args) self[:example_group][:description] = description_from(*args) self[:example_group][:full_description] = full_description_from(*args) self[:example_group][:block] = user_metadata.delete(:example_group_block) self[:example_group][:file_path], self[:example_group][:line_number] = file_and_line_number_from(caller) self[:example_group][:location] = location_from(self[:example_group]) update(user_metadata) end
Generated with the Darkfish Rdoc Generator 2.