module Spec::Extensions::Main
def describe(*args, &block)
register special implementations.
See Spec::Example::ExampleFactory#register for details about how to
matcher methods available from within the describe block.
The reason for using different behaviour classes is to have different
describe "name", :type => :something_special do ...
type with an options Hash as the last argument:
It is also possible to override autodiscovery of the example group
spec/controllers.
spec/helpers, spec/views and
classes for specs living in spec/models,
calling this method. For example, Spec::Rails will use different
module. Which ExampleGroup type is created depends on the directory of the file
Creates and returns a class that includes the ExampleGroupMethods
def describe(*args, &block) raise ArgumentError if args.empty? raise ArgumentError unless block args << {} unless Hash === args.last args.last[:spec_path] = caller(0)[1] Spec::Example::ExampleGroupFactory.create_example_group(*args, &block) end
def init_rspec_options(options)
def init_rspec_options(options) $rspec_options = options if $rspec_options.nil? end
def rspec_options
def rspec_options $rspec_options ||= begin; \ parser = ::Spec::Runner::OptionParser.new(STDERR, STDOUT); \ parser.order!(ARGV); \ $rspec_options = parser.options; \ end $rspec_options end
def share_as(name, &block)
end
...
it "should do small edition stuff" do
include AllEditions
describe SmallEdition do
can just include the module directly
And, for those of you who prefer to use something more like Ruby, you
end
end
...
it "should do small edition stuff" do
it_should_behave_like AllEditions
describe SmallEdition do
end
it "should do all editions stuff" ...
share_as :AllEditions do
Creates a Shared Example Group and assigns it to a constant
def share_as(name, &block) begin Object.const_set(name, share_examples_for(name, &block)) rescue NameError => e raise NameError.new(e.message + "\nThe first argument to share_as must be a legal name for a constant\n") end end
def share_examples_for(name, &block)
end
...
it "should do small edition stuff" do
it_should_behave_like "All Editions"
describe SmallEdition do
end
it "all editions behaviour" ...
share_examples_for "All Editions" do
== Examples
Creates an example group that can be shared by other example groups
def share_examples_for(name, &block) describe(name, :shared => true, &block) end