rspec 1.0.4 → 1.0.5

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.
Files changed (107) hide show
  1. data/CHANGES +12 -0
  2. data/EXAMPLES.rd +1 -1
  3. data/Rakefile +1 -0
  4. data/examples/auto_spec_description_example.rb +1 -1
  5. data/examples/before_and_after_example.rb +1 -1
  6. data/examples/behave_as_example.rb +1 -1
  7. data/examples/dynamic_spec.rb +1 -1
  8. data/examples/file_accessor.rb +18 -18
  9. data/examples/file_accessor_spec.rb +38 -38
  10. data/examples/greeter_spec.rb +1 -1
  11. data/examples/helper_method_example.rb +1 -1
  12. data/examples/io_processor.rb +8 -8
  13. data/examples/io_processor_spec.rb +1 -1
  14. data/examples/legacy_spec.rb +1 -1
  15. data/examples/not_yet_implemented_spec.rb +1 -1
  16. data/examples/partial_mock_example.rb +1 -1
  17. data/examples/predicate_example.rb +1 -1
  18. data/examples/stack.rb +1 -1
  19. data/examples/stack_spec.rb +1 -1
  20. data/examples/stubbing_example.rb +1 -1
  21. data/examples/test_case_adapter_example.rb +1 -1
  22. data/lib/autotest/discover.rb +1 -1
  23. data/lib/autotest/rspec.rb +15 -16
  24. data/lib/spec.rb +1 -1
  25. data/lib/spec/dsl/behaviour.rb +1 -0
  26. data/lib/spec/dsl/configuration.rb +1 -1
  27. data/lib/spec/dsl/description.rb +1 -1
  28. data/lib/spec/expectations.rb +1 -1
  29. data/lib/spec/expectations/extensions/string_and_symbol.rb +1 -1
  30. data/lib/spec/extensions/object.rb +1 -1
  31. data/lib/spec/matchers.rb +1 -1
  32. data/lib/spec/matchers/be_close.rb +1 -1
  33. data/lib/spec/matchers/eql.rb +1 -1
  34. data/lib/spec/matchers/equal.rb +1 -1
  35. data/lib/spec/matchers/have.rb +7 -2
  36. data/lib/spec/mocks.rb +1 -1
  37. data/lib/spec/mocks/argument_constraint_matchers.rb +1 -1
  38. data/lib/spec/mocks/error_generator.rb +1 -1
  39. data/lib/spec/mocks/methods.rb +1 -1
  40. data/lib/spec/mocks/mock.rb +1 -1
  41. data/lib/spec/mocks/proxy.rb +1 -1
  42. data/lib/spec/mocks/space.rb +1 -1
  43. data/lib/spec/mocks/spec_methods.rb +1 -1
  44. data/lib/spec/rake/verify_rcov.rb +1 -1
  45. data/lib/spec/runner/backtrace_tweaker.rb +1 -1
  46. data/lib/spec/runner/behaviour_runner.rb +1 -1
  47. data/lib/spec/runner/command_line.rb +1 -1
  48. data/lib/spec/runner/drb_command_line.rb +1 -1
  49. data/lib/spec/runner/formatter/failing_behaviours_formatter.rb +1 -1
  50. data/lib/spec/runner/formatter/failing_examples_formatter.rb +1 -1
  51. data/lib/spec/runner/formatter/progress_bar_formatter.rb +1 -1
  52. data/lib/spec/runner/formatter/rdoc_formatter.rb +1 -1
  53. data/lib/spec/runner/formatter/snippet_extractor.rb +1 -1
  54. data/lib/spec/runner/heckle_runner_unsupported.rb +10 -10
  55. data/lib/spec/runner/spec_parser.rb +1 -1
  56. data/lib/spec/test_case_adapter.rb +1 -1
  57. data/lib/spec/translator.rb +106 -106
  58. data/lib/spec/version.rb +22 -22
  59. data/spec/spec/dsl/behaviour_factory_spec.rb +1 -1
  60. data/spec/spec/dsl/configuration_spec.rb +1 -1
  61. data/spec/spec/dsl/description_spec.rb +1 -1
  62. data/spec/spec/dsl/predicate_matcher_spec.rb +1 -1
  63. data/spec/spec/dsl/shared_behaviour_spec.rb +19 -6
  64. data/spec/spec/matchers/description_generation_spec.rb +1 -1
  65. data/spec/spec/matchers/exist_spec.rb +1 -1
  66. data/spec/spec/matchers/handler_spec.rb +1 -1
  67. data/spec/spec/matchers/have_spec.rb +14 -1
  68. data/spec/spec/matchers/mock_constraint_matchers_spec.rb +1 -1
  69. data/spec/spec/matchers/respond_to_spec.rb +1 -1
  70. data/spec/spec/mocks/any_number_of_times_spec.rb +1 -1
  71. data/spec/spec/mocks/at_least_spec.rb +1 -1
  72. data/spec/spec/mocks/at_most_spec.rb +1 -1
  73. data/spec/spec/mocks/bug_report_7611_spec.rb +1 -1
  74. data/spec/spec/mocks/bug_report_7805_spec.rb +1 -1
  75. data/spec/spec/mocks/bug_report_8165_spec.rb +1 -1
  76. data/spec/spec/mocks/bug_report_8302_spec.rb +1 -1
  77. data/spec/spec/mocks/mock_ordering_spec.rb +1 -1
  78. data/spec/spec/mocks/once_counts_spec.rb +1 -1
  79. data/spec/spec/mocks/partial_mock_spec.rb +1 -1
  80. data/spec/spec/mocks/partial_mock_using_mocks_directly_spec.rb +1 -1
  81. data/spec/spec/mocks/precise_counts_spec.rb +1 -1
  82. data/spec/spec/mocks/record_messages_spec.rb +1 -1
  83. data/spec/spec/mocks/stub_spec.rb +1 -1
  84. data/spec/spec/mocks/twice_counts_spec.rb +1 -1
  85. data/spec/spec/package/bin_spec_spec.rb +1 -1
  86. data/spec/spec/runner/context_matching_spec.rb +1 -1
  87. data/spec/spec/runner/example_matcher_spec.rb +1 -1
  88. data/spec/spec/runner/formatter/failing_behaviours_formatter_spec.rb +1 -1
  89. data/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +1 -1
  90. data/spec/spec/runner/formatter/html_formatter_spec.rb +0 -2
  91. data/spec/spec/runner/formatter/progress_bar_formatter_dry_run_spec.rb +1 -1
  92. data/spec/spec/runner/formatter/progress_bar_formatter_failure_dump_spec.rb +1 -1
  93. data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +1 -1
  94. data/spec/spec/runner/formatter/rdoc_formatter_dry_run_spec.rb +1 -1
  95. data/spec/spec/runner/formatter/rdoc_formatter_spec.rb +1 -1
  96. data/spec/spec/runner/formatter/snippet_extractor_spec.rb +1 -1
  97. data/spec/spec/runner/formatter/specdoc_formatter_dry_run_spec.rb +1 -1
  98. data/spec/spec/runner/heckle_runner_spec.rb +1 -1
  99. data/spec/spec/runner/heckler_spec.rb +1 -1
  100. data/spec/spec/runner/noisy_backtrace_tweaker_spec.rb +1 -1
  101. data/spec/spec/runner/quiet_backtrace_tweaker_spec.rb +1 -1
  102. data/spec/spec/runner/reporter_spec.rb +1 -1
  103. data/spec/spec/runner/spec_parser_spec.rb +1 -1
  104. data/spec/spec/translator_spec.rb +1 -1
  105. data/spec/spec_helper.rb +0 -29
  106. metadata +3 -4
  107. data/lib/autotest.rb +0 -1
@@ -81,4 +81,4 @@ module Spec
81
81
 
82
82
  end
83
83
  end
84
- end
84
+ end
@@ -32,4 +32,4 @@ module Spec
32
32
  end
33
33
  end
34
34
  end
35
- end
35
+ end
@@ -26,4 +26,4 @@ module Spec
26
26
  end
27
27
  end
28
28
  end
29
- end
29
+ end
@@ -160,4 +160,4 @@ module Spec
160
160
 
161
161
  end
162
162
  end
163
- end
163
+ end
@@ -25,4 +25,4 @@ module Spec
25
25
  end
26
26
  end
27
27
  end
28
- end
28
+ end
@@ -27,4 +27,4 @@ module Spec
27
27
 
28
28
  end
29
29
  end
30
- end
30
+ end
@@ -49,4 +49,4 @@ module RCov
49
49
  end
50
50
  end
51
51
  end
52
- end
52
+ end
@@ -53,4 +53,4 @@ module Spec
53
53
  end
54
54
  end
55
55
  end
56
- end
56
+ end
@@ -82,7 +82,7 @@ module Spec
82
82
 
83
83
  def load_specs(paths)
84
84
  paths.each do |path|
85
- require path
85
+ load path
86
86
  end
87
87
  end
88
88
 
@@ -19,4 +19,4 @@ module Spec
19
19
  end
20
20
  end
21
21
  end
22
- end
22
+ end
@@ -18,4 +18,4 @@ module Spec
18
18
  end
19
19
  end
20
20
  end
21
- end
21
+ end
@@ -22,4 +22,4 @@ module Spec
22
22
  end
23
23
  end
24
24
  end
25
- end
25
+ end
@@ -19,4 +19,4 @@ module Spec
19
19
  end
20
20
  end
21
21
  end
22
- end
22
+ end
@@ -27,4 +27,4 @@ module Spec
27
27
  end
28
28
  end
29
29
  end
30
- end
30
+ end
@@ -21,4 +21,4 @@ module Spec
21
21
  end
22
22
  end
23
23
  end
24
- end
24
+ end
@@ -49,4 +49,4 @@ module Spec
49
49
  end
50
50
  end
51
51
  end
52
- end
52
+ end
@@ -1,10 +1,10 @@
1
- module Spec
2
- module Runner
3
- # Dummy implementation for Windows that just fails (Heckle is not supported on Windows)
4
- class HeckleRunner
5
- def initialize(filter)
6
- raise "Heckle not supported on Windows"
7
- end
8
- end
9
- end
10
- end
1
+ module Spec
2
+ module Runner
3
+ # Dummy implementation for Windows that just fails (Heckle is not supported on Windows)
4
+ class HeckleRunner
5
+ def initialize(filter)
6
+ raise "Heckle not supported on Windows"
7
+ end
8
+ end
9
+ end
10
+ end
@@ -47,4 +47,4 @@ module Spec
47
47
  end
48
48
  end
49
49
  end
50
- end
50
+ end
@@ -7,4 +7,4 @@ module Test
7
7
  include Spec::Matchers
8
8
  end
9
9
  end
10
- end
10
+ end
@@ -1,106 +1,106 @@
1
- require 'fileutils'
2
-
3
- module Spec
4
- class Translator
5
- def translate(from, to)
6
- from = File.expand_path(from)
7
- to = File.expand_path(to)
8
- if File.directory?(from)
9
- translate_dir(from, to)
10
- elsif(from =~ /\.rb$/)
11
- translate_file(from, to)
12
- end
13
- end
14
-
15
- def translate_dir(from, to)
16
- FileUtils.mkdir_p(to) unless File.directory?(to)
17
- Dir["#{from}/*"].each do |sub_from|
18
- path = sub_from[from.length+1..-1]
19
- sub_to = File.join(to, path)
20
- translate(sub_from, sub_to)
21
- end
22
- end
23
-
24
- def translate_file(from, to)
25
- translation = ""
26
- File.open(from) do |io|
27
- io.each_line do |line|
28
- translation << translate_line(line)
29
- end
30
- end
31
- File.open(to, "w") do |io|
32
- io.write(translation)
33
- end
34
- end
35
-
36
- def translate_line(line)
37
- return line if line =~ /(should_not|should)_receive/
38
-
39
- line.gsub!(/(^\s*)context([\s*|\(]['|"|A-Z])/, '\1describe\2')
40
- line.gsub!(/(^\s*)specify([\s*|\(]['|"|A-Z])/, '\1it\2')
41
- line.gsub!(/(^\s*)context_setup(\s*[do|\{])/, '\1before(:all)\2')
42
- line.gsub!(/(^\s*)context_teardown(\s*[do|\{])/, '\1after(:all)\2')
43
- line.gsub!(/(^\s*)setup(\s*[do|\{])/, '\1before(:each)\2')
44
- line.gsub!(/(^\s*)teardown(\s*[do|\{])/, '\1after(:each)\2')
45
-
46
- if line =~ /(.*\.)(should_not|should)(?:_be)(?!_)(.*)/m
47
- pre = $1
48
- should = $2
49
- post = $3
50
- be_or_equal = post =~ /(<|>)/ ? "be" : "equal"
51
-
52
- return "#{pre}#{should} #{be_or_equal}#{post}"
53
- end
54
-
55
- if line =~ /(.*\.)(should_not|should)_(?!not)\s*(.*)/m
56
- pre = $1
57
- should = $2
58
- post = $3
59
-
60
- post.gsub!(/^raise/, 'raise_error')
61
- post.gsub!(/^throw/, 'throw_symbol')
62
-
63
- unless standard_matcher?(post)
64
- post = "be_#{post}"
65
- end
66
-
67
- # Add parenthesis
68
- post.gsub!(/^(\w+)\s+([\w|\.|\,|\(.*\)|\'|\"|\:|@| ]+)(\})/, '\1(\2)\3') # inside a block
69
- post.gsub!(/^(redirect_to)\s+(.*)/, '\1(\2)') # redirect_to, which often has http:
70
- post.gsub!(/^(\w+)\s+([\w|\.|\,|\(.*\)|\{.*\}|\'|\"|\:|@| ]+)/, '\1(\2)')
71
- post.gsub!(/(\s+\))/, ')')
72
- post.gsub!(/\)\}/, ') }')
73
- post.gsub!(/^(\w+)\s+(\/.*\/)/, '\1(\2)') #regexps
74
- line = "#{pre}#{should} #{post}"
75
- end
76
-
77
- line
78
- end
79
-
80
- def standard_matcher?(matcher)
81
- patterns = [
82
- /^be/,
83
- /^be_close/,
84
- /^eql/,
85
- /^equal/,
86
- /^has/,
87
- /^have/,
88
- /^change/,
89
- /^include/,
90
- /^match/,
91
- /^raise_error/,
92
- /^respond_to/,
93
- /^redirect_to/,
94
- /^satisfy/,
95
- /^throw_symbol/,
96
- # Extra ones that we use in spec_helper
97
- /^pass/,
98
- /^fail/,
99
- /^fail_with/,
100
- ]
101
- matched = patterns.detect{ |p| matcher =~ p }
102
- !matched.nil?
103
- end
104
-
105
- end
106
- end
1
+ require 'fileutils'
2
+
3
+ module Spec
4
+ class Translator
5
+ def translate(from, to)
6
+ from = File.expand_path(from)
7
+ to = File.expand_path(to)
8
+ if File.directory?(from)
9
+ translate_dir(from, to)
10
+ elsif(from =~ /\.rb$/)
11
+ translate_file(from, to)
12
+ end
13
+ end
14
+
15
+ def translate_dir(from, to)
16
+ FileUtils.mkdir_p(to) unless File.directory?(to)
17
+ Dir["#{from}/*"].each do |sub_from|
18
+ path = sub_from[from.length+1..-1]
19
+ sub_to = File.join(to, path)
20
+ translate(sub_from, sub_to)
21
+ end
22
+ end
23
+
24
+ def translate_file(from, to)
25
+ translation = ""
26
+ File.open(from) do |io|
27
+ io.each_line do |line|
28
+ translation << translate_line(line)
29
+ end
30
+ end
31
+ File.open(to, "w") do |io|
32
+ io.write(translation)
33
+ end
34
+ end
35
+
36
+ def translate_line(line)
37
+ return line if line =~ /(should_not|should)_receive/
38
+
39
+ line.gsub!(/(^\s*)context([\s*|\(]['|"|A-Z])/, '\1describe\2')
40
+ line.gsub!(/(^\s*)specify([\s*|\(]['|"|A-Z])/, '\1it\2')
41
+ line.gsub!(/(^\s*)context_setup(\s*[do|\{])/, '\1before(:all)\2')
42
+ line.gsub!(/(^\s*)context_teardown(\s*[do|\{])/, '\1after(:all)\2')
43
+ line.gsub!(/(^\s*)setup(\s*[do|\{])/, '\1before(:each)\2')
44
+ line.gsub!(/(^\s*)teardown(\s*[do|\{])/, '\1after(:each)\2')
45
+
46
+ if line =~ /(.*\.)(should_not|should)(?:_be)(?!_)(.*)/m
47
+ pre = $1
48
+ should = $2
49
+ post = $3
50
+ be_or_equal = post =~ /(<|>)/ ? "be" : "equal"
51
+
52
+ return "#{pre}#{should} #{be_or_equal}#{post}"
53
+ end
54
+
55
+ if line =~ /(.*\.)(should_not|should)_(?!not)\s*(.*)/m
56
+ pre = $1
57
+ should = $2
58
+ post = $3
59
+
60
+ post.gsub!(/^raise/, 'raise_error')
61
+ post.gsub!(/^throw/, 'throw_symbol')
62
+
63
+ unless standard_matcher?(post)
64
+ post = "be_#{post}"
65
+ end
66
+
67
+ # Add parenthesis
68
+ post.gsub!(/^(\w+)\s+([\w|\.|\,|\(.*\)|\'|\"|\:|@| ]+)(\})/, '\1(\2)\3') # inside a block
69
+ post.gsub!(/^(redirect_to)\s+(.*)/, '\1(\2)') # redirect_to, which often has http:
70
+ post.gsub!(/^(\w+)\s+([\w|\.|\,|\(.*\)|\{.*\}|\'|\"|\:|@| ]+)/, '\1(\2)')
71
+ post.gsub!(/(\s+\))/, ')')
72
+ post.gsub!(/\)\}/, ') }')
73
+ post.gsub!(/^(\w+)\s+(\/.*\/)/, '\1(\2)') #regexps
74
+ line = "#{pre}#{should} #{post}"
75
+ end
76
+
77
+ line
78
+ end
79
+
80
+ def standard_matcher?(matcher)
81
+ patterns = [
82
+ /^be/,
83
+ /^be_close/,
84
+ /^eql/,
85
+ /^equal/,
86
+ /^has/,
87
+ /^have/,
88
+ /^change/,
89
+ /^include/,
90
+ /^match/,
91
+ /^raise_error/,
92
+ /^respond_to/,
93
+ /^redirect_to/,
94
+ /^satisfy/,
95
+ /^throw_symbol/,
96
+ # Extra ones that we use in spec_helper
97
+ /^pass/,
98
+ /^fail/,
99
+ /^fail_with/,
100
+ ]
101
+ matched = patterns.detect{ |p| matcher =~ p }
102
+ !matched.nil?
103
+ end
104
+
105
+ end
106
+ end
@@ -1,22 +1,22 @@
1
- module Spec
2
- module VERSION
3
- unless defined? MAJOR
4
- MAJOR = 1
5
- MINOR = 0
6
- TINY = 4
7
- RELEASE_CANDIDATE = nil
8
-
9
- # RANDOM_TOKEN: 0.691783562403103
10
- REV = "$LastChangedRevision: 2054 $".match(/LastChangedRevision: (\d+)/)[1]
11
-
12
- STRING = [MAJOR, MINOR, TINY].join('.')
13
- TAG = "REL_#{[MAJOR, MINOR, TINY, RELEASE_CANDIDATE].compact.join('_')}".upcase.gsub(/\.|-/, '_')
14
- FULL_VERSION = "#{[MAJOR, MINOR, TINY, RELEASE_CANDIDATE].compact.join('.')} (r#{REV})"
15
-
16
- NAME = "RSpec"
17
- URL = "http://rspec.rubyforge.org/"
18
-
19
- DESCRIPTION = "#{NAME}-#{FULL_VERSION} - BDD for Ruby\n#{URL}"
20
- end
21
- end
22
- end
1
+ module Spec
2
+ module VERSION
3
+ unless defined? MAJOR
4
+ MAJOR = 1
5
+ MINOR = 0
6
+ TINY = 5
7
+ RELEASE_CANDIDATE = nil
8
+
9
+ # RANDOM_TOKEN: 0.956731547671535
10
+ REV = "$LastChangedRevision: 2081 $".match(/LastChangedRevision: (\d+)/)[1]
11
+
12
+ STRING = [MAJOR, MINOR, TINY].join('.')
13
+ TAG = "REL_#{[MAJOR, MINOR, TINY, RELEASE_CANDIDATE].compact.join('_')}".upcase.gsub(/\.|-/, '_')
14
+ FULL_VERSION = "#{[MAJOR, MINOR, TINY, RELEASE_CANDIDATE].compact.join('.')} (r#{REV})"
15
+
16
+ NAME = "RSpec"
17
+ URL = "http://rspec.rubyforge.org/"
18
+
19
+ DESCRIPTION = "#{NAME}-#{FULL_VERSION} - BDD for Ruby\n#{URL}"
20
+ end
21
+ end
22
+ end
@@ -27,4 +27,4 @@ module Spec
27
27
  end
28
28
  end
29
29
  end
30
- end
30
+ end
@@ -47,4 +47,4 @@ module Spec
47
47
  end
48
48
  end
49
49
  end
50
- end
50
+ end
@@ -78,4 +78,4 @@ module Spec
78
78
  end
79
79
  end
80
80
  end
81
- end
81
+ end
@@ -18,4 +18,4 @@ module Spec
18
18
  end
19
19
  end
20
20
  end
21
- end
21
+ end
@@ -74,16 +74,29 @@ module Spec
74
74
  end
75
75
 
76
76
  it "should complain when adding a second shared behaviour with the same description" do
77
- make_shared_behaviour("shared behaviour") {}
78
- lambda { make_shared_behaviour("shared behaviour") {} }.should raise_error(ArgumentError)
77
+ describe "shared behaviour", :shared => true do
78
+ end
79
+ lambda do
80
+ describe "shared behaviour", :shared => true do
81
+ end
82
+ end.should raise_error(ArgumentError)
79
83
  end
80
84
 
81
- it "should NOT complain when adding a the same shared behaviour again (i.e. file gets reloaded)" do
82
- behaviour = behaviour_class.new("shared behaviour") {}
83
- behaviour_class.add_shared_behaviour(behaviour)
84
- behaviour_class.add_shared_behaviour(behaviour)
85
+ it "should NOT complain when adding the same shared behaviour instance again" do
86
+ shared_behaviour = behaviour_class.new("shared behaviour", :shared => true) {}
87
+ behaviour_class.add_shared_behaviour(shared_behaviour)
88
+ behaviour_class.add_shared_behaviour(shared_behaviour)
85
89
  end
86
90
 
91
+ it "should NOT complain when adding the same shared behaviour again (i.e. file gets reloaded)" do
92
+ lambda do
93
+ 2.times do
94
+ describe "shared behaviour which gets loaded twice", :shared => true do
95
+ end
96
+ end
97
+ end.should_not raise_error(ArgumentError)
98
+ end
99
+
87
100
  it "should add examples to current behaviour when calling it_should_behave_like" do
88
101
  shared_behaviour = make_shared_behaviour("shared behaviour") {}
89
102
  shared_behaviour.it("shared example") {}