Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

behaviour to example_group

  • Loading branch information...
commit 6b1ff00afd4b79bd4b6136793ddb5ea301643b60 1 parent 12615ba
@dchelimsky dchelimsky authored
View
2  lib/rspec/core.rb
@@ -8,7 +8,7 @@
require 'rspec/core/example'
require 'rspec/core/metadata'
require 'rspec/core/kernel_extensions'
-require 'rspec/core/shared_behaviour'
+require 'rspec/core/shared_example_group'
require 'rspec/core/example_group_subject'
require 'rspec/core/example_group'
require 'rspec/core/formatters'
View
19 lib/rspec/core/example.rb
@@ -2,11 +2,12 @@ module Rspec
module Core
class Example
- attr_reader :behaviour, :metadata, :example_block
+ attr_reader :example_group, :metadata, :example_block
+ alias_method :behaviour, :example_group
- def initialize(behaviour, desc, options, example_block=nil)
- @behaviour, @options, @example_block = behaviour, options, example_block
- @metadata = @behaviour.metadata.for_example(desc, options)
+ def initialize(example_group, desc, options, example_block=nil)
+ @example_group, @options, @example_block = example_group, options, example_block
+ @metadata = @example_group.metadata.for_example(desc, options)
end
def description
@@ -22,7 +23,7 @@ def execution_result
end
def file_path
- @metadata[:file_path] || behaviour.file_path
+ @metadata[:file_path] || example_group.file_path
end
def run_started
@@ -50,11 +51,11 @@ def run_finished(status, results={})
def run_before_each
@example_group_instance._setup_mocks if @example_group_instance.respond_to?(:_setup_mocks)
- @behaviour.eval_before_eachs(@example_group_instance)
+ @example_group.eval_before_eachs(@example_group_instance)
end
def run_after_each
- @behaviour.eval_after_eachs(@example_group_instance)
+ @example_group.eval_after_eachs(@example_group_instance)
@example_group_instance._verify_mocks if @example_group_instance.respond_to?(:_verify_mocks)
ensure
@example_group_instance._teardown_mocks if @example_group_instance.respond_to?(:_teardown_mocks)
@@ -92,10 +93,10 @@ def run(example_group_instance)
begin
run_before_each
- if @behaviour.around_eachs.empty?
+ if @example_group.around_eachs.empty?
@example_group_instance.instance_eval(&example_block) if runnable?
else
- @behaviour.around_eachs.first.call(AroundProxy.new(self, &example_block))
+ @example_group.around_eachs.first.call(AroundProxy.new(self, &example_block))
end
rescue Exception => e
exception_encountered = e
View
54 lib/rspec/core/example_group.rb
@@ -13,7 +13,7 @@ class ExampleGroup
def self.inherited(klass)
super
Rspec::Core.configuration.autorun!
- Rspec::Core.world.behaviours << klass
+ Rspec::Core.world.example_groups << klass
end
def self.extended_modules #:nodoc:
@@ -45,7 +45,7 @@ def self.#{new_alias}(desc=nil, options={}, &block)
alias_example_to :pending, :pending => true
def self.it_should_behave_like(*names)
- Rspec::Core.world.shared_behaviours.each do |name, block|
+ Rspec::Core.world.shared_example_groups.each do |name, block|
module_eval(&block) if names.include?(name)
end
end
@@ -75,11 +75,11 @@ def self.metadata
end
def self.name(friendly=true)
- friendly ? metadata[:behaviour][:name] : super
+ friendly ? metadata[:example_group][:name] : super
end
def self.describes
- metadata[:behaviour][:describes]
+ metadata[:example_group][:describes]
end
def self.described_class
@@ -87,24 +87,24 @@ def self.described_class
end
def self.description
- metadata[:behaviour][:description]
+ metadata[:example_group][:description]
end
def self.file_path
- metadata[:behaviour][:file_path]
+ metadata[:example_group][:file_path]
end
- def self.describe(*args, &behaviour_block)
+ def self.describe(*args, &example_group_block)
raise(ArgumentError, "No arguments given. You must a least supply a type or description") if args.empty?
- raise(ArgumentError, "You must supply a block when calling describe") if behaviour_block.nil?
+ raise(ArgumentError, "You must supply a block when calling describe") if example_group_block.nil?
# TODO: Pull out the below into a metadata object, that we can defer the subclassing if necessary
# describe 'foo', :shared => true will need this to be completed first
subclass('NestedLevel') do
args << {} unless args.last.is_a?(Hash)
- args.last.update(:behaviour_block => behaviour_block, :caller => caller)
+ args.last.update(:example_group_block => example_group_block, :caller => caller)
set_it_up(*args)
- module_eval(&behaviour_block)
+ module_eval(&example_group_block)
end
end
@@ -136,33 +136,33 @@ def self.before_all_ivars
@before_all_ivars ||= {}
end
- def self.eval_before_alls(running_behaviour)
- superclass.before_all_ivars.each { |ivar, val| running_behaviour.instance_variable_set(ivar, val) }
- Rspec::Core.configuration.find_advice(:before, :all, self).each { |blk| running_behaviour.instance_eval(&blk) }
+ def self.eval_before_alls(running_example_group)
+ superclass.before_all_ivars.each { |ivar, val| running_example_group.instance_variable_set(ivar, val) }
+ Rspec::Core.configuration.find_advice(:before, :all, self).each { |blk| running_example_group.instance_eval(&blk) }
- before_alls.each { |blk| running_behaviour.instance_eval(&blk) }
- running_behaviour.instance_variables.each { |ivar| before_all_ivars[ivar] = running_behaviour.instance_variable_get(ivar) }
+ before_alls.each { |blk| running_example_group.instance_eval(&blk) }
+ running_example_group.instance_variables.each { |ivar| before_all_ivars[ivar] = running_example_group.instance_variable_get(ivar) }
end
- def self.eval_before_eachs(running_behaviour)
- Rspec::Core.configuration.find_advice(:before, :each, self).each { |blk| running_behaviour.instance_eval(&blk) }
- before_ancestors.each { |ancestor| ancestor.before_eachs.each { |blk| running_behaviour.instance_eval(&blk) } }
+ def self.eval_before_eachs(running_example_group)
+ Rspec::Core.configuration.find_advice(:before, :each, self).each { |blk| running_example_group.instance_eval(&blk) }
+ before_ancestors.each { |ancestor| ancestor.before_eachs.each { |blk| running_example_group.instance_eval(&blk) } }
end
- def self.eval_after_alls(running_behaviour)
- after_alls.each { |blk| running_behaviour.instance_eval(&blk) }
- Rspec::Core.configuration.find_advice(:after, :all, self).each { |blk| running_behaviour.instance_eval(&blk) }
- before_all_ivars.keys.each { |ivar| before_all_ivars[ivar] = running_behaviour.instance_variable_get(ivar) }
+ def self.eval_after_alls(running_example_group)
+ after_alls.each { |blk| running_example_group.instance_eval(&blk) }
+ Rspec::Core.configuration.find_advice(:after, :all, self).each { |blk| running_example_group.instance_eval(&blk) }
+ before_all_ivars.keys.each { |ivar| before_all_ivars[ivar] = running_example_group.instance_variable_get(ivar) }
end
- def self.eval_after_eachs(running_behaviour)
- after_ancestors.each { |ancestor| ancestor.after_eachs.each { |blk| running_behaviour.instance_eval(&blk) } }
- Rspec::Core.configuration.find_advice(:after, :each, self).each { |blk| running_behaviour.instance_eval(&blk) }
+ def self.eval_after_eachs(running_example_group)
+ after_ancestors.each { |ancestor| ancestor.after_eachs.each { |blk| running_example_group.instance_eval(&blk) } }
+ Rspec::Core.configuration.find_advice(:after, :each, self).each { |blk| running_example_group.instance_eval(&blk) }
end
def self.run(reporter)
example_world = new
- reporter.add_behaviour(self)
+ reporter.add_example_group(self)
eval_before_alls(example_world)
success = run_examples(example_world, reporter)
eval_after_alls(example_world)
@@ -210,7 +210,7 @@ def assignments
end
def described_class
- running_example.metadata[:behaviour][:describes]
+ running_example.metadata[:example_group][:describes]
end
def __reset__
View
16 lib/rspec/core/formatters/base_formatter.rb
@@ -5,13 +5,13 @@ module Core
module Formatters
class BaseFormatter
- attr_accessor :behaviour
+ attr_accessor :example_group
attr_reader :example_count, :duration, :examples
def initialize
@example_count = 0
@examples = []
- @behaviour = nil
+ @example_group = nil
end
def configuration
@@ -43,7 +43,7 @@ def failed_examples
# formatters that need to provide progress on feedback (graphical ones)
#
# This method will only be invoked once, and the next one to be invoked
- # is #add_behaviour
+ # is #add_example_group
def start(example_count)
@example_count = example_count
end
@@ -52,13 +52,15 @@ def example_finished(example)
examples << example
end
- # This method is invoked at the beginning of the execution of each behaviour.
- # +behaviour+ is the behaviour.
+ # This method is invoked at the beginning of the execution of each example group.
+ # +example_group+ is the example_group.
#
# The next method to be invoked after this is #example_failed or #example_finished
- def add_behaviour(behaviour)
- @behaviour = behaviour
+ def add_example_group(example_group)
+ @example_group = example_group
end
+
+ alias_method :add_example_group, :add_example_group
# This method is invoked after all of the examples have executed. The next method
# to be invoked after this one is #dump_failure (once for each failed example),
View
22 lib/rspec/core/formatters/documentation_formatter.rb
@@ -6,28 +6,26 @@ module Formatters
class DocumentationFormatter < BaseTextFormatter
- attr_reader :previous_nested_behaviours
-
def initialize
super
- @previous_nested_behaviours = []
+ @previous_nested_example_groups = []
end
- def add_behaviour(behaviour)
+ def add_example_group(example_group)
super
- described_behaviour_chain.each_with_index do |nested_behaviour, i|
- unless nested_behaviour == previous_nested_behaviours[i]
+ described_example_group_chain.each_with_index do |nested_example_group, i|
+ unless nested_example_group == @previous_nested_example_groups[i]
at_root_level = (i == 0)
- desc_or_name = at_root_level ? nested_behaviour.name : nested_behaviour.description
+ desc_or_name = at_root_level ? nested_example_group.name : nested_example_group.description
output.puts if at_root_level
output.puts "#{' ' * i}#{desc_or_name}"
end
end
- @previous_nested_behaviours = described_behaviour_chain
+ @previous_nested_example_groups = described_example_group_chain
end
-
+
def output_for(example)
case example.execution_result[:status]
when 'failed'
@@ -68,11 +66,11 @@ def pending_output(example, message)
end
def current_indentation
- ' ' * previous_nested_behaviours.size
+ ' ' * @previous_nested_example_groups.size
end
- def described_behaviour_chain
- behaviour.ancestors
+ def described_example_group_chain
+ example_group.ancestors
end
end
View
4 lib/rspec/core/kernel_extensions.rb
@@ -2,10 +2,10 @@ module Rspec
module Core
module KernelExtensions
- def describe(*args, &behaviour_block)
+ def describe(*args, &example_group_block)
args << {} unless args.last.is_a?(Hash)
args.last.update :caller => caller(1)
- Rspec::Core::ExampleGroup.describe(*args, &behaviour_block)
+ Rspec::Core::ExampleGroup.describe(*args, &example_group_block)
end
alias :context :describe
View
34 lib/rspec/core/metadata.rb
@@ -13,24 +13,26 @@ def self.process(superclass_metadata, *args)
def initialize(superclass_metadata=nil)
@superclass_metadata = superclass_metadata
update(@superclass_metadata) if @superclass_metadata
- store(:behaviour, {})
+ store(:example_group, {})
+ store(:behaviour, self[:example_group])
yield self if block_given?
end
def process(*args)
extra_metadata = args.last.is_a?(Hash) ? args.pop : {}
- extra_metadata.delete(:behaviour) # Remove it when present to prevent it clobbering the one we setup
+ extra_metadata.delete(:example_group) # Remove it when present to prevent it clobbering the one we setup
+ extra_metadata.delete(:behaviour) # Remove it when present to prevent it clobbering the one we setup
- self[:behaviour][:describes] = args.shift unless args.first.is_a?(String)
- self[:behaviour][:describes] ||= self.superclass_metadata && self.superclass_metadata[:behaviour][:describes]
- self[:behaviour][:description] = args.shift || ''
+ self[:example_group][:describes] = args.shift unless args.first.is_a?(String)
+ self[:example_group][:describes] ||= self.superclass_metadata && self.superclass_metadata[:example_group][:describes]
+ self[:example_group][:description] = args.shift || ''
- self[:behaviour][:name] = determine_name
- self[:behaviour][:block] = extra_metadata.delete(:behaviour_block)
- self[:behaviour][:caller] = extra_metadata.delete(:caller)
- self[:behaviour][:file_path] = file_path_from(self[:behaviour], extra_metadata.delete(:file_path))
- self[:behaviour][:line_number] = line_number_from(self[:behaviour], extra_metadata.delete(:line_number))
- self[:behaviour][:location] = location_from(self[:behaviour])
+ self[:example_group][:name] = determine_name
+ self[:example_group][:block] = extra_metadata.delete(:example_group_block)
+ self[:example_group][:caller] = extra_metadata.delete(:caller)
+ self[:example_group][:file_path] = file_path_from(self[:example_group], extra_metadata.delete(:file_path))
+ self[:example_group][:line_number] = line_number_from(self[:example_group], extra_metadata.delete(:line_number))
+ self[:example_group][:location] = location_from(self[:example_group])
update(extra_metadata)
end
@@ -41,7 +43,7 @@ def for_example(description, options)
def configure_for_example(description, options)
store(:description, description.to_s)
- store(:full_description, "#{self[:behaviour][:name]} #{self[:description]}")
+ store(:full_description, "#{self[:example_group][:name]} #{self[:description]}")
store(:execution_result, {})
store(:caller, options.delete(:caller))
if self[:caller]
@@ -64,7 +66,7 @@ def apply_condition(filter_on, filter, metadata=nil)
filter.call(metadata[filter_on]) rescue false
when Fixnum
if filter_on == :line_number
- [metadata[:line_number],metadata[:behaviour][:line_number]].include?(filter)
+ [metadata[:line_number],metadata[:example_group][:line_number]].include?(filter)
else
metadata[filter_on] == filter
end
@@ -102,10 +104,10 @@ def candidate_entries_from_caller(metadata)
end
def determine_name
- if superclass_metadata && superclass_metadata[:behaviour][:name]
- self[:behaviour][:name] = "#{superclass_metadata[:behaviour][:name]} #{self[:behaviour][:description]}".strip
+ if superclass_metadata && superclass_metadata[:example_group][:name]
+ self[:example_group][:name] = "#{superclass_metadata[:example_group][:name]} #{self[:example_group][:description]}".strip
else
- self[:behaviour][:name] = "#{self[:behaviour][:describes]} #{self[:behaviour][:description]}".strip
+ self[:example_group][:name] = "#{self[:example_group][:describes]} #{self[:example_group][:description]}".strip
end
end
View
4 lib/rspec/core/runner.rb
@@ -42,8 +42,8 @@ def run(args = [])
formatter.start(total_examples_to_run) # start the clock
start = Time.now
- Rspec::Core.world.behaviours_to_run.each do |behaviour|
- suite_success &= behaviour.run(formatter)
+ Rspec::Core.world.example_groups_to_run.each do |example_group|
+ suite_success &= example_group.run(formatter)
end
formatter.start_dump(Time.now - start)
View
10 lib/rspec/core/shared_behaviour.rb → lib/rspec/core/shared_example_group.rb
@@ -1,10 +1,10 @@
module Rspec
module Core
- module SharedBehaviour
+ module SharedExampleGroup
def share_examples_for(name, &block)
ensure_shared_example_group_name_not_taken(name)
- Rspec::Core.world.shared_behaviours[name] = block
+ Rspec::Core.world.shared_example_groups[name] = block
end
def share_as(name, &block)
@@ -21,7 +21,7 @@ def self.included(kls)
end
shared_const = Object.const_set(name, mod)
- Rspec::Core.world.shared_behaviours[shared_const] = block
+ Rspec::Core.world.shared_example_groups[shared_const] = block
end
alias :shared_examples_for :share_examples_for
@@ -29,7 +29,7 @@ def self.included(kls)
private
def ensure_shared_example_group_name_not_taken(name)
- if Rspec::Core.world.shared_behaviours.has_key?(name)
+ if Rspec::Core.world.shared_example_groups.has_key?(name)
raise ArgumentError.new("Shared example group '#{name}' already exists")
end
end
@@ -38,4 +38,4 @@ def ensure_shared_example_group_name_not_taken(name)
end
end
-include Rspec::Core::SharedBehaviour
+include Rspec::Core::SharedExampleGroup
View
6 lib/rspec/core/shared_behaviour_kernel_extensions.rb → ...ec/core/shared_example_group_kernel_extensions.rb
@@ -1,9 +1,9 @@
module Rspec
module Core
- module SharedBehaviourKernelExtensions
+ module SharedExampleGroupKernelExtensions
def share_examples_for(name, &block)
- Rspec::Core.world.shared_behaviours[name] = block
+ Rspec::Core.world.shared_example_groups[name] = block
end
def share_as(name, &block)
@@ -21,7 +21,7 @@ def self.included(kls)
end
shared_const = Object.const_set(name, mod)
- Rspec::Core.world.shared_behaviours[shared_const] = block
+ Rspec::Core.world.shared_example_groups[shared_const] = block
end
alias :shared_examples_for :share_examples_for
View
34 lib/rspec/core/world.rb
@@ -2,10 +2,10 @@ module Rspec
module Core
class World
- attr_reader :behaviours
+ attr_reader :example_groups
def initialize
- @behaviours = []
+ @example_groups = []
end
def filter
@@ -16,38 +16,38 @@ def exclusion_filter
Rspec::Core.configuration.exclusion_filter
end
- def shared_behaviours
- @shared_behaviours ||= {}
+ def shared_example_groups
+ @shared_example_groups ||= {}
end
- def behaviours_to_run
- return @behaviours_to_run if @behaviours_to_run
+ def example_groups_to_run
+ return @example_groups_to_run if @example_groups_to_run
if filter || exclusion_filter
- @behaviours_to_run = filter_behaviours
+ @example_groups_to_run = filter_example_groups
- if @behaviours_to_run.size == 0 && Rspec::Core.configuration.run_all_when_everything_filtered?
+ if @example_groups_to_run.size == 0 && Rspec::Core.configuration.run_all_when_everything_filtered?
Rspec::Core.configuration.puts "No examples were matched by #{filter.inspect}, running all"
- # reset the behaviour list to all behaviours, and add back all examples
- @behaviours_to_run = @behaviours
- @behaviours.each { |b| b.examples_to_run.replace(b.examples) }
+ # reset the behaviour list to all example groups, and add back all examples
+ @example_groups_to_run = @example_groups
+ @example_groups.each { |b| b.examples_to_run.replace(b.examples) }
else
Rspec::Core.configuration.puts "Run filtered using #{filter.inspect}"
end
else
- @behaviours_to_run = @behaviours
- @behaviours.each { |b| b.examples_to_run.replace(b.examples) }
+ @example_groups_to_run = @example_groups
+ @example_groups.each { |b| b.examples_to_run.replace(b.examples) }
end
- @behaviours_to_run
+ @example_groups_to_run
end
def total_examples_to_run
- @total_examples_to_run ||= behaviours_to_run.inject(0) { |sum, b| sum += b.examples_to_run.size }
+ @total_examples_to_run ||= example_groups_to_run.inject(0) { |sum, b| sum += b.examples_to_run.size }
end
- def filter_behaviours
- behaviours.inject([]) do |list_of_example_groups, example_group|
+ def filter_example_groups
+ example_groups.inject([]) do |list_of_example_groups, example_group|
examples = example_group.examples
examples = apply_exclusion_filters(examples, exclusion_filter) if exclusion_filter
examples = apply_inclusion_filters(examples, filter) if filter
View
12 rspec-core.gemspec
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
s.authors = ["David Chelimsky", "Chad Humphries"]
- s.date = %q{2010-01-31}
+ s.date = %q{2010-02-03}
s.default_executable = %q{rspec}
s.description = %q{Rspec runner and example group classes}
s.email = %q{dchelimsky@gmail.com;chad.humphries@gmail.com}
@@ -137,8 +137,8 @@ Gem::Specification.new do |s|
"lib/rspec/core/rake_task.rb",
"lib/rspec/core/ruby_project.rb",
"lib/rspec/core/runner.rb",
- "lib/rspec/core/shared_behaviour.rb",
- "lib/rspec/core/shared_behaviour_kernel_extensions.rb",
+ "lib/rspec/core/shared_example_group.rb",
+ "lib/rspec/core/shared_example_group_kernel_extensions.rb",
"lib/rspec/core/version.rb",
"lib/rspec/core/world.rb",
"rspec-core.gemspec",
@@ -154,6 +154,7 @@ Gem::Specification.new do |s|
"spec/rspec/core/kernel_extensions_spec.rb",
"spec/rspec/core/metadata_spec.rb",
"spec/rspec/core/mocha_spec.rb",
+ "spec/rspec/core/pending_example_spec.rb",
"spec/rspec/core/resources/a_bar.rb",
"spec/rspec/core/resources/a_foo.rb",
"spec/rspec/core/resources/a_spec.rb",
@@ -161,7 +162,7 @@ Gem::Specification.new do |s|
"spec/rspec/core/resources/utf8_encoded.rb",
"spec/rspec/core/ruby_project_spec.rb",
"spec/rspec/core/runner_spec.rb",
- "spec/rspec/core/shared_behaviour_spec.rb",
+ "spec/rspec/core/shared_example_group_spec.rb",
"spec/rspec/core/world_spec.rb",
"spec/rspec/core_spec.rb",
"spec/ruby_forker.rb",
@@ -186,6 +187,7 @@ Gem::Specification.new do |s|
"spec/rspec/core/kernel_extensions_spec.rb",
"spec/rspec/core/metadata_spec.rb",
"spec/rspec/core/mocha_spec.rb",
+ "spec/rspec/core/pending_example_spec.rb",
"spec/rspec/core/resources/a_bar.rb",
"spec/rspec/core/resources/a_foo.rb",
"spec/rspec/core/resources/a_spec.rb",
@@ -193,7 +195,7 @@ Gem::Specification.new do |s|
"spec/rspec/core/resources/utf8_encoded.rb",
"spec/rspec/core/ruby_project_spec.rb",
"spec/rspec/core/runner_spec.rb",
- "spec/rspec/core/shared_behaviour_spec.rb",
+ "spec/rspec/core/shared_example_group_spec.rb",
"spec/rspec/core/world_spec.rb",
"spec/rspec/core_spec.rb",
"spec/ruby_forker.rb",
View
2  spec/rspec/core/configuration_spec.rb
@@ -149,7 +149,7 @@ def that_thing
end
- it "should extend the given module into each matching behaviour" do
+ it "should extend the given module into each matching example group" do
Rspec::Core.configuration.extend(ThatThingISentYou, :magic_key => :extend)
group = Rspec::Core::ExampleGroup.describe(ThatThingISentYou, :magic_key => :extend) { }
View
52 spec/rspec/core/example_group_spec.rb
@@ -91,7 +91,7 @@
it "adds the caller to metadata" do
disconnect_from_world do
- Rspec::Core::ExampleGroup.describe(Object) { }.metadata[:behaviour][:caller].any? {|f|
+ Rspec::Core::ExampleGroup.describe(Object) { }.metadata[:example_group][:caller].any? {|f|
f =~ /#{__FILE__}/
}.should be_true
end
@@ -99,7 +99,7 @@
it "adds the the file_path to metadata" do
disconnect_from_world do
- Rspec::Core::ExampleGroup.describe(Object) { }.metadata[:behaviour][:file_path].should == __FILE__
+ Rspec::Core::ExampleGroup.describe(Object) { }.metadata[:example_group][:file_path].should == __FILE__
end
end
@@ -111,15 +111,15 @@
it "adds the line_number to metadata" do
disconnect_from_world do
- Rspec::Core::ExampleGroup.describe(Object) { }.metadata[:behaviour][:line_number].should == __LINE__
+ Rspec::Core::ExampleGroup.describe(Object) { }.metadata[:example_group][:line_number].should == __LINE__
end
end
it "adds file path and line number metadata for arbitrarily nested describes" do
Rspec::Core::ExampleGroup.describe(Object) do
Rspec::Core::ExampleGroup.describe("foo") do
- Rspec::Core::ExampleGroup.describe(Object) { }.metadata[:behaviour][:file_path].should == __FILE__
- Rspec::Core::ExampleGroup.describe(Object) { }.metadata[:behaviour][:line_number].should == __LINE__
+ Rspec::Core::ExampleGroup.describe(Object) { }.metadata[:example_group][:file_path].should == __FILE__
+ Rspec::Core::ExampleGroup.describe(Object) { }.metadata[:example_group][:line_number].should == __LINE__
end
end
@@ -238,15 +238,15 @@
describe "A sample nested group", :nested_describe => "yep" do
it "sets the described class to the constant Object" do
- running_example.behaviour.describes.should == Object
+ running_example.example_group.describes.should == Object
end
it "sets the description to 'A sample nested describe'" do
- running_example.behaviour.description.should == 'A sample nested group'
+ running_example.example_group.description.should == 'A sample nested group'
end
- it "has top level metadata from the behaviour and its ancestors" do
- running_example.behaviour.metadata.should include(:little_less_nested => 'yep', :nested_describe => 'yep')
+ it "has top level metadata from the example_group and its ancestors" do
+ running_example.example_group.metadata.should include(:little_less_nested => 'yep', :nested_describe => 'yep')
end
it "exposes the parent metadata to the contained examples" do
@@ -261,10 +261,10 @@
@fake_formatter = Rspec::Core::Formatters::BaseFormatter.new
end
- def stub_behaviour
- stub('behaviour',
+ def stub_example_group
+ stub('example_group',
:metadata => Rspec::Core::Metadata.new.process(
- 'behaviour_name',
+ 'example_group_name',
:caller => ['foo_spec.rb:37']
)
).as_null_object
@@ -272,33 +272,33 @@ def stub_behaviour
it "should return true if all examples pass" do
use_formatter(@fake_formatter) do
- passing_example1 = Rspec::Core::Example.new(stub_behaviour, 'description', {}, (lambda { 1.should == 1 }))
- passing_example2 = Rspec::Core::Example.new(stub_behaviour, 'description', {}, (lambda { 1.should == 1 }))
+ passing_example1 = Rspec::Core::Example.new(stub_example_group, 'description', {}, (lambda { 1.should == 1 }))
+ passing_example2 = Rspec::Core::Example.new(stub_example_group, 'description', {}, (lambda { 1.should == 1 }))
Rspec::Core::ExampleGroup.stub!(:examples_to_run).and_return([passing_example1, passing_example2])
- Rspec::Core::ExampleGroup.run_examples(stub_behaviour, mock('reporter').as_null_object).should be_true
+ Rspec::Core::ExampleGroup.run_examples(stub_example_group, mock('reporter').as_null_object).should be_true
end
end
it "should return false if any of the examples return false" do
use_formatter(@fake_formatter) do
- failing_example = Rspec::Core::Example.new(stub_behaviour, 'description', {}, (lambda { 1.should == 2 }))
- passing_example = Rspec::Core::Example.new(stub_behaviour, 'description', {}, (lambda { 1.should == 1 }))
+ failing_example = Rspec::Core::Example.new(stub_example_group, 'description', {}, (lambda { 1.should == 2 }))
+ passing_example = Rspec::Core::Example.new(stub_example_group, 'description', {}, (lambda { 1.should == 1 }))
Rspec::Core::ExampleGroup.stub!(:examples_to_run).and_return([failing_example, passing_example])
- Rspec::Core::ExampleGroup.run_examples(stub_behaviour, mock('reporter').as_null_object).should be_false
+ Rspec::Core::ExampleGroup.run_examples(stub_example_group, mock('reporter').as_null_object).should be_false
end
end
it "should run all examples, regardless of any of them failing" do
use_formatter(@fake_formatter) do
- failing_example = Rspec::Core::Example.new(stub_behaviour, 'description', {}, (lambda { 1.should == 2 }))
- passing_example = Rspec::Core::Example.new(stub_behaviour, 'description', {}, (lambda { 1.should == 1 }))
+ failing_example = Rspec::Core::Example.new(stub_example_group, 'description', {}, (lambda { 1.should == 2 }))
+ passing_example = Rspec::Core::Example.new(stub_example_group, 'description', {}, (lambda { 1.should == 1 }))
Rspec::Core::ExampleGroup.stub!(:examples_to_run).and_return([failing_example, passing_example])
passing_example.should_receive(:run)
- Rspec::Core::ExampleGroup.run_examples(stub_behaviour, mock('reporter', :null_object => true))
+ Rspec::Core::ExampleGroup.run_examples(stub_example_group, mock('reporter', :null_object => true))
end
end
@@ -323,19 +323,19 @@ def stub_behaviour
it "should be able to access the before all ivars in the before_all_ivars hash" do
with_ruby('1.8') do
- running_example.behaviour.before_all_ivars.should include('@before_all_top_level' => 'before_all_top_level')
+ running_example.example_group.before_all_ivars.should include('@before_all_top_level' => 'before_all_top_level')
end
with_ruby('1.9') do
- running_example.behaviour.before_all_ivars.should include(:@before_all_top_level => 'before_all_top_level')
+ running_example.example_group.before_all_ivars.should include(:@before_all_top_level => 'before_all_top_level')
end
end
describe "but now I am nested" do
- it "should be able to access a parent behaviours before each ivar at a nested level" do
+ it "should be able to access a parent example groups before each ivar at a nested level" do
@before_each_top_level.should == 'before_each_top_level'
end
- it "should be able to access a parent behaviours before all ivar at a nested level" do
+ it "should be able to access a parent example groups before all ivar at a nested level" do
@before_all_top_level.should == "before_all_top_level"
end
@@ -343,7 +343,7 @@ def stub_behaviour
@before_all_top_level = "ive been changed"
end
- describe "accessing a before_all ivar that was changed in a parent behaviour" do
+ describe "accessing a before_all ivar that was changed in a parent example_group" do
it "does not have access to the modified version" do
@before_all_top_level.should == 'before_all_top_level'
end
View
12 spec/rspec/core/example_spec.rb
@@ -3,18 +3,18 @@
describe Rspec::Core::Example, :parent_metadata => 'sample' do
before do
- behaviour = stub('behaviour',
+ example_group = stub('example_group',
:metadata => Rspec::Core::Metadata.new.process(
'group description',
:caller => ['foo_spec.rb:37']
)
).as_null_object
- @example = Rspec::Core::Example.new(behaviour, 'example description', {}, (lambda {}))
+ @example = Rspec::Core::Example.new(example_group, 'example description', {}, (lambda {}))
end
describe "attr readers" do
- it "should have one for the parent behaviour" do
- @example.should respond_to(:behaviour)
+ it "should have one for the parent example group" do
+ @example.should respond_to(:example_group)
end
it "should have one for it's description" do
@@ -53,8 +53,8 @@
running_example.description.should == "should have a reference to itself when running"
end
- it "should be able to access the behaviours top level metadata as if it were its own" do
- running_example.behaviour.metadata.should include(:parent_metadata => 'sample')
+ it "should be able to access the example group's top level metadata as if it were its own" do
+ running_example.example_group.metadata.should include(:parent_metadata => 'sample')
running_example.metadata.should include(:parent_metadata => 'sample')
end
end
View
4 spec/rspec/core/formatters/base_formatter_spec.rb
@@ -68,8 +68,8 @@ def have_interface_for(method)
@formatter.should have_interface_for(:start).with(1).argument
end
- it "should have add_behaviour as an interface with one argument" do
- @formatter.should have_interface_for(:add_behaviour).with(1).argument
+ it "should have add_example_group as an interface with one argument" do
+ @formatter.should have_interface_for(:add_example_group).with(1).argument
end
it "should have example_finished as an interface with one argument" do
View
26 spec/rspec/core/metadata_spec.rb
@@ -3,36 +3,38 @@
module Rspec
module Core
describe Metadata do
- describe "[:behaviour][:name]" do
+ describe "[:example_group][:name]" do
it "generates name for top level example group" do
m = Metadata.new
m.process("description", :caller => caller(0))
- m[:behaviour][:name].should == "description"
+ m[:example_group][:name].should == "description"
end
it "concats args to describe()" do
m = Metadata.new
m.process(String, "with dots", :caller => caller(0))
- m[:behaviour][:name].should == "String with dots"
+ m[:example_group][:name].should == "String with dots"
end
it "concats nested names" do
- m = Metadata.new(:behaviour => {:name => 'parent'})
- m.process(String, "child", :caller => caller(0))
- m[:behaviour][:name].should == "parent child"
+ parent = Metadata.new
+ parent.process("parent", :caller => caller(0))
+ m = Metadata.new(parent)
+ m.process("child", :caller => caller(0))
+ m[:example_group][:name].should == "parent child"
end
it "strips the name" do
m = Metadata.new
m.process(" description \n", :caller => caller(0))
- m[:behaviour][:name].should == "description"
+ m[:example_group][:name].should == "description"
end
end
describe "[:full_description]" do
- it "concats the behaviour name and description" do
+ it "concats the example group name and description" do
m = Metadata.new
- m[:behaviour][:name] = "group"
+ m[:example_group][:name] = "group"
m = m.for_example("example", {})
m[:full_description].should == "group example"
@@ -48,7 +50,7 @@ module Core
"bar_spec.rb:23",
"baz"
])
- m[:behaviour][:file_path].should == __FILE__
+ m[:example_group][:file_path].should == __FILE__
end
end
@@ -61,7 +63,7 @@ module Core
"bar_spec.rb:23",
"baz"
])
- m[:behaviour][:line_number].should == __LINE__ - 4
+ m[:example_group][:line_number].should == __LINE__ - 4
end
it "uses the number after the first : for ruby 1.9" do
m = Metadata.new
@@ -71,7 +73,7 @@ module Core
"bar_spec.rb:23",
"baz"
])
- m[:behaviour][:line_number].should == __LINE__ - 4
+ m[:example_group][:line_number].should == __LINE__ - 4
end
end
View
40 spec/rspec/core/shared_behaviour_spec.rb → spec/rspec/core/shared_example_group_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Rspec::Core::SharedBehaviour do
+describe Rspec::Core::SharedExampleGroup do
it "should add the 'share_examples_for' method to the global namespace" do
Kernel.should respond_to(:share_examples_for)
@@ -14,7 +14,7 @@
Kernel.should respond_to(:share_as)
end
- it "should raise an ArgumentError when adding a second shared behaviour with the same name" do
+ it "should raise an ArgumentError when adding a second shared example group with the same name" do
group = isolated_example_group('example group')
group.share_examples_for('really important business value') { }
lambda do
@@ -24,22 +24,22 @@
describe "share_examples_for" do
- it "should capture the given name and block in the Worlds collection of shared behaviours" do
- Rspec::Core.world.shared_behaviours.should_receive(:[]=).with(:foo, anything)
+ it "should capture the given name and block in the Worlds collection of shared example groups" do
+ Rspec::Core.world.shared_example_groups.should_receive(:[]=).with(:foo, anything)
share_examples_for(:foo) { }
end
end
- describe "including shared behaviours using #it_should_behave_like" do
+ describe "including shared example_groups using #it_should_behave_like" do
- def cleanup_shared_behaviours
- original_shared_behaviours = Rspec::Core.world.shared_behaviours
+ def cleanup_shared_example_groups
+ original_shared_example_groups = Rspec::Core.world.shared_example_groups
yield if block_given?
- Rspec::Core.world.shared_behaviours.replace(original_shared_behaviours)
+ Rspec::Core.world.shared_example_groups.replace(original_shared_example_groups)
end
- it "should module_eval any found shared behaviours" do
+ it "should module_eval any found shared example_groups" do
group = isolated_example_group('fake group')
block1 = lambda {}
block2 = lambda {
@@ -47,19 +47,19 @@ def extra_helper
'extra_helper'
end
}
- Rspec::Core.world.stub!(:shared_behaviours).and_return({ :a => block1, :shared_behaviour => block2 })
+ Rspec::Core.world.stub!(:shared_example_groups).and_return({ :a => block1, :shared_example_group => block2 })
group.should_receive(:module_eval).once
- group.it_should_behave_like :shared_behaviour
+ group.it_should_behave_like :shared_example_group
end
- it "should make any shared behaviour available at the correct level" do
+ it "should make any shared example_group available at the correct level" do
group = isolated_example_group('fake group')
block = lambda {
def self.class_helper; end
def extra_helper; end
}
- Rspec::Core.world.stub!(:shared_behaviours).and_return({ :shared_behaviour => block })
- group.it_should_behave_like :shared_behaviour
+ Rspec::Core.world.stub!(:shared_example_groups).and_return({ :shared_example_group => block })
+ group.it_should_behave_like :shared_example_group
with_ruby(1.8) do
group.instance_methods.should include('extra_helper')
group.singleton_methods.should include('class_helper')
@@ -73,7 +73,7 @@ def extra_helper; end
it "should raise when named shared example_group can not be found"
it "adds examples to current example_group using it_should_behave_like" do
- cleanup_shared_behaviours do
+ cleanup_shared_example_groups do
group = isolated_example_group("example_group") do
it("i was already here") {}
end
@@ -92,7 +92,7 @@ def extra_helper; end
end
it "adds examples to from two shared groups" do
- cleanup_shared_behaviours do
+ cleanup_shared_example_groups do
group = isolated_example_group("example_group") do |g|
g.it("i was already here") {}
end
@@ -125,7 +125,7 @@ def extra_helper; end
end
it "adds examples to current example_group using it_should_behave_like with a module" do
- cleanup_shared_behaviours do
+ cleanup_shared_example_groups do
group = isolated_example_group("example_group") {}
shared_foo = group.share_as(:FooShared) do
@@ -168,13 +168,13 @@ def magic
it "should run after(:all) only once from shared example_group", :compat => 'rspec-1.2'
it "should include modules, included into shared example_group, into current example_group", :compat => 'rspec-1.2' do
- running_example.behaviour.included_modules.should include(RunningSharedExamplesJustForTesting)
+ running_example.example_group.included_modules.should include(RunningSharedExamplesJustForTesting)
end
it "should make methods defined in the shared example_group available in consuming example_group", :compat => 'rspec-1.2' do
# TODO: Consider should have_method(...) simple matcher
- with_ruby('1.8') { running_example.behaviour.methods.should include('magic') }
- with_ruby('1.9') { running_example.behaviour.methods.should include(:magic) }
+ with_ruby('1.8') { running_example.example_group.methods.should include('magic') }
+ with_ruby('1.9') { running_example.example_group.methods.should include(:magic) }
end
end
View
46 spec/rspec/core/world_spec.rb
@@ -10,11 +10,13 @@ class Foo; end
Rspec::Core.stub(:world).and_return(@world)
end
- describe "behaviour groups" do
+ describe "example groups" do
- it "should contain all defined behaviour groups" do
- behaviour_group = Rspec::Core::ExampleGroup.describe(Bar, 'Empty Behaviour Group') { }
- @world.behaviours.should include(behaviour_group)
+ it "should contain all defined example groups" do
+ disconnect_from_world do
+ example_group = Rspec::Core::ExampleGroup.describe(Bar, 'Empty Example Group') { }
+ @world.example_groups.should include(example_group)
+ end
end
end
@@ -35,14 +37,14 @@ class Foo; end
it("not so awesome", :awesome => false) {}
it("I also have no options") {}
end
- @behaviours = [@bg1, @bg2, @bg3, @bg4]
+ @example_groups = [@bg1, @bg2, @bg3, @bg4]
end
after(:all) do
- Rspec::Core.world.behaviours.delete(@bg1)
- Rspec::Core.world.behaviours.delete(@bg2)
- Rspec::Core.world.behaviours.delete(@bg3)
- Rspec::Core.world.behaviours.delete(@bg4)
+ Rspec::Core.world.example_groups.delete(@bg1)
+ Rspec::Core.world.example_groups.delete(@bg2)
+ Rspec::Core.world.example_groups.delete(@bg3)
+ Rspec::Core.world.example_groups.delete(@bg4)
end
it "finds no groups when given no search parameters" do
@@ -50,35 +52,35 @@ class Foo; end
end
it "finds matching groups when filtering on :describes (described class or module)" do
- @world.apply_inclusion_filters(@behaviours, :behaviour => { :describes => Bar }).should == [@bg1, @bg2, @bg3]
+ @world.apply_inclusion_filters(@example_groups, :example_group => { :describes => Bar }).should == [@bg1, @bg2, @bg3]
end
it "finds matching groups when filtering on :description with text" do
- @world.apply_inclusion_filters(@behaviours, :behaviour => { :description => 'find group-1' }).should == [@bg1]
+ @world.apply_inclusion_filters(@example_groups, :example_group => { :description => 'find group-1' }).should == [@bg1]
end
it "finds matching groups when filtering on :description with a lambda" do
- @world.apply_inclusion_filters(@behaviours, :behaviour => { :description => lambda { |v| v.include?('-1') || v.include?('-3') } }).should == [@bg1, @bg3]
+ @world.apply_inclusion_filters(@example_groups, :example_group => { :description => lambda { |v| v.include?('-1') || v.include?('-3') } }).should == [@bg1, @bg3]
end
it "finds matching groups when filtering on :description with a regular expression" do
- @world.apply_inclusion_filters(@behaviours, :behaviour => { :description => /find group/ }).should == [@bg1, @bg2, @bg3]
+ @world.apply_inclusion_filters(@example_groups, :example_group => { :description => /find group/ }).should == [@bg1, @bg2, @bg3]
end
it "finds one group when searching for :pending => true" do
- @world.apply_inclusion_filters(@behaviours, :pending => true ).should == [@bg2]
+ @world.apply_inclusion_filters(@example_groups, :pending => true ).should == [@bg2]
end
it "finds matching groups when filtering on arbitrary metadata with a number" do
- @world.apply_inclusion_filters(@behaviours, :foo => 1 ).should == [@bg1]
+ @world.apply_inclusion_filters(@example_groups, :foo => 1 ).should == [@bg1]
end
it "finds matching groups when filtering on arbitrary metadata with an array" do
- @world.apply_inclusion_filters(@behaviours, :array => [1,2,3,4]).should == [@bg3]
+ @world.apply_inclusion_filters(@example_groups, :array => [1,2,3,4]).should == [@bg3]
end
it "finds no groups when filtering on arbitrary metadata with an array but the arrays do not match" do
- @world.apply_inclusion_filters(@behaviours, :array => [4,3,2,1]).should be_empty
+ @world.apply_inclusion_filters(@example_groups, :array => [4,3,2,1]).should be_empty
end
it "finds matching examples when filtering on arbitrary metadata" do
@@ -115,7 +117,7 @@ class Foo; end
end
@world.apply_exclusion_filters(group.examples, :name => /exclude/).should == []
@world.apply_exclusion_filters(group.examples, :name => /exclude/, :another => "foo").should == []
- @world.apply_exclusion_filters(group.examples, :name => /exclude/, :another => "foo", :behaviour => {
+ @world.apply_exclusion_filters(group.examples, :name => /exclude/, :another => "foo", :example_group => {
:describes => lambda { |b| b == Bar } } ).should == []
@world.apply_exclusion_filters(group.examples, :name => /exclude not/).should == group.examples
@@ -125,7 +127,7 @@ class Foo; end
end
- describe "filtering behaviours" do
+ describe "filtering example groups" do
it "should run matches" do
@group1 = isolated_example_group(Bar, "find these examples") do
@@ -135,9 +137,9 @@ class Foo; end
end
Rspec::Core.world.stub(:exclusion_filter).and_return({ :awesome => false })
Rspec::Core.world.stub(:filter).and_return({ :color => :red })
- Rspec::Core.world.stub(:behaviours).and_return([@group1])
- filtered_behaviours = @world.filter_behaviours
- filtered_behaviours.should == [@group1]
+ Rspec::Core.world.stub(:example_groups).and_return([@group1])
+ filtered_example_groups = @world.filter_example_groups
+ filtered_example_groups.should == [@group1]
@group1.examples_to_run.should == @group1.examples[0..1]
end
View
10 spec/spec_helper.rb
@@ -28,16 +28,16 @@ def fail_with(message)
end
def remove_last_example_group_from_world
- Rspec::Core.world.behaviours.pop
+ Rspec::Core.world.example_groups.pop
end
def disconnect_from_world
- example_groups = Rspec::Core.world.behaviours.dup
- Rspec::Core.world.behaviours.clear
+ example_groups = Rspec::Core.world.example_groups.dup
+ Rspec::Core.world.example_groups.clear
yield
ensure
- Rspec::Core.world.behaviours.clear
- Rspec::Core.world.behaviours.concat(example_groups)
+ Rspec::Core.world.example_groups.clear
+ Rspec::Core.world.example_groups.concat(example_groups)
end
def isolated_example_group(*args, &block)
Please sign in to comment.
Something went wrong with that request. Please try again.