rspec-spies 1.2.9 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ gem 'rspec', '~> 2.0'
2
+
3
+ group :development do
4
+ gem 'rake'
5
+ gem 'jeweler'
6
+ gem 'rdoc'
7
+ end
@@ -0,0 +1,27 @@
1
+ GEM
2
+ specs:
3
+ diff-lcs (1.1.2)
4
+ git (1.2.5)
5
+ jeweler (1.6.4)
6
+ bundler (~> 1.0)
7
+ git (>= 1.2.5)
8
+ rake
9
+ rake (0.9.2)
10
+ rdoc (3.6.1)
11
+ rspec (2.6.0)
12
+ rspec-core (~> 2.6.0)
13
+ rspec-expectations (~> 2.6.0)
14
+ rspec-mocks (~> 2.6.0)
15
+ rspec-core (2.6.4)
16
+ rspec-expectations (2.6.0)
17
+ diff-lcs (~> 1.1.2)
18
+ rspec-mocks (2.6.0)
19
+
20
+ PLATFORMS
21
+ ruby
22
+
23
+ DEPENDENCIES
24
+ jeweler
25
+ rake
26
+ rdoc
27
+ rspec (~> 2.0)
@@ -23,7 +23,7 @@ In general, I think it should work by doing your usual stub!, followed running t
23
23
 
24
24
  To get started, you just need to:
25
25
 
26
- * Run: gem install rspec-spies
26
+ * Run: gem install rspec-spies --source http://gemcutter.org
27
27
  * Update spec_helper to include this line: require 'rspec-spies'
28
28
 
29
29
 
data/Rakefile CHANGED
@@ -1,41 +1,36 @@
1
1
  require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.setup(:default, :development)
4
+
2
5
  require 'rake'
3
6
 
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "rspec-spies"
8
- gem.summary = %Q{rspec has gone without tests spies. no more!}
9
- gem.description = %Q{test spies, for rspec}
10
- gem.email = "josh@technicalpickles.com"
11
- gem.homepage = "http://github.com/technicalpickles/rspec-spies"
12
- gem.authors = ["Joshua Nichols"]
13
- gem.add_development_dependency "rspec", ">= 1.2.9"
14
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
- end
16
- Jeweler::GemcutterTasks.new
17
- rescue LoadError
18
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
7
+ require 'jeweler'
8
+ Jeweler::Tasks.new do |gem|
9
+ gem.name = "rspec-spies"
10
+ gem.summary = %Q{rspec has gone without tests spies. no more!}
11
+ gem.description = %Q{test spies, for rspec}
12
+ gem.email = "josh@technicalpickles.com"
13
+ gem.homepage = "http://github.com/technicalpickles/rspec-spies"
14
+ gem.authors = ["Joshua Nichols"]
15
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
19
16
  end
17
+ Jeweler::GemcutterTasks.new
20
18
 
21
- require 'spec/rake/spectask'
22
- Spec::Rake::SpecTask.new(:spec) do |spec|
23
- spec.libs << 'lib' << 'spec'
24
- spec.spec_files = FileList['spec/**/*_spec.rb']
19
+ require 'rspec/core/rake_task'
20
+ RSpec::Core::RakeTask.new do |t|
21
+ t.pattern = FileList['spec/**/*_spec.rb']
25
22
  end
26
23
 
27
- Spec::Rake::SpecTask.new(:rcov) do |spec|
28
- spec.libs << 'lib' << 'spec'
29
- spec.pattern = 'spec/**/*_spec.rb'
30
- spec.rcov = true
24
+ RSpec::Core::RakeTask.new(:rcov) do |t|
25
+ t.pattern = FileList['spec/**/*_spec.rb']
26
+ t.rcov = true
27
+ t.rcov_opts = ['--exclude', 'spec']
31
28
  end
32
29
 
33
- task :spec => :check_dependencies
34
-
35
30
  task :default => :spec
36
31
 
37
- require 'rake/rdoctask'
38
- Rake::RDocTask.new do |rdoc|
32
+ require 'rdoc/task'
33
+ RDoc::Task.new do |rdoc|
39
34
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
40
35
 
41
36
  rdoc.rdoc_dir = 'rdoc'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.9
1
+ 2.0.0
@@ -1,49 +1,44 @@
1
- require 'spec/mocks/proxy'
2
- Spec::Mocks::Proxy.class_eval do
1
+ require 'rspec/mocks/method_double'
2
+ RSpec::Mocks::MethodDouble.class_eval do
3
3
  # override defining stubs to record the message was called.
4
4
  # there's only one line difference from upstream rspec, but can't change it without fully overriding
5
-
6
- def define_expected_method(sym)
7
- unless @proxied_methods.include?(sym)
8
- visibility_string = "#{visibility(sym)} :#{sym}"
9
- if target_responds_to?(sym)
10
- munged_sym = munge(sym)
11
- target_metaclass.instance_eval do
12
- alias_method munged_sym, sym if method_defined?(sym)
13
- end
14
- @proxied_methods << sym
15
- end
16
- target_metaclass.class_eval(<<-EOF, __FILE__, __LINE__)
17
- def #{sym}(*args, &block)
18
- __mock_proxy.record_message_received(:#{sym}, args, block) # this is the only line changed by rspec-spies in this method
19
- __mock_proxy.message_received :#{sym}, *args, &block
20
- end
21
- #{visibility_string}
22
- EOF
23
- end
5
+ def define_proxy_method
6
+ method_name = @method_name
7
+ visibility_for_method = "#{visibility} :#{method_name}"
8
+ object_singleton_class.class_eval(<<-EOF, __FILE__, __LINE__)
9
+ def #{method_name}(*args, &block)
10
+ __mock_proxy.record_message_received :#{method_name}, *args, &block
11
+ __mock_proxy.message_received :#{method_name}, *args, &block
12
+ end
13
+ #{visibility_for_method}
14
+ EOF
24
15
  end
25
16
  end
26
17
 
27
- require 'spec/matchers'
28
- Spec::Matchers.module_eval do
18
+ require 'rspec/matchers'
19
+ RSpec::Matchers.module_eval do
29
20
  def have_received(sym, &block)
30
- Spec::Matchers::Matcher.new :have_received, sym, @args, block do |sym, args, block|
21
+ RSpec::Matchers::Matcher.new :have_received, sym, @args, block do |sym, args, block|
31
22
  match do |actual|
32
23
  actual.received_message?(sym, *@args, &block)
33
24
  end
34
25
 
26
+
35
27
  failure_message_for_should do |actual|
36
- "expected #{actual.inspect} to have received #{sym.inspect} with #{args.inspect}"
28
+ "expected #{actual.inspect} to have received #{sym.inspect} with #{@args.inspect}"
37
29
  end
38
30
 
31
+
39
32
  failure_message_for_should_not do |actual|
40
- "expected #{actual.inspect} to not have received #{sym.inspect} with #{args.inspect}, but did"
33
+ "expected #{actual.inspect} to not have received #{sym.inspect} with #{@args.inspect}, but did"
41
34
  end
42
35
 
36
+
43
37
  description do
44
38
  "to have received #{sym.inspect} with #{args.inspect}"
45
39
  end
46
40
 
41
+
47
42
  def with(*args)
48
43
  @args = args
49
44
  self
@@ -4,7 +4,7 @@ module Spec
4
4
  module Matchers
5
5
  describe "[object.should] have_received(method, *args)" do
6
6
  before do
7
- @object = String.new
7
+ @object = String.new("HI!")
8
8
  end
9
9
 
10
10
  it "does match if method is called with correct args" do
@@ -27,6 +27,23 @@ module Spec
27
27
  have_received(:slice).with(5).matches?(@object).should be_false
28
28
  end
29
29
 
30
+ it "correctly lists expects arguments for should" do
31
+ @object.stub!(:slice)
32
+
33
+ matcher = have_received(:slice).with(5, 3)
34
+ messages = matcher.instance_variable_get("@messages")
35
+ message = messages[:failure_message_for_should].call(@object)
36
+ message.should == "expected \"HI!\" to have received :slice with [5, 3]"
37
+ end
38
+
39
+ it "correctly lists expects arguments for should_not" do
40
+ @object.stub!(:slice)
41
+
42
+ matcher = have_received(:slice).with(1, 2)
43
+ messages = matcher.instance_variable_get("@messages")
44
+ message = messages[:failure_message_for_should_not].call(@object)
45
+ message.should == "expected \"HI!\" to not have received :slice with [1, 2], but did"
46
+ end
30
47
  end
31
48
 
32
49
  end
@@ -1,9 +1,9 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
- require 'spec'
4
- require 'spec/autorun'
3
+ require 'rspec'
4
+ require 'rspec/autorun'
5
5
 
6
6
  require 'rspec-spies'
7
7
 
8
- Spec::Runner.configure do |config|
8
+ RSpec.configure do |config|
9
9
  end
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-spies
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.9
4
+ hash: 15
5
+ prerelease:
6
+ segments:
7
+ - 2
8
+ - 0
9
+ - 0
10
+ version: 2.0.0
5
11
  platform: ruby
6
12
  authors:
7
13
  - Joshua Nichols
@@ -9,19 +15,66 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2009-11-05 00:00:00 -05:00
18
+ date: 2011-07-07 00:00:00 -04:00
13
19
  default_executable:
14
20
  dependencies:
15
21
  - !ruby/object:Gem::Dependency
22
+ type: :runtime
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 2
31
+ - 0
32
+ version: "2.0"
33
+ version_requirements: *id001
16
34
  name: rspec
35
+ prerelease: false
36
+ - !ruby/object:Gem::Dependency
17
37
  type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
20
40
  requirements:
21
41
  - - ">="
22
42
  - !ruby/object:Gem::Version
23
- version: 1.2.9
24
- version:
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ version_requirements: *id002
48
+ name: rake
49
+ prerelease: false
50
+ - !ruby/object:Gem::Dependency
51
+ type: :development
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ version_requirements: *id003
62
+ name: jeweler
63
+ prerelease: false
64
+ - !ruby/object:Gem::Dependency
65
+ type: :development
66
+ requirement: &id004 !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ hash: 3
72
+ segments:
73
+ - 0
74
+ version: "0"
75
+ version_requirements: *id004
76
+ name: rdoc
77
+ prerelease: false
25
78
  description: test spies, for rspec
26
79
  email: josh@technicalpickles.com
27
80
  executables: []
@@ -33,7 +86,8 @@ extra_rdoc_files:
33
86
  - README.rdoc
34
87
  files:
35
88
  - .document
36
- - .gitignore
89
+ - Gemfile
90
+ - Gemfile.lock
37
91
  - LICENSE
38
92
  - README.rdoc
39
93
  - Rakefile
@@ -47,29 +101,34 @@ homepage: http://github.com/technicalpickles/rspec-spies
47
101
  licenses: []
48
102
 
49
103
  post_install_message:
50
- rdoc_options:
51
- - --charset=UTF-8
104
+ rdoc_options: []
105
+
52
106
  require_paths:
53
107
  - lib
54
108
  required_ruby_version: !ruby/object:Gem::Requirement
109
+ none: false
55
110
  requirements:
56
111
  - - ">="
57
112
  - !ruby/object:Gem::Version
113
+ hash: 3
114
+ segments:
115
+ - 0
58
116
  version: "0"
59
- version:
60
117
  required_rubygems_version: !ruby/object:Gem::Requirement
118
+ none: false
61
119
  requirements:
62
120
  - - ">="
63
121
  - !ruby/object:Gem::Version
122
+ hash: 3
123
+ segments:
124
+ - 0
64
125
  version: "0"
65
- version:
66
126
  requirements: []
67
127
 
68
128
  rubyforge_project:
69
- rubygems_version: 1.3.5
129
+ rubygems_version: 1.6.2
70
130
  signing_key:
71
131
  specification_version: 3
72
132
  summary: rspec has gone without tests spies. no more!
73
- test_files:
74
- - spec/rspec-spies_spec.rb
75
- - spec/spec_helper.rb
133
+ test_files: []
134
+
data/.gitignore DELETED
@@ -1,21 +0,0 @@
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