crispy 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aeabc7281ef6034dc9561bf66275b5a96646ec7e
4
- data.tar.gz: 0d59f9c8a70531346cfc064724520b0703511d7f
3
+ metadata.gz: c3f5cac13b6c7c9ab3d1a02c14d7c4aab8d49a37
4
+ data.tar.gz: 0d3a8f30a788ca7b6f65656e2d754500edfed384
5
5
  SHA512:
6
- metadata.gz: 10e249a572a5a3ac6e17aaf6a0bc537472467157a788c7a1fb1f3014764f6266fb1ac32ea453a6ecebe4284372302833680ab07ee94248ca54e60357b9b55f82
7
- data.tar.gz: 65fcd4b0434c4ca977a47439864cabf6133fa3a7e29d26494cd464cfadafdbafec6ee8136b8a8fb8545faeb297766dbc0e3150935911aaeace032a7ce23cd6fa
6
+ metadata.gz: 18e6deacab79ac272ae87429c086e1f087209f237c428c1fd5f4a5e23fe58b02d583df118d8534692d79d03a167024f0559f266d8f4851cab6bbe25377d956f2
7
+ data.tar.gz: 831d33b2b1878255f2396b2f2d14175569e5a6e5ad17d8d81a97864f27b93d69e8cadf7ce58b90ac070bfd973170ce5556bbc028a8679a4a22c3911d4e208e27
data/ChangeLog.md CHANGED
@@ -1,7 +1,12 @@
1
+ # 0.3.3 (2015.3.27)
2
+
3
+ - Fix Bug: Causes a crash when some of `@spies_to_reset` gets GCed just before `reinitialize`. [3a1ce2d](https://github.com/igrep/crispy/commit/3a1ce2dfc25ba48d07505b6ed1d7125f393e9579)
4
+ - Enhancement: raise error when given some non spied object (or class) by mistake. [4719652](https://github.com/igrep/crispy/commit/4719652d35292749b76fd2531bfec83a4d383a66 )
5
+
1
6
  # 0.3.2 (2015.1.11)
2
7
 
3
8
  - New Feature: `spied_instances?`. [#28](https://github.com/igrep/crispy/pull/28)
4
- - Enhancement only for developers of crispy: reduce the number of gems we install by `bundle install`.
9
+ - Enhancement: only for developers of crispy: reduce the number of gems we install by `bundle install`.
5
10
  - Refactor: minor changes. [`701a051`](https://github.com/igrep/crispy/commit/701a051d3910e8b9f0470c0f3e9cb81ed643f8af)
6
11
 
7
12
  # 0.3.1 (2015.1.3)
data/lib/crispy.rb CHANGED
@@ -24,10 +24,14 @@ module Crispy
24
24
 
25
25
  def spy object
26
26
  object.__CRISPY_SPY__
27
+ rescue ::NoMethodError
28
+ object_string = object.inspect rescue 'object' # BasicObject can't inspect!
29
+ raise ::Crispy::CrispyError, "#{object_string} is not spied!"
27
30
  end
28
31
 
29
32
  def spy_of_instances klass
30
- ::Crispy::CrispyInternal::ClassSpy.of_target(klass)
33
+ ::Crispy::CrispyInternal::ClassSpy.of_target(klass) \
34
+ || raise(::Crispy::CrispyError, "#{klass} does not have its instances spied!")
31
35
  end
32
36
 
33
37
  def stub_const full_const_name, value
@@ -43,4 +47,7 @@ module Crispy
43
47
  !!::Crispy::CrispyInternal::ClassSpy.of_target(klass)
44
48
  end
45
49
 
50
+ class CrispyError < ::Exception
51
+ end
52
+
46
53
  end
@@ -49,9 +49,12 @@ module Crispy
49
49
 
50
50
  def self.reset_all
51
51
  # get rid of spies of GCed objects
52
- @spies_to_reset.select! {|spy| spy.weakref_alive? }
53
-
54
- @spies_to_reset.each {|spy| spy.reinitialize }
52
+ @spies_to_reset.select! do|spy|
53
+ if alive = spy.weakref_alive?
54
+ spy.reinitialize
55
+ end
56
+ alive
57
+ end
55
58
  end
56
59
 
57
60
  end
@@ -1,3 +1,3 @@
1
1
  module Crispy
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
data/test/test_crispy.rb CHANGED
@@ -49,7 +49,7 @@ class TestCrispy < MiniTest::Test
49
49
  'method to stub 3 (before stubbed)'
50
50
  end
51
51
 
52
- def private_foo a
52
+ def private_foo _
53
53
  :private_foo
54
54
  end
55
55
  private :private_foo
@@ -204,6 +204,10 @@ class TestCrispy < MiniTest::Test
204
204
  assert_equal(:stubbed2, @object.method_to_stub2)
205
205
  end
206
206
 
207
+ def test_spy_raises_an_error_given_non_spied_object
208
+ assert_raises(::Crispy::CrispyError){ spy(ObjectClass.new) }
209
+ end
210
+
207
211
  end
208
212
 
209
213
  class TestCrispySpyIntoClass < TestCrispy
@@ -259,6 +263,10 @@ class TestCrispy < MiniTest::Test
259
263
  assert_equal 1, spy(ObjectClass).count_received(:stubbed_method1)
260
264
  end
261
265
 
266
+ def test_spy_of_instances_raises_an_error_given_non_spied_instances_object
267
+ assert_raises(::Crispy::CrispyError){ spy_of_instances(Class.new) }
268
+ end
269
+
262
270
  end
263
271
 
264
272
  class TestCrispySpyIntoInstances < TestCrispy
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crispy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuji Yamamoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-11 00:00:00.000000000 Z
11
+ date: 2015-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler