stubborn 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +2 -2
- data/VERSION +1 -1
- data/lib/stubborn.rb +3 -9
- data/stubborn.gemspec +1 -1
- data/test/stubborn_test.rb +2 -2
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -9,7 +9,7 @@ Let's explain through an example. Say you have this classes:
|
|
9
9
|
class Api
|
10
10
|
def slow_method(a, b, c)
|
11
11
|
...
|
12
|
-
#this is slow
|
12
|
+
#this is slow, dangerous, or it's just an external dependency that should be stubbed
|
13
13
|
...
|
14
14
|
end
|
15
15
|
end
|
@@ -51,7 +51,7 @@ Which produces this output:
|
|
51
51
|
GreatClass.singleton.stub!(:slow_method).with(123, AClass, "hi").and_return(another_class_instance)
|
52
52
|
GreatClass.singleton.stub!(:slow_method).and_return(another_class_instance)
|
53
53
|
|
54
|
-
So all class methods of the Api class and
|
54
|
+
So all unstubbed class methods of the Api class and its instances will raise this special exception while running the tests. If you prefer you can use it on a single instance like this:
|
55
55
|
|
56
56
|
Stubborn.should_be_stubbed(Api.new)
|
57
57
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
data/lib/stubborn.rb
CHANGED
@@ -1,10 +1,3 @@
|
|
1
|
-
begin
|
2
|
-
require 'proxen'
|
3
|
-
rescue LoadError
|
4
|
-
puts "You need to install the proxen gem: sudo gem install nakajima-proxen -s http://gems.github.com"
|
5
|
-
exit
|
6
|
-
end
|
7
|
-
|
8
1
|
require 'suggesters/rspec_suggester'
|
9
2
|
require 'missed_stub_exception'
|
10
3
|
|
@@ -18,8 +11,9 @@ module Stubborn
|
|
18
11
|
end
|
19
12
|
|
20
13
|
class ProxyForInstance
|
21
|
-
|
22
|
-
|
14
|
+
instance_methods.each do |sym|
|
15
|
+
undef_method(sym) unless sym.to_s =~ /__/ || sym.to_s == "send"
|
16
|
+
end
|
23
17
|
|
24
18
|
def initialize(proxy_target, options = {})
|
25
19
|
options = {:class => proxy_target.class}.merge(options)
|
data/stubborn.gemspec
CHANGED
data/test/stubborn_test.rb
CHANGED
@@ -33,7 +33,7 @@ Expectations do
|
|
33
33
|
reset_test_api_class
|
34
34
|
api = TestApi.new
|
35
35
|
api = Stubborn.should_be_stubbed(api)
|
36
|
-
api.
|
36
|
+
api.send(method, TestApi)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -42,7 +42,7 @@ Expectations do
|
|
42
42
|
reset_test_api_class
|
43
43
|
api = TestApi.new
|
44
44
|
proxied_api = Stubborn.should_be_stubbed(api)
|
45
|
-
proxied_api.
|
45
|
+
proxied_api.send(method, api)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|