From 04683a0f74e774d4cd1ef362908e9befb9e532fd Mon Sep 17 00:00:00 2001 From: Brian Ford Date: Fri, 11 Jul 2008 12:07:08 -0700 Subject: [PATCH] Updated MSpec source to 49dcfba0. --- mspec/lib/mspec/runner/actions/tag.rb | 8 +++++--- mspec/lib/mspec/runner/formatters/specdoc.rb | 1 + mspec/spec/runner/actions/tag_spec.rb | 11 ++++++++++- mspec/spec/runner/formatters/specdoc_spec.rb | 8 ++++++++ 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/mspec/lib/mspec/runner/actions/tag.rb b/mspec/lib/mspec/runner/actions/tag.rb index 4916a1f7a..760152b2a 100644 --- a/mspec/lib/mspec/runner/actions/tag.rb +++ b/mspec/lib/mspec/runner/actions/tag.rb @@ -48,9 +48,9 @@ class TagAction < ActionFilter end # Callback for the MSpec :exception event. Sets the +#exception?+ - # flag. + # flag to true. def exception(exception) - @exception = exception + @exception = true end # Callback for the MSpec :after event. Performs the tag action @@ -86,7 +86,7 @@ class TagAction < ActionFilter # Returns true if an exception was raised while evaluating the # current example. def exception? - !!@exception + @exception end def report @@ -117,6 +117,7 @@ class TagAction < ActionFilter def register super + MSpec.register :before, self MSpec.register :exception, self MSpec.register :after, self MSpec.register :finish, self @@ -124,6 +125,7 @@ class TagAction < ActionFilter def unregister super + MSpec.unregister :before, self MSpec.unregister :exception, self MSpec.unregister :after, self MSpec.unregister :finish, self diff --git a/mspec/lib/mspec/runner/formatters/specdoc.rb b/mspec/lib/mspec/runner/formatters/specdoc.rb index 23adc1d17..29adde3c5 100644 --- a/mspec/lib/mspec/runner/formatters/specdoc.rb +++ b/mspec/lib/mspec/runner/formatters/specdoc.rb @@ -16,6 +16,7 @@ class SpecdocFormatter < DottedFormatter # Callback for the MSpec :before event. Prints the # +it+ block string. def before(state) + super print "- #{state.it}" end diff --git a/mspec/spec/runner/actions/tag_spec.rb b/mspec/spec/runner/actions/tag_spec.rb index e098a0e41..1d74ae942 100644 --- a/mspec/spec/runner/actions/tag_spec.rb +++ b/mspec/spec/runner/actions/tag_spec.rb @@ -266,6 +266,11 @@ describe TagAction, "#register" do @action = TagAction.new :add, :all, nil, nil, nil, nil end + it "registers itself with MSpec for the :before event" do + MSpec.should_receive(:register).with(:before, @action) + @action.register + end + it "registers itself with MSpec for the :after event" do MSpec.should_receive(:register).with(:after, @action) @action.register @@ -289,8 +294,12 @@ describe TagAction, "#unregister" do @action = TagAction.new :add, :all, nil, nil, nil, nil end + it "unregisters itself with MSpec for the :before event" do + MSpec.should_receive(:unregister).with(:before, @action) + @action.unregister + end + it "unregisters itself with MSpec for the :after event" do - MSpec.should_receive(:unregister).with(:exception, @action) MSpec.should_receive(:unregister).with(:after, @action) @action.unregister end diff --git a/mspec/spec/runner/formatters/specdoc_spec.rb b/mspec/spec/runner/formatters/specdoc_spec.rb index c1272cef1..a4f91aee9 100644 --- a/mspec/spec/runner/formatters/specdoc_spec.rb +++ b/mspec/spec/runner/formatters/specdoc_spec.rb @@ -45,6 +45,14 @@ describe SpecdocFormatter, "#before" do @formatter.before @state @out.should == "- it" end + + it "resets the #exception? flag" do + exc = ExceptionState.new @state, nil, ExpectationNotMetError.new("disappointing") + @formatter.exception exc + @formatter.exception?.should be_true + @formatter.before @state + @formatter.exception?.should be_false + end end describe SpecdocFormatter, "#exception" do -- 2.11.4.GIT