rspec-expectations 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,12 @@
1
1
  ## rspec-expectations release history (incomplete)
2
2
 
3
+ ### 2.0.1 / 2010-10-18
4
+
5
+ [full changelog](http://github.com/rspec/rspec-expectations/compare/v2.0.0...v2.0.1)
6
+
7
+ * Enhancements
8
+ * Make dependencies on other rspec gems consistent across gems
9
+
3
10
  ### 2.0.0 / 2010-10-10
4
11
 
5
12
  [full changelog](http://github.com/rspec/rspec-expectations/compare/v2.0.0.rc...v2.0.0)
@@ -0,0 +1,114 @@
1
+ Feature: Type Check matchers
2
+
3
+ rspec-expectations includes two matchers specify types of objects:
4
+
5
+ * obj.should be_kind_of(type): calls obj.kind_of?(type), which returns
6
+ true if type is in obj's class hierarchy or is a module and is
7
+ included in a class in obj's class hierarchy.
8
+ * obj.should be_instance_of(type): calls obj.instance_of?(type), which
9
+ returns true if and only if type if obj's class.
10
+
11
+ Both of these matchers have aliases:
12
+
13
+ * obj.should be_a_kind_of(type) # same as obj.should be_kind_of(type)
14
+ * obj.should be_a(type) # same as obj.should be_kind_of(type)
15
+ * obj.should be_an(type) # same as obj.should be_kind_of(type)
16
+ * obj.should be_an_instance_of(type) # same as obj.should be_instance_of(type)
17
+
18
+ Scenario: be_(a_)kind_of matcher
19
+ Given a file named "be_kind_of_matcher_spec.rb" with:
20
+ """
21
+ module MyModule; end
22
+
23
+ class Fixnum
24
+ include MyModule
25
+ end
26
+
27
+ describe 17 do
28
+ # the actual class
29
+ it { should be_kind_of(Fixnum) }
30
+ it { should be_a_kind_of(Fixnum) }
31
+ it { should be_a(Fixnum) }
32
+
33
+ # the superclass
34
+ it { should be_kind_of(Integer) }
35
+ it { should be_a_kind_of(Integer) }
36
+ it { should be_an(Integer) }
37
+
38
+ # an included module
39
+ it { should be_kind_of(MyModule) }
40
+ it { should be_a_kind_of(MyModule) }
41
+ it { should be_a(MyModule) }
42
+
43
+ # negative passing case
44
+ it { should_not be_kind_of(String) }
45
+ it { should_not be_a_kind_of(String) }
46
+ it { should_not be_a(String) }
47
+
48
+ # deliberate failures
49
+ it { should_not be_kind_of(Fixnum) }
50
+ it { should_not be_a_kind_of(Fixnum) }
51
+ it { should_not be_a(Fixnum) }
52
+ it { should_not be_kind_of(Integer) }
53
+ it { should_not be_a_kind_of(Integer) }
54
+ it { should_not be_an(Integer) }
55
+ it { should_not be_kind_of(MyModule) }
56
+ it { should_not be_a_kind_of(MyModule) }
57
+ it { should_not be_a(MyModule) }
58
+ it { should be_kind_of(String) }
59
+ it { should be_a_kind_of(String) }
60
+ it { should be_a(String) }
61
+ end
62
+ """
63
+ When I run "rspec be_kind_of_matcher_spec.rb"
64
+ Then the output should contain all of these:
65
+ | 24 examples, 12 failures |
66
+ | expected 17 not to be a kind of Fixnum |
67
+ | expected 17 not to be a kind of Integer |
68
+ | expected 17 not to be a kind of MyModule |
69
+ | expected 17 to be a kind of String |
70
+
71
+ Scenario: be_(an_)instance_of matcher
72
+ Given a file named "be_instance_of_matcher_spec.rb" with:
73
+ """
74
+ module MyModule; end
75
+
76
+ class Fixnum
77
+ include MyModule
78
+ end
79
+
80
+ describe 17 do
81
+ # the actual class
82
+ it { should be_instance_of(Fixnum) }
83
+ it { should be_an_instance_of(Fixnum) }
84
+
85
+ # the superclass
86
+ it { should_not be_instance_of(Integer) }
87
+ it { should_not be_an_instance_of(Integer) }
88
+
89
+ # an included module
90
+ it { should_not be_instance_of(MyModule) }
91
+ it { should_not be_an_instance_of(MyModule) }
92
+
93
+ # another class with no relation to the subject's hierarchy
94
+ it { should_not be_instance_of(String) }
95
+ it { should_not be_an_instance_of(String) }
96
+
97
+ # deliberate failures
98
+ it { should_not be_instance_of(Fixnum) }
99
+ it { should_not be_an_instance_of(Fixnum) }
100
+ it { should be_instance_of(Integer) }
101
+ it { should be_an_instance_of(Integer) }
102
+ it { should be_instance_of(MyModule) }
103
+ it { should be_an_instance_of(MyModule) }
104
+ it { should be_instance_of(String) }
105
+ it { should be_an_instance_of(String) }
106
+ end
107
+ """
108
+ When I run "rspec be_instance_of_matcher_spec.rb"
109
+ Then the output should contain all of these:
110
+ | 16 examples, 8 failures |
111
+ | expected 17 not to be an instance of Fixnum |
112
+ | expected 17 to be an instance of Integer |
113
+ | expected 17 to be an instance of MyModule |
114
+ | expected 17 to be an instance of String |
@@ -12,6 +12,15 @@ Feature: Test::Unit integration
12
12
  require 'rspec/expectations'
13
13
 
14
14
  class RSpecExpectationsTest < Test::Unit::TestCase
15
+ RSpec::Matchers.define :be_an_integer do
16
+ match { |actual| Integer === actual }
17
+ end
18
+
19
+ def be_an_int
20
+ RSpec.deprecate(:be_an_int, :be_an_integer)
21
+ be_an_integer
22
+ end
23
+
15
24
  def test_passing_expectation
16
25
  x = 1 + 3
17
26
  x.should == 4
@@ -21,9 +30,13 @@ Feature: Test::Unit integration
21
30
  array = [1, 2]
22
31
  array.should be_empty
23
32
  end
33
+
34
+ def test_custom_matcher_and_deprecation_warning
35
+ 1.should be_an_int
36
+ end
24
37
  end
25
38
  """
26
39
  When I run "ruby rspec_expectations_test.rb"
27
- Then the output should contain "2 tests"
28
- And the output should contain "1 failure" or "1 error"
40
+ Then the output should contain "3 tests, 0 assertions, 1 failures, 0 errors" or "3 tests, 0 assertions, 0 failures, 1 errors"
29
41
  And the output should contain "expected empty? to return true, got false"
42
+ And the output should contain "be_an_int is deprecated"
@@ -1,6 +1,7 @@
1
1
  require 'rspec/matchers'
2
2
  require 'rspec/expectations/fail_with'
3
3
  require 'rspec/expectations/errors'
4
+ require 'rspec/expectations/deprecation'
4
5
  require 'rspec/expectations/extensions'
5
6
  require 'rspec/expectations/handler'
6
7
  require 'rspec/expectations/version'
@@ -0,0 +1,36 @@
1
+ module RSpec
2
+
3
+ # This is defined in rspec-core, but we can't assume it's loaded since
4
+ # rspec-expectations should be usable w/o rspec-core.
5
+ unless respond_to?(:deprecate)
6
+ class << self
7
+ def deprecate(method, alternate_method=nil, version=nil)
8
+ version_string = version ? "rspec-#{version}" : "a future version of RSpec"
9
+
10
+ message = <<-NOTICE
11
+
12
+ *****************************************************************
13
+ DEPRECATION WARNING: you are using deprecated behaviour that will
14
+ be removed from #{version_string}.
15
+
16
+ #{caller(0)[2]}
17
+
18
+ * #{method} is deprecated.
19
+ NOTICE
20
+ if alternate_method
21
+ message << <<-ADDITIONAL
22
+ * please use #{alternate_method} instead.
23
+ ADDITIONAL
24
+ end
25
+
26
+ message << "*****************************************************************"
27
+ warn_deprecation(message)
28
+ end
29
+
30
+ def warn_deprecation(message)
31
+ send :warn, message
32
+ end
33
+ end
34
+ end
35
+ end
36
+
@@ -1,7 +1,7 @@
1
1
  module RSpec # :nodoc:
2
2
  module Expectations # :nodoc:
3
3
  module Version # :nodoc:
4
- STRING = '2.0.0'
4
+ STRING = '2.0.1'
5
5
  end
6
6
  end
7
7
  end
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
25
25
  s.add_runtime_dependency 'diff-lcs', '>= 1.1.2'
26
26
  s.add_development_dependency 'cucumber', ">= 0.6.2"
27
27
  s.add_development_dependency 'aruba', ">= 0.1.1"
28
- s.add_development_dependency 'rspec-core', ">= #{RSpec::Expectations::Version::STRING}"
29
- s.add_development_dependency 'rspec-mocks', ">= #{RSpec::Expectations::Version::STRING}"
28
+ s.add_development_dependency 'rspec-core', "~> 2.0.1"
29
+ s.add_development_dependency 'rspec-mocks', "~> 2.0.1"
30
30
  end
31
31
 
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-expectations
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 13
4
5
  prerelease: false
5
6
  segments:
6
7
  - 2
7
8
  - 0
8
- - 0
9
- version: 2.0.0
9
+ - 1
10
+ version: 2.0.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - David Chelimsky
@@ -15,84 +16,89 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-10-10 00:00:00 -05:00
19
+ date: 2010-10-18 00:00:00 -05:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
22
- name: diff-lcs
23
- requirement: &id001 !ruby/object:Gem::Requirement
23
+ version_requirements: &id001 !ruby/object:Gem::Requirement
24
24
  none: false
25
25
  requirements:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
+ hash: 23
28
29
  segments:
29
30
  - 1
30
31
  - 1
31
32
  - 2
32
33
  version: 1.1.2
34
+ requirement: *id001
33
35
  type: :runtime
36
+ name: diff-lcs
34
37
  prerelease: false
35
- version_requirements: *id001
36
38
  - !ruby/object:Gem::Dependency
37
- name: cucumber
38
- requirement: &id002 !ruby/object:Gem::Requirement
39
+ version_requirements: &id002 !ruby/object:Gem::Requirement
39
40
  none: false
40
41
  requirements:
41
42
  - - ">="
42
43
  - !ruby/object:Gem::Version
44
+ hash: 3
43
45
  segments:
44
46
  - 0
45
47
  - 6
46
48
  - 2
47
49
  version: 0.6.2
50
+ requirement: *id002
48
51
  type: :development
52
+ name: cucumber
49
53
  prerelease: false
50
- version_requirements: *id002
51
54
  - !ruby/object:Gem::Dependency
52
- name: aruba
53
- requirement: &id003 !ruby/object:Gem::Requirement
55
+ version_requirements: &id003 !ruby/object:Gem::Requirement
54
56
  none: false
55
57
  requirements:
56
58
  - - ">="
57
59
  - !ruby/object:Gem::Version
60
+ hash: 25
58
61
  segments:
59
62
  - 0
60
63
  - 1
61
64
  - 1
62
65
  version: 0.1.1
66
+ requirement: *id003
63
67
  type: :development
68
+ name: aruba
64
69
  prerelease: false
65
- version_requirements: *id003
66
70
  - !ruby/object:Gem::Dependency
67
- name: rspec-core
68
- requirement: &id004 !ruby/object:Gem::Requirement
71
+ version_requirements: &id004 !ruby/object:Gem::Requirement
69
72
  none: false
70
73
  requirements:
71
- - - ">="
74
+ - - ~>
72
75
  - !ruby/object:Gem::Version
76
+ hash: 13
73
77
  segments:
74
78
  - 2
75
79
  - 0
76
- - 0
77
- version: 2.0.0
80
+ - 1
81
+ version: 2.0.1
82
+ requirement: *id004
78
83
  type: :development
84
+ name: rspec-core
79
85
  prerelease: false
80
- version_requirements: *id004
81
86
  - !ruby/object:Gem::Dependency
82
- name: rspec-mocks
83
- requirement: &id005 !ruby/object:Gem::Requirement
87
+ version_requirements: &id005 !ruby/object:Gem::Requirement
84
88
  none: false
85
89
  requirements:
86
- - - ">="
90
+ - - ~>
87
91
  - !ruby/object:Gem::Version
92
+ hash: 13
88
93
  segments:
89
94
  - 2
90
95
  - 0
91
- - 0
92
- version: 2.0.0
96
+ - 1
97
+ version: 2.0.1
98
+ requirement: *id005
93
99
  type: :development
100
+ name: rspec-mocks
94
101
  prerelease: false
95
- version_requirements: *id005
96
102
  description: rspec expectations (should[_not] and matchers)
97
103
  email: dchelimsky@gmail.com;chad.humphries@gmail.com
98
104
  executables: []
@@ -129,12 +135,14 @@ files:
129
135
  - features/matchers/operators.feature
130
136
  - features/matchers/predicates.feature
131
137
  - features/matchers/respond_to.feature
138
+ - features/matchers/types.feature
132
139
  - features/step_definitions/additional_cli_steps.rb
133
140
  - features/support/env.rb
134
141
  - features/test_frameworks/test_unit.feature
135
142
  - lib/rspec-expectations.rb
136
143
  - lib/rspec/expectations.rb
137
144
  - lib/rspec/expectations/backward_compatibility.rb
145
+ - lib/rspec/expectations/deprecation.rb
138
146
  - lib/rspec/expectations/differ.rb
139
147
  - lib/rspec/expectations/errors.rb
140
148
  - lib/rspec/expectations/extensions.rb
@@ -219,7 +227,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
219
227
  requirements:
220
228
  - - ">="
221
229
  - !ruby/object:Gem::Version
222
- hash: -4161069882601304184
230
+ hash: 3
223
231
  segments:
224
232
  - 0
225
233
  version: "0"
@@ -228,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
228
236
  requirements:
229
237
  - - ">="
230
238
  - !ruby/object:Gem::Version
231
- hash: -4161069882601304184
239
+ hash: 3
232
240
  segments:
233
241
  - 0
234
242
  version: "0"
@@ -238,7 +246,7 @@ rubyforge_project: rspec
238
246
  rubygems_version: 1.3.7
239
247
  signing_key:
240
248
  specification_version: 3
241
- summary: rspec-expectations-2.0.0
249
+ summary: rspec-expectations-2.0.1
242
250
  test_files:
243
251
  - features/README.markdown
244
252
  - features/expectations/attribute_of_subject.feature
@@ -258,6 +266,7 @@ test_files:
258
266
  - features/matchers/operators.feature
259
267
  - features/matchers/predicates.feature
260
268
  - features/matchers/respond_to.feature
269
+ - features/matchers/types.feature
261
270
  - features/step_definitions/additional_cli_steps.rb
262
271
  - features/support/env.rb
263
272
  - features/test_frameworks/test_unit.feature