Skip to content

Commit

Permalink
More refactoring away global options - example_group.run now requires…
Browse files Browse the repository at this point in the history
… options passed in.
  • Loading branch information
dchelimsky committed Dec 18, 2008
1 parent 48a77e3 commit 07a299e
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 53 deletions.
2 changes: 1 addition & 1 deletion lib/spec/example/example_group_methods.rb
Expand Up @@ -161,7 +161,7 @@ def xexample(description=nil, opts={}, &block)
alias_method :xit, :xexample
alias_method :xspecify, :xexample

def run(run_options=Spec::Runner.options)
def run(run_options)
examples = examples_to_run(run_options)
run_options.reporter.add_example_group(self) unless examples.empty?
return true if examples.empty?
Expand Down
8 changes: 4 additions & 4 deletions spec/spec/example/configuration_spec.rb
Expand Up @@ -150,7 +150,7 @@ module Example
@example_group.it "calls prepend_before" do
end

@example_group.run
@example_group.run(Spec::Runner.options)
order.should == [
:prepend__before_all,
:special_prepend__before_all,
Expand Down Expand Up @@ -193,7 +193,7 @@ module Example
@example_group.it "calls append_before" do
end

@example_group.run
@example_group.run(Spec::Runner.options)
order.should == [
:append_before_all,
:special_append_before_all,
Expand Down Expand Up @@ -236,7 +236,7 @@ module Example
@example_group.it "calls prepend_after" do
end

@example_group.run
@example_group.run(Spec::Runner.options)
order.should == [
:special_child_prepend__after_each,
:special_prepend__after_each,
Expand Down Expand Up @@ -279,7 +279,7 @@ module Example
@example_group.it "calls append_after" do
end

@example_group.run
@example_group.run(Spec::Runner.options)
order.should == [
:special_child_append__after_each,
:special_append__after_each,
Expand Down
74 changes: 37 additions & 37 deletions spec/spec/example/example_group_spec.rb
Expand Up @@ -60,7 +60,7 @@ class ExampleClassVariablePollutionSpec < ExampleGroup

describe ExampleGroup, "#run with failure in example", :shared => true do
it "should add an example failure to the TestResult" do
example_group.run.should be_false
example_group.run(options).should be_false
end
end

Expand Down Expand Up @@ -96,7 +96,7 @@ class << example_group

reporter = mock("Reporter")
reporter.should_not_receive(:add_example_group)
example_group.run
example_group.run(options)
end

describe "when before_each fails" do
Expand All @@ -114,20 +114,20 @@ class << example_group
end

it "should not run example block" do
example_group.run
example_group.run(options)
$example_ran.should be_false
end

it "should run after_each" do
example_group.run
example_group.run(options)
$after_each_ran.should be_true
end

it "should report failure location when in before_each" do
reporter.should_receive(:example_finished) do |example_group, error|
error.message.should eql("in before_each")
end
example_group.run
example_group.run(options)
end
end

Expand All @@ -142,15 +142,15 @@ class << example_group
ExampleGroup.before(:all) { before_all_ran = true }
ExampleGroup.after(:all) { after_all_ran = true }
example_group.it("should") {}
example_group.run
example_group.run(options)
before_all_ran.should be_false
after_all_ran.should be_false
end

it "should not run example" do
example_ran = false
example_group.it("should") {example_ran = true}
example_group.run
example_group.run(options)
example_ran.should be_false
end
end
Expand Down Expand Up @@ -178,7 +178,7 @@ class << example_group
end

it "should not run the Examples in the ExampleGroup" do
example_group.run
example_group.run(options)
examples_that_were_run.should == ['should be run', 'should also be run']
end
end
Expand All @@ -196,7 +196,7 @@ class << example_group
end

it "should not run the example" do
example_group.run
example_group.run(options)
examples_that_were_run.should == ['should be run']
end
end
Expand All @@ -214,7 +214,7 @@ class << example_group
end

it "should not run the example" do
example_group.run
example_group.run(options)
examples_that_were_run.should == []
end
end
Expand All @@ -235,12 +235,12 @@ class << example_group
end

it "should run only the example, when there is only one" do
example_group.run
example_group.run(options)
examples_that_were_run.should == ["should be run"]
end

it "should run only the one example" do
example_group.run
example_group.run(options)
examples_that_were_run.should == ["should be run"] end
end
end
Expand All @@ -258,14 +258,14 @@ class << example_group
end

it "should send reporter add_example_group" do
example_group.run
example_group.run(options)
reporter.example_groups.should == [example_group]
end

it "should run example on run" do
example_ran = false
example_group.it("should") {example_ran = true}
example_group.run
example_group.run(options)
example_ran.should be_true
end

Expand All @@ -274,7 +274,7 @@ class << example_group
example_group.before(:all) {before_all_run_count_run_count += 1}
example_group.it("test") {true}
example_group.it("test2") {true}
example_group.run
example_group.run(options)
before_all_run_count_run_count.should == 1
end

Expand All @@ -283,7 +283,7 @@ class << example_group
example_group.after(:all) {after_all_run_count += 1}
example_group.it("test") {true}
example_group.it("test2") {true}
example_group.run
example_group.run(options)
after_all_run_count.should == 1
@reporter.rspec_verify
end
Expand All @@ -294,7 +294,7 @@ class << example_group
example_group.before(:all) { @instance_var = context_instance_value_in }
example_group.after(:all) { context_instance_value_out = @instance_var }
example_group.it("test") {true}
example_group.run
example_group.run(options)
context_instance_value_in.should == context_instance_value_out
end

Expand All @@ -303,7 +303,7 @@ class << example_group
context_instance_value_out = ""
example_group.before(:all) { @instance_var = context_instance_value_in }
example_group.it("test") {context_instance_value_out = @instance_var}
example_group.run
example_group.run(options)
context_instance_value_in.should == context_instance_value_out
end

Expand All @@ -321,7 +321,7 @@ class << example_group
describe("I'm not special", :type => :not_special)
it "does nothing"
end
example_group.run
example_group.run(options)
fiddle.should == [
'Example.prepend_before(:all)',
'Example.before(:all)',
Expand All @@ -341,7 +341,7 @@ class << example_group

example_group = Class.new(@special_example_group).describe("I'm a special example_group") {}
example_group.it("test") {true}
example_group.run
example_group.run(options)
fiddle.should == [
'Example.prepend_before(:all)',
'Example.before(:all)',
Expand All @@ -361,7 +361,7 @@ class << example_group
example_group.before(:all) { fiddle << "before(:all)" }
example_group.prepend_before(:each) { fiddle << "prepend_before(:each)" }
example_group.before(:each) { fiddle << "before(:each)" }
example_group.run
example_group.run(options)
fiddle.should == [
'Example.prepend_before(:all)',
'Example.before(:all)',
Expand All @@ -380,7 +380,7 @@ class << example_group
example_group.append_after(:all) { fiddle << "append_after(:all)" }
ExampleGroup.after(:all) { fiddle << "Example.after(:all)" }
ExampleGroup.append_after(:all) { fiddle << "Example.append_after(:all)" }
example_group.run
example_group.run(options)
fiddle.should == [
'after(:each)',
'append_after(:each)',
Expand Down Expand Up @@ -412,7 +412,7 @@ class << example_group
mod1_method
mod2_method
end
example_group.run
example_group.run(options)
mod1_method_called.should be_true
mod2_method_called.should be_true
end
Expand All @@ -427,7 +427,7 @@ class << example_group
example_group = Class.new(@special_example_group).describe("I'm special", :type => :special) do
it "does nothing"
end
example_group.run
example_group.run(options)

example_group.included_modules.should include(mod1)
example_group.included_modules.should include(mod2)
Expand All @@ -443,7 +443,7 @@ class << example_group
$included_predicate_matcher_found = respond_to?(:do_something)
end
end
example_group.run
example_group.run(options)
$included_predicate_matcher_found.should be(true)
end

Expand All @@ -467,7 +467,7 @@ def teardown_mocks_for_rspec
describe('example')
it "does nothing"
end
example_group.run
example_group.run(options)

$included_module.should_not be_nil
$torn_down.should == true
Expand All @@ -486,7 +486,7 @@ def teardown_mocks_for_rspec

it "should send example_pending to formatter" do
@formatter.should_receive(:example_pending).with("example", "should be pending", "Example fails")
example_group.run
example_group.run(options)
end
end

Expand All @@ -501,7 +501,7 @@ def teardown_mocks_for_rspec

it "should send example_pending to formatter" do
@formatter.should_receive(:example_pending).with("example", "should be pending", "Example passes")
example_group.run
example_group.run(options)
end
end

Expand All @@ -515,21 +515,21 @@ def teardown_mocks_for_rspec
it "should not run any example" do
spec_ran = false
example_group.it("test") {spec_ran = true}
example_group.run
example_group.run(options)
spec_ran.should be_false
end

it "should run ExampleGroup after(:all)" do
after_all_ran = false
ExampleGroup.after(:all) { after_all_ran = true }
example_group.run
example_group.run(options)
after_all_ran.should be_true
end

it "should run example_group after(:all)" do
after_all_ran = false
example_group.after(:all) { after_all_ran = true }
example_group.run
example_group.run(options)
after_all_ran.should be_true
end

Expand All @@ -540,7 +540,7 @@ def teardown_mocks_for_rspec
end

example_group.it("test") {true}
example_group.run
example_group.run(options)
end
end

Expand All @@ -554,7 +554,7 @@ def teardown_mocks_for_rspec
it "should run after(:all)" do
after_all_ran = false
ExampleGroup.after(:all) { after_all_ran = true }
example_group.run
example_group.run(options)
after_all_ran.should be_true
end
end
Expand All @@ -569,7 +569,7 @@ def teardown_mocks_for_rspec
it "should run after(:all)" do
after_all_ran = false
ExampleGroup.after(:all) { after_all_ran = true }
example_group.run
example_group.run(options)
after_all_ran.should be_true
end
end
Expand Down Expand Up @@ -598,7 +598,7 @@ class << example_group
example.should equal(example)
error.message.should eql("first")
end
example_group.run
example_group.run(options)
example_group.first_after_ran.should be_true
example_group.second_after_ran.should be_true
end
Expand Down Expand Up @@ -627,7 +627,7 @@ class << example_group
reporter.should_receive(:example_finished) do |name, error|
error.message.should eql("first")
end
example_group.run
example_group.run(options)
example_group.first_before_ran.should be_true
example_group.second_before_ran.should be_false
end
Expand All @@ -641,7 +641,7 @@ class << example_group
end

it "should return false" do
example_group.run.should be_false
example_group.run(options).should be_false
end
end
end
Expand Down

0 comments on commit 07a299e

Please sign in to comment.