flexmock 0.8.11 → 0.9.0

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.
Files changed (51) hide show
  1. data/README.rdoc +2 -2
  2. data/Rakefile +23 -65
  3. data/TAGS +689 -691
  4. data/doc/releases/flexmock-0.9.0.rdoc +89 -0
  5. data/lib/flexmock.rb +1 -1
  6. data/lib/flexmock/argument_matchers.rb +5 -5
  7. data/lib/flexmock/argument_types.rb +1 -1
  8. data/lib/flexmock/base.rb +1 -1
  9. data/lib/flexmock/core.rb +5 -5
  10. data/lib/flexmock/core_class_methods.rb +6 -6
  11. data/lib/flexmock/default_framework_adapter.rb +2 -2
  12. data/lib/flexmock/deprecated_methods.rb +1 -1
  13. data/lib/flexmock/errors.rb +1 -1
  14. data/lib/flexmock/expectation.rb +12 -12
  15. data/lib/flexmock/expectation_director.rb +1 -1
  16. data/lib/flexmock/mock_container.rb +12 -2
  17. data/lib/flexmock/noop.rb +2 -2
  18. data/lib/flexmock/ordering.rb +1 -1
  19. data/lib/flexmock/partial_mock.rb +10 -3
  20. data/lib/flexmock/rails.rb +1 -1
  21. data/lib/flexmock/recorder.rb +1 -1
  22. data/lib/flexmock/rspec.rb +1 -1
  23. data/lib/flexmock/test_unit.rb +2 -2
  24. data/lib/flexmock/test_unit_integration.rb +5 -5
  25. data/lib/flexmock/undefined.rb +8 -4
  26. data/lib/flexmock/validators.rb +2 -2
  27. data/lib/flexmock/version.rb +11 -0
  28. data/test/{test_aliasing.rb → aliasing_test.rb} +7 -8
  29. data/test/{test_container_methods.rb → container_methods_test.rb} +21 -22
  30. data/test/{test_default_framework_adapter.rb → default_framework_adapter_test.rb} +8 -9
  31. data/test/{test_demeter_mocking.rb → demeter_mocking_test.rb} +1 -4
  32. data/test/{test_deprecated_methods.rb → deprecated_methods_test.rb} +11 -13
  33. data/test/{test_examples_from_readme.rb → examples_from_readme_test.rb} +5 -6
  34. data/test/{test_extended_should_receive.rb → extended_should_receive_test.rb} +11 -12
  35. data/test/{test_flexmodel.rb → flexmodel_test.rb} +1 -2
  36. data/test/{test_naming.rb → naming_test.rb} +5 -6
  37. data/test/{test_new_instances.rb → new_instances_test.rb} +36 -28
  38. data/test/{test_partial_mock.rb → partial_mock_test.rb} +20 -18
  39. data/test/{test_rails_view_stub.rb → rails_view_stub_test.rb} +3 -3
  40. data/test/{test_record_mode.rb → record_mode_test.rb} +2 -5
  41. data/test/rspec_integration/integration_spec.rb +14 -8
  42. data/test/{test_samples.rb → samples_test.rb} +13 -14
  43. data/test/{test_should_ignore_missing.rb → should_ignore_missing_test.rb} +4 -6
  44. data/test/{test_should_receive.rb → should_receive_test.rb} +39 -42
  45. data/test/test_setup.rb +30 -0
  46. data/test/test_unit_integration/{test_auto_test_unit.rb → auto_test_unit_test.rb} +4 -4
  47. data/test/tu_integration_test.rb +99 -0
  48. data/test/{test_undefined.rb → undefined_test.rb} +2 -3
  49. metadata +31 -39
  50. data/test/asserts.rb +0 -34
  51. data/test/test_tu_integration.rb +0 -94
@@ -0,0 +1,30 @@
1
+ require 'test/unit'
2
+ require 'fileutils'
3
+
4
+ require 'flexmock'
5
+ require 'test/redirect_error'
6
+
7
+ class FlexMock
8
+ module TestCase
9
+ def assertion_failed_error
10
+ FlexMock.framework_adapter.assertion_failed_error
11
+ end
12
+
13
+ # Assertion helper used to assert validation failure. If a
14
+ # message is given, then the error message should match the
15
+ # expected error message.
16
+ def assert_failure(message=nil)
17
+ ex = assert_raises(assertion_failed_error) { yield }
18
+ if message
19
+ case message
20
+ when Regexp
21
+ assert_match message, ex.message
22
+ when String
23
+ assert ex.message.index(message), "Error message '#{ex.message}' should contain '#{message}'"
24
+ end
25
+ end
26
+ ex
27
+ end
28
+
29
+ end
30
+ end
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  #---
4
- # Copyright 2003, 2004, 2005, 2006, 2007 by Jim Weirich (jim@weirichhouse.org).
4
+ # Copyright 2003-2011 by Jim Weirich (jim@weirichhouse.org).
5
5
  # All rights reserved.
6
6
 
7
7
  # Permission is granted for use, copying, modification, distribution,
@@ -9,7 +9,7 @@
9
9
  # above copyright notice is included.
10
10
  #+++
11
11
 
12
- require "test/unit"
12
+ require "test/test_setup"
13
13
 
14
14
  require "flexmock/base"
15
15
  require "flexmock/test_unit"
@@ -25,10 +25,10 @@ class TestFlexmockTestUnit < Test::Unit::TestCase
25
25
  m.should_receive(:hi).once
26
26
  m.hi
27
27
  end
28
-
28
+
29
29
  # This test should fail during teardown.
30
30
  def test_should_fail__mocks_are_auto_verified
31
31
  m = flexmock("mock")
32
32
  m.should_receive(:hi).once
33
33
  end
34
- end
34
+ end
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #---
4
+ # Copyright 2003-2011 by Jim Weirich (jim@weirichhouse.org).
5
+ # All rights reserved.
6
+
7
+ # Permission is granted for use, copying, modification, distribution,
8
+ # and distribution of modified versions of this work as long as the
9
+ # above copyright notice is included.
10
+ #+++
11
+
12
+ require 'test/test_setup'
13
+
14
+ # The following tests exercise Test::Unit integration. They are
15
+ # disabled if actually running under MiniTest because the MiniTest is
16
+ # different enough internally that the tests are not worthwhile.
17
+
18
+ unless defined?(MiniTest)
19
+ class TestTuIntegrationFlexMockMethod < Test::Unit::TestCase
20
+ include FlexMock::TestCase
21
+
22
+ def test_can_construct_flexmock
23
+ mock = flexmock("x")
24
+ mock.should_receive(:hi).and_return(:hello)
25
+ assert_equal :hello, mock.hi
26
+ end
27
+
28
+ def test_can_construct_flexmock_with_block
29
+ mock = flexmock("x") do |m|
30
+ m.should_receive(:hi).and_return(:hello)
31
+ end
32
+ assert_equal :hello, mock.hi
33
+ end
34
+ end
35
+
36
+ class TestTuIntegrationMockVerificationInTeardown < Test::Unit::TestCase
37
+ include FlexMock::TestCase
38
+
39
+ def teardown
40
+ assert_raise(assertion_failed_error) do
41
+ super
42
+ end
43
+ end
44
+
45
+ def test_mock_verification_occurs_during_teardown
46
+ flexmock("xyz").should_receive(:hi).with(any).once
47
+ end
48
+ end
49
+
50
+ class TestTuIntegrationMockVerificationWithoutSetup < Test::Unit::TestCase
51
+ include FlexMock::TestCase
52
+
53
+ def teardown
54
+ assert_raise(assertion_failed_error) do
55
+ super
56
+ end
57
+ end
58
+
59
+ def test_mock_verification_occurs_during_teardown
60
+ flexmock("xyz").should_receive(:hi).with(any).once
61
+ end
62
+ end
63
+
64
+ class TestTuIntegrationMockVerificationForgetfulSetup < Test::Unit::TestCase
65
+ include FlexMock::TestCase
66
+
67
+ def teardown
68
+ assert_raise(assertion_failed_error) do
69
+ super
70
+ end
71
+ end
72
+
73
+ def test_mock_verification_occurs_during_teardown
74
+ flexmock("xyz").should_receive(:hi).with(any).once
75
+ end
76
+ end
77
+
78
+ class TestTuIntegrationSetupOverridenAndNoMocksOk < Test::Unit::TestCase
79
+ include FlexMock::TestCase
80
+
81
+ def test_mock_verification_occurs_during_teardown
82
+ end
83
+ end
84
+
85
+ class TestTuIntegrationFailurePreventsVerification < Test::Unit::TestCase
86
+ include FlexMock::TestCase
87
+
88
+ def test_mock_verification_occurs_during_teardown
89
+ flexmock('m').should_receive(:hi).once
90
+ simulate_failure
91
+ end
92
+
93
+ private
94
+
95
+ def simulate_failure
96
+ @test_passed = false
97
+ end
98
+ end
99
+ end
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  #---
4
- # Copyright 2003, 2004, 2005, 2006, 2007 by Jim Weirich (jim@weirichhouse.org).
4
+ # Copyright 2003-2011 by Jim Weirich (jim@weirichhouse.org).
5
5
  # All rights reserved.
6
6
 
7
7
  # Permission is granted for use, copying, modification, distribution,
@@ -9,8 +9,7 @@
9
9
  # above copyright notice is included.
10
10
  #+++
11
11
 
12
- require "test/unit"
13
- require "flexmock"
12
+ require "test/test_setup"
14
13
 
15
14
  class UndefinedTest < Test::Unit::TestCase
16
15
  def test_undefined_method_calls_return_undefined
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flexmock
3
3
  version: !ruby/object:Gem::Version
4
- hash: 41
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 8
9
- - 11
10
- version: 0.8.11
4
+ prerelease:
5
+ version: 0.9.0
11
6
  platform: ruby
12
7
  authors:
13
8
  - Jim Weirich
@@ -15,12 +10,12 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2010-10-15 00:00:00 -04:00
13
+ date: 2011-02-27 00:00:00 -05:00
19
14
  default_executable:
20
15
  dependencies: []
21
16
 
22
17
  description: "\n FlexMock is a extremely simple mock object class compatible\n with the Test::Unit framework. Although the FlexMock's\n interface is simple, it is very flexible.\n "
23
- email: jim@weirichhouse.org
18
+ email: jim.weirich@gmail.com
24
19
  executables: []
25
20
 
26
21
  extensions: []
@@ -47,6 +42,7 @@ extra_rdoc_files:
47
42
  - doc/releases/flexmock-0.8.3.rdoc
48
43
  - doc/releases/flexmock-0.8.4.rdoc
49
44
  - doc/releases/flexmock-0.8.5.rdoc
45
+ - doc/releases/flexmock-0.9.0.rdoc
50
46
  files:
51
47
  - CHANGES
52
48
  - Rakefile
@@ -75,29 +71,30 @@ files:
75
71
  - lib/flexmock/test_unit_integration.rb
76
72
  - lib/flexmock/undefined.rb
77
73
  - lib/flexmock/validators.rb
74
+ - lib/flexmock/version.rb
78
75
  - lib/flexmock.rb
79
- - test/asserts.rb
76
+ - test/aliasing_test.rb
77
+ - test/container_methods_test.rb
78
+ - test/default_framework_adapter_test.rb
79
+ - test/demeter_mocking_test.rb
80
+ - test/deprecated_methods_test.rb
81
+ - test/examples_from_readme_test.rb
82
+ - test/extended_should_receive_test.rb
83
+ - test/flexmodel_test.rb
84
+ - test/naming_test.rb
85
+ - test/new_instances_test.rb
86
+ - test/partial_mock_test.rb
87
+ - test/rails_view_stub_test.rb
88
+ - test/record_mode_test.rb
80
89
  - test/redirect_error.rb
81
90
  - test/rspec_integration/integration_spec.rb
82
- - test/test_aliasing.rb
83
- - test/test_container_methods.rb
84
- - test/test_default_framework_adapter.rb
85
- - test/test_demeter_mocking.rb
86
- - test/test_deprecated_methods.rb
87
- - test/test_examples_from_readme.rb
88
- - test/test_extended_should_receive.rb
89
- - test/test_flexmodel.rb
90
- - test/test_naming.rb
91
- - test/test_new_instances.rb
92
- - test/test_partial_mock.rb
93
- - test/test_rails_view_stub.rb
94
- - test/test_record_mode.rb
95
- - test/test_samples.rb
96
- - test/test_should_ignore_missing.rb
97
- - test/test_should_receive.rb
98
- - test/test_tu_integration.rb
99
- - test/test_undefined.rb
100
- - test/test_unit_integration/test_auto_test_unit.rb
91
+ - test/samples_test.rb
92
+ - test/should_ignore_missing_test.rb
93
+ - test/should_receive_test.rb
94
+ - test/test_setup.rb
95
+ - test/test_unit_integration/auto_test_unit_test.rb
96
+ - test/tu_integration_test.rb
97
+ - test/undefined_test.rb
101
98
  - flexmock.blurb
102
99
  - install.rb
103
100
  - doc/GoogleExample.rdoc
@@ -119,16 +116,17 @@ files:
119
116
  - doc/releases/flexmock-0.8.3.rdoc
120
117
  - doc/releases/flexmock-0.8.4.rdoc
121
118
  - doc/releases/flexmock-0.8.5.rdoc
119
+ - doc/releases/flexmock-0.9.0.rdoc
122
120
  has_rdoc: true
123
- homepage: http://flexmock.rubyforge.org
121
+ homepage: https://github.com/jimweirich/flexmock
124
122
  licenses: []
125
123
 
126
124
  post_install_message:
127
125
  rdoc_options:
128
126
  - --title
129
- - Flex Mock
127
+ - FlexMock
130
128
  - --main
131
- - README
129
+ - README.rdoc
132
130
  - --line-numbers
133
131
  require_paths:
134
132
  - lib
@@ -137,23 +135,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
137
135
  requirements:
138
136
  - - ">="
139
137
  - !ruby/object:Gem::Version
140
- hash: 3
141
- segments:
142
- - 0
143
138
  version: "0"
144
139
  required_rubygems_version: !ruby/object:Gem::Requirement
145
140
  none: false
146
141
  requirements:
147
142
  - - ">="
148
143
  - !ruby/object:Gem::Version
149
- hash: 3
150
- segments:
151
- - 0
152
144
  version: "0"
153
145
  requirements: []
154
146
 
155
147
  rubyforge_project:
156
- rubygems_version: 1.3.7
148
+ rubygems_version: 1.5.2
157
149
  signing_key:
158
150
  specification_version: 3
159
151
  summary: Simple and Flexible Mock Objects for Testing
@@ -1,34 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- #---
4
- # Copyright 2003, 2004, 2005, 2006, 2007 by Jim Weirich (jim@weirichhouse.org).
5
- # All rights reserved.
6
-
7
- # Permission is granted for use, copying, modification, distribution,
8
- # and distribution of modified versions of this work as long as the
9
- # above copyright notice is included.
10
- #+++
11
-
12
- class FlexMock
13
-
14
- # Provide a common failure assertion.
15
- module FailureAssertion
16
- private
17
-
18
- # Assertion helper used to assert validation failure. If a
19
- # message is given, then the error message should match the
20
- # expected error message.
21
- def assert_failure(message=nil)
22
- ex = assert_raises(Test::Unit::AssertionFailedError) { yield }
23
- if message
24
- case message
25
- when Regexp
26
- assert_match message, ex.message
27
- when String
28
- assert ex.message.index(message), "Error message '#{ex.message}' should contain '#{message}'"
29
- end
30
- end
31
- ex
32
- end
33
- end
34
- end
@@ -1,94 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- #---
4
- # Copyright 2003, 2004, 2005, 2006, 2007 by Jim Weirich (jim@weirichhouse.org).
5
- # All rights reserved.
6
-
7
- # Permission is granted for use, copying, modification, distribution,
8
- # and distribution of modified versions of this work as long as the
9
- # above copyright notice is included.
10
- #+++
11
-
12
- require 'test/unit'
13
- require 'flexmock'
14
-
15
- class TestTuIntegrationFlexMockMethod < Test::Unit::TestCase
16
- include FlexMock::TestCase
17
-
18
- def test_can_construct_flexmock
19
- mock = flexmock("x")
20
- mock.should_receive(:hi).and_return(:hello)
21
- assert_equal :hello, mock.hi
22
- end
23
-
24
- def test_can_construct_flexmock_with_block
25
- mock = flexmock("x") do |m|
26
- m.should_receive(:hi).and_return(:hello)
27
- end
28
- assert_equal :hello, mock.hi
29
- end
30
- end
31
-
32
- class TestTuIntegrationMockVerificationInTeardown < Test::Unit::TestCase
33
- include FlexMock::TestCase
34
-
35
- def teardown
36
- assert_raise(Test::Unit::AssertionFailedError) do
37
- super
38
- end
39
- end
40
-
41
- def test_mock_verification_occurs_during_teardown
42
- flexmock("xyz").should_receive(:hi).with(any).once
43
- end
44
- end
45
-
46
- class TestTuIntegrationMockVerificationWithoutSetup < Test::Unit::TestCase
47
- include FlexMock::TestCase
48
-
49
- def teardown
50
- assert_raise(Test::Unit::AssertionFailedError) do
51
- super
52
- end
53
- end
54
-
55
- def test_mock_verification_occurs_during_teardown
56
- flexmock("xyz").should_receive(:hi).with(any).once
57
- end
58
- end
59
-
60
- class TestTuIntegrationMockVerificationForgetfulSetup < Test::Unit::TestCase
61
- include FlexMock::TestCase
62
-
63
- def teardown
64
- assert_raise(Test::Unit::AssertionFailedError) do
65
- super
66
- end
67
- end
68
-
69
- def test_mock_verification_occurs_during_teardown
70
- flexmock("xyz").should_receive(:hi).with(any).once
71
- end
72
- end
73
-
74
- class TestTuIntegrationSetupOverridenAndNoMocksOk < Test::Unit::TestCase
75
- include FlexMock::TestCase
76
-
77
- def test_mock_verification_occurs_during_teardown
78
- end
79
- end
80
-
81
- class TestTuIntegrationFailurePreventsVerification < Test::Unit::TestCase
82
- include FlexMock::TestCase
83
-
84
- def test_mock_verification_occurs_during_teardown
85
- flexmock('m').should_receive(:hi).once
86
- simulate_failure
87
- end
88
-
89
- private
90
-
91
- def simulate_failure
92
- @test_passed = false
93
- end
94
- end