mspec 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'spec/rake/spectask'
3
3
  require 'rake/gempackagetask'
4
+ require 'lib/mspec/version'
4
5
 
5
6
  Spec::Rake::SpecTask.new
6
7
 
@@ -9,7 +10,7 @@ task :default => :spec
9
10
 
10
11
  spec = Gem::Specification.new do |s|
11
12
  s.name = %q{mspec}
12
- s.version = "1.3.0"
13
+ s.version = MSpec::VERSION
13
14
 
14
15
  s.specification_version = 2 if s.respond_to? :specification_version=
15
16
 
@@ -48,9 +48,9 @@ class TagAction < ActionFilter
48
48
  end
49
49
 
50
50
  # Callback for the MSpec :exception event. Sets the +#exception?+
51
- # flag.
51
+ # flag to true.
52
52
  def exception(exception)
53
- @exception = exception
53
+ @exception = true
54
54
  end
55
55
 
56
56
  # Callback for the MSpec :after event. Performs the tag action
@@ -86,7 +86,7 @@ class TagAction < ActionFilter
86
86
  # Returns true if an exception was raised while evaluating the
87
87
  # current example.
88
88
  def exception?
89
- !!@exception
89
+ @exception
90
90
  end
91
91
 
92
92
  def report
@@ -117,6 +117,7 @@ class TagAction < ActionFilter
117
117
 
118
118
  def register
119
119
  super
120
+ MSpec.register :before, self
120
121
  MSpec.register :exception, self
121
122
  MSpec.register :after, self
122
123
  MSpec.register :finish, self
@@ -124,6 +125,7 @@ class TagAction < ActionFilter
124
125
 
125
126
  def unregister
126
127
  super
128
+ MSpec.unregister :before, self
127
129
  MSpec.unregister :exception, self
128
130
  MSpec.unregister :after, self
129
131
  MSpec.unregister :finish, self
@@ -73,10 +73,10 @@ class ContextState
73
73
 
74
74
  if protect("before :each", @before)
75
75
  MSpec.clear_expectations
76
- protect nil, spec
76
+ passed = protect nil, spec
77
77
  if spec
78
78
  MSpec.actions :example, state, spec
79
- protect nil, @expectation_missing unless MSpec.expectation?
79
+ protect nil, @expectation_missing unless MSpec.expectation? or not passed
80
80
  end
81
81
  protect "after :each", @after
82
82
  protect "Mock.verify_count", @mock_verify
@@ -16,6 +16,7 @@ class SpecdocFormatter < DottedFormatter
16
16
  # Callback for the MSpec :before event. Prints the
17
17
  # +it+ block string.
18
18
  def before(state)
19
+ super
19
20
  print "- #{state.it}"
20
21
  end
21
22
 
@@ -1,3 +1,3 @@
1
1
  module MSpec
2
- VERSION = '1.3.0'
2
+ VERSION = '1.3.1'
3
3
  end
@@ -266,6 +266,11 @@ describe TagAction, "#register" do
266
266
  @action = TagAction.new :add, :all, nil, nil, nil, nil
267
267
  end
268
268
 
269
+ it "registers itself with MSpec for the :before event" do
270
+ MSpec.should_receive(:register).with(:before, @action)
271
+ @action.register
272
+ end
273
+
269
274
  it "registers itself with MSpec for the :after event" do
270
275
  MSpec.should_receive(:register).with(:after, @action)
271
276
  @action.register
@@ -289,8 +294,12 @@ describe TagAction, "#unregister" do
289
294
  @action = TagAction.new :add, :all, nil, nil, nil, nil
290
295
  end
291
296
 
297
+ it "unregisters itself with MSpec for the :before event" do
298
+ MSpec.should_receive(:unregister).with(:before, @action)
299
+ @action.unregister
300
+ end
301
+
292
302
  it "unregisters itself with MSpec for the :after event" do
293
- MSpec.should_receive(:unregister).with(:exception, @action)
294
303
  MSpec.should_receive(:unregister).with(:after, @action)
295
304
  @action.unregister
296
305
  end
@@ -231,6 +231,12 @@ describe ContextState, "#process" do
231
231
  @state.process
232
232
  ScratchPad.recorded.should be_nil
233
233
  end
234
+
235
+ it "does not raise an ExpectationNotFoundError if the #it block causes a failure" do
236
+ @state.it("it") { raise Exception, "Failed!" }
237
+ @state.process
238
+ ScratchPad.recorded.should be_nil
239
+ end
234
240
  end
235
241
 
236
242
  describe ContextState, "#process" do
@@ -45,6 +45,14 @@ describe SpecdocFormatter, "#before" do
45
45
  @formatter.before @state
46
46
  @out.should == "- it"
47
47
  end
48
+
49
+ it "resets the #exception? flag" do
50
+ exc = ExceptionState.new @state, nil, ExpectationNotMetError.new("disappointing")
51
+ @formatter.exception exc
52
+ @formatter.exception?.should be_true
53
+ @formatter.before @state
54
+ @formatter.exception?.should be_false
55
+ end
48
56
  end
49
57
 
50
58
  describe SpecdocFormatter, "#exception" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Ford