1 require 'spec/runner/options'
2 require 'spec/runner/option_parser'
3 require 'spec/runner/example_group_runner'
4 require 'spec/runner/command_line'
5 require 'spec/runner/drb_command_line'
6 require 'spec/runner/backtrace_tweaker'
7 require 'spec/runner/reporter'
8 require 'spec/runner/spec_parser'
9 require 'spec/runner/class_and_arguments_parser'
12 # == ExampleGroups and Examples
14 # Rather than expressing examples in classes, RSpec uses a custom DSLL (DSL light) to
15 # describe groups of examples.
17 # A ExampleGroup is the equivalent of a fixture in xUnit-speak. It is a metaphor for the context
18 # in which you will run your executable example - a set of known objects in a known starting state.
19 # We begin be describing
24 # @account = Account.new
27 # it "should have a balance of $0" do
28 # @account.balance.should == Money.new(0, :dollars)
33 # We use the before block to set up the Example (given), and then the #it method to
34 # hold the example code that expresses the event (when) and the expected outcome (then).
38 # A primary goal of RSpec is to keep the examples clear. We therefore prefer
39 # less indirection than you might see in xUnit examples and in well factored, DRY production code. We feel
40 # that duplication is OK if removing it makes it harder to understand an example without
41 # having to look elsewhere to understand its context.
43 # That said, RSpec does support some level of encapsulating common code in helper
44 # methods that can exist within a context or within an included module.
46 # == Setup and Teardown
48 # You can use before and after within a Example. Both methods take an optional
49 # scope argument so you can run the block before :each example or before :all examples
60 # it "should do something" do
64 # it "should do something else" do
78 # The <tt>before :each</tt> block will run before each of the examples, once for each example. Likewise,
79 # the <tt>after :each</tt> block will run after each of the examples.
81 # It is also possible to specify a <tt>before :all</tt> and <tt>after :all</tt>
82 # block that will run only once for each behaviour, respectively before the first <code>before :each</code>
83 # and after the last <code>after :each</code>. The use of these is generally discouraged, because it
84 # introduces dependencies between the examples. Still, it might prove useful for very expensive operations
85 # if you know what you are doing.
87 # == Local helper methods
89 # You can include local helper methods by simply expressing them within a context:
103 # == Included helper methods
105 # You can include helper methods in multiple contexts by expressing them within
106 # a module, and then including that module in your context:
108 # module AccountExampleHelperMethods
114 # describe "A new account" do
115 # include AccountExampleHelperMethods
117 # @account = Account.new
120 # it "should have a balance of $0" do
122 # @account.balance.should eql(Money.new(0, :dollars))
126 # == Shared Example Groups
128 # You can define a shared Example Group, that may be used on other groups
130 # share_examples_for "All Editions" do
131 # it "all editions behaviour" ...
134 # describe SmallEdition do
135 # it_should_behave_like "All Editions"
137 # it "should do small edition stuff" do
142 # You can also assign the shared group to a module and include that
144 # share_as :AllEditions do
145 # it "should do all editions stuff" ...
148 # describe SmallEdition do
149 # it_should_behave_like AllEditions
151 # it "should do small edition stuff" do
156 # And, for those of you who prefer to use something more like Ruby, you
157 # can just include the module directly
159 # describe SmallEdition do
160 # include AllEditions
162 # it "should do small edition stuff" do
168 def configuration # :nodoc:
169 @configuration ||= Spec::Example::Configuration.new
172 # Use this to configure various configurable aspects of
175 # Spec::Runner.configure do |configuration|
176 # # Configure RSpec here
179 # The yielded <tt>configuration</tt> object is a
180 # Spec::Example::Configuration instance. See its RDoc
181 # for details about what you can do with it.