stubble 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/Rakefile +1 -1
  2. data/lib/stubble.rb +1 -1
  3. data/test/stubble_test.rb +20 -0
  4. metadata +3 -3
data/Rakefile CHANGED
@@ -34,7 +34,7 @@ spec = Gem::Specification.new do |s|
34
34
 
35
35
  # Change these as appropriate
36
36
  s.name = "stubble"
37
- s.version = "0.1.2"
37
+ s.version = "0.1.3"
38
38
  s.summary = "(experimental) simple stubbing"
39
39
  s.author = "Matthew Rudy Jacobs"
40
40
  s.email = "MatthewRudyJacobs@gmail.com"
data/lib/stubble.rb CHANGED
@@ -90,7 +90,7 @@ module Stubble
90
90
 
91
91
  unstubbled_method_name = "__unstubbled__#{method_name}"
92
92
  unless methods.include?(unstubbled_method_name)
93
- class_eval <<-RUBY
93
+ instance_eval <<-RUBY
94
94
  alias #{unstubbled_method_name} #{method_name}
95
95
  def #{method_name}(*args, &block)
96
96
  if stubbed_return = self._stubble.called!(#{method_name.inspect}, args, block)
data/test/stubble_test.rb CHANGED
@@ -28,6 +28,10 @@ class StubbleTest < Test::Unit::TestCase
28
28
  yield @hits+=1
29
29
  end
30
30
 
31
+ def self.some_classy
32
+ "classy"
33
+ end
34
+
31
35
  end
32
36
 
33
37
  test "stubble is added on an individual basis" do
@@ -65,6 +69,13 @@ class StubbleTest < Test::Unit::TestCase
65
69
  assert_equal [[[2],false], [[1,"purple"],false]], this._stubble[:some_method_with_arguments]
66
70
  end
67
71
 
72
+ test "track! - with a class" do
73
+ Stubble.add_stubble!(StubThis)
74
+
75
+ StubThis.track!(:some_classy)
76
+ StubThis.some_classy
77
+ end
78
+
68
79
  test "track! - tracks blocks" do
69
80
  this = StubThis.new
70
81
 
@@ -140,6 +151,15 @@ class StubbleTest < Test::Unit::TestCase
140
151
  assert_equal 2, this.some_method
141
152
  end
142
153
 
154
+ test "stub! - with a class" do
155
+ Stubble.add_stubble!(StubThis)
156
+
157
+ assert_equal "classy", StubThis.some_classy
158
+ StubThis.stub!(:some_classy, ["purple"])
159
+ assert_equal "purple", StubThis.some_classy
160
+ assert_equal "classy", StubThis.some_classy
161
+ end
162
+
143
163
  test "stub! - can be done progressively" do
144
164
  this = StubThis.new
145
165
  assert_equal 1, this.some_method
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stubble
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matthew Rudy Jacobs