orangutan 0.0.1 → 0.0.2
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.
- data/README +58 -58
- data/Rakefile +34 -34
- data/VERSION.yml +4 -0
- data/lib/orangutan.rb +2 -2
- data/lib/orangutan/chantek.rb +49 -67
- data/lib/orangutan/clean_slate.rb +31 -2
- data/lib/orangutan/container.rb +3 -1
- data/lib/orangutan/expectation.rb +38 -36
- data/lib/orangutan/raiser.rb +9 -9
- data/lib/orangutan/stub_base.rb +32 -0
- data/orangutan.gemspec +65 -62
- data/prepare.cmd +11 -11
- data/spec/{ClassWithANonVirtualMethod.cs → clr/ClassWithANonVirtualMethod.cs} +12 -12
- data/spec/{ClassWithANonVirtualProperty.cs → clr/ClassWithANonVirtualProperty.cs} +21 -21
- data/spec/{ClassWithAVirtualMethod.cs → clr/ClassWithAVirtualMethod.cs} +13 -13
- data/spec/{ClassWithAVirtualProperty.cs → clr/ClassWithAVirtualProperty.cs} +22 -22
- data/spec/{Consumer.cs → clr/Consumer.cs} +29 -29
- data/spec/{IHaveAMethod.cs → clr/IHaveAMethod.cs} +8 -8
- data/spec/{IHaveAProperty.cs → clr/IHaveAProperty.cs} +9 -9
- data/spec/{IHaveAnEvent.cs → clr/IHaveAnEvent.cs} +8 -8
- data/spec/spec_chantek.rb +60 -60
- data/spec/spec_chantek_clr.rb +11 -11
- data/spec/spec_chantek_recurse.rb +24 -0
- data/spec/spec_expectation.rb +48 -50
- metadata +15 -14
- data/VERSION +0 -1
data/spec/spec_chantek.rb
CHANGED
@@ -1,61 +1,61 @@
|
|
1
|
-
require 'orangutan'
|
2
|
-
|
3
|
-
describe Orangutan::Chantek, 'creating ruby stubs' do
|
4
|
-
before do
|
5
|
-
@o = Orangutan::Chantek.new
|
6
|
-
@foo = @o.stub :foo
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'should record method calls and their parameters on a stub' do
|
10
|
-
@foo.method1(1,2,3)
|
11
|
-
@o.calls[0].should == Orangutan::Call.new(:foo, :method1, [1,2,3])
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'should record all ordinary object methods calls (except __send__ and __id__)' do
|
15
|
-
methods = Object.new.methods
|
16
|
-
methods.each { |m| @foo.__send__(m.to_sym) unless m =~ /^__/ }
|
17
|
-
@o.calls.length.should == (methods.length-2)
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'should allow method return values to be stubbed' do
|
21
|
-
@o.when(:foo).receives(:bar).return('baz')
|
22
|
-
@foo.bar.should == 'baz'
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'should allow method return values to be stubbed for method invocations with specific arguments' do
|
26
|
-
@o.when(:foo).receives(:bar).with(7).return('baz')
|
27
|
-
@foo.bar(7).should == 'baz'
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'should allow stubbed methods to yield' do
|
31
|
-
@o.when(:foo).receives(:bar).with(7).yield('baz')
|
32
|
-
a = nil
|
33
|
-
@foo.bar(7) {|s| a = s}
|
34
|
-
a.should == 'baz'
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'should allow stubbed methods to yield nils' do
|
38
|
-
@o.when(:foo).receives(:bar).yield(nil)
|
39
|
-
called = false
|
40
|
-
@foo.bar {|s| called = true}
|
41
|
-
called.should == true
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'should allow stubbed methods to raise error from string' do
|
45
|
-
@o.when(:foo).receives(:bar).raise("you can't be serious")
|
46
|
-
begin
|
47
|
-
@foo.bar
|
48
|
-
rescue RuntimeError => e
|
49
|
-
e.message.should == "you can't be serious"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'should allow stubbed methods to raise error from string' do
|
54
|
-
@o.when(:foo).receives(:bar).raise(RuntimeError, "you can't be serious")
|
55
|
-
begin
|
56
|
-
@foo.bar
|
57
|
-
rescue RuntimeError => e
|
58
|
-
e.message.should == "you can't be serious"
|
59
|
-
end
|
60
|
-
end
|
1
|
+
require 'orangutan'
|
2
|
+
|
3
|
+
describe Orangutan::Chantek, 'creating ruby stubs' do
|
4
|
+
before do
|
5
|
+
@o = Orangutan::Chantek.new
|
6
|
+
@foo = @o.stub :foo
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should record method calls and their parameters on a stub' do
|
10
|
+
@foo.method1(1,2,3)
|
11
|
+
@o.calls[0].should == Orangutan::Call.new(:foo, :method1, [1,2,3])
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should record all ordinary object methods calls (except __send__ and __id__)' do
|
15
|
+
methods = Object.new.methods
|
16
|
+
methods.each { |m| @foo.__send__(m.to_sym) unless m =~ /^__/ }
|
17
|
+
@o.calls.length.should == (methods.length-2)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should allow method return values to be stubbed' do
|
21
|
+
@o.when(:foo).receives(:bar).return('baz')
|
22
|
+
@foo.bar.should == 'baz'
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should allow method return values to be stubbed for method invocations with specific arguments' do
|
26
|
+
@o.when(:foo).receives(:bar).with(7).return('baz')
|
27
|
+
@foo.bar(7).should == 'baz'
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should allow stubbed methods to yield' do
|
31
|
+
@o.when(:foo).receives(:bar).with(7).yield('baz')
|
32
|
+
a = nil
|
33
|
+
@foo.bar(7) {|s| a = s}
|
34
|
+
a.should == 'baz'
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should allow stubbed methods to yield nils' do
|
38
|
+
@o.when(:foo).receives(:bar).yield(nil)
|
39
|
+
called = false
|
40
|
+
@foo.bar {|s| called = true}
|
41
|
+
called.should == true
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should allow stubbed methods to raise error from string' do
|
45
|
+
@o.when(:foo).receives(:bar).raise("you can't be serious")
|
46
|
+
begin
|
47
|
+
@foo.bar
|
48
|
+
rescue RuntimeError => e
|
49
|
+
e.message.should == "you can't be serious"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should allow stubbed methods to raise error from string' do
|
54
|
+
@o.when(:foo).receives(:bar).raise(RuntimeError, "you can't be serious")
|
55
|
+
begin
|
56
|
+
@foo.bar
|
57
|
+
rescue RuntimeError => e
|
58
|
+
e.message.should == "you can't be serious"
|
59
|
+
end
|
60
|
+
end
|
61
61
|
end
|
data/spec/spec_chantek_clr.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
require 'orangutan'
|
2
|
-
require 'ClassLibrary.dll'
|
3
|
-
|
4
|
-
describe Orangutan::Chantek, 'creating clr stubs' do
|
5
|
-
it 'should create stub implementations of a clr interface with a method' do
|
6
|
-
o = Orangutan::Chantek.new
|
7
|
-
s = o.stub :foo, :clr_interface => ClassLibrary::IHaveAMethod
|
8
|
-
c = ClassLibrary::Consumer.new
|
9
|
-
c.call_method(s)
|
10
|
-
o.calls[0].should == Orangutan::Call.new(:foo, :my_method, ['thing'])
|
11
|
-
end
|
1
|
+
require 'orangutan'
|
2
|
+
require 'ClassLibrary.dll'
|
3
|
+
|
4
|
+
describe Orangutan::Chantek, 'creating clr stubs' do
|
5
|
+
it 'should create stub implementations of a clr interface with a method' do
|
6
|
+
o = Orangutan::Chantek.new
|
7
|
+
s = o.stub :foo, :clr_interface => ClassLibrary::IHaveAMethod
|
8
|
+
c = ClassLibrary::Consumer.new
|
9
|
+
c.call_method(s)
|
10
|
+
o.calls[0].should == Orangutan::Call.new(:foo, :my_method, ['thing'])
|
11
|
+
end
|
12
12
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Orangutan
|
2
|
+
describe Chantek, 'creating recursive ruby stubs' do
|
3
|
+
before do
|
4
|
+
@o = Chantek.new
|
5
|
+
@foo = @o.stub :foo, :recursive => true
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should return the same object when generating a stub for the same name" do
|
9
|
+
@foo.__id__.should. == @o.stub(:foo).__id__
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should return nil instead of new stub when instructed to" do
|
13
|
+
@o.when(:foo).receives(:bar).return(nil)
|
14
|
+
@foo.bar.should == nil
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should return new stubs from each method call" do
|
18
|
+
bar = @foo.bar
|
19
|
+
baz = bar.baz
|
20
|
+
@o.calls[0].should == Call.new(:foo, :bar,[])
|
21
|
+
@o.calls[1].should == Call.new(:"foo/bar", :baz,[])
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/spec/spec_expectation.rb
CHANGED
@@ -1,51 +1,49 @@
|
|
1
|
-
require 'orangutan'
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
@e.raise('description').raiser.should.not == nil
|
50
|
-
end
|
1
|
+
require 'orangutan'
|
2
|
+
|
3
|
+
module Orangutan
|
4
|
+
describe Expectation do
|
5
|
+
before do
|
6
|
+
@e = Expectation.new.receives(:foo)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should not match when method is different' do
|
10
|
+
@e.matches?(:bar).should == false
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should match when method matches and args are unspecified' do
|
14
|
+
@e.matches?(:foo).should == true
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should match when method matches and args match' do
|
18
|
+
@e.with(7).matches?(:foo, 7).should == true
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should not match when method matches but args do not match' do
|
22
|
+
@e.with(7).matches?(:foo, 8).should == false
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should not yield by default' do
|
26
|
+
@e.yield_container.should == nil
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should store yield_value' do
|
30
|
+
@e.yield(1).yield_container.should == Container.new(1)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should not return by default' do
|
34
|
+
@e.return_container.should == nil
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should store return value' do
|
38
|
+
@e.return(1).return_container.should == Container.new(1)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should not raise by default' do
|
42
|
+
@e.raiser.should == nil
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should store raiser' do
|
46
|
+
@e.raise('description').raiser.should.not == nil
|
47
|
+
end
|
48
|
+
end
|
51
49
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: orangutan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Ryall
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-10 00:00:00 +10:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -24,7 +24,7 @@ extra_rdoc_files:
|
|
24
24
|
files:
|
25
25
|
- README
|
26
26
|
- Rakefile
|
27
|
-
- VERSION
|
27
|
+
- VERSION.yml
|
28
28
|
- lib/orangutan.rb
|
29
29
|
- lib/orangutan/call.rb
|
30
30
|
- lib/orangutan/chantek.rb
|
@@ -32,23 +32,23 @@ files:
|
|
32
32
|
- lib/orangutan/container.rb
|
33
33
|
- lib/orangutan/expectation.rb
|
34
34
|
- lib/orangutan/raiser.rb
|
35
|
+
- lib/orangutan/stub_base.rb
|
35
36
|
- orangutan.gemspec
|
36
37
|
- prepare.cmd
|
37
|
-
- spec/ClassWithANonVirtualMethod.cs
|
38
|
-
- spec/ClassWithANonVirtualProperty.cs
|
39
|
-
- spec/ClassWithAVirtualMethod.cs
|
40
|
-
- spec/ClassWithAVirtualProperty.cs
|
41
|
-
- spec/Consumer.cs
|
42
|
-
- spec/IHaveAMethod.cs
|
43
|
-
- spec/IHaveAProperty.cs
|
44
|
-
- spec/IHaveAnEvent.cs
|
38
|
+
- spec/clr/ClassWithANonVirtualMethod.cs
|
39
|
+
- spec/clr/ClassWithANonVirtualProperty.cs
|
40
|
+
- spec/clr/ClassWithAVirtualMethod.cs
|
41
|
+
- spec/clr/ClassWithAVirtualProperty.cs
|
42
|
+
- spec/clr/Consumer.cs
|
43
|
+
- spec/clr/IHaveAMethod.cs
|
44
|
+
- spec/clr/IHaveAProperty.cs
|
45
|
+
- spec/clr/IHaveAnEvent.cs
|
45
46
|
- spec/spec_chantek.rb
|
46
47
|
- spec/spec_chantek_clr.rb
|
48
|
+
- spec/spec_chantek_recurse.rb
|
47
49
|
- spec/spec_expectation.rb
|
48
50
|
has_rdoc: true
|
49
51
|
homepage: http://github.com/markryall/orangutan
|
50
|
-
licenses: []
|
51
|
-
|
52
52
|
post_install_message:
|
53
53
|
rdoc_options:
|
54
54
|
- --charset=UTF-8
|
@@ -69,11 +69,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
69
|
requirements: []
|
70
70
|
|
71
71
|
rubyforge_project: orangutan
|
72
|
-
rubygems_version: 1.3.
|
72
|
+
rubygems_version: 1.3.1
|
73
73
|
signing_key:
|
74
74
|
specification_version: 2
|
75
75
|
summary: A mock objects library
|
76
76
|
test_files:
|
77
77
|
- spec/spec_chantek.rb
|
78
78
|
- spec/spec_chantek_clr.rb
|
79
|
+
- spec/spec_chantek_recurse.rb
|
79
80
|
- spec/spec_expectation.rb
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.0.1
|