rspec 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. data/CHANGES +10 -2
  2. data/EXAMPLES.rd +34 -0
  3. data/README +1 -1
  4. data/Rakefile +23 -28
  5. data/bin/spec +0 -1
  6. data/doc/src/core_team.page +18 -9
  7. data/doc/src/tools/rails.page +71 -5
  8. data/doc/src/tools/rake.page +5 -8
  9. data/doc/src/tools/rcov.page +14 -5
  10. data/doc/src/tools/spec.page +33 -18
  11. data/doc/src/tutorials/meta.info +6 -1
  12. data/doc/src/tutorials/stack.rb +1 -1
  13. data/doc/src/tutorials/stack_01.page +2 -0
  14. data/doc/src/tutorials/stack_02.page +6 -4
  15. data/doc/src/tutorials/stack_03.page +7 -15
  16. data/doc/src/tutorials/stack_04.page +39 -78
  17. data/doc/src/tutorials/stack_05.page +1 -1
  18. data/doc/src/tutorials/stack_spec.rb +2 -18
  19. data/lib/spec/rake/rcov_verify.rb +2 -2
  20. data/lib/spec/rake/spectask.rb +4 -9
  21. data/lib/spec/runner.rb +1 -0
  22. data/lib/spec/runner/backtrace_tweaker.rb +2 -0
  23. data/lib/spec/runner/context.rb +7 -5
  24. data/lib/spec/runner/context_runner.rb +4 -4
  25. data/lib/spec/runner/kernel_ext.rb +1 -1
  26. data/lib/spec/runner/spec_matcher.rb +39 -0
  27. data/lib/spec/runner/specification.rb +3 -3
  28. data/lib/spec/version.rb +1 -1
  29. data/test/spec/api/helper/equality_test.rb +1 -1
  30. data/test/spec/runner/backtrace_tweaker_test.rb +15 -9
  31. data/test/spec/runner/context_matching_test.rb +35 -0
  32. data/test/spec/runner/context_runner_test.rb +16 -16
  33. data/test/spec/runner/context_test.rb +0 -21
  34. data/test/spec/runner/spec_matcher_test.rb +42 -0
  35. data/test/spec/runner/specification_test.rb +9 -4
  36. metadata +12 -10
  37. data/doc/reference/rspec reference.page +0 -0
  38. 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?@single_spec
18
- context.isolate @single_spec if context.matches?@single_spec
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=false)
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!(exit_code)
31
+ exit(exit_code)
32
32
  end
33
33
  end
34
34
 
@@ -3,7 +3,7 @@ module Kernel
3
3
  context = Spec::Runner::Context.new(name, &block)
4
4
  runner = context_runner
5
5
  runner.add_context(context)
6
- runner.run if runner.standalone
6
+ runner.run(false) if runner.standalone
7
7
  end
8
8
 
9
9
  private
@@ -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
@@ -41,10 +41,10 @@ module Spec
41
41
  @mocks << mock
42
42
  end
43
43
 
44
- def matches? name
45
- name == @name
44
+ def matches_matcher? matcher
45
+ matcher.matches? @name
46
46
  end
47
-
47
+
48
48
  private
49
49
 
50
50
  def first_error errors
data/lib/spec/version.rb CHANGED
@@ -3,7 +3,7 @@ module Spec
3
3
  unless defined? MAJOR
4
4
  MAJOR = 0
5
5
  MINOR = 5
6
- TINY = 4
6
+ TINY = 5
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY].join('.')
9
9
 
@@ -34,7 +34,7 @@ module Spec
34
34
  end
35
35
  end
36
36
 
37
- def test_should_not_equal_should_raise_when_objects_are_not_equal
37
+ def test_should_not_equal_should_raise_when_objects_are_equal
38
38
  assert_raise(ExpectationNotMetError) do
39
39
  @dummy.should.not.equal @equal_dummy
40
40
  end
@@ -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].should.equal "./examples/airport_spec.rb:28:in `spec name'"
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].should.equal "/lib/spec/api/anything.rb"
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.should.not.be.empty
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.should.not.be.empty
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].should.equal "./examples/airport_spec.rb:28:in `spec name'"
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.should.be.empty
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.should.be.empty
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.should.be.empty
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
- legal_context = Api::Mock.new "legal context"
33
- legal_context.should_receive(:matches?).at_least(:once).and_return(true)
34
- legal_context.should_receive(:run)
35
- legal_context.should_receive(:isolate)
36
- legal_context.should_receive(:number_of_specs).and_return(1)
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
- illegal_context = Api::Mock.new "illegal context"
39
- illegal_context.should_receive(:matches?).and_return(false)
40
- illegal_context.should_receive(:run).never
41
- illegal_context.should_receive(:number_of_specs).never
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, "legal context legal spec")
46
- runner.add_context legal_context
47
- runner.add_context illegal_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
- legal_context.__verify
56
- illegal_context.__verify
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 test_should_match_if_name_matches
93
+ def test_should_match_if_name_matches_end_of_input
94
94
  spec = Specification.new("spec")
95
- assert spec.matches?"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("specification")
100
- assert (!spec.matches?"spec")
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.10
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.4
7
- date: 2006-05-13
8
- summary: Behaviour Specification Framework for Ruby
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: srbaker@pobox.com
11
+ email: rspec-devel@rubyforge.org
12
12
  homepage: http://rspec.rubyforge.org
13
13
  rubyforge_project: rspec
14
- description: "RSpec is a behaviour specification 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."
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