em-dextras 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/em-dextras/spec/spy.rb +3 -1
- data/lib/em-dextras/version.rb +1 -1
- data/spec/em-dextras/spec/spy_spec.rb +11 -0
- metadata +2 -2
data/lib/em-dextras/spec/spy.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
module EMDextras::Spec
|
2
2
|
class Spy
|
3
|
-
def initialize
|
3
|
+
def initialize(options = {})
|
4
4
|
@calls = []
|
5
|
+
@return_value = options[:default_return]
|
5
6
|
end
|
6
7
|
|
7
8
|
def called?(method_name, *args)
|
@@ -16,6 +17,7 @@ module EMDextras::Spec
|
|
16
17
|
|
17
18
|
def method_missing(method_name, *args, &block)
|
18
19
|
@calls << { :name => method_name, :args => args }
|
20
|
+
@return_value
|
19
21
|
end
|
20
22
|
|
21
23
|
private
|
data/lib/em-dextras/version.rb
CHANGED
@@ -12,6 +12,17 @@ describe EMDextras::Spec::Spy do
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
+
describe "default return value" do
|
16
|
+
it "returns nil if no default return value is defined" do
|
17
|
+
spy = EMDextras::Spec::Spy.new
|
18
|
+
spy.some_method.should == nil
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns the default value if defined" do
|
22
|
+
spy = EMDextras::Spec::Spy.new :default_return => "default"
|
23
|
+
spy.some_method.should == "default"
|
24
|
+
end
|
25
|
+
end
|
15
26
|
describe :received_call! do
|
16
27
|
it "should do nothing if the call was really received" do
|
17
28
|
EM.run do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: em-dextras
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine
|