rspec 0.5.4 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +10 -2
- data/EXAMPLES.rd +34 -0
- data/README +1 -1
- data/Rakefile +23 -28
- data/bin/spec +0 -1
- data/doc/src/core_team.page +18 -9
- data/doc/src/tools/rails.page +71 -5
- data/doc/src/tools/rake.page +5 -8
- data/doc/src/tools/rcov.page +14 -5
- data/doc/src/tools/spec.page +33 -18
- data/doc/src/tutorials/meta.info +6 -1
- data/doc/src/tutorials/stack.rb +1 -1
- data/doc/src/tutorials/stack_01.page +2 -0
- data/doc/src/tutorials/stack_02.page +6 -4
- data/doc/src/tutorials/stack_03.page +7 -15
- data/doc/src/tutorials/stack_04.page +39 -78
- data/doc/src/tutorials/stack_05.page +1 -1
- data/doc/src/tutorials/stack_spec.rb +2 -18
- data/lib/spec/rake/rcov_verify.rb +2 -2
- data/lib/spec/rake/spectask.rb +4 -9
- data/lib/spec/runner.rb +1 -0
- data/lib/spec/runner/backtrace_tweaker.rb +2 -0
- data/lib/spec/runner/context.rb +7 -5
- data/lib/spec/runner/context_runner.rb +4 -4
- data/lib/spec/runner/kernel_ext.rb +1 -1
- data/lib/spec/runner/spec_matcher.rb +39 -0
- data/lib/spec/runner/specification.rb +3 -3
- data/lib/spec/version.rb +1 -1
- data/test/spec/api/helper/equality_test.rb +1 -1
- data/test/spec/runner/backtrace_tweaker_test.rb +15 -9
- data/test/spec/runner/context_matching_test.rb +35 -0
- data/test/spec/runner/context_runner_test.rb +16 -16
- data/test/spec/runner/context_test.rb +0 -21
- data/test/spec/runner/spec_matcher_test.rb +42 -0
- data/test/spec/runner/specification_test.rb +9 -4
- metadata +12 -10
- data/doc/reference/rspec reference.page +0 -0
- data/test/rcov/rcov_testtask.rb +0 -46
@@ -14,12 +14,12 @@ module Spec
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def add_context(context)
|
17
|
-
return if !@single_spec.nil? unless context.matches
|
18
|
-
context.
|
17
|
+
return if !@single_spec.nil? unless context.matches?(@single_spec)
|
18
|
+
context.run_single_spec @single_spec if context.matches?(@single_spec)
|
19
19
|
@contexts << context
|
20
20
|
end
|
21
21
|
|
22
|
-
def run(exit_when_done
|
22
|
+
def run(exit_when_done)
|
23
23
|
@reporter.start number_of_specs
|
24
24
|
@contexts.each do |context|
|
25
25
|
context.run(@reporter, @dry_run)
|
@@ -28,7 +28,7 @@ module Spec
|
|
28
28
|
failure_count = @reporter.dump
|
29
29
|
if(exit_when_done)
|
30
30
|
exit_code = (failure_count == 0) ? 0 : 1
|
31
|
-
exit
|
31
|
+
exit(exit_code)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class SpecMatcher
|
2
|
+
|
3
|
+
def initialize(context_and_or_spec_name, context_name)
|
4
|
+
@context_name = context_name
|
5
|
+
@name_to_match = context_and_or_spec_name
|
6
|
+
end
|
7
|
+
|
8
|
+
def matches? spec
|
9
|
+
if matches_context?
|
10
|
+
if matches_spec?(spec) or context_only?
|
11
|
+
return true
|
12
|
+
end
|
13
|
+
end
|
14
|
+
if matches_spec? spec
|
15
|
+
if spec_only? spec
|
16
|
+
return true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def spec_only? spec
|
24
|
+
@name_to_match == spec
|
25
|
+
end
|
26
|
+
|
27
|
+
def context_only?
|
28
|
+
@name_to_match == @context_name
|
29
|
+
end
|
30
|
+
|
31
|
+
def matches_context?
|
32
|
+
@name_to_match =~ /^#{@context_name}\b/
|
33
|
+
end
|
34
|
+
|
35
|
+
def matches_spec? spec
|
36
|
+
@name_to_match =~ /\b#{spec}$/
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
data/lib/spec/version.rb
CHANGED
@@ -14,25 +14,25 @@ module Spec
|
|
14
14
|
def test_should_replace___instance_exec_with_spec_name
|
15
15
|
@error.set_backtrace ["./examples/airport_spec.rb:28:in `__instance_exec_1014688_1661744'"]
|
16
16
|
@tweaker.tweak_backtrace @error, 'spec name'
|
17
|
-
@error.backtrace[0].
|
17
|
+
@error.backtrace[0].should_equal "./examples/airport_spec.rb:28:in `spec name'"
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_should_leave_anything_in_api_dir_in_full_backtrace_mode
|
21
21
|
@error.set_backtrace ["/lib/spec/api/anything.rb"]
|
22
22
|
@tweaker.tweak_backtrace @error, 'spec name'
|
23
|
-
@error.backtrace[0].
|
23
|
+
@error.backtrace[0].should_equal "/lib/spec/api/anything.rb"
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
def test_should_leave_anything_in_runner_dir_in_full_backtrace_mode
|
27
27
|
@error.set_backtrace ["/lib/spec/runner/anything.rb"]
|
28
28
|
@tweaker.tweak_backtrace @error, 'spec name'
|
29
|
-
@error.backtrace.
|
29
|
+
@error.backtrace.should_not_be_empty
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_should_leave_bin_spec
|
33
33
|
@error.set_backtrace ["bin/spec:"]
|
34
34
|
@tweaker.tweak_backtrace @error, 'spec name'
|
35
|
-
@error.backtrace.
|
35
|
+
@error.backtrace.should_not_be_empty
|
36
36
|
end
|
37
37
|
|
38
38
|
end
|
@@ -50,25 +50,31 @@ module Spec
|
|
50
50
|
def test_should_replace___instance_exec_with_spec_name
|
51
51
|
@error.set_backtrace ["./examples/airport_spec.rb:28:in `__instance_exec_1014688_1661744'"]
|
52
52
|
@tweaker.tweak_backtrace @error, 'spec name'
|
53
|
-
@error.backtrace[0].
|
53
|
+
@error.backtrace[0].should_equal "./examples/airport_spec.rb:28:in `spec name'"
|
54
54
|
end
|
55
55
|
|
56
56
|
def test_should_remove_anything_in_api_dir
|
57
57
|
@error.set_backtrace ["/lib/spec/api/anything.rb"]
|
58
58
|
@tweaker.tweak_backtrace @error, 'spec name'
|
59
|
-
@error.backtrace.
|
59
|
+
@error.backtrace.should_be_empty
|
60
60
|
end
|
61
61
|
|
62
62
|
def test_should_remove_anything_in_runner_dir
|
63
63
|
@error.set_backtrace ["/lib/spec/runner/anything.rb"]
|
64
64
|
@tweaker.tweak_backtrace @error, 'spec name'
|
65
|
-
@error.backtrace.
|
65
|
+
@error.backtrace.should_be_empty
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_should_remove_anything_from_textmate_ruby_bundle
|
69
|
+
@error.set_backtrace ["/Applications/TextMate.app/Contents/SharedSupport/Bundles/Ruby.tmbundle/Support/tmruby.rb:147"]
|
70
|
+
@tweaker.tweak_backtrace @error, 'spec name'
|
71
|
+
@error.backtrace.should_be_empty
|
66
72
|
end
|
67
73
|
|
68
74
|
def test_should_remove_bin_spec
|
69
75
|
@error.set_backtrace ["bin/spec:"]
|
70
76
|
@tweaker.tweak_backtrace @error, 'spec name'
|
71
|
-
@error.backtrace.
|
77
|
+
@error.backtrace.should_be_empty
|
72
78
|
end
|
73
79
|
|
74
80
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
2
|
+
|
3
|
+
module Spec
|
4
|
+
module Runner
|
5
|
+
class ContextMatchingTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@formatter = Api::Mock.new "formatter"
|
9
|
+
@context = Context.new("context") {}
|
10
|
+
@matcher = Spec::Api::Mock.new("matcher")
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_should_use_spec_matcher
|
14
|
+
@matcher.should_receive(:matches?).with("submitted spec")
|
15
|
+
@context.specify("submitted spec") {}
|
16
|
+
assert !@context.matches?("context with spec", @matcher)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_run_single_spec_should_trim_specs_when_spec_is_specified
|
20
|
+
@context.specify("spec1") {}
|
21
|
+
@context.specify("spec2") {}
|
22
|
+
@context.run_single_spec "context spec1"
|
23
|
+
assert_equal 1, @context.number_of_specs
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_run_single_spec_should_not_trim_specs_when_spec_is_not_specified
|
27
|
+
@context.specify("spec1") {}
|
28
|
+
@context.specify("spec2") {}
|
29
|
+
@context.run_single_spec "context"
|
30
|
+
assert_equal 2, @context.number_of_specs
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -21,7 +21,7 @@ module Spec
|
|
21
21
|
runner.add_context context1
|
22
22
|
runner.add_context context2
|
23
23
|
|
24
|
-
runner.run
|
24
|
+
runner.run(false)
|
25
25
|
|
26
26
|
context1.__verify
|
27
27
|
context2.__verify
|
@@ -29,31 +29,31 @@ module Spec
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_should_support_single_spec
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
desired_context = Api::Mock.new "desired context"
|
33
|
+
desired_context.should_receive(:matches?).at_least(:once).and_return(true)
|
34
|
+
desired_context.should_receive(:run)
|
35
|
+
desired_context.should_receive(:run_single_spec)
|
36
|
+
desired_context.should_receive(:number_of_specs).and_return(1)
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
other_context = Api::Mock.new "other context"
|
39
|
+
other_context.should_receive(:matches?).and_return(false)
|
40
|
+
other_context.should_receive(:run).never
|
41
|
+
other_context.should_receive(:number_of_specs).never
|
42
42
|
|
43
43
|
reporter = Api::Mock.new 'reporter'
|
44
44
|
|
45
|
-
runner = ContextRunner.new(reporter, false, false, "
|
46
|
-
runner.add_context
|
47
|
-
runner.add_context
|
45
|
+
runner = ContextRunner.new(reporter, false, false, "desired context legal spec")
|
46
|
+
runner.add_context desired_context
|
47
|
+
runner.add_context other_context
|
48
48
|
|
49
49
|
reporter.should_receive(:start)
|
50
50
|
reporter.should_receive(:end)
|
51
51
|
reporter.should_receive(:dump)
|
52
52
|
|
53
|
-
runner.run
|
53
|
+
runner.run(false)
|
54
54
|
|
55
|
-
|
56
|
-
|
55
|
+
desired_context.__verify
|
56
|
+
other_context.__verify
|
57
57
|
reporter.__verify
|
58
58
|
end
|
59
59
|
|
@@ -69,27 +69,6 @@ module Spec
|
|
69
69
|
@context.specify("four") {}
|
70
70
|
assert_equal(4, @context.number_of_specs)
|
71
71
|
end
|
72
|
-
|
73
|
-
def test_matches_should_pass_if_matches_context_and_spec
|
74
|
-
@context.specify("spec") {}
|
75
|
-
assert @context.matches? "context spec"
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_matches_should_fail_if_input_does_not_start_with_name
|
79
|
-
assert !@context.matches?("contextual spec")
|
80
|
-
end
|
81
|
-
|
82
|
-
def test_matches_should_fail_if_input_does_not_include_valid_spec
|
83
|
-
assert !@context.matches?("context spec")
|
84
|
-
end
|
85
|
-
|
86
|
-
def test_isolate_should_trim_specs
|
87
|
-
@context.specify("spec1") {}
|
88
|
-
@context.specify("spec2") {}
|
89
|
-
@context.isolate "context spec1"
|
90
|
-
assert_equal 1, @context.number_of_specs
|
91
|
-
end
|
92
|
-
|
93
72
|
end
|
94
73
|
end
|
95
74
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
2
|
+
module Spec
|
3
|
+
module Runner
|
4
|
+
class SpecMatcherTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_should_match_context_and_spec
|
7
|
+
matcher = SpecMatcher.new("a context with a spec", "a context")
|
8
|
+
assert matcher.matches?("with a spec")
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_should_not_match_wrong_context
|
12
|
+
matcher = SpecMatcher.new("another context with a spec", "a context")
|
13
|
+
assert !matcher.matches?("with a spec")
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_should_not_match_wrong_spec
|
17
|
+
matcher = SpecMatcher.new("a context with another spec", "a context")
|
18
|
+
assert !matcher.matches?("with a spec")
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_should_match_context_only
|
22
|
+
matcher = SpecMatcher.new("a context", "a context")
|
23
|
+
assert matcher.matches?("with a spec")
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_should_not_match_wrong_context_only
|
27
|
+
matcher = SpecMatcher.new("another context", "a context")
|
28
|
+
assert !matcher.matches?("with a spec")
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_should_match_spec_only
|
32
|
+
matcher = SpecMatcher.new("with a spec", "a context")
|
33
|
+
assert matcher.matches?("with a spec")
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_should_match_wrong_spec_only
|
37
|
+
matcher = SpecMatcher.new("with another spec", "a context")
|
38
|
+
assert !matcher.matches?("with a spec")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -90,14 +90,19 @@ module Spec
|
|
90
90
|
spec.run @reporter, nil, teardown
|
91
91
|
end
|
92
92
|
|
93
|
-
def
|
93
|
+
def test_should_match_if_name_matches_end_of_input
|
94
94
|
spec = Specification.new("spec")
|
95
|
-
assert spec.
|
95
|
+
assert spec.matches_matcher?(SpecMatcher.new("context spec", "context"))
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_should_match_if_name_matches_entire_input
|
99
|
+
spec = Specification.new("spec")
|
100
|
+
assert spec.matches_matcher?(SpecMatcher.new("spec", "context"))
|
96
101
|
end
|
97
102
|
|
98
103
|
def test_should_not_match_if_name_does_not_match
|
99
|
-
spec = Specification.new("
|
100
|
-
assert
|
104
|
+
spec = Specification.new("otherspec")
|
105
|
+
assert !spec.matches_matcher?(SpecMatcher.new("context spec", "context"))
|
101
106
|
end
|
102
107
|
|
103
108
|
def teardown
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.8.
|
2
|
+
rubygems_version: 0.8.11
|
3
3
|
specification_version: 1
|
4
4
|
name: rspec
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.5.
|
7
|
-
date: 2006-05
|
8
|
-
summary:
|
6
|
+
version: 0.5.5
|
7
|
+
date: 2006-06-06 00:00:00 -05:00
|
8
|
+
summary: RSpec-0.5.5 - BDD for Ruby http://rspec.rubyforge.org/
|
9
9
|
require_paths:
|
10
10
|
- lib
|
11
|
-
email:
|
11
|
+
email: rspec-devel@rubyforge.org
|
12
12
|
homepage: http://rspec.rubyforge.org
|
13
13
|
rubyforge_project: rspec
|
14
|
-
description: "RSpec is a behaviour
|
14
|
+
description: "RSpec is a behaviour driven development (BDD) framework for Ruby. RSpec was created in response to Dave Astels' article _A New Look at Test Driven Development_ which can be read at: http://daveastels.com/index.php?p=5 RSpec is intended to provide the features discussed in Dave's article."
|
15
15
|
autorequire: spec
|
16
16
|
default_executable: spec
|
17
17
|
bindir: bin
|
@@ -23,8 +23,10 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
23
23
|
version: 0.0.0
|
24
24
|
version:
|
25
25
|
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
26
28
|
authors:
|
27
|
-
- Steven Baker
|
29
|
+
- Steven Baker, Aslak Hellesoy, Dave Astels, David Chelimsky
|
28
30
|
files:
|
29
31
|
- CHANGES
|
30
32
|
- EXAMPLES.rd
|
@@ -65,12 +67,12 @@ files:
|
|
65
67
|
- lib/spec/runner/progress_bar_formatter.rb
|
66
68
|
- lib/spec/runner/rdoc_formatter.rb
|
67
69
|
- lib/spec/runner/reporter.rb
|
70
|
+
- lib/spec/runner/spec_matcher.rb
|
68
71
|
- lib/spec/runner/specdoc_formatter.rb
|
69
72
|
- lib/spec/runner/specification.rb
|
70
73
|
- lib/spec/tool/command_line.rb
|
71
74
|
- lib/spec/tool/test_unit_translator.rb
|
72
75
|
- test/test_helper.rb
|
73
|
-
- test/rcov/rcov_testtask.rb
|
74
76
|
- test/spec/api/duck_type_test.rb
|
75
77
|
- test/spec/api/sugar_test.rb
|
76
78
|
- test/spec/api/helper/arbitrary_predicate_test.rb
|
@@ -89,6 +91,7 @@ files:
|
|
89
91
|
- test/spec/api/mocks/mock_test.rb
|
90
92
|
- test/spec/api/mocks/null_object_test.rb
|
91
93
|
- test/spec/runner/backtrace_tweaker_test.rb
|
94
|
+
- test/spec/runner/context_matching_test.rb
|
92
95
|
- test/spec/runner/context_runner_test.rb
|
93
96
|
- test/spec/runner/context_test.rb
|
94
97
|
- test/spec/runner/execution_context_test.rb
|
@@ -98,6 +101,7 @@ files:
|
|
98
101
|
- test/spec/runner/progress_bar_formatter_test.rb
|
99
102
|
- test/spec/runner/rdoc_formatter_test.rb
|
100
103
|
- test/spec/runner/reporter_test.rb
|
104
|
+
- test/spec/runner/spec_matcher_test.rb
|
101
105
|
- test/spec/runner/specdoc_formatter_test.rb
|
102
106
|
- test/spec/runner/specification_test.rb
|
103
107
|
- test/spec/tool/command_line_test.rb
|
@@ -113,10 +117,8 @@ files:
|
|
113
117
|
- doc/config.yaml
|
114
118
|
- doc/plugin
|
115
119
|
- doc/README
|
116
|
-
- doc/reference
|
117
120
|
- doc/src
|
118
121
|
- doc/plugin/syntax.rb
|
119
|
-
- doc/reference/rspec reference.page
|
120
122
|
- doc/src/core_team.page
|
121
123
|
- doc/src/default.css
|
122
124
|
- doc/src/default.template
|
Binary file
|