rspec-mocks 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -5,14 +5,17 @@ source "http://rubygems.org"
5
5
  end
6
6
 
7
7
  gem "rake"
8
- gem "cucumber", "0.8.5"
8
+ gem "cucumber", "0.9.4"
9
9
  gem "aruba", "0.2.2"
10
10
  gem "autotest"
11
11
  gem "relish"
12
+ gem "guard-rspec"
13
+ gem "growl"
12
14
 
13
- case RUBY_VERSION.to_s
14
- when '1.9.2'
15
- gem "ruby-debug19"
16
- when /^1.8/
17
- gem "ruby-debug"
15
+ gem "ruby-debug", :platforms => :ruby_18
16
+ gem "ruby-debug19", :platforms => :ruby_19
17
+
18
+ platforms :ruby_18, :ruby_19 do
19
+ gem "rb-fsevent"
20
+ gem "ruby-prof"
18
21
  end
@@ -0,0 +1,8 @@
1
+ # A sample Guardfile
2
+ # More info at http://github.com/guard/guard#readme
3
+
4
+ guard 'rspec', :version => 2 do
5
+ watch('^spec/(.*)_spec.rb')
6
+ watch('^lib/(.*)\.rb') { "spec" }
7
+ watch('^spec/spec_helper.rb') { "spec" }
8
+ end
@@ -1,5 +1,17 @@
1
1
  ## rspec-mocks release history (incomplete)
2
2
 
3
+ ### 2.2.0 / 2010-11-28
4
+
5
+ [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.1.0...v2.2.0)
6
+
7
+ * Enhancements
8
+ * Added "rspec/mocks/standalone" for exploring the rspec-mocks in irb.
9
+
10
+ * Bug fix
11
+ * Eliminate warning on splat args without parens (Gioele Barabucci)
12
+ * Fix bug where obj.should_receive(:foo).with(stub.as_null_object) would
13
+ pass with a false positive.
14
+
3
15
  ### 2.1.0 / 2010-11-07
4
16
 
5
17
  [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.0.1...v2.1.0)
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2005-2009 The RSpec Development Team
3
+ Copyright (c) 2005 The RSpec Development Team
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
19
  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
20
  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
21
  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -5,8 +5,16 @@ for method stubs, fakes, and message expectations.
5
5
 
6
6
  ## Documentation
7
7
 
8
- * [Cucumber features](http://relishapp.com/rspec/rspec-mocks/v/2-0)
9
- * [RDoc](http://rubydoc.info/gems/rspec-mocks/2.0.1/frames)
8
+ The [Cucumber features](http://relishapp.com/rspec/rspec-mocks/v/2-1) are the
9
+ most comprehensive and up-to-date docs for end-users.
10
+
11
+ The [RDoc](http://rubydoc.info/gems/rspec-mocks/2.1/frames) provides additional
12
+ information for contributors and/or extenders.
13
+
14
+ All of the documentation is open source and a work in progress. If you find it
15
+ lacking or confusing, you can help improve it by submitting requests and
16
+ patches to the [rspec-mocks issue
17
+ tracker](https://github.com/rspec/rspec-mocks/issues).
10
18
 
11
19
  ## Install
12
20
 
data/Rakefile CHANGED
@@ -64,7 +64,7 @@ end
64
64
  desc "Push cukes to relishapp using the relish-client-gem"
65
65
  task :relish, :version do |t, args|
66
66
  raise "rake relish[VERSION]" unless args[:version]
67
- sh "bundle exec relish --organization rspec --project rspec-mocks -v #{args[:version]} push"
67
+ sh "relish push --organization rspec --project rspec-mocks -v #{args[:version]}"
68
68
  end
69
69
 
70
70
  task :default => [:spec, :cucumber]
@@ -0,0 +1,14 @@
1
+ # rspec-mocks-2.2
2
+
3
+ ## What's new
4
+
5
+ ### `require "rspec/mocks/standalone"`
6
+
7
+ Sets up top-level environment to explore rspec-mocks. Mostly useful in irb:
8
+
9
+ $ irb
10
+ > require 'rspec/mocks/standalone'
11
+ > foo = double()
12
+ > foo.stub(:bar) { :baz }
13
+ > foo.bar
14
+ => :baz
@@ -0,0 +1,32 @@
1
+ Feature: standalone
2
+
3
+ require "rspec/mocks/standalone" to expose the mock framework
4
+ outside the RSpec environment. This is especially useful for
5
+ exploring rspec-mocks in irb.
6
+
7
+ Scenario: stub outside rspec
8
+ Given a file named "example.rb" with:
9
+ """
10
+ require "rspec/mocks/standalone"
11
+
12
+ greeter = double("greeter")
13
+ greeter.stub(:say_hi) { "Hello!" }
14
+ puts greeter.say_hi
15
+ """
16
+ When I run "ruby example.rb"
17
+ Then the output should contain "Hello!"
18
+
19
+ Scenario: message expectation outside rspec
20
+ Given a file named "example.rb" with:
21
+ """
22
+ require "rspec/mocks/standalone"
23
+
24
+ greeter = double("greeter")
25
+ greeter.should_receive(:say_hi)
26
+
27
+ RSpec::Mocks.verify
28
+ """
29
+ When I run "ruby example.rb"
30
+ Then the output should contain "say_hi(any args) (RSpec::Mocks::MockExpectationError)"
31
+ Then the output should contain "expected: 1 time"
32
+ Then the output should contain "received: 0 times"
@@ -1,5 +1,6 @@
1
1
  require 'rspec/mocks/framework'
2
2
  require 'rspec/mocks/version'
3
+ require 'rspec/mocks/spec_methods'
3
4
 
4
5
  module RSpec
5
6
  # == Test Doubles
@@ -176,8 +177,7 @@ module RSpec
176
177
  attr_accessor :space
177
178
 
178
179
  def setup(includer)
179
- require 'rspec/mocks/extensions/object'
180
- require 'rspec/mocks/spec_methods'
180
+ Object.class_eval { include RSpec::Mocks::Methods } unless Object < RSpec::Mocks::Methods
181
181
  (class << includer; self; end).class_eval do
182
182
  include RSpec::Mocks::ExampleMethods
183
183
  end
@@ -9,9 +9,10 @@ module RSpec
9
9
  @match_any_args = false
10
10
  @matchers = nil
11
11
 
12
- if ArgumentMatchers::AnyArgsMatcher === args.first
12
+ case args.first
13
+ when ArgumentMatchers::AnyArgsMatcher
13
14
  @match_any_args = true
14
- elsif ArgumentMatchers::NoArgsMatcher === args.first
15
+ when ArgumentMatchers::NoArgsMatcher
15
16
  @matchers = []
16
17
  else
17
18
  @matchers = args.collect {|arg| matcher_for(arg)}
@@ -19,13 +20,17 @@ module RSpec
19
20
  end
20
21
 
21
22
  def matcher_for(arg)
22
- return ArgumentMatchers::MatcherMatcher.new(arg) if is_matcher?(arg)
23
- return ArgumentMatchers::RegexpMatcher.new(arg) if arg.is_a?(Regexp)
23
+ return ArgumentMatchers::MatcherMatcher.new(arg) if is_matcher?(arg)
24
+ return ArgumentMatchers::RegexpMatcher.new(arg) if arg.is_a?(Regexp)
24
25
  return ArgumentMatchers::EqualityProxy.new(arg)
25
26
  end
26
27
 
27
28
  def is_matcher?(obj)
28
- return obj.respond_to?(:matches?) & obj.respond_to?(:description)
29
+ !is_stub_as_null_object?(obj) & obj.respond_to?(:matches?) & obj.respond_to?(:description)
30
+ end
31
+
32
+ def is_stub_as_null_object?(obj)
33
+ obj.respond_to?(:__rspec_double_acting_as_null_object?) && obj.__rspec_double_acting_as_null_object?
29
34
  end
30
35
 
31
36
  def args_match?(*args)
@@ -40,7 +40,7 @@ module RSpec
40
40
  new_gen = error_generator.clone
41
41
  new_gen.opts = opts
42
42
  child.error_generator = new_gen
43
- child.clone_args_to_yield *@args_to_yield
43
+ child.clone_args_to_yield(*@args_to_yield)
44
44
  child
45
45
  end
46
46
 
@@ -0,0 +1,3 @@
1
+ require 'rspec/mocks'
2
+
3
+ RSpec::Mocks.setup(self)
@@ -1,7 +1,7 @@
1
1
  module RSpec # :nodoc:
2
2
  module Mocks # :nodoc:
3
3
  module Version # :nodoc:
4
- STRING = '2.1.0'
4
+ STRING = '2.2.0'
5
5
  end
6
6
  end
7
7
  end
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.files = `git ls-files`.split("\n")
19
19
  s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
20
20
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
- s.extra_rdoc_files = [ "README.markdown" ]
21
+ s.extra_rdoc_files = [ "README.md" ]
22
22
  s.rdoc_options = ["--charset=UTF-8"]
23
23
  s.require_path = "lib"
24
24
  end
@@ -6,16 +6,18 @@ module RSpec
6
6
  it "considers an object that responds to #matches? and #description to be a matcher" do
7
7
  argument_expecatation = RSpec::Mocks::ArgumentExpectation.new
8
8
  obj = double("matcher")
9
- obj.should_receive(:respond_to?).with(:matches?).and_return(true)
10
- obj.should_receive(:respond_to?).with(:description).and_return(true)
9
+ obj.stub(:respond_to?).with(:__rspec_double_acting_as_null_object?).and_return(false)
10
+ obj.stub(:respond_to?).with(:matches?).and_return(true)
11
+ obj.stub(:respond_to?).with(:description).and_return(true)
11
12
  argument_expecatation.is_matcher?(obj).should be_true
12
13
  end
13
14
 
14
15
  it "does NOT consider an object that only responds to #matches? to be a matcher" do
15
16
  argument_expecatation = RSpec::Mocks::ArgumentExpectation.new
16
17
  obj = double("matcher")
17
- obj.should_receive(:respond_to?).with(:matches?).and_return(true)
18
- obj.should_receive(:respond_to?).with(:description).and_return(false)
18
+ obj.stub(:respond_to?).with(:__rspec_double_acting_as_null_object?).and_return(false)
19
+ obj.stub(:respond_to?).with(:matches?).and_return(true)
20
+ obj.stub(:respond_to?).with(:description).and_return(false)
19
21
  argument_expecatation.is_matcher?(obj).should be_false
20
22
  end
21
23
  end
@@ -635,6 +635,30 @@ module RSpec
635
635
  @mock.rspec_reset
636
636
  end
637
637
  end
638
+
639
+ context "with non-matching doubles" do
640
+ it "fails" do
641
+ d1 = double('1')
642
+ d2 = double('2')
643
+ @mock.should_receive(:foo).with(d1)
644
+ expect do
645
+ @mock.foo(d2)
646
+ end.to raise_error
647
+ @mock.rspec_reset
648
+ end
649
+ end
650
+
651
+ context "with non-matching doubles as_null_object" do
652
+ it "fails" do
653
+ d1 = double('1').as_null_object
654
+ d2 = double('2').as_null_object
655
+ @mock.should_receive(:foo).with(d1)
656
+ expect do
657
+ @mock.foo(d2)
658
+ end.to raise_error
659
+ @mock.rspec_reset
660
+ end
661
+ end
638
662
  end
639
663
 
640
664
  context "with a block" do
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 2
7
- - 1
7
+ - 2
8
8
  - 0
9
- version: 2.1.0
9
+ version: 2.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - David Chelimsky
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-07 01:00:00 -05:00
18
+ date: 2010-11-28 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -26,16 +26,18 @@ executables: []
26
26
  extensions: []
27
27
 
28
28
  extra_rdoc_files:
29
- - README.markdown
29
+ - README.md
30
30
  files:
31
31
  - .autotest
32
32
  - .document
33
33
  - .gitignore
34
34
  - Gemfile
35
+ - Guardfile
35
36
  - History.markdown
36
37
  - License.txt
37
- - README.markdown
38
+ - README.md
38
39
  - Rakefile
40
+ - Upgrade.markdown
39
41
  - autotest/discover.rb
40
42
  - cucumber.yml
41
43
  - features/README.markdown
@@ -43,6 +45,7 @@ files:
43
45
  - features/message_expectations/expect_message.feature
44
46
  - features/message_expectations/warn_when_expectation_is_set_on_nil.feature
45
47
  - features/outside_rspec/configuration.feature
48
+ - features/outside_rspec/standalone.feature
46
49
  - features/stubs/simple_return_value.feature
47
50
  - features/stubs/stub_chain.feature
48
51
  - features/stubs/stub_implementation.feature
@@ -54,7 +57,6 @@ files:
54
57
  - lib/rspec/mocks/errors.rb
55
58
  - lib/rspec/mocks/extensions/instance_exec.rb
56
59
  - lib/rspec/mocks/extensions/marshal.rb
57
- - lib/rspec/mocks/extensions/object.rb
58
60
  - lib/rspec/mocks/framework.rb
59
61
  - lib/rspec/mocks/message_expectation.rb
60
62
  - lib/rspec/mocks/method_double.rb
@@ -65,6 +67,7 @@ files:
65
67
  - lib/rspec/mocks/serialization.rb
66
68
  - lib/rspec/mocks/space.rb
67
69
  - lib/rspec/mocks/spec_methods.rb
70
+ - lib/rspec/mocks/standalone.rb
68
71
  - lib/rspec/mocks/version.rb
69
72
  - lib/spec/mocks.rb
70
73
  - rspec-mocks.gemspec
@@ -126,7 +129,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
126
129
  requirements:
127
130
  - - ">="
128
131
  - !ruby/object:Gem::Version
129
- hash: -1767543596298256707
132
+ hash: -3345678086829726871
130
133
  segments:
131
134
  - 0
132
135
  version: "0"
@@ -135,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
138
  requirements:
136
139
  - - ">="
137
140
  - !ruby/object:Gem::Version
138
- hash: -1767543596298256707
141
+ hash: -3345678086829726871
139
142
  segments:
140
143
  - 0
141
144
  version: "0"
@@ -145,13 +148,14 @@ rubyforge_project: rspec
145
148
  rubygems_version: 1.3.7
146
149
  signing_key:
147
150
  specification_version: 3
148
- summary: rspec-mocks-2.1.0
151
+ summary: rspec-mocks-2.2.0
149
152
  test_files:
150
153
  - features/README.markdown
151
154
  - features/message_expectations/block_local_expectations.feature.pending
152
155
  - features/message_expectations/expect_message.feature
153
156
  - features/message_expectations/warn_when_expectation_is_set_on_nil.feature
154
157
  - features/outside_rspec/configuration.feature
158
+ - features/outside_rspec/standalone.feature
155
159
  - features/stubs/simple_return_value.feature
156
160
  - features/stubs/stub_chain.feature
157
161
  - features/stubs/stub_implementation.feature
@@ -1,3 +0,0 @@
1
- class Object
2
- include RSpec::Mocks::Methods
3
- end