rspec 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +7 -12
- data/Rakefile +17 -12
- data/TUTORIAL +1 -1
- data/WHY_RSPEC +115 -0
- data/bin/spec +17 -4
- data/bin/test2rspec +35 -0
- data/examples/airport_spec.rb +35 -0
- data/examples/mocking_spec.rb +16 -0
- data/examples/spec_framework_spec.rb +28 -0
- data/examples/stack.rb +36 -0
- data/examples/stack_spec.rb +112 -0
- data/lib/spec.rb +5 -18
- data/lib/spec/api.rb +4 -0
- data/lib/spec/{exceptions.rb → api/exceptions.rb} +1 -1
- data/lib/spec/{expectations.rb → api/expectations.rb} +5 -4
- data/lib/spec/api/helper.rb +10 -0
- data/lib/spec/{have_helper.rb → api/helper/have_helper.rb} +1 -1
- data/lib/spec/{instance_helper.rb → api/helper/instance_helper.rb} +0 -0
- data/lib/spec/{instance_negator.rb → api/helper/instance_negator.rb} +0 -0
- data/lib/spec/{kind_helper.rb → api/helper/kind_helper.rb} +0 -0
- data/lib/spec/{kind_negator.rb → api/helper/kind_negator.rb} +0 -0
- data/lib/spec/{respond_helper.rb → api/helper/respond_helper.rb} +0 -0
- data/lib/spec/{respond_negator.rb → api/helper/respond_negator.rb} +0 -0
- data/lib/spec/{should_base.rb → api/helper/should_base.rb} +6 -4
- data/lib/spec/{should_helper.rb → api/helper/should_helper.rb} +12 -0
- data/lib/spec/{should_negator.rb → api/helper/should_negator.rb} +11 -0
- data/lib/spec/api/mock.rb +184 -0
- data/lib/spec/rake/spectask.rb +153 -0
- data/lib/spec/runner.rb +9 -0
- data/lib/spec/runner/backtrace_tweaker.rb +17 -0
- data/lib/spec/runner/context.rb +47 -0
- data/lib/spec/runner/context_runner.rb +52 -0
- data/lib/spec/runner/execution_context.rb +15 -0
- data/lib/spec/runner/instance_exec.rb +15 -0
- data/lib/spec/runner/kernel_ext.rb +6 -0
- data/lib/spec/runner/option_parser.rb +41 -0
- data/lib/spec/runner/rdoc_formatter.rb +17 -0
- data/lib/spec/runner/simple_text_reporter.rb +92 -0
- data/lib/spec/runner/specification.rb +42 -0
- data/lib/spec/tool/command_line.rb +39 -0
- data/lib/spec/tool/test_unit_translator.rb +112 -0
- data/lib/spec/version.rb +13 -0
- data/test/spec/api/helper/arbitrary_predicate_test.rb +121 -0
- data/test/spec/api/helper/containment_test.rb +117 -0
- data/test/spec/api/helper/equality_test.rb +46 -0
- data/test/spec/api/helper/identity_test.rb +68 -0
- data/test/spec/api/helper/raising_test.rb +50 -0
- data/test/spec/api/helper/regex_matching_test.rb +38 -0
- data/test/spec/api/helper/should_satisfy_test.rb +37 -0
- data/test/spec/api/helper/throwing_test.rb +56 -0
- data/test/spec/api/helper/true_false_special_case_test.rb +87 -0
- data/test/spec/api/helper/typing_test.rb +107 -0
- data/test/spec/api/mock_test.rb +161 -0
- data/test/spec/runner/backtrace_tweaker_test.rb +20 -0
- data/test/spec/runner/context_runner_test.rb +19 -0
- data/test/spec/runner/context_test.rb +29 -0
- data/test/spec/runner/execution_context_test.rb +13 -0
- data/test/spec/runner/option_parser_test.rb +50 -0
- data/test/spec/runner/rdoc_formatter_test.rb +23 -0
- data/test/spec/runner/simple_text_reporter_test.rb +128 -0
- data/test/spec/runner/specification_test.rb +70 -0
- data/test/spec/tool/command_line_test.rb +22 -0
- data/test/spec/tool/test_unit_api_spec.rb +61 -0
- data/test/spec/tool/test_unit_api_test.rb +61 -0
- data/test/spec/tool/test_unit_translator_test.rb +29 -0
- data/test/test_helper.rb +8 -0
- metadata +89 -67
- data/examples/add_specification_spec.rb +0 -15
- data/examples/craps.rb +0 -15
- data/examples/craps_spec.rb +0 -105
- data/examples/dsl_spec.rb +0 -8
- data/examples/movie.rb +0 -7
- data/examples/movie_list.rb +0 -19
- data/examples/movie_spec.rb +0 -37
- data/lib/spec/collector.rb +0 -17
- data/lib/spec/context.rb +0 -89
- data/lib/spec/dsl.rb +0 -23
- data/lib/spec/gui_runner.rb +0 -59
- data/lib/spec/mock.rb +0 -183
- data/lib/spec/text_runner.rb +0 -75
- data/test/collection_owner.rb +0 -48
- data/test/context_fixtures_test.rb +0 -71
- data/test/context_run_test.rb +0 -174
- data/test/dsl_test.rb +0 -48
- data/test/error_reporting_test.rb +0 -225
- data/test/expectations_for_should_have_test.rb +0 -144
- data/test/expectations_test.rb +0 -592
- data/test/get_classes.rb +0 -6
- data/test/gui_runner_test.rb +0 -162
- data/test/mock_test.rb +0 -157
- data/test/spec_collection_test.rb +0 -39
- data/test/specification_addition_test.rb +0 -29
- data/test/specification_identification_test.rb +0 -71
- data/test/text_runner_test.rb +0 -146
@@ -0,0 +1,61 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
2
|
+
|
3
|
+
module Spec
|
4
|
+
module Tool
|
5
|
+
class TestUnitApiTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@an_int = 789
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_can_be_translated_to_rspec
|
15
|
+
a_float = 123.45
|
16
|
+
a_nil = nil
|
17
|
+
|
18
|
+
assert @an_int
|
19
|
+
assert_block { true }
|
20
|
+
assert_block do
|
21
|
+
true
|
22
|
+
end
|
23
|
+
assert_equal 789 ,@an_int, "a message"
|
24
|
+
assert_in_delta 123.5, a_float, 0.1, "a message"
|
25
|
+
assert_instance_of Fixnum, @an_int, "a message"
|
26
|
+
assert_kind_of Numeric, @an_int, "a message"
|
27
|
+
assert_match /789/ , @an_int.to_s
|
28
|
+
assert_nil a_nil
|
29
|
+
assert_no_match /7890/, @an_int.to_s, "a message"
|
30
|
+
assert_not_equal 780, @an_int
|
31
|
+
assert_not_nil @an_int, "a message"
|
32
|
+
assert_not_same @an_int, a_float, "a message"
|
33
|
+
assert_nothing_raised { foo = 1 }
|
34
|
+
assert_nothing_raised do
|
35
|
+
foo = 2
|
36
|
+
end
|
37
|
+
assert_nothing_thrown { foo = 3 }
|
38
|
+
assert_nothing_thrown do
|
39
|
+
foo = 4
|
40
|
+
end
|
41
|
+
#assert_operator object1, operator, object2, "a message"
|
42
|
+
assert_raise(NotImplementedError){ raise NotImplementedError }
|
43
|
+
assert_raise(NotImplementedError) do
|
44
|
+
raise NotImplementedError
|
45
|
+
end
|
46
|
+
assert_raises(NotImplementedError){ raise NotImplementedError }
|
47
|
+
assert_raises(NotImplementedError) do
|
48
|
+
raise NotImplementedError
|
49
|
+
end
|
50
|
+
assert_respond_to @an_int, :to_f, "a message"
|
51
|
+
assert_same a_float, a_float, "a message"
|
52
|
+
#assert_send send_array, "a message"
|
53
|
+
assert_throws(:foo, "a message"){ throw :foo }
|
54
|
+
assert_throws(:foo, "a message") do
|
55
|
+
throw :foo
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
2
|
+
require 'spec/tool/test_unit_translator'
|
3
|
+
require 'tempfile'
|
4
|
+
|
5
|
+
module Spec
|
6
|
+
module Tool
|
7
|
+
class TestUnitTranslatorTest < Test::Unit::TestCase
|
8
|
+
def test_should_translate_test_classes_to_contexts
|
9
|
+
c = TestUnitTranslator.new
|
10
|
+
test_unit_file = File.dirname(__FILE__) + '/test_unit_api_test.rb'
|
11
|
+
translated = c.translate(test_unit_file)
|
12
|
+
expected_path = File.dirname(__FILE__) + '/test_unit_api_spec.rb'
|
13
|
+
expected = File.open(expected_path).read
|
14
|
+
|
15
|
+
translated_tmp = Tempfile.open("translated")
|
16
|
+
translated_tmp.write(translated)
|
17
|
+
translated_tmp.flush
|
18
|
+
translated_tmp.close
|
19
|
+
|
20
|
+
diff = `diff -w -u #{expected_path} #{translated_tmp.path}`
|
21
|
+
if diff.strip != ""
|
22
|
+
fail("Conversion didn't match expectation. Diff:\n#{diff}")
|
23
|
+
else
|
24
|
+
assert true # Just so we get an assertion count in the output
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
$LOAD_PATH.push File.dirname(__FILE__) + '/../lib'
|
3
|
+
$LOAD_PATH.push File.dirname(__FILE__) + '/../test'
|
4
|
+
require 'spec'
|
5
|
+
mock_context_runner = Spec::Api::Mock.new "mock_context_runner"
|
6
|
+
mock_context_runner.should_receive(:add_context).any_number_of_times
|
7
|
+
mock_context_runner.should_receive(:run).any_number_of_times
|
8
|
+
Spec::Runner::Context.context_runner = mock_context_runner
|
metadata
CHANGED
@@ -3,93 +3,115 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: rspec
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2006-
|
6
|
+
version: 0.5.0
|
7
|
+
date: 2006-04-03 00:00:00 -05:00
|
8
8
|
summary: Behaviour Specification Framework for Ruby
|
9
9
|
require_paths:
|
10
|
-
|
10
|
+
- lib
|
11
11
|
email: srbaker@pobox.com
|
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
|
15
|
-
response to Dave Astels' article _A New Look at Test Driven Development_ which
|
16
|
-
can be read at: http://daveastels.com/index.php?p=5 RSpec is intended to
|
17
|
-
provide the features discussed in Dave's article."
|
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."
|
18
15
|
autorequire: spec
|
19
16
|
default_executable: spec
|
20
17
|
bindir: bin
|
21
18
|
has_rdoc: true
|
22
19
|
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
23
20
|
requirements:
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
version: 0.0.0
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
28
24
|
version:
|
29
25
|
platform: ruby
|
30
26
|
signing_key:
|
31
27
|
cert_chain:
|
32
28
|
authors:
|
33
|
-
|
29
|
+
- Steven Baker
|
34
30
|
files:
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
31
|
+
- CHANGES
|
32
|
+
- Rakefile
|
33
|
+
- README
|
34
|
+
- TODO
|
35
|
+
- TUTORIAL
|
36
|
+
- WHY_RSPEC
|
37
|
+
- lib/spec.rb
|
38
|
+
- lib/spec/api.rb
|
39
|
+
- lib/spec/runner.rb
|
40
|
+
- lib/spec/version.rb
|
41
|
+
- lib/spec/api/exceptions.rb
|
42
|
+
- lib/spec/api/expectations.rb
|
43
|
+
- lib/spec/api/helper.rb
|
44
|
+
- lib/spec/api/mock.rb
|
45
|
+
- lib/spec/api/helper/have_helper.rb
|
46
|
+
- lib/spec/api/helper/instance_helper.rb
|
47
|
+
- lib/spec/api/helper/instance_negator.rb
|
48
|
+
- lib/spec/api/helper/kind_helper.rb
|
49
|
+
- lib/spec/api/helper/kind_negator.rb
|
50
|
+
- lib/spec/api/helper/respond_helper.rb
|
51
|
+
- lib/spec/api/helper/respond_negator.rb
|
52
|
+
- lib/spec/api/helper/should_base.rb
|
53
|
+
- lib/spec/api/helper/should_helper.rb
|
54
|
+
- lib/spec/api/helper/should_negator.rb
|
55
|
+
- lib/spec/rake/spectask.rb
|
56
|
+
- lib/spec/runner/backtrace_tweaker.rb
|
57
|
+
- lib/spec/runner/context.rb
|
58
|
+
- lib/spec/runner/context_runner.rb
|
59
|
+
- lib/spec/runner/execution_context.rb
|
60
|
+
- lib/spec/runner/instance_exec.rb
|
61
|
+
- lib/spec/runner/kernel_ext.rb
|
62
|
+
- lib/spec/runner/option_parser.rb
|
63
|
+
- lib/spec/runner/rdoc_formatter.rb
|
64
|
+
- lib/spec/runner/simple_text_reporter.rb
|
65
|
+
- lib/spec/runner/specification.rb
|
66
|
+
- lib/spec/tool/command_line.rb
|
67
|
+
- lib/spec/tool/test_unit_translator.rb
|
68
|
+
- test/test_helper.rb
|
69
|
+
- test/spec/api/mock_test.rb
|
70
|
+
- test/spec/api/helper/arbitrary_predicate_test.rb
|
71
|
+
- test/spec/api/helper/containment_test.rb
|
72
|
+
- test/spec/api/helper/equality_test.rb
|
73
|
+
- test/spec/api/helper/identity_test.rb
|
74
|
+
- test/spec/api/helper/raising_test.rb
|
75
|
+
- test/spec/api/helper/regex_matching_test.rb
|
76
|
+
- test/spec/api/helper/should_satisfy_test.rb
|
77
|
+
- test/spec/api/helper/throwing_test.rb
|
78
|
+
- test/spec/api/helper/true_false_special_case_test.rb
|
79
|
+
- test/spec/api/helper/typing_test.rb
|
80
|
+
- test/spec/runner/backtrace_tweaker_test.rb
|
81
|
+
- test/spec/runner/context_runner_test.rb
|
82
|
+
- test/spec/runner/context_test.rb
|
83
|
+
- test/spec/runner/execution_context_test.rb
|
84
|
+
- test/spec/runner/option_parser_test.rb
|
85
|
+
- test/spec/runner/rdoc_formatter_test.rb
|
86
|
+
- test/spec/runner/simple_text_reporter_test.rb
|
87
|
+
- test/spec/runner/specification_test.rb
|
88
|
+
- test/spec/tool/command_line_test.rb
|
89
|
+
- test/spec/tool/test_unit_api_spec.rb
|
90
|
+
- test/spec/tool/test_unit_api_test.rb
|
91
|
+
- test/spec/tool/test_unit_translator_test.rb
|
92
|
+
- examples/airport_spec.rb
|
93
|
+
- examples/mocking_spec.rb
|
94
|
+
- examples/spec_framework_spec.rb
|
95
|
+
- examples/stack.rb
|
96
|
+
- examples/stack_spec.rb
|
80
97
|
test_files: []
|
98
|
+
|
81
99
|
rdoc_options:
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
100
|
+
- --title
|
101
|
+
- RSpec
|
102
|
+
- --main
|
103
|
+
- README
|
104
|
+
- --line-numbers
|
87
105
|
extra_rdoc_files:
|
88
|
-
|
89
|
-
|
90
|
-
|
106
|
+
- README
|
107
|
+
- CHANGES
|
108
|
+
- TUTORIAL
|
91
109
|
executables:
|
92
|
-
|
110
|
+
- spec
|
111
|
+
- test2rspec
|
93
112
|
extensions: []
|
113
|
+
|
94
114
|
requirements: []
|
95
|
-
|
115
|
+
|
116
|
+
dependencies: []
|
117
|
+
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'spec'
|
2
|
-
|
3
|
-
class AddSpecification < Spec::Context
|
4
|
-
|
5
|
-
def a_passing_spec
|
6
|
-
true.should.be true
|
7
|
-
end
|
8
|
-
|
9
|
-
def a_failing_spec
|
10
|
-
true.should.be false
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
AddSpecification.add_specification('another_failing_spec') { false.should.be true }
|
data/examples/craps.rb
DELETED
data/examples/craps_spec.rb
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
require 'spec'
|
2
|
-
require File.dirname(__FILE__) + '/craps'
|
3
|
-
|
4
|
-
class CrapsSpecification < Spec::Context
|
5
|
-
|
6
|
-
def setup
|
7
|
-
@die1 = mock "die1"
|
8
|
-
@die2 = mock "die2"
|
9
|
-
@game = Craps.new(@die1, @die2)
|
10
|
-
end
|
11
|
-
|
12
|
-
# coming out roll of 7
|
13
|
-
|
14
|
-
def come_out_roll_of_1_6_wins
|
15
|
-
_load_dice([1], [6])
|
16
|
-
@game.play.should.be true
|
17
|
-
end
|
18
|
-
|
19
|
-
def come_out_roll_of_2_5_wins
|
20
|
-
_load_dice([2], [5])
|
21
|
-
@game.play.should.be true
|
22
|
-
end
|
23
|
-
|
24
|
-
def come_out_roll_of_3_4_wins
|
25
|
-
_load_dice([3], [4])
|
26
|
-
@game.play.should.be true
|
27
|
-
end
|
28
|
-
|
29
|
-
def come_out_roll_of_4_3_wins
|
30
|
-
_load_dice([4], [3])
|
31
|
-
@game.play.should.be true
|
32
|
-
end
|
33
|
-
|
34
|
-
def come_out_roll_of_5_2_wins
|
35
|
-
_load_dice([5], [2])
|
36
|
-
@game.play.should.be true
|
37
|
-
end
|
38
|
-
|
39
|
-
def come_out_roll_of_6_1_wins
|
40
|
-
_load_dice([6], [1])
|
41
|
-
@game.play.should.be true
|
42
|
-
end
|
43
|
-
|
44
|
-
# coming out roll of 11
|
45
|
-
|
46
|
-
def come_out_roll_of_5_6_wins
|
47
|
-
_load_dice([5], [6])
|
48
|
-
@game.play.should.be true
|
49
|
-
end
|
50
|
-
|
51
|
-
def come_out_roll_of_6_5_wins
|
52
|
-
_load_dice([6], [5])
|
53
|
-
@game.play.should.be true
|
54
|
-
end
|
55
|
-
|
56
|
-
# coming out roll of 2
|
57
|
-
|
58
|
-
def come_out_roll_of_1_1_looses
|
59
|
-
_load_dice([1], [1])
|
60
|
-
@game.play.should.be false
|
61
|
-
end
|
62
|
-
|
63
|
-
# coming out roll of 3
|
64
|
-
|
65
|
-
def come_out_roll_of_1_2_looses
|
66
|
-
_load_dice([1], [2])
|
67
|
-
@game.play.should.be false
|
68
|
-
end
|
69
|
-
|
70
|
-
def come_out_roll_of_2_1_looses
|
71
|
-
_load_dice([2], [1])
|
72
|
-
@game.play.should.be false
|
73
|
-
end
|
74
|
-
|
75
|
-
# coming out roll of 12
|
76
|
-
|
77
|
-
def come_out_roll_of_6_6_looses
|
78
|
-
_load_dice([6], [6])
|
79
|
-
@game.play.should.be false
|
80
|
-
end
|
81
|
-
|
82
|
-
# loosing with a point
|
83
|
-
|
84
|
-
# def second_roll_of_7_looses
|
85
|
-
# _load_dice([2, 4], [2, 3])
|
86
|
-
# @game.play.should.be false
|
87
|
-
# end
|
88
|
-
|
89
|
-
# support
|
90
|
-
|
91
|
-
def _load_dice(rolls1, rolls2)
|
92
|
-
_load_die(@die1, rolls1)
|
93
|
-
_load_die(@die2, rolls2)
|
94
|
-
end
|
95
|
-
|
96
|
-
def _load_die(die, rolls)
|
97
|
-
rolls.each { |roll| die.should_receive(:roll).once.with_no_args.and_return(roll) }
|
98
|
-
end
|
99
|
-
|
100
|
-
end
|
101
|
-
|
102
|
-
if __FILE__ == $0
|
103
|
-
runner = Spec::TextRunner.new($stdout)
|
104
|
-
runner.run(CrapsSpecification)
|
105
|
-
end
|
data/examples/dsl_spec.rb
DELETED
data/examples/movie.rb
DELETED
data/examples/movie_list.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
class MovieList
|
2
|
-
|
3
|
-
def initialize
|
4
|
-
@movies = Hash.new
|
5
|
-
end
|
6
|
-
|
7
|
-
def size
|
8
|
-
@movies.size
|
9
|
-
end
|
10
|
-
|
11
|
-
def add (movieToAdd)
|
12
|
-
@movies.store(movieToAdd.name, movieToAdd)
|
13
|
-
end
|
14
|
-
|
15
|
-
def include? (aName)
|
16
|
-
@movies.include?(aName)
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|