lib/r_spec.rb in r_spec-1.0.0.beta10 vs lib/r_spec.rb in r_spec-1.0.0.beta11
- old
+ new
@@ -63,10 +63,49 @@
# # Success: expected to be 42.
# # Success: expected to be 43.
#
# @api public
module RSpec
- # Specs are built with this method.
+ # Defines an example group that establishes a specific context, like _empty
+ # array_ versus _array with elements_.
+ #
+ # Unlike {.describe}, the block is evaluated in isolation in order to scope
+ # possible side effects inside its context.
+ #
+ # @example
+ # require "r_spec"
+ #
+ # RSpec.context "when divided by zero" do
+ # subject { 42 / 0 }
+ #
+ # it { is_expected.to raise_exception ZeroDivisionError }
+ # end
+ #
+ # # Output to the console
+ # # Success: divided by 0.
+ #
+ # @param description [String] A description that usually begins with "when",
+ # "with" or "without".
+ # @param block [Proc] The block to define the specs.
+ #
+ # @api public
+ def self.context(description, &block)
+ Dsl.context(description, &block)
+ end
+
+ # Defines an example group that describes a unit to be tested.
+ #
+ # @example
+ # require "r_spec"
+ #
+ # RSpec.describe String do
+ # describe "+" do
+ # it("concats") { expect("foo" + "bar").to eq "foobar" }
+ # end
+ # end
+ #
+ # # Output to the console
+ # # Success: expected to eq "foobar".
#
# @param const [Module, String] A module to include in block context.
# @param block [Proc] The block to define the specs.
#
# @api public