proxymock 0.0.1

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/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Brad Phelan
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,16 @@
1
+ = proxymock
2
+
3
+ Adds a should_receive! method that actually calls the method instead of behaving like a true mock
4
+ == Note on Patches/Pull Requests
5
+
6
+ * Fork the project.
7
+ * Make your feature addition or bug fix.
8
+ * Add tests for it. This is important so I don't break it in a
9
+ future version unintentionally.
10
+ * Commit, do not mess with rakefile, version, or history.
11
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
12
+ * Send me a pull request. Bonus points for topic branches.
13
+
14
+ == Copyright
15
+
16
+ Copyright (c) 2010 Brad Phelan. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,46 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "proxymock"
8
+ gem.summary = %Q{Adds a should_receive! method to rspec.}
9
+ gem.description = %Q{Adds a should_receive! method to rspec that actually calls the method instead of behaving like a true mock
10
+ }
11
+ gem.email = "bradphelan@xtargets.com"
12
+ gem.homepage = "http://github.com/bradphelan/proxymock"
13
+ gem.authors = ["Brad Phelan"]
14
+ gem.add_development_dependency "rspec", ">= 1.2.9"
15
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
+ end
17
+ Jeweler::GemcutterTasks.new
18
+ rescue LoadError
19
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20
+ end
21
+
22
+ require 'spec/rake/spectask'
23
+ Spec::Rake::SpecTask.new(:spec) do |spec|
24
+ spec.libs << 'lib' << 'spec'
25
+ spec.spec_files = FileList['spec/**/*_spec.rb']
26
+ end
27
+
28
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
29
+ spec.libs << 'lib' << 'spec'
30
+ spec.pattern = 'spec/**/*_spec.rb'
31
+ spec.rcov = true
32
+ end
33
+
34
+ task :spec => :check_dependencies
35
+
36
+ task :default => :spec
37
+
38
+ require 'rake/rdoctask'
39
+ Rake::RDocTask.new do |rdoc|
40
+ version = File.exist?('VERSION') ? File.read('VERSION') : "0.0.1"
41
+
42
+ rdoc.rdoc_dir = 'rdoc'
43
+ rdoc.title = "proxymock #{version}"
44
+ rdoc.rdoc_files.include('README*')
45
+ rdoc.rdoc_files.include('lib/**/*.rb')
46
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/lib/proxymock.rb ADDED
@@ -0,0 +1,47 @@
1
+ class Object
2
+
3
+ # Just helps generating nice error messages
4
+ # when things go wrong
5
+ class ProxyObject
6
+
7
+ attr_accessor :fake_class
8
+
9
+ def to_s
10
+ @fake_class.to_s
11
+ end
12
+
13
+ end
14
+
15
+ # Just like should_receive in the standard rspec
16
+ # but also calls the real method
17
+ def should_receive!(sym, opts={}, &block)
18
+
19
+ @__rspec_obj__ ||= ProxyObject.new
20
+ @__rspec_obj__.fake_class = self.class
21
+
22
+ m = class<<self;self;end
23
+
24
+ sym_old = "__#{sym}__old__"
25
+
26
+ # Generates for sym => :foo
27
+ #
28
+ # alias :foo_old :foo
29
+ #
30
+ # def foo *args, &block
31
+ # foo_old *args, &block
32
+ # @__rspec_obj__.send :foo, *args, &block
33
+ # end
34
+ if not respond_to?("#{sym_old}".to_sym)
35
+ m.class_eval <<-EOS, __FILE__, __LINE__
36
+ alias :#{sym_old} :#{sym}
37
+
38
+ def #{sym} *args, &block
39
+ #{sym_old} *args, &block
40
+ @__rspec_obj__.send :#{sym}, *args, &block
41
+ end
42
+ EOS
43
+ end
44
+ @__rspec_obj__.should_receive(sym, opts, &block)
45
+ end
46
+
47
+ end
data/proxymock.gemspec ADDED
@@ -0,0 +1,56 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{proxymock}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Brad Phelan"]
12
+ s.date = %q{2010-03-19}
13
+ s.description = %q{Adds a should_receive! method to rspec that actually calls the method instead of behaving like a true mock
14
+ }
15
+ s.email = %q{bradphelan@xtargets.com}
16
+ s.extra_rdoc_files = [
17
+ "LICENSE",
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ ".gitignore",
23
+ "LICENSE",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "lib/proxymock.rb",
28
+ "proxymock.gemspec",
29
+ "spec/proxymock_spec.rb",
30
+ "spec/spec.opts",
31
+ "spec/spec_helper.rb"
32
+ ]
33
+ s.homepage = %q{http://github.com/bradphelan/proxymock}
34
+ s.rdoc_options = ["--charset=UTF-8"]
35
+ s.require_paths = ["lib"]
36
+ s.rubygems_version = %q{1.3.5}
37
+ s.summary = %q{Adds a should_receive! method to rspec.}
38
+ s.test_files = [
39
+ "spec/proxymock_spec.rb",
40
+ "spec/spec_helper.rb"
41
+ ]
42
+
43
+ if s.respond_to? :specification_version then
44
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
45
+ s.specification_version = 3
46
+
47
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
48
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
49
+ else
50
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
51
+ end
52
+ else
53
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
54
+ end
55
+ end
56
+
@@ -0,0 +1,28 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ require 'proxymock'
4
+
5
+ class Fing
6
+ attr_accessor :x
7
+ attr_accessor :y
8
+ def bar
9
+ @x = 10
10
+ end
11
+ def bing
12
+ @y = 20
13
+ end
14
+ end
15
+
16
+ describe "proxy mock" do
17
+ it "should work" do
18
+ b = Fing.new
19
+ b.should_receive!(:bar).once.ordered
20
+ b.should_receive!(:bing).once.ordered
21
+ b.should_receive!(:bar).once.ordered
22
+ b.bar
23
+ b.bing
24
+ b.bar
25
+ b.x.should == 10
26
+ b.y.should == 20
27
+ end
28
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,9 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'proxymock'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: proxymock
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Brad Phelan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-03-19 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.2.9
24
+ version:
25
+ description: |
26
+ Adds a should_receive! method to rspec that actually calls the method instead of behaving like a true mock
27
+
28
+ email: bradphelan@xtargets.com
29
+ executables: []
30
+
31
+ extensions: []
32
+
33
+ extra_rdoc_files:
34
+ - LICENSE
35
+ - README.rdoc
36
+ files:
37
+ - .document
38
+ - .gitignore
39
+ - LICENSE
40
+ - README.rdoc
41
+ - Rakefile
42
+ - VERSION
43
+ - lib/proxymock.rb
44
+ - proxymock.gemspec
45
+ - spec/proxymock_spec.rb
46
+ - spec/spec.opts
47
+ - spec/spec_helper.rb
48
+ has_rdoc: true
49
+ homepage: http://github.com/bradphelan/proxymock
50
+ licenses: []
51
+
52
+ post_install_message:
53
+ rdoc_options:
54
+ - --charset=UTF-8
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: "0"
62
+ version:
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: "0"
68
+ version:
69
+ requirements: []
70
+
71
+ rubyforge_project:
72
+ rubygems_version: 1.3.5
73
+ signing_key:
74
+ specification_version: 3
75
+ summary: Adds a should_receive! method to rspec.
76
+ test_files:
77
+ - spec/proxymock_spec.rb
78
+ - spec/spec_helper.rb