1 require File.dirname(__FILE__) + '/../../spec_helper'
5 module ModuleThatIsReopened
9 include ModuleThatIsReopened
12 module ModuleThatIsReopened
13 def module_that_is_reopened_method
17 describe "ExampleMethods with an included module that is reopened" do
18 it "should have repoened methods" do
19 method(:module_that_is_reopened_method).should_not be_nil
23 describe ExampleMethods, "lifecycle" do
25 @options = ::Spec::Runner::Options.new(StringIO.new, StringIO.new)
26 @options.formatters << mock("formatter", :null_object => true)
27 @options.backtrace_tweaker = mock("backtrace_tweaker", :null_object => true)
28 @reporter = FakeReporter.new(@options)
29 @options.reporter = @reporter
31 ExampleMethods.before_all_parts.should == []
32 ExampleMethods.before_each_parts.should == []
33 ExampleMethods.after_each_parts.should == []
34 ExampleMethods.after_all_parts.should == []
35 def ExampleMethods.count
43 ExampleMethods.instance_variable_set("@before_all_parts", [])
44 ExampleMethods.instance_variable_set("@before_each_parts", [])
45 ExampleMethods.instance_variable_set("@after_each_parts", [])
46 ExampleMethods.instance_variable_set("@after_all_parts", [])
49 it "should pass before and after callbacks to all ExampleGroup subclasses" do
50 ExampleMethods.before(:all) do
51 ExampleMethods.count.should == 1
54 ExampleMethods.before(:each) do
55 ExampleMethods.count.should == 2
58 ExampleMethods.after(:each) do
59 ExampleMethods.count.should == 3
62 ExampleMethods.after(:all) do
63 ExampleMethods.count.should == 4
66 @example_group = Class.new(ExampleGroup) do
67 it "should use ExampleMethods callbacks" do
71 ExampleMethods.count.should == 5
74 describe "run_with_description_capturing" do
76 @example_group = Class.new(ExampleGroup) do end
77 @example = @example_group.new("foo", &(lambda { 2.should == 2 }))
78 @example.run_with_description_capturing
81 it "should provide the generated description" do
82 @example.instance_eval { @_matcher_description }.should == "should == 2"
85 it "should clear the global generated_description" do
86 Spec::Matchers.generated_description.should == nil