caricature 0.7.2 → 0.7.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/README.rdoc +97 -97
  2. data/Rakefile +310 -310
  3. data/caricature.gemspec +110 -106
  4. data/lib/caricature.rb +3 -1
  5. data/lib/caricature/bacon.rb +2 -2
  6. data/lib/caricature/bacon/integration.rb +75 -55
  7. data/lib/caricature/clr.rb +4 -3
  8. data/lib/caricature/clr/aspnet_mvc.rb +3 -3
  9. data/lib/caricature/clr/descriptor.rb +106 -39
  10. data/lib/caricature/clr/event_verification.rb +57 -0
  11. data/lib/caricature/clr/expectation.rb +101 -0
  12. data/lib/caricature/clr/isolation.rb +49 -13
  13. data/lib/caricature/clr/isolator.rb +141 -5
  14. data/lib/caricature/clr/messenger.rb +6 -0
  15. data/lib/caricature/clr/method_call_recorder.rb +97 -0
  16. data/lib/caricature/core_ext.rb +11 -0
  17. data/lib/{core_ext → caricature/core_ext}/array.rb +0 -0
  18. data/lib/{core_ext → caricature/core_ext}/class.rb +0 -0
  19. data/lib/{core_ext → caricature/core_ext}/hash.rb +0 -0
  20. data/lib/{core_ext → caricature/core_ext}/module.rb +0 -0
  21. data/lib/{core_ext → caricature/core_ext}/object.rb +0 -0
  22. data/lib/{core_ext → caricature/core_ext}/string.rb +0 -0
  23. data/lib/{core_ext → caricature/core_ext}/system/string.rb +0 -0
  24. data/lib/{core_ext → caricature/core_ext}/system/type.rb +6 -0
  25. data/lib/caricature/expectation.rb +108 -66
  26. data/lib/caricature/isolator.rb +3 -3
  27. data/lib/caricature/method_call_recorder.rb +32 -4
  28. data/lib/caricature/rspec/integration.rb +118 -77
  29. data/lib/caricature/version.rb +5 -5
  30. data/spec/bacon/integration/callback_spec.rb +156 -156
  31. data/spec/bacon/integration/clr_to_clr_spec.rb +1 -2
  32. data/spec/bacon/integration/event_spec.rb +98 -0
  33. data/spec/bacon/integration/indexer_spec.rb +1 -1
  34. data/spec/bacon/spec_helper.rb +4 -4
  35. data/spec/bacon/unit/descriptor_spec.rb +95 -42
  36. data/spec/bacon/unit/expectation_spec.rb +2 -2
  37. data/spec/bacon/unit/interop_spec.rb +1 -14
  38. data/spec/bacon/unit/isolation_spec.rb +1 -1
  39. data/spec/bacon/unit/isolator_spec.rb +5 -5
  40. data/spec/bin/ClrModels.dll +0 -0
  41. data/spec/models/ClrModels.cs +32 -8
  42. data/spec/models/ruby_models.rb +150 -150
  43. data/spec/rspec/integration/callback_spec.rb +156 -156
  44. data/spec/rspec/integration/indexer_spec.rb +1 -1
  45. data/spec/rspec/spec_helper.rb +12 -6
  46. data/spec/rspec/unit/descriptor_spec.rb +93 -42
  47. data/spec/rspec/unit/event_spec.rb +17 -0
  48. data/spec/rspec/unit/interop_spec.rb +0 -13
  49. data/spec/spec_helper.rb +14 -14
  50. metadata +20 -22
  51. data/lib/core_ext/core_ext.rb +0 -8
  52. data/spec/bin/ClrModels.dll.mdb +0 -0
@@ -1,98 +1,98 @@
1
- = Caricature - Bringing simple mocking to the DLR
2
-
3
- * http://github.com/casualjim/caricature
4
-
5
- == DESCRIPTION:
6
-
7
- This project aims to make interop between IronRuby objects and .NET objects easier.
8
- The idea is that it integrates nicely with bacon and later rspec and that it transparently lets you mock ironruby ojbects
9
- as well as CLR objects/interfaces.
10
- Caricature handles interfaces, interface inheritance, CLR objects, CLR object instances, Ruby classes and instances of Ruby classes.
11
-
12
- From the start I wanted to do away with names like mock, stub, record, replay, verify etc.
13
- Instead I took the advice from Roy Osherhove and went with a name of Isolation for creating a mock.
14
-
15
- An Isolation will create what in Rhino.Mocks would be called a DynamicMock (but can be a partial too) :)
16
- In Moq it would be the Loose mocking strategy.
17
-
18
- The naming of the methods for creating mocks is the one that JP Boodhoo proposed WhenToldTo and WasToldTo.
19
- To specify a stub/expectation on an isolation you have one and only one way of doing that with the method called when_receiving.
20
- Then only if you're interested in asserting if a method has been called you can use the did_receive? method for this.
21
-
22
- It may be very important to note that when you're going to be isolating CLR classes to be used in other CLR classes
23
- you still need to obide by the CLR rules. That means if you want to redefine a method you'll need to make sure it's
24
- marked as virtual. Static types are still governed by static type rules. I'm working on a solution around those
25
- problems but for the time being this is how it has to be.
26
-
27
- == FEATURES/PROBLEMS:
28
-
29
- * [CLR-to-CLR mocking]: Caricature won't mock static methods because you can't override those according to CLR rules
30
- * [CLR-to-CLR mocking]: Caricature can only override methods that are marked virtual (CLR rules)
31
-
32
- == SYNOPSIS:
33
-
34
- isolation = Isolation.for(Ninja)
35
- isolation.when_receiving(:attack) do |exp|
36
- exp.with(:shuriken)
37
- exp.return(3)
38
- end
39
-
40
- Battle.new(mock)
41
- battle.combat
42
-
43
- isolation.should.have_received?(:attack)
44
-
45
-
46
- == REQUIREMENTS:
47
-
48
- * To use the caricature library you need to have uuidtools installed
49
- (sudo) gem install uuidtools
50
- (sudo) igem install uuidtools
51
-
52
- == INSTALL:
53
-
54
- (sudo) gem install caricature
55
-
56
- == LICENSE:
57
-
58
- Caricature -- A simple mocking framework for IronRuby
59
-
60
- Copyright (c) 2009, Caricature Team
61
- http://github.com/casualjim/caricature
62
- All rights reserved.
63
-
64
- Redistribution and use in source and binary forms,
65
- with or without modification, are permitted provided
66
- that the following conditions are met:
67
-
68
- * Redistributions of source code must retain the
69
- above copyright notice, this list of conditions and
70
- the following disclaimer.
71
-
72
- * Redistributions in binary form must reproduce
73
- the above copyright notice, this list of conditions
74
- and the following disclaimer in the documentation
75
- and/or other materials provided with the distribution.
76
-
77
- * Neither the name of the Caricature Team nor the
78
- names of its contributors may be used to endorse
79
- or promote products derived from this software
80
- without specific prior written permission.
81
-
82
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
83
- CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
84
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
85
- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
86
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
87
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
88
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
89
- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
90
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
91
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
92
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
93
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
94
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
95
- SUCH DAMAGE.
96
-
97
- [This is the BSD license, see
1
+ = Caricature - Bringing simple mocking to the DLR
2
+
3
+ * http://github.com/casualjim/caricature
4
+
5
+ == DESCRIPTION:
6
+
7
+ This project aims to make interop between IronRuby objects and .NET objects easier.
8
+ The idea is that it integrates nicely with bacon and later rspec and that it transparently lets you mock ironruby ojbects
9
+ as well as CLR objects/interfaces.
10
+ Caricature handles interfaces, interface inheritance, CLR objects, CLR object instances, Ruby classes and instances of Ruby classes.
11
+
12
+ From the start I wanted to do away with names like mock, stub, record, replay, verify etc.
13
+ Instead I took the advice from Roy Osherhove and went with a name of Isolation for creating a mock.
14
+
15
+ An Isolation will create what in Rhino.Mocks would be called a DynamicMock (but can be a partial too) :)
16
+ In Moq it would be the Loose mocking strategy.
17
+
18
+ The naming of the methods for creating mocks is the one that JP Boodhoo proposed WhenToldTo and WasToldTo.
19
+ To specify a stub/expectation on an isolation you have one and only one way of doing that with the method called when_receiving.
20
+ Then only if you're interested in asserting if a method has been called you can use the did_receive? method for this.
21
+
22
+ It may be very important to note that when you're going to be isolating CLR classes to be used in other CLR classes
23
+ you still need to obide by the CLR rules. That means if you want to redefine a method you'll need to make sure it's
24
+ marked as virtual. Static types are still governed by static type rules. I'm working on a solution around those
25
+ problems but for the time being this is how it has to be.
26
+
27
+ == FEATURES/PROBLEMS:
28
+
29
+ * [CLR-to-CLR mocking]: Caricature won't mock static methods because you can't override those according to CLR rules
30
+ * [CLR-to-CLR mocking]: Caricature can only override methods that are marked virtual (CLR rules)
31
+
32
+ == SYNOPSIS:
33
+
34
+ isolation = Isolation.for(Ninja)
35
+ isolation.when_receiving(:attack) do |exp|
36
+ exp.with(:shuriken)
37
+ exp.return(3)
38
+ end
39
+
40
+ Battle.new(mock)
41
+ battle.combat
42
+
43
+ isolation.should.have_received?(:attack)
44
+
45
+
46
+ == REQUIREMENTS:
47
+
48
+ * To use the caricature library you need to have uuidtools installed
49
+ (sudo) gem install uuidtools
50
+ (sudo) igem install uuidtools
51
+
52
+ == INSTALL:
53
+
54
+ (sudo) gem install caricature
55
+
56
+ == LICENSE:
57
+
58
+ Caricature -- A simple mocking framework for IronRuby
59
+
60
+ Copyright (c) 2009, Caricature Team
61
+ http://github.com/casualjim/caricature
62
+ All rights reserved.
63
+
64
+ Redistribution and use in source and binary forms,
65
+ with or without modification, are permitted provided
66
+ that the following conditions are met:
67
+
68
+ * Redistributions of source code must retain the
69
+ above copyright notice, this list of conditions and
70
+ the following disclaimer.
71
+
72
+ * Redistributions in binary form must reproduce
73
+ the above copyright notice, this list of conditions
74
+ and the following disclaimer in the documentation
75
+ and/or other materials provided with the distribution.
76
+
77
+ * Neither the name of the Caricature Team nor the
78
+ names of its contributors may be used to endorse
79
+ or promote products derived from this software
80
+ without specific prior written permission.
81
+
82
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
83
+ CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
84
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
85
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
86
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
87
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
88
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
89
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
90
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
91
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
92
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
93
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
94
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
95
+ SUCH DAMAGE.
96
+
97
+ [This is the BSD license, see
98
98
  http://www.opensource.org/licenses/bsd-license.php]
data/Rakefile CHANGED
@@ -1,310 +1,310 @@
1
- require 'rubygems'
2
- require 'fileutils'
3
- require 'rake/rdoctask'
4
-
5
- $:.unshift 'lib'
6
- require 'caricature'
7
-
8
- desc "The default task is to run all the specs"
9
- task :default => [:clr_models, :spec]
10
-
11
- %w(bacon spec).each do |fw|
12
-
13
- gem_name = fw == "bacon" ? fw : "r#{fw}"
14
-
15
- desc "Runs all the #{gem_name} specs"
16
- task fw.to_sym do
17
- system "i#{fw} #{Dir.glob("spec/#{gem_name}/**/*_spec.rb").join(' ')}"
18
- end
19
-
20
- namespace fw.to_sym do
21
-
22
- desc "runs the #{gem_name} examples for the different classes"
23
- task :unit do
24
- specs = Dir.glob("spec/#{gem_name}/unit/**/*_spec.rb")
25
- system "i#{fw} #{specs.join(' ')}"
26
- end
27
-
28
- desc "runs the #{gem_name} integration examples"
29
- task :integration do
30
- specs = Dir.glob("spec/#{gem_name}/integration/**/*_spec.rb")
31
- system "i#{fw} #{specs.join(' ')}"
32
- end
33
- end
34
- end
35
-
36
-
37
-
38
- def csc
39
- system "gmcs"
40
- $?.pid.zero? ? "csc" : "gmcs"
41
- end
42
-
43
- desc "Compiles the clr models"
44
- task :clr_models do
45
- Dir.chdir(File.dirname(__FILE__))
46
- files = Dir.glob("spec/models/*.cs").join(' ') #.collect { |f| f.gsub(/\//, "\\") }.join(" ")
47
- system "#{csc} /noconfig /target:library /debug+ /debug:full /out:spec/bin/ClrModels.dll #{files}"
48
- end
49
-
50
- ##############################################################################
51
- # OPTIONS
52
- ##############################################################################
53
-
54
- PKG_NAME = 'caricature'
55
- PKG_VERSION = Caricature::VERSION
56
- AUTHORS = ['Ivan Porto Carrero']
57
- EMAIL = "ivan@flanders.co.nz"
58
- HOMEPAGE = "http://casualjim.github.com/caricature"
59
- SUMMARY = "Caricature brings simple mocking to Ruby, DLR and CLR."
60
-
61
- # These are the common rdoc options that are shared between generation of
62
- # rdoc files using BOTH 'rake rdoc' and the installation by users of a
63
- # RubyGem version which builds rdoc's along with its installation. Any
64
- # rdoc options that are ONLY for developers running 'rake rdoc' should be
65
- # added in the 'Rake::RDocTask' block below.
66
- RDOC_OPTIONS = [
67
- "--quiet",
68
- "--title", SUMMARY,
69
- "--main", "README.rdoc",
70
- "--line-numbers",
71
- "--format","darkfish"
72
- ]
73
-
74
- # Extra files outside of the lib dir that should be included with the rdocs.
75
- RDOC_FILES = (%w( README.rdoc)).sort
76
-
77
- # The full file list used for rdocs, tarballs, gems, and for generating the xmpp4r.gemspec.
78
- PKG_FILES = (%w( Rakefile caricature.gemspec ) + RDOC_FILES + Dir["{lib,spec}/**/*"]).sort
79
-
80
- # RDOC
81
- #######
82
- Rake::RDocTask.new do |rd|
83
-
84
- # which dir should rdoc files be installed in?
85
- rd.rdoc_dir = 'rdoc'
86
-
87
- # the full list of files to be included
88
- rd.rdoc_files.include(RDOC_FILES, "lib/**/*.rb")
89
-
90
- # the full list of options that are common between gem build
91
- # and 'rake rdoc' build of docs.
92
- rd.options = RDOC_OPTIONS
93
-
94
- # Devs Only : Uncomment to also document private methods in the rdocs
95
- # Please don't check this change in to the source repo.
96
- #rd.options << '--all'
97
-
98
- # Devs Only : Uncomment to generate dot (graphviz) diagrams along with rdocs.
99
- # This requires that graphiz (dot) be installed as a local binary and on your path.
100
- # See : http://www.graphviz.org/
101
- # Please don't check this change in to the source repo as it introduces a binary dependency.
102
- #rd.options << '--diagram'
103
- #rd.options << '--fileboxes'
104
-
105
- end
106
-
107
- desc "Check syntax of all Ruby files."
108
- task :check_syntax do
109
- `find . -name "*.rb" |xargs -n1 ruby -c |grep -v "Syntax OK"`
110
- puts "* Done"
111
- end
112
-
113
- ##############################################################################
114
- # PACKAGING & INSTALLATION
115
- ##############################################################################
116
-
117
- # What files/dirs should 'rake clean' remove?
118
- #CLEAN.include ["*.gem", "pkg", "rdoc", "coverage"]
119
-
120
- begin
121
- require 'rake/gempackagetask'
122
-
123
- spec = Gem::Specification.new do |s|
124
- s.name = PKG_NAME
125
- s.version = PKG_VERSION
126
- s.authors = AUTHORS
127
- s.email = EMAIL
128
- s.homepage = HOMEPAGE
129
- s.rubyforge_project = PKG_NAME
130
- s.summary = SUMMARY
131
- s.description = s.summary
132
- s.platform = Gem::Platform::RUBY
133
- s.require_path = 'lib'
134
- s.executables = []
135
- s.files = PKG_FILES
136
- s.test_files = []
137
- s.has_rdoc = true
138
- s.extra_rdoc_files = RDOC_FILES
139
- s.rdoc_options = RDOC_OPTIONS
140
- s.required_ruby_version = ">= 1.8.4"
141
- s.add_dependency 'uuidtools', ">= 2.0.0"
142
- end
143
-
144
- Rake::GemPackageTask.new(spec) do |pkg|
145
- pkg.gem_spec = spec
146
- pkg.need_tar = true
147
- pkg.need_zip = true
148
- end
149
-
150
- namespace :gem do
151
-
152
- desc "Run :package and install the .gem locally"
153
- task :install => [:update_gemspec, :package] do
154
- sh %{sudo gem install --local pkg/#{PKG_NAME}-#{PKG_VERSION}.gem}
155
- end
156
-
157
- desc "Like gem:install but without ri or rdocs"
158
- task :install_fast => [:update_gemspec, :package] do
159
- sh %{sudo gem install --local pkg/#{PKG_NAME}-#{PKG_VERSION}.gem --no-rdoc --no-ri}
160
- end
161
-
162
- desc "Run :clean and uninstall the .gem"
163
- task :uninstall => :clean do
164
- sh %{sudo gem uninstall #{PKG_NAME}}
165
- end
166
-
167
- # Thanks to the Merb project for this code.
168
- desc "Update Github Gemspec"
169
- task :update_gemspec do
170
- skip_fields = %w(new_platform original_platform date)
171
-
172
- result = "# WARNING : RAKE AUTO-GENERATED FILE. DO NOT MANUALLY EDIT!\n"
173
- result << "# RUN : 'rake gem:update_gemspec'\n\n"
174
- result << "Gem::Specification.new do |s|\n"
175
- spec.instance_variables.sort.each do |ivar|
176
- value = spec.instance_variable_get(ivar)
177
- name = ivar.to_s.split("@").last
178
- next if skip_fields.include?(name) || value.nil? || value == "" || (value.respond_to?(:empty?) && value.empty?)
179
- if name == "dependencies"
180
- value.each do |d|
181
- dep, *ver = d.to_s.split(" ")
182
- result << " s.add_dependency #{dep.inspect}, #{ver.join(" ").inspect.gsub(/[()]/, "")}\n"
183
- end
184
- else
185
- case value
186
- when Array
187
- value = name != "files" ? value.inspect : value.sort.uniq.inspect.split(",").join(",\n")
188
- when String, Fixnum, true, false
189
- value = value.inspect
190
- else
191
- value = value.to_s.inspect
192
- end
193
- result << " s.#{name} = #{value}\n"
194
- end
195
- end
196
- result << "end"
197
- File.open(File.join(File.dirname(__FILE__), "#{spec.name}.gemspec"), "w"){|f| f << result}
198
- end
199
-
200
- end # namespace :gem
201
-
202
- # also keep the gemspec up to date each time we package a tarball or gem
203
- task :package => ['gem:update_gemspec']
204
- task :gem => ['gem:update_gemspec']
205
-
206
- rescue LoadError
207
- puts <<EOF
208
- ###
209
- Packaging Warning : RubyGems is apparently not installed on this
210
- system and any file add/remove/rename will not
211
- be auto-updated in the 'caricature.gemspec' when you run any
212
- package tasks. All such file changes are recommended
213
- to be packaged on a system with RubyGems installed
214
- if you intend to push commits to the Git repo so the
215
- gemspec will also stay in sync for others.
216
- ###
217
- EOF
218
- end
219
-
220
- # we are apparently on a system that does not have RubyGems installed.
221
- # Lets try to provide only the basic tarball package tasks as a fallback.
222
- unless defined? Gem
223
- begin
224
- require 'rake/packagetask'
225
- Rake::PackageTask.new(PKG_NAME, PKG_VERSION) do |p|
226
- p.package_files = PKG_FILES
227
- p.need_tar = true
228
- p.need_zip = true
229
- end
230
- rescue LoadError
231
- puts <<EOF
232
- ###
233
- Warning : Unable to require the 'rake/packagetask'. Is Rake installed?
234
- ###
235
- EOF
236
- end
237
- end
238
-
239
-
240
- # # Generate all the Rake tasks
241
- # # Run 'rake -T' to see list of generated tasks (from gem root directory)
242
- # $hoe = Hoe.spec 'cloudslide' do
243
- # self.developer 'Ivan Porto Carrero', 'ivan@flanders.co.nz'
244
- # self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
245
- # self.rubyforge_name = self.name # TODO this is default value
246
- # self.extra_deps = [['uuidtools','>= 2.0.0'], ['newgem', '>= 1.5.2']]
247
- # end
248
- #
249
- # require 'newgem/tasks'
250
- # Dir['tasks/**/*.rake'].each { |t| load t }
251
-
252
- # TODO - want other tests/tasks run by default? Add them to the list
253
- # remove_task :default
254
- # task :default => [:spec, :features]
255
-
256
- # file_list = Dir.glob("lib/**/*.rb")
257
-
258
- # desc "Create RDoc documentation"
259
- # file 'doc/index.html' => file_list do
260
- # puts "######## Creating RDoc documentation"
261
- # system "rdoc --title 'Caricature isolation framework documentation' -m README README.markdown lib/"
262
- # end
263
- #
264
- # desc "An alias for creating the RDoc documentation"
265
- # task :rdoc do
266
- # Rake::Task['doc/index.html'].invoke
267
- # end
268
-
269
- # begin
270
- #
271
- # Jeweler::Tasks.new do |gemspec|
272
- # gemspec.name = "caricature"
273
- # gemspec.summary = "Caricature - Bringing simple mocking to the DLR"
274
- # gemspec.email = "ivan@flanders.co.nz"
275
- # gemspec.homepage = "http://github.com/casualjim/caricature"
276
- # gemspec.description = "This project aims to make interop between IronRuby objects and .NET objects easier. The idea is that it integrates nicely with bacon and later rspec and that it transparently lets you mock ironruby ojbects as well as CLR objects/interfaces. Caricature handles interfaces, interface inheritance, CLR objects, CLR object instances, Ruby classes and instances of Ruby classes."
277
- # gemspec.authors = ["Ivan Porto Carrero"]
278
- # gemspec.rubyforge_project = 'caricature' # This line would be new
279
- # end
280
- # rescue LoadError
281
- # puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
282
- # end
283
- #
284
- begin
285
- require 'rake/contrib/sshpublisher'
286
- namespace :rubyforge do
287
-
288
- desc "Release gem and RDoc documentation to RubyForge"
289
- task :release => ["rubyforge:release:gem", 'rubyforge:release:docs']
290
-
291
- namespace :release do
292
- desc "Publish RDoc to RubyForge."
293
- task :docs => [:rdoc] do
294
- config = YAML.load(
295
- File.read(File.expand_path('~/.rubyforge/user-config.yml'))
296
- )
297
-
298
- host = "#{config['username']}@rubyforge.org"
299
- remote_dir = "/var/www/gforge-projects/caricature/"
300
- local_dir = 'doc'
301
-
302
- Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
303
- end
304
- end
305
- end
306
- rescue LoadError
307
- puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
308
- end
309
-
310
-
1
+ require 'rubygems'
2
+ require 'fileutils'
3
+ require 'rake/rdoctask'
4
+
5
+ $:.unshift 'lib'
6
+ require 'caricature'
7
+
8
+ desc "The default task is to run all the specs"
9
+ task :default => [:clr_models, :spec]
10
+
11
+ %w(bacon spec).each do |fw|
12
+
13
+ gem_name = fw == "bacon" ? fw : "r#{fw}"
14
+
15
+ desc "Runs all the #{gem_name} specs"
16
+ task fw.to_sym do
17
+ system "i#{fw} #{Dir.glob("spec/#{gem_name}/**/*_spec.rb").join(' ')}"
18
+ end
19
+
20
+ namespace fw.to_sym do
21
+
22
+ desc "runs the #{gem_name} examples for the different classes"
23
+ task :unit do
24
+ specs = Dir.glob("spec/#{gem_name}/unit/**/*_spec.rb")
25
+ system "i#{fw} #{specs.join(' ')}"
26
+ end
27
+
28
+ desc "runs the #{gem_name} integration examples"
29
+ task :integration do
30
+ specs = Dir.glob("spec/#{gem_name}/integration/**/*_spec.rb")
31
+ system "i#{fw} #{specs.join(' ')}"
32
+ end
33
+ end
34
+ end
35
+
36
+
37
+
38
+ def csc
39
+ system "gmcs"
40
+ $?.pid.zero? ? "csc" : "gmcs"
41
+ end
42
+
43
+ desc "Compiles the clr models"
44
+ task :clr_models do
45
+ Dir.chdir(File.dirname(__FILE__))
46
+ files = Dir.glob("spec/models/*.cs").join(' ') #.collect { |f| f.gsub(/\//, "\\") }.join(" ")
47
+ system "#{csc} /noconfig /target:library /debug+ /debug:full /out:spec/bin/ClrModels.dll #{files}"
48
+ end
49
+
50
+ ##############################################################################
51
+ # OPTIONS
52
+ ##############################################################################
53
+
54
+ PKG_NAME = 'caricature'
55
+ PKG_VERSION = Caricature::VERSION
56
+ AUTHORS = ['Ivan Porto Carrero']
57
+ EMAIL = "ivan@flanders.co.nz"
58
+ HOMEPAGE = "http://casualjim.github.com/caricature"
59
+ SUMMARY = "Caricature brings simple mocking to Ruby, DLR and CLR."
60
+
61
+ # These are the common rdoc options that are shared between generation of
62
+ # rdoc files using BOTH 'rake rdoc' and the installation by users of a
63
+ # RubyGem version which builds rdoc's along with its installation. Any
64
+ # rdoc options that are ONLY for developers running 'rake rdoc' should be
65
+ # added in the 'Rake::RDocTask' block below.
66
+ RDOC_OPTIONS = [
67
+ "--quiet",
68
+ "--title", SUMMARY,
69
+ "--main", "README.rdoc",
70
+ "--line-numbers",
71
+ "--format","darkfish"
72
+ ]
73
+
74
+ # Extra files outside of the lib dir that should be included with the rdocs.
75
+ RDOC_FILES = (%w( README.rdoc)).sort
76
+
77
+ # The full file list used for rdocs, tarballs, gems, and for generating the xmpp4r.gemspec.
78
+ PKG_FILES = (%w( Rakefile caricature.gemspec ) + RDOC_FILES + Dir["{lib,spec}/**/*"]).sort
79
+
80
+ # RDOC
81
+ #######
82
+ Rake::RDocTask.new do |rd|
83
+
84
+ # which dir should rdoc files be installed in?
85
+ rd.rdoc_dir = 'rdoc'
86
+
87
+ # the full list of files to be included
88
+ rd.rdoc_files.include(RDOC_FILES, "lib/**/*.rb")
89
+
90
+ # the full list of options that are common between gem build
91
+ # and 'rake rdoc' build of docs.
92
+ rd.options = RDOC_OPTIONS
93
+
94
+ # Devs Only : Uncomment to also document private methods in the rdocs
95
+ # Please don't check this change in to the source repo.
96
+ #rd.options << '--all'
97
+
98
+ # Devs Only : Uncomment to generate dot (graphviz) diagrams along with rdocs.
99
+ # This requires that graphiz (dot) be installed as a local binary and on your path.
100
+ # See : http://www.graphviz.org/
101
+ # Please don't check this change in to the source repo as it introduces a binary dependency.
102
+ #rd.options << '--diagram'
103
+ #rd.options << '--fileboxes'
104
+
105
+ end
106
+
107
+ desc "Check syntax of all Ruby files."
108
+ task :check_syntax do
109
+ `find . -name "*.rb" |xargs -n1 ruby -c |grep -v "Syntax OK"`
110
+ puts "* Done"
111
+ end
112
+
113
+ ##############################################################################
114
+ # PACKAGING & INSTALLATION
115
+ ##############################################################################
116
+
117
+ # What files/dirs should 'rake clean' remove?
118
+ #CLEAN.include ["*.gem", "pkg", "rdoc", "coverage"]
119
+
120
+ begin
121
+ require 'rake/gempackagetask'
122
+
123
+ spec = Gem::Specification.new do |s|
124
+ s.name = PKG_NAME
125
+ s.version = PKG_VERSION
126
+ s.authors = AUTHORS
127
+ s.email = EMAIL
128
+ s.homepage = HOMEPAGE
129
+ s.rubyforge_project = PKG_NAME
130
+ s.summary = SUMMARY
131
+ s.description = s.summary
132
+ s.platform = Gem::Platform::RUBY
133
+ s.require_path = 'lib'
134
+ s.executables = []
135
+ s.files = PKG_FILES
136
+ s.test_files = []
137
+ s.has_rdoc = true
138
+ s.extra_rdoc_files = RDOC_FILES
139
+ s.rdoc_options = RDOC_OPTIONS
140
+ s.required_ruby_version = ">= 1.8.4"
141
+ s.add_dependency 'uuidtools', ">= 2.0.0"
142
+ end
143
+
144
+ Rake::GemPackageTask.new(spec) do |pkg|
145
+ pkg.gem_spec = spec
146
+ pkg.need_tar = true
147
+ pkg.need_zip = true
148
+ end
149
+
150
+ namespace :gem do
151
+
152
+ desc "Run :package and install the .gem locally"
153
+ task :install => [:update_gemspec, :package] do
154
+ sh %{sudo gem install --local pkg/#{PKG_NAME}-#{PKG_VERSION}.gem}
155
+ end
156
+
157
+ desc "Like gem:install but without ri or rdocs"
158
+ task :install_fast => [:update_gemspec, :package] do
159
+ sh %{sudo gem install --local pkg/#{PKG_NAME}-#{PKG_VERSION}.gem --no-rdoc --no-ri}
160
+ end
161
+
162
+ desc "Run :clean and uninstall the .gem"
163
+ task :uninstall => :clean do
164
+ sh %{sudo gem uninstall #{PKG_NAME}}
165
+ end
166
+
167
+ # Thanks to the Merb project for this code.
168
+ desc "Update Github Gemspec"
169
+ task :update_gemspec do
170
+ skip_fields = %w(new_platform original_platform date)
171
+
172
+ result = "# WARNING : RAKE AUTO-GENERATED FILE. DO NOT MANUALLY EDIT!\n"
173
+ result << "# RUN : 'rake gem:update_gemspec'\n\n"
174
+ result << "Gem::Specification.new do |s|\n"
175
+ spec.instance_variables.sort.each do |ivar|
176
+ value = spec.instance_variable_get(ivar)
177
+ name = ivar.to_s.split("@").last
178
+ next if skip_fields.include?(name) || value.nil? || value == "" || (value.respond_to?(:empty?) && value.empty?)
179
+ if name == "dependencies"
180
+ value.each do |d|
181
+ dep, *ver = d.to_s.split(" ")
182
+ result << " s.add_dependency #{dep.inspect}, #{ver.join(" ").inspect.gsub(/[()]/, "")}\n"
183
+ end
184
+ else
185
+ case value
186
+ when Array
187
+ value = name != "files" ? value.inspect : value.sort.uniq.inspect.split(",").join(",\n")
188
+ when String, Fixnum, true, false
189
+ value = value.inspect
190
+ else
191
+ value = value.to_s.inspect
192
+ end
193
+ result << " s.#{name} = #{value}\n"
194
+ end
195
+ end
196
+ result << "end"
197
+ File.open(File.join(File.dirname(__FILE__), "#{spec.name}.gemspec"), "w"){|f| f << result}
198
+ end
199
+
200
+ end # namespace :gem
201
+
202
+ # also keep the gemspec up to date each time we package a tarball or gem
203
+ task :package => ['gem:update_gemspec']
204
+ task :gem => ['gem:update_gemspec']
205
+
206
+ rescue LoadError
207
+ puts <<EOF
208
+ ###
209
+ Packaging Warning : RubyGems is apparently not installed on this
210
+ system and any file add/remove/rename will not
211
+ be auto-updated in the 'caricature.gemspec' when you run any
212
+ package tasks. All such file changes are recommended
213
+ to be packaged on a system with RubyGems installed
214
+ if you intend to push commits to the Git repo so the
215
+ gemspec will also stay in sync for others.
216
+ ###
217
+ EOF
218
+ end
219
+
220
+ # we are apparently on a system that does not have RubyGems installed.
221
+ # Lets try to provide only the basic tarball package tasks as a fallback.
222
+ unless defined? Gem
223
+ begin
224
+ require 'rake/packagetask'
225
+ Rake::PackageTask.new(PKG_NAME, PKG_VERSION) do |p|
226
+ p.package_files = PKG_FILES
227
+ p.need_tar = true
228
+ p.need_zip = true
229
+ end
230
+ rescue LoadError
231
+ puts <<EOF
232
+ ###
233
+ Warning : Unable to require the 'rake/packagetask'. Is Rake installed?
234
+ ###
235
+ EOF
236
+ end
237
+ end
238
+
239
+
240
+ # # Generate all the Rake tasks
241
+ # # Run 'rake -T' to see list of generated tasks (from gem root directory)
242
+ # $hoe = Hoe.spec 'cloudslide' do
243
+ # self.developer 'Ivan Porto Carrero', 'ivan@flanders.co.nz'
244
+ # self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
245
+ # self.rubyforge_name = self.name # TODO this is default value
246
+ # self.extra_deps = [['uuidtools','>= 2.0.0'], ['newgem', '>= 1.5.2']]
247
+ # end
248
+ #
249
+ # require 'newgem/tasks'
250
+ # Dir['tasks/**/*.rake'].each { |t| load t }
251
+
252
+ # TODO - want other tests/tasks run by default? Add them to the list
253
+ # remove_task :default
254
+ # task :default => [:spec, :features]
255
+
256
+ # file_list = Dir.glob("lib/**/*.rb")
257
+
258
+ # desc "Create RDoc documentation"
259
+ # file 'doc/index.html' => file_list do
260
+ # puts "######## Creating RDoc documentation"
261
+ # system "rdoc --title 'Caricature isolation framework documentation' -m README README.markdown lib/"
262
+ # end
263
+ #
264
+ # desc "An alias for creating the RDoc documentation"
265
+ # task :rdoc do
266
+ # Rake::Task['doc/index.html'].invoke
267
+ # end
268
+
269
+ # begin
270
+ #
271
+ # Jeweler::Tasks.new do |gemspec|
272
+ # gemspec.name = "caricature"
273
+ # gemspec.summary = "Caricature - Bringing simple mocking to the DLR"
274
+ # gemspec.email = "ivan@flanders.co.nz"
275
+ # gemspec.homepage = "http://github.com/casualjim/caricature"
276
+ # gemspec.description = "This project aims to make interop between IronRuby objects and .NET objects easier. The idea is that it integrates nicely with bacon and later rspec and that it transparently lets you mock ironruby ojbects as well as CLR objects/interfaces. Caricature handles interfaces, interface inheritance, CLR objects, CLR object instances, Ruby classes and instances of Ruby classes."
277
+ # gemspec.authors = ["Ivan Porto Carrero"]
278
+ # gemspec.rubyforge_project = 'caricature' # This line would be new
279
+ # end
280
+ # rescue LoadError
281
+ # puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
282
+ # end
283
+ #
284
+ begin
285
+ require 'rake/contrib/sshpublisher'
286
+ namespace :rubyforge do
287
+
288
+ desc "Release gem and RDoc documentation to RubyForge"
289
+ task :release => ["rubyforge:release:gem", 'rubyforge:release:docs']
290
+
291
+ namespace :release do
292
+ desc "Publish RDoc to RubyForge."
293
+ task :docs => [:rdoc] do
294
+ config = YAML.load(
295
+ File.read(File.expand_path('~/.rubyforge/user-config.yml'))
296
+ )
297
+
298
+ host = "#{config['username']}@rubyforge.org"
299
+ remote_dir = "/var/www/gforge-projects/caricature/"
300
+ local_dir = 'doc'
301
+
302
+ Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
303
+ end
304
+ end
305
+ end
306
+ rescue LoadError
307
+ puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
308
+ end
309
+
310
+