rspec 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +6 -0
- data/Manifest.txt +2 -0
- data/features/matchers/define_diffable_matcher.feature +26 -0
- data/lib/spec/expectations/fail_with.rb +39 -0
- data/lib/spec/version.rb +1 -1
- metadata +5 -3
data/History.rdoc
CHANGED
data/Manifest.txt
CHANGED
@@ -67,6 +67,7 @@ features/interop/examples_and_tests_together.feature
|
|
67
67
|
features/interop/rspec_output.feature
|
68
68
|
features/interop/test_but_not_test_unit.feature
|
69
69
|
features/interop/test_case_with_should_methods.feature
|
70
|
+
features/matchers/define_diffable_matcher.feature
|
70
71
|
features/matchers/define_matcher.feature
|
71
72
|
features/matchers/define_matcher_outside_rspec.feature
|
72
73
|
features/mock_framework_integration/use_flexmock.feature
|
@@ -113,6 +114,7 @@ lib/spec/expectations.rb
|
|
113
114
|
lib/spec/expectations/errors.rb
|
114
115
|
lib/spec/expectations/extensions.rb
|
115
116
|
lib/spec/expectations/extensions/kernel.rb
|
117
|
+
lib/spec/expectations/fail_with.rb
|
116
118
|
lib/spec/expectations/handler.rb
|
117
119
|
lib/spec/interop/test.rb
|
118
120
|
lib/spec/interop/test/unit/autorunner.rb
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Feature: define diffable matcher
|
2
|
+
|
3
|
+
When a matcher is defined as diffable, and the --diff
|
4
|
+
flag is set, the output will include a diff of the submitted
|
5
|
+
objects.
|
6
|
+
|
7
|
+
Scenario: define a diffable matcher
|
8
|
+
Given a file named "diffable_matcher_spec.rb" with:
|
9
|
+
"""
|
10
|
+
Spec::Matchers.define :be_just_like do |expected|
|
11
|
+
match do |actual|
|
12
|
+
actual == expected
|
13
|
+
end
|
14
|
+
|
15
|
+
diffable
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "this" do
|
19
|
+
it {should be_just_like("that")}
|
20
|
+
end
|
21
|
+
"""
|
22
|
+
When I run "spec diffable_matcher_spec.rb --diff"
|
23
|
+
Then the exit code should be 256
|
24
|
+
|
25
|
+
And the stdout should match "should be just like \"that\""
|
26
|
+
And the stdout should match "Diff:\n@@ -1,2 +1,2 @@\n-that\n+this"
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Spec
|
2
|
+
module Expectations
|
3
|
+
class << self
|
4
|
+
attr_accessor :differ
|
5
|
+
|
6
|
+
# raises a Spec::Expectations::ExpectationNotMetError with message
|
7
|
+
#
|
8
|
+
# When a differ has been assigned and fail_with is passed
|
9
|
+
# <code>expected</code> and <code>target</code>, passes them
|
10
|
+
# to the differ to append a diff message to the failure message.
|
11
|
+
def fail_with(message, expected=nil, target=nil) # :nodoc:
|
12
|
+
if (Array === message) & (message.length == 3)
|
13
|
+
::Spec.warn(<<-NOTICE
|
14
|
+
|
15
|
+
*****************************************************************
|
16
|
+
DEPRECATION WARNING: you are using deprecated behaviour that will
|
17
|
+
be removed from a future version of RSpec.
|
18
|
+
|
19
|
+
* Support for matchers that return arrays from failure message
|
20
|
+
methods is deprecated.
|
21
|
+
* Instead, the matcher should return a string, and expose methods
|
22
|
+
for the expected() and actual() values.
|
23
|
+
*****************************************************************
|
24
|
+
NOTICE
|
25
|
+
)
|
26
|
+
message, expected, target = message[0], message[1], message[2]
|
27
|
+
end
|
28
|
+
unless (differ.nil? || expected.nil? || target.nil?)
|
29
|
+
if expected.is_a?(String)
|
30
|
+
message << "\nDiff:" << self.differ.diff_as_string(target.to_s, expected)
|
31
|
+
elsif !target.is_a?(Proc)
|
32
|
+
message << "\nDiff:" << self.differ.diff_as_object(target, expected)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
Kernel::raise(Spec::Expectations::ExpectationNotMetError.new(message))
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/spec/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RSpec Development Team
|
@@ -115,6 +115,7 @@ files:
|
|
115
115
|
- features/interop/rspec_output.feature
|
116
116
|
- features/interop/test_but_not_test_unit.feature
|
117
117
|
- features/interop/test_case_with_should_methods.feature
|
118
|
+
- features/matchers/define_diffable_matcher.feature
|
118
119
|
- features/matchers/define_matcher.feature
|
119
120
|
- features/matchers/define_matcher_outside_rspec.feature
|
120
121
|
- features/mock_framework_integration/use_flexmock.feature
|
@@ -161,6 +162,7 @@ files:
|
|
161
162
|
- lib/spec/expectations/errors.rb
|
162
163
|
- lib/spec/expectations/extensions.rb
|
163
164
|
- lib/spec/expectations/extensions/kernel.rb
|
165
|
+
- lib/spec/expectations/fail_with.rb
|
164
166
|
- lib/spec/expectations/handler.rb
|
165
167
|
- lib/spec/interop/test.rb
|
166
168
|
- lib/spec/interop/test/unit/autorunner.rb
|
@@ -410,7 +412,7 @@ homepage: http://rspec.info
|
|
410
412
|
post_install_message: |
|
411
413
|
**************************************************
|
412
414
|
|
413
|
-
Thank you for installing rspec-1.2.
|
415
|
+
Thank you for installing rspec-1.2.4
|
414
416
|
|
415
417
|
Please be sure to read History.rdoc and Upgrade.rdoc
|
416
418
|
for useful information about this release.
|
@@ -440,6 +442,6 @@ rubyforge_project: rspec
|
|
440
442
|
rubygems_version: 1.3.1
|
441
443
|
signing_key:
|
442
444
|
specification_version: 2
|
443
|
-
summary: rspec 1.2.
|
445
|
+
summary: rspec 1.2.4
|
444
446
|
test_files: []
|
445
447
|
|