rspec 1.3.0 → 1.3.1.rc
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +17 -0
- data/README.rdoc +10 -23
- data/examples/passing/shared_example_group_example.rb +0 -36
- data/examples/passing/simple_matcher_example.rb +3 -3
- data/features/interop/test_but_not_test_unit.feature +1 -1
- data/features/interop/test_case_with_should_methods.feature +1 -1
- data/geminstaller.yml +3 -2
- data/lib/spec/deprecation.rb +2 -1
- data/lib/spec/dsl/main.rb +1 -0
- data/lib/spec/example/example_group_methods.rb +6 -1
- data/lib/spec/example/subject.rb +8 -2
- data/lib/spec/matchers.rb +1 -1
- data/lib/spec/matchers/operator_matcher.rb +6 -1
- data/lib/spec/matchers/pretty.rb +2 -2
- data/lib/spec/matchers/simple_matcher.rb +2 -1
- data/lib/spec/matchers/throw_symbol.rb +2 -2
- data/lib/spec/mocks/proxy.rb +2 -0
- data/lib/spec/runner/backtrace_tweaker.rb +3 -2
- data/lib/spec/runner/configuration.rb +8 -0
- data/lib/spec/runner/options.rb +2 -1
- data/lib/spec/version.rb +2 -2
- data/spec/spec/dsl/main_spec.rb +10 -2
- data/spec/spec/example/example_group_methods_spec.rb +19 -0
- data/spec/spec/example/example_matcher_spec.rb +3 -4
- data/spec/spec/example/subject_spec.rb +7 -0
- data/spec/spec/expectations/wrap_expectation_spec.rb +2 -1
- data/spec/spec/matchers/have_spec.rb +278 -293
- data/spec/spec/matchers/match_array_spec.rb +5 -0
- data/spec/spec/matchers/simple_matcher_spec.rb +51 -44
- data/spec/spec/matchers/throw_symbol_spec.rb +3 -3
- data/spec/spec/mocks/bug_report_496_spec.rb +2 -4
- data/spec/spec_helper.rb +1 -1
- metadata +99 -34
data/History.rdoc
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
=== Version 1.3.1 / (Date TBD)
|
2
|
+
|
3
|
+
* enhancements
|
4
|
+
* Array =~ matcher works with subclasses of Array (Matthew Peychich & Pat Maddox)
|
5
|
+
* config.suppress_deprecation_warnings!
|
6
|
+
|
7
|
+
* bug fixes
|
8
|
+
* QuitBacktraceTweaker no longer eats all paths with 'lib'
|
9
|
+
(Tim Harper - #912)
|
10
|
+
* Fix delegation of stubbed values on superclass class-level methods.
|
11
|
+
(Scott Taylor - #496 - #957)
|
12
|
+
* Fix pending to work with ruby-1.9
|
13
|
+
|
14
|
+
* deprecations
|
15
|
+
* share_as (will be removed from rspec-core-2.0)
|
16
|
+
* simple_matcher (will be removed from rspec-core-2.0)
|
17
|
+
|
1
18
|
=== Version 1.3.0 / 2010-01-11
|
2
19
|
|
3
20
|
* enhancements
|
data/README.rdoc
CHANGED
@@ -1,24 +1,18 @@
|
|
1
|
-
|
1
|
+
== RSpec
|
2
2
|
|
3
|
-
|
4
|
-
* http://rubyforge.org/projects/rspec
|
5
|
-
* http://github.com/dchelimsky/rspec/wikis
|
6
|
-
* mailto:rspec-users@rubyforge.org
|
7
|
-
* mailto:rspec-devel@rubyforge.org
|
3
|
+
http://rspec.info
|
8
4
|
|
9
|
-
|
5
|
+
Behaviour Driven Development for Ruby
|
10
6
|
|
11
|
-
|
12
|
-
|
7
|
+
This is the repository for rspec-1.x. If you're looking
|
8
|
+
for rspec-2 (and if you're not, what are you waiting for?),
|
9
|
+
see http://github.com/rspec/rspec
|
13
10
|
|
14
|
-
==
|
11
|
+
== Install
|
15
12
|
|
16
|
-
|
17
|
-
* Spec::Expectations adds #should and #should_not to every object
|
18
|
-
* Spec::Matchers provides Expression Matchers for use with #should and #should_not
|
19
|
-
* Spec::Mocks is a full featured mock object/stubbing library
|
13
|
+
gem install rspec
|
20
14
|
|
21
|
-
==
|
15
|
+
== Synopsis
|
22
16
|
|
23
17
|
describe Account do
|
24
18
|
context "transfering money" do
|
@@ -38,17 +32,10 @@ examples.
|
|
38
32
|
end
|
39
33
|
end
|
40
34
|
|
41
|
-
$ spec spec/account_spec.rb --format nested
|
35
|
+
$ spec ./spec/account_spec.rb --format nested
|
42
36
|
Account
|
43
37
|
transfering money
|
44
38
|
deposits transfer amount to the other account
|
45
39
|
reduces its balance by the transfer amount
|
46
40
|
|
47
41
|
2 examples, 0 failures
|
48
|
-
|
49
|
-
== INSTALL:
|
50
|
-
|
51
|
-
[sudo] gem install rspec
|
52
|
-
|
53
|
-
See http://wiki.github.com/dchelimsky/rspec if you want
|
54
|
-
to clone/build/install.
|
@@ -29,18 +29,6 @@ module SharedExampleGroupExample
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
# A SharedExampleGroup is also a module. If you create one like this it gets
|
33
|
-
# assigned to the constant MostThings
|
34
|
-
share_as :MostThings do
|
35
|
-
def helper_method
|
36
|
-
"helper method"
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should do what things do" do
|
40
|
-
@thing.what_things_do.should == "stuff"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
32
|
describe OneThing do
|
45
33
|
# Now you can include the shared example group like this, which
|
46
34
|
# feels more like what you might say ...
|
@@ -52,28 +40,4 @@ module SharedExampleGroupExample
|
|
52
40
|
helper_method.should == "helper method"
|
53
41
|
end
|
54
42
|
end
|
55
|
-
|
56
|
-
describe AnotherThing do
|
57
|
-
# ... or you can include the example group like this, which
|
58
|
-
# feels more like the programming language we love.
|
59
|
-
it_should_behave_like MostThings
|
60
|
-
|
61
|
-
before(:each) { @thing = AnotherThing.new }
|
62
|
-
|
63
|
-
it "should have access to helper methods defined in the shared example group" do
|
64
|
-
helper_method.should == "helper method"
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
describe YetAnotherThing do
|
69
|
-
# ... or you can include the example group like this, which
|
70
|
-
# feels more like the programming language we love.
|
71
|
-
include MostThings
|
72
|
-
|
73
|
-
before(:each) { @thing = AnotherThing.new }
|
74
|
-
|
75
|
-
it "should have access to helper methods defined in the shared example group" do
|
76
|
-
helper_method.should == "helper method"
|
77
|
-
end
|
78
|
-
end
|
79
43
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
describe "arrays" do
|
2
|
-
|
3
|
-
|
2
|
+
Spec::Matchers.define :contain_same_elements_as do |expected|
|
3
|
+
match do |actual|
|
4
4
|
if actual.size == expected.size
|
5
5
|
a, e = actual.dup, expected.dup
|
6
6
|
until e.empty? do
|
@@ -26,4 +26,4 @@ describe "arrays" do
|
|
26
26
|
it { should_not contain_same_elements_as([1,2,2,3])}
|
27
27
|
it { should_not contain_same_elements_as([1,2])}
|
28
28
|
end
|
29
|
-
end
|
29
|
+
end
|
data/geminstaller.yml
CHANGED
@@ -18,11 +18,12 @@ gems:
|
|
18
18
|
version: '>= 0.9.5'
|
19
19
|
- name: rake
|
20
20
|
version: '>= 0.8.4'
|
21
|
-
- name:
|
22
|
-
version: '>= 0.
|
21
|
+
- name: rcov
|
22
|
+
version: '>= 0.9.7.1'
|
23
23
|
- name: syntax
|
24
24
|
version: '>= 1.0.0'
|
25
25
|
- name: rr
|
26
26
|
version: '>= 0.10.0'
|
27
27
|
- name: ruby-debug
|
28
28
|
version: '>= 0.10.3'
|
29
|
+
- name: autotest-growl
|
data/lib/spec/deprecation.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
module Spec
|
2
2
|
class << self
|
3
3
|
def deprecate(method, alternate_method=nil)
|
4
|
-
|
4
|
+
return if Spec::Runner.configuration.suppress_deprecation_warnings?
|
5
|
+
message = <<-NOTICE
|
5
6
|
|
6
7
|
*****************************************************************
|
7
8
|
DEPRECATION WARNING: you are using deprecated behaviour that will
|
data/lib/spec/dsl/main.rb
CHANGED
@@ -77,7 +77,7 @@ module Spec
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def pending_implementation
|
80
|
-
lambda { raise(Spec::Example::NotYetImplementedError) }
|
80
|
+
lambda {|*args| raise(Spec::Example::NotYetImplementedError) }
|
81
81
|
end
|
82
82
|
|
83
83
|
alias_method :it, :example
|
@@ -172,6 +172,11 @@ module Spec
|
|
172
172
|
end
|
173
173
|
end
|
174
174
|
|
175
|
+
def let!(name, &block)
|
176
|
+
let(name, &block)
|
177
|
+
before { __send__(name) }
|
178
|
+
end
|
179
|
+
|
175
180
|
private
|
176
181
|
|
177
182
|
def subclass(*args, &example_group_block)
|
data/lib/spec/example/subject.rb
CHANGED
@@ -22,8 +22,14 @@ module Spec
|
|
22
22
|
|
23
23
|
def its(attribute, &block)
|
24
24
|
describe(attribute) do
|
25
|
-
|
26
|
-
|
25
|
+
example do
|
26
|
+
self.class.class_eval do
|
27
|
+
define_method(:subject) do
|
28
|
+
super().send(attribute)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
instance_eval(&block)
|
32
|
+
end
|
27
33
|
end
|
28
34
|
end
|
29
35
|
|
data/lib/spec/matchers.rb
CHANGED
@@ -13,7 +13,12 @@ module Spec
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def get(klass, operator)
|
16
|
-
registry[klass] && registry[klass][operator]
|
16
|
+
matcher = registry[klass] && registry[klass][operator]
|
17
|
+
unless matcher
|
18
|
+
parent_class = registry.keys.detect {|pc| klass <= pc }
|
19
|
+
matcher = registry[parent_class] && registry[parent_class][operator]
|
20
|
+
end
|
21
|
+
matcher
|
17
22
|
end
|
18
23
|
end
|
19
24
|
|
data/lib/spec/matchers/pretty.rb
CHANGED
@@ -127,7 +127,8 @@ module Spec
|
|
127
127
|
# failing), will fail when you want it to pass.
|
128
128
|
#
|
129
129
|
def simple_matcher(description=nil, &match_block)
|
130
|
+
Spec.deprecate("simple_matcher", "Matcher DSL (http://rspec.rubyforge.org/rspec/1.3.0/classes/Spec/Matchers.html)")
|
130
131
|
SimpleMatcher.new(description, &match_block)
|
131
132
|
end
|
132
133
|
end
|
133
|
-
end
|
134
|
+
end
|
@@ -93,8 +93,8 @@ module Spec
|
|
93
93
|
# lambda { do_something_risky }.should_not throw_symbol
|
94
94
|
# lambda { do_something_risky }.should_not throw_symbol(:that_was_risky)
|
95
95
|
# lambda { do_something_risky }.should_not throw_symbol(:that_was_risky, culprit)
|
96
|
-
def throw_symbol(
|
97
|
-
Matchers::ThrowSymbol.new(
|
96
|
+
def throw_symbol(expected_symbol = nil, expected_arg=nil)
|
97
|
+
Matchers::ThrowSymbol.new(expected_symbol, expected_arg)
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|
data/lib/spec/mocks/proxy.rb
CHANGED
@@ -111,6 +111,8 @@ module Spec
|
|
111
111
|
invoke_expectation(expectation, *args, &block)
|
112
112
|
elsif expectation = find_almost_matching_expectation(sym, *args)
|
113
113
|
record_almost_matching_expectation(expectation, sym, *args, &block)
|
114
|
+
elsif @target.is_a?(Class)
|
115
|
+
@target.superclass.send(sym, *args, &block)
|
114
116
|
else
|
115
117
|
@target.__send__ :method_missing, sym, *args, &block
|
116
118
|
end
|
@@ -38,8 +38,9 @@ module Spec
|
|
38
38
|
# Tweaks raised Exceptions to mask noisy (unneeded) parts of the backtrace
|
39
39
|
class QuietBacktraceTweaker < BacktraceTweaker
|
40
40
|
unless defined?(IGNORE_PATTERNS)
|
41
|
-
|
42
|
-
|
41
|
+
root_dir = File.expand_path(File.join(__FILE__, '..', '..', '..', '..'))
|
42
|
+
spec_files = Dir["#{root_dir}/lib/*"].map do |path|
|
43
|
+
subpath = path[root_dir.length..-1]
|
43
44
|
/#{subpath}/
|
44
45
|
end
|
45
46
|
IGNORE_PATTERNS = spec_files + [
|
@@ -154,6 +154,14 @@ module Spec
|
|
154
154
|
def ignored_backtrace_patterns # :nodoc:
|
155
155
|
@ignored_backtrace_patterns ||= []
|
156
156
|
end
|
157
|
+
|
158
|
+
def suppress_deprecation_warnings!
|
159
|
+
@suppress_deprecation_warnings = true
|
160
|
+
end
|
161
|
+
|
162
|
+
def suppress_deprecation_warnings?
|
163
|
+
@suppress_deprecation_warnings ||= false
|
164
|
+
end
|
157
165
|
|
158
166
|
private
|
159
167
|
|
data/lib/spec/runner/options.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'ostruct'
|
2
|
+
require 'rbconfig'
|
2
3
|
|
3
4
|
module Spec
|
4
5
|
module Runner
|
@@ -184,7 +185,7 @@ module Spec
|
|
184
185
|
|
185
186
|
def colour=(colour)
|
186
187
|
@colour = colour
|
187
|
-
if @colour &&
|
188
|
+
if @colour && Config::CONFIG['host_os'] =~ /mswin|mingw/ ;\
|
188
189
|
begin ;\
|
189
190
|
replace_output = @output_stream.equal?($stdout) ;\
|
190
191
|
require 'rubygems' unless ENV['NO_RUBYGEMS'] ;\
|
data/lib/spec/version.rb
CHANGED
data/spec/spec/dsl/main_spec.rb
CHANGED
@@ -57,7 +57,6 @@ module Spec
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
|
61
60
|
describe "#share_as" do
|
62
61
|
def self.next_group_name
|
63
62
|
@group_number ||= 0
|
@@ -68,6 +67,15 @@ module Spec
|
|
68
67
|
def group_name
|
69
68
|
@group_name ||= self.class.next_group_name
|
70
69
|
end
|
70
|
+
|
71
|
+
before(:each) do
|
72
|
+
Spec.stub(:deprecate)
|
73
|
+
end
|
74
|
+
|
75
|
+
it "is deprecated" do
|
76
|
+
Spec.should_receive(:deprecate)
|
77
|
+
share_as group_name do; end
|
78
|
+
end
|
71
79
|
|
72
80
|
it "registers a shared ExampleGroup" do
|
73
81
|
block = lambda {|a,b|}
|
@@ -92,4 +100,4 @@ module Spec
|
|
92
100
|
end
|
93
101
|
end
|
94
102
|
end
|
95
|
-
|
103
|
+
|
@@ -753,6 +753,25 @@ module Spec
|
|
753
753
|
counter.count.should == 2
|
754
754
|
end
|
755
755
|
end
|
756
|
+
|
757
|
+
describe "#let!" do
|
758
|
+
let!(:creator) do
|
759
|
+
class Creator
|
760
|
+
@count = 0
|
761
|
+
def self.count
|
762
|
+
@count += 1
|
763
|
+
end
|
764
|
+
end
|
765
|
+
end
|
766
|
+
|
767
|
+
it "evaluates the value non-lazily" do
|
768
|
+
lambda { Creator.count }.should_not raise_error
|
769
|
+
end
|
770
|
+
|
771
|
+
it "does not interfere between tests" do
|
772
|
+
Creator.count.should == 1
|
773
|
+
end
|
774
|
+
end
|
756
775
|
end
|
757
776
|
end
|
758
777
|
end
|
@@ -3,10 +3,9 @@ require 'spec_helper'
|
|
3
3
|
module Spec
|
4
4
|
module Example
|
5
5
|
describe ExampleMatcher, "#matches?" do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
matcher.negative_failure_message = "expected matcher.matches?(#{description.inspect}) to return false, got true"
|
6
|
+
|
7
|
+
Spec::Matchers.define :match_examples do |examples|
|
8
|
+
match do |actual|
|
10
9
|
actual.matches?(examples)
|
11
10
|
end
|
12
11
|
end
|
@@ -86,6 +86,13 @@ module Spec
|
|
86
86
|
|
87
87
|
describe ".its (to access subject's attributes)" do
|
88
88
|
with_sandboxed_options do
|
89
|
+
it "allows before(:each) blocks on subjects in outer scope" do
|
90
|
+
group = Class.new(ExampleGroupDouble).describe(Array)
|
91
|
+
group.before(:each) { subject << 1 }
|
92
|
+
child = group.its(:length) { should == 1 }
|
93
|
+
child.run(options).should == true
|
94
|
+
end
|
95
|
+
|
89
96
|
it "passes when expectation should pass" do
|
90
97
|
group = Class.new(ExampleGroupDouble).describe(Array)
|
91
98
|
child = group.its(:length) { should == 0 }
|