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.
@@ -0,0 +1,32 @@
1
+ module Orangutan
2
+ class StubBase
3
+ instance_methods.each { |m| undef_method m unless m =~ /^__/ }
4
+
5
+ def initialize name, parent, recursive=false
6
+ @name, @parent, @recursive = name, parent, recursive
7
+ end
8
+
9
+ def method_missing method, *args
10
+ yield_container, return_container = __react__(method, args)
11
+ yield yield_container.value if yield_container && block_given?
12
+ __return__(method, return_container)
13
+ end
14
+ private
15
+ def __return__ method, return_container
16
+ return return_container.value if return_container
17
+ return @parent.stub(:"#{@name}/#{method}") if @recursive
18
+ nil
19
+ end
20
+
21
+ def __react__ method, args
22
+ yield_container, return_container = nil, nil
23
+ @parent.calls << Call.new(@name, method, args)
24
+ first_match = @parent.first_match(@name, method, args)
25
+ if first_match
26
+ first_match.raiser.execute if first_match.raiser
27
+ yield_container, return_container = first_match.yield_container, first_match.return_container
28
+ end
29
+ return yield_container, return_container
30
+ end
31
+ end
32
+ end
data/orangutan.gemspec CHANGED
@@ -1,62 +1,65 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- Gem::Specification.new do |s|
4
- s.name = %q{orangutan}
5
- s.version = "0.0.1"
6
-
7
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Mark Ryall"]
9
- s.date = %q{2009-05-09}
10
- s.description = %q{A mocking library that supports creation of ironruby mock objects (in addition to pure ruby ones)}
11
- s.email = %q{mark@ryall.name}
12
- s.extra_rdoc_files = [
13
- "README"
14
- ]
15
- s.files = [
16
- "README",
17
- "Rakefile",
18
- "VERSION",
19
- "lib/orangutan.rb",
20
- "lib/orangutan/call.rb",
21
- "lib/orangutan/chantek.rb",
22
- "lib/orangutan/clean_slate.rb",
23
- "lib/orangutan/container.rb",
24
- "lib/orangutan/expectation.rb",
25
- "lib/orangutan/raiser.rb",
26
- "orangutan.gemspec",
27
- "prepare.cmd",
28
- "spec/ClassWithANonVirtualMethod.cs",
29
- "spec/ClassWithANonVirtualProperty.cs",
30
- "spec/ClassWithAVirtualMethod.cs",
31
- "spec/ClassWithAVirtualProperty.cs",
32
- "spec/Consumer.cs",
33
- "spec/IHaveAMethod.cs",
34
- "spec/IHaveAProperty.cs",
35
- "spec/IHaveAnEvent.cs",
36
- "spec/spec_chantek.rb",
37
- "spec/spec_chantek_clr.rb",
38
- "spec/spec_expectation.rb"
39
- ]
40
- s.has_rdoc = true
41
- s.homepage = %q{http://github.com/markryall/orangutan}
42
- s.rdoc_options = ["--charset=UTF-8"]
43
- s.require_paths = ["lib"]
44
- s.rubyforge_project = %q{orangutan}
45
- s.rubygems_version = %q{1.3.1}
46
- s.summary = %q{A mock objects library}
47
- s.test_files = [
48
- "spec/spec_chantek.rb",
49
- "spec/spec_chantek_clr.rb",
50
- "spec/spec_expectation.rb"
51
- ]
52
-
53
- if s.respond_to? :specification_version then
54
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
55
- s.specification_version = 2
56
-
57
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
58
- else
59
- end
60
- else
61
- end
62
- end
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{orangutan}
5
+ s.version = "0.0.2"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Mark Ryall"]
9
+ s.date = %q{2009-05-10}
10
+ s.description = %q{A mocking library that supports creation of ironruby mock objects (in addition to pure ruby ones)}
11
+ s.email = %q{mark@ryall.name}
12
+ s.extra_rdoc_files = [
13
+ "README"
14
+ ]
15
+ s.files = [
16
+ "README",
17
+ "Rakefile",
18
+ "VERSION.yml",
19
+ "lib/orangutan.rb",
20
+ "lib/orangutan/call.rb",
21
+ "lib/orangutan/chantek.rb",
22
+ "lib/orangutan/clean_slate.rb",
23
+ "lib/orangutan/container.rb",
24
+ "lib/orangutan/expectation.rb",
25
+ "lib/orangutan/raiser.rb",
26
+ "lib/orangutan/stub_base.rb",
27
+ "orangutan.gemspec",
28
+ "prepare.cmd",
29
+ "spec/clr/ClassWithANonVirtualMethod.cs",
30
+ "spec/clr/ClassWithANonVirtualProperty.cs",
31
+ "spec/clr/ClassWithAVirtualMethod.cs",
32
+ "spec/clr/ClassWithAVirtualProperty.cs",
33
+ "spec/clr/Consumer.cs",
34
+ "spec/clr/IHaveAMethod.cs",
35
+ "spec/clr/IHaveAProperty.cs",
36
+ "spec/clr/IHaveAnEvent.cs",
37
+ "spec/spec_chantek.rb",
38
+ "spec/spec_chantek_clr.rb",
39
+ "spec/spec_chantek_recurse.rb",
40
+ "spec/spec_expectation.rb"
41
+ ]
42
+ s.has_rdoc = true
43
+ s.homepage = %q{http://github.com/markryall/orangutan}
44
+ s.rdoc_options = ["--charset=UTF-8"]
45
+ s.require_paths = ["lib"]
46
+ s.rubyforge_project = %q{orangutan}
47
+ s.rubygems_version = %q{1.3.1}
48
+ s.summary = %q{A mock objects library}
49
+ s.test_files = [
50
+ "spec/spec_chantek.rb",
51
+ "spec/spec_chantek_clr.rb",
52
+ "spec/spec_chantek_recurse.rb",
53
+ "spec/spec_expectation.rb"
54
+ ]
55
+
56
+ if s.respond_to? :specification_version then
57
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
58
+ s.specification_version = 2
59
+
60
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
61
+ else
62
+ end
63
+ else
64
+ end
65
+ end
data/prepare.cmd CHANGED
@@ -1,11 +1,11 @@
1
- call path_git
2
- call path_bacon
3
- call path_ironruby
4
- call path_msbuild
5
- pushd %BACON_HOME%
6
- git pull
7
- popd
8
- pushd %IRONRUBY_HOME%
9
- git pull
10
- msbuild Merlin\Main\Languages\Ruby\Ruby.sln
11
- popd
1
+ call path_git
2
+ call path_bacon
3
+ call path_ironruby
4
+ call path_msbuild
5
+ pushd %BACON_HOME%
6
+ git pull
7
+ popd
8
+ pushd %IRONRUBY_HOME%
9
+ git pull
10
+ msbuild Merlin\Main\Languages\Ruby\Ruby.sln
11
+ popd
@@ -1,13 +1,13 @@
1
- using System;
2
-
3
- namespace ClassLibrary
4
- {
5
- public class ClassWithANonVirtualMethod : IHaveAMethod
6
- {
7
- public bool MyMethod(string parameter)
8
- {
9
- Console.WriteLine("clr method was called with " + parameter);
10
- return true;
11
- }
12
- }
1
+ using System;
2
+
3
+ namespace ClassLibrary
4
+ {
5
+ public class ClassWithANonVirtualMethod : IHaveAMethod
6
+ {
7
+ public bool MyMethod(string parameter)
8
+ {
9
+ Console.WriteLine("clr method was called with " + parameter);
10
+ return true;
11
+ }
12
+ }
13
13
  }
@@ -1,22 +1,22 @@
1
- using System;
2
-
3
- namespace ClassLibrary
4
- {
5
- public class ClassWithANonVirtualProperty : IHaveAProperty
6
- {
7
- private string _MyProperty;
8
- public string MyProperty
9
- {
10
- get
11
- {
12
- Console.WriteLine("clr getter called");
13
- return _MyProperty;
14
- }
15
- set
16
- {
17
- Console.WriteLine("clr setter called");
18
- _MyProperty = value;
19
- }
20
- }
21
- }
1
+ using System;
2
+
3
+ namespace ClassLibrary
4
+ {
5
+ public class ClassWithANonVirtualProperty : IHaveAProperty
6
+ {
7
+ private string _MyProperty;
8
+ public string MyProperty
9
+ {
10
+ get
11
+ {
12
+ Console.WriteLine("clr getter called");
13
+ return _MyProperty;
14
+ }
15
+ set
16
+ {
17
+ Console.WriteLine("clr setter called");
18
+ _MyProperty = value;
19
+ }
20
+ }
21
+ }
22
22
  }
@@ -1,13 +1,13 @@
1
- using System;
2
-
3
- namespace ClassLibrary
4
- {
5
- public class ClassWithAnVirtualMethod : IHaveAMethod
6
- {
7
- public virtual bool MyMethod(string parameter)
8
- {
9
- Console.WriteLine("clr method was called with " + parameter);
10
- return true;
11
- }
12
- }
13
- }
1
+ using System;
2
+
3
+ namespace ClassLibrary
4
+ {
5
+ public class ClassWithAnVirtualMethod : IHaveAMethod
6
+ {
7
+ public virtual bool MyMethod(string parameter)
8
+ {
9
+ Console.WriteLine("clr method was called with " + parameter);
10
+ return true;
11
+ }
12
+ }
13
+ }
@@ -1,22 +1,22 @@
1
- using System;
2
-
3
- namespace ClassLibrary
4
- {
5
- public class ClassWithAVirtualProperty : IHaveAProperty
6
- {
7
- private string _MyProperty;
8
- public virtual string MyProperty
9
- {
10
- get
11
- {
12
- Console.WriteLine("clr getter called");
13
- return _MyProperty;
14
- }
15
- set
16
- {
17
- Console.WriteLine("clr setter called");
18
- _MyProperty = value;
19
- }
20
- }
21
- }
22
- }
1
+ using System;
2
+
3
+ namespace ClassLibrary
4
+ {
5
+ public class ClassWithAVirtualProperty : IHaveAProperty
6
+ {
7
+ private string _MyProperty;
8
+ public virtual string MyProperty
9
+ {
10
+ get
11
+ {
12
+ Console.WriteLine("clr getter called");
13
+ return _MyProperty;
14
+ }
15
+ set
16
+ {
17
+ Console.WriteLine("clr setter called");
18
+ _MyProperty = value;
19
+ }
20
+ }
21
+ }
22
+ }
@@ -1,30 +1,30 @@
1
- using System;
2
-
3
- namespace ClassLibrary
4
- {
5
- public class Consumer
6
- {
7
- private int count = 0;
8
-
9
- public void CallMethod(IHaveAMethod consumable)
10
- {
11
- consumable.MyMethod("thing");
12
- }
13
-
14
- public void RegisterEvent(IHaveAnEvent e)
15
- {
16
- e.MyEvent += (s,ev) => Console.WriteLine(s);
17
- }
18
-
19
- public void CallSetter(IHaveAProperty p)
20
- {
21
- p.MyProperty = ""+count;
22
- count++;
23
- }
24
-
25
- public void CallGetter(IHaveAProperty p)
26
- {
27
- Console.WriteLine(p.MyProperty);
28
- }
29
- }
1
+ using System;
2
+
3
+ namespace ClassLibrary
4
+ {
5
+ public class Consumer
6
+ {
7
+ private int count = 0;
8
+
9
+ public void CallMethod(IHaveAMethod consumable)
10
+ {
11
+ consumable.MyMethod("thing");
12
+ }
13
+
14
+ public void RegisterEvent(IHaveAnEvent e)
15
+ {
16
+ e.MyEvent += (s,ev) => Console.WriteLine(s);
17
+ }
18
+
19
+ public void CallSetter(IHaveAProperty p)
20
+ {
21
+ p.MyProperty = ""+count;
22
+ count++;
23
+ }
24
+
25
+ public void CallGetter(IHaveAProperty p)
26
+ {
27
+ Console.WriteLine(p.MyProperty);
28
+ }
29
+ }
30
30
  }
@@ -1,9 +1,9 @@
1
- using System;
2
-
3
- namespace ClassLibrary
4
- {
5
- public interface IHaveAMethod
6
- {
7
- bool MyMethod(string parameter);
8
- }
1
+ using System;
2
+
3
+ namespace ClassLibrary
4
+ {
5
+ public interface IHaveAMethod
6
+ {
7
+ bool MyMethod(string parameter);
8
+ }
9
9
  }
@@ -1,9 +1,9 @@
1
- using System;
2
-
3
- namespace ClassLibrary
4
- {
5
- public interface IHaveAProperty
6
- {
7
- String MyProperty { get; set; }
8
- }
9
- }
1
+ using System;
2
+
3
+ namespace ClassLibrary
4
+ {
5
+ public interface IHaveAProperty
6
+ {
7
+ String MyProperty { get; set; }
8
+ }
9
+ }
@@ -1,9 +1,9 @@
1
- using System;
2
-
3
- namespace ClassLibrary
4
- {
5
- public interface IHaveAnEvent
6
- {
7
- event EventHandler<EventArgs> MyEvent;
8
- }
1
+ using System;
2
+
3
+ namespace ClassLibrary
4
+ {
5
+ public interface IHaveAnEvent
6
+ {
7
+ event EventHandler<EventArgs> MyEvent;
8
+ }
9
9
  }