hardmock 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2006 Atomic Object, LLC
1
+ Copyright (c) 2006,2007 David Crosby at Atomic Object, LLC
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
4
 
data/README CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  Strict, ordered mock objects using very lightweight syntax in your tests.
4
4
 
5
-
6
5
  == How
7
6
 
8
7
  The basic procedure for using Hardmock in your tests is:
@@ -46,3 +45,7 @@ Expects <tt>@garage.open_door</tt>, <tt>@car.start(:choke)</tt> and <tt>@car.dri
46
45
  * Rails plugin: script/plugin install
47
46
  * SVN access: svn co svn://rubyforge.org/var/svn/hardmock/trunk
48
47
  * Developer SVN access: svn co svn://developername@rubyforge.org/var/svn/hardmock/trunk
48
+
49
+ == Author
50
+ * David Crosby crosby at http://atomicobject.com
51
+ * (c) 2006,2007 Atomic Object LLC
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rake'
2
2
  require 'rubygems'
3
3
 
4
- HARDMOCK_VERSION = "1.3.1"
4
+ HARDMOCK_VERSION = "1.3.2"
5
5
 
6
6
  Dir["lib/tasks/*.rake"].each { |f| load f }
7
7
 
@@ -64,7 +64,15 @@ module Hardmock
64
64
  @options[:returns] = val
65
65
  self
66
66
  end
67
-
67
+
68
+ # Set the arguments for an expected method call.
69
+ # Eg,
70
+ # @cash_machine.expects.deposit.with(20, "dollars").returns(:balance => "20")
71
+ def with(*args)
72
+ @options[:arguments] = args
73
+ self
74
+ end
75
+
68
76
  # Rig an expected method to raise an exception when the mock is invoked.
69
77
  #
70
78
  # Eg,
@@ -48,6 +48,13 @@ class HardmockTest < Test::Unit::TestCase
48
48
  verify_mocks
49
49
  end
50
50
 
51
+ it "supports 'with' for specifying argument expectations" do
52
+ create_mocks :car
53
+ @car.expects(:fill).with('gas','booze')
54
+ @car.fill('gas', 'booze')
55
+ verify_mocks
56
+ end
57
+
51
58
  it "supports several mocks at once" do
52
59
  create_mocks :order_builder, :order, :customer
53
60
 
@@ -354,5 +354,19 @@ class ExpectationTest < Test::Unit::TestCase
354
354
  se.apply_method_call(@mock,'do_later',[],lambda { |doesnt,match| raise "Surprise!" } )
355
355
  end
356
356
  end
357
+
358
+ def test_that_arguments_can_be_added_to_expectation
359
+ expectation = Expectation.new(:mock => @mock, :method => "each_bean")
360
+ assert_same expectation, expectation.with("jello", "for", "cosby"), "should have returned the same expectation"
361
+
362
+ err = assert_raise ExpectationError do
363
+ expectation.apply_method_call(@mock, 'each_bean', [], nil)
364
+ end
365
+ assert_match(/wrong arguments/i, err.message)
366
+
367
+ assert_nothing_raised(ExpectationError) do
368
+ expectation.apply_method_call(@mock, 'each_bean', ["jello", "for", "cosby"], nil)
369
+ end
370
+ end
357
371
 
358
372
  end
metadata CHANGED
@@ -1,36 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0
3
- specification_version: 1
4
2
  name: hardmock
5
3
  version: !ruby/object:Gem::Version
6
- version: 1.3.1
7
- date: 2007-11-17 00:00:00 -05:00
8
- summary: A strict, ordered, expectation-oriented mock object library.
9
- require_paths:
10
- - lib
11
- email: crosby@atomicobject.com
12
- homepage: http://hardmock.rubyforge.org
13
- rubyforge_project: hardmock
14
- description:
15
- autorequire: hardmock
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ version: 1.3.2
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
7
  - David Crosby
8
+ autorequire: hardmock
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2007-11-28 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: crosby@atomicobject.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README
24
+ - CHANGES
25
+ - LICENSE
31
26
  files:
32
27
  - lib/assert_error.rb
33
- - lib/hardmock.rb
34
28
  - lib/hardmock/errors.rb
35
29
  - lib/hardmock/expectation.rb
36
30
  - lib/hardmock/expectation_builder.rb
@@ -41,13 +35,14 @@ files:
41
35
  - lib/hardmock/stubbing.rb
42
36
  - lib/hardmock/trapper.rb
43
37
  - lib/hardmock/utils.rb
38
+ - lib/hardmock.rb
44
39
  - lib/tasks/rdoc_options.rb
45
- - test/test_helper.rb
46
40
  - test/functional/assert_error_test.rb
47
41
  - test/functional/auto_verify_test.rb
48
42
  - test/functional/direct_mock_usage_test.rb
49
43
  - test/functional/hardmock_test.rb
50
44
  - test/functional/stubbing_test.rb
45
+ - test/test_helper.rb
51
46
  - test/unit/expectation_builder_test.rb
52
47
  - test/unit/expectation_test.rb
53
48
  - test/unit/expector_test.rb
@@ -63,6 +58,37 @@ files:
63
58
  - README
64
59
  - CHANGES
65
60
  - LICENSE
61
+ has_rdoc: true
62
+ homepage: http://hardmock.rubyforge.org
63
+ post_install_message:
64
+ rdoc_options:
65
+ - --line-numbers
66
+ - --inline-source
67
+ - --main
68
+ - README
69
+ - --title
70
+ - Hardmock
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: "0"
78
+ version:
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: "0"
84
+ version:
85
+ requirements: []
86
+
87
+ rubyforge_project: hardmock
88
+ rubygems_version: 0.9.5
89
+ signing_key:
90
+ specification_version: 2
91
+ summary: A strict, ordered, expectation-oriented mock object library.
66
92
  test_files:
67
93
  - test/functional/assert_error_test.rb
68
94
  - test/functional/auto_verify_test.rb
@@ -77,22 +103,3 @@ test_files:
77
103
  - test/unit/mock_test.rb
78
104
  - test/unit/trapper_test.rb
79
105
  - test/unit/verify_error_test.rb
80
- rdoc_options:
81
- - --line-numbers
82
- - --inline-source
83
- - --main
84
- - README
85
- - --title
86
- - Hardmock
87
- extra_rdoc_files:
88
- - README
89
- - CHANGES
90
- - LICENSE
91
- executables: []
92
-
93
- extensions: []
94
-
95
- requirements: []
96
-
97
- dependencies: []
98
-