rspec 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +12 -0
- data/EXAMPLES.rd +1 -1
- data/Rakefile +1 -0
- data/examples/auto_spec_description_example.rb +1 -1
- data/examples/before_and_after_example.rb +1 -1
- data/examples/behave_as_example.rb +1 -1
- data/examples/dynamic_spec.rb +1 -1
- data/examples/file_accessor.rb +18 -18
- data/examples/file_accessor_spec.rb +38 -38
- data/examples/greeter_spec.rb +1 -1
- data/examples/helper_method_example.rb +1 -1
- data/examples/io_processor.rb +8 -8
- data/examples/io_processor_spec.rb +1 -1
- data/examples/legacy_spec.rb +1 -1
- data/examples/not_yet_implemented_spec.rb +1 -1
- data/examples/partial_mock_example.rb +1 -1
- data/examples/predicate_example.rb +1 -1
- data/examples/stack.rb +1 -1
- data/examples/stack_spec.rb +1 -1
- data/examples/stubbing_example.rb +1 -1
- data/examples/test_case_adapter_example.rb +1 -1
- data/lib/autotest/discover.rb +1 -1
- data/lib/autotest/rspec.rb +15 -16
- data/lib/spec.rb +1 -1
- data/lib/spec/dsl/behaviour.rb +1 -0
- data/lib/spec/dsl/configuration.rb +1 -1
- data/lib/spec/dsl/description.rb +1 -1
- data/lib/spec/expectations.rb +1 -1
- data/lib/spec/expectations/extensions/string_and_symbol.rb +1 -1
- data/lib/spec/extensions/object.rb +1 -1
- data/lib/spec/matchers.rb +1 -1
- data/lib/spec/matchers/be_close.rb +1 -1
- data/lib/spec/matchers/eql.rb +1 -1
- data/lib/spec/matchers/equal.rb +1 -1
- data/lib/spec/matchers/have.rb +7 -2
- data/lib/spec/mocks.rb +1 -1
- data/lib/spec/mocks/argument_constraint_matchers.rb +1 -1
- data/lib/spec/mocks/error_generator.rb +1 -1
- data/lib/spec/mocks/methods.rb +1 -1
- data/lib/spec/mocks/mock.rb +1 -1
- data/lib/spec/mocks/proxy.rb +1 -1
- data/lib/spec/mocks/space.rb +1 -1
- data/lib/spec/mocks/spec_methods.rb +1 -1
- data/lib/spec/rake/verify_rcov.rb +1 -1
- data/lib/spec/runner/backtrace_tweaker.rb +1 -1
- data/lib/spec/runner/behaviour_runner.rb +1 -1
- data/lib/spec/runner/command_line.rb +1 -1
- data/lib/spec/runner/drb_command_line.rb +1 -1
- data/lib/spec/runner/formatter/failing_behaviours_formatter.rb +1 -1
- data/lib/spec/runner/formatter/failing_examples_formatter.rb +1 -1
- data/lib/spec/runner/formatter/progress_bar_formatter.rb +1 -1
- data/lib/spec/runner/formatter/rdoc_formatter.rb +1 -1
- data/lib/spec/runner/formatter/snippet_extractor.rb +1 -1
- data/lib/spec/runner/heckle_runner_unsupported.rb +10 -10
- data/lib/spec/runner/spec_parser.rb +1 -1
- data/lib/spec/test_case_adapter.rb +1 -1
- data/lib/spec/translator.rb +106 -106
- data/lib/spec/version.rb +22 -22
- data/spec/spec/dsl/behaviour_factory_spec.rb +1 -1
- data/spec/spec/dsl/configuration_spec.rb +1 -1
- data/spec/spec/dsl/description_spec.rb +1 -1
- data/spec/spec/dsl/predicate_matcher_spec.rb +1 -1
- data/spec/spec/dsl/shared_behaviour_spec.rb +19 -6
- data/spec/spec/matchers/description_generation_spec.rb +1 -1
- data/spec/spec/matchers/exist_spec.rb +1 -1
- data/spec/spec/matchers/handler_spec.rb +1 -1
- data/spec/spec/matchers/have_spec.rb +14 -1
- data/spec/spec/matchers/mock_constraint_matchers_spec.rb +1 -1
- data/spec/spec/matchers/respond_to_spec.rb +1 -1
- data/spec/spec/mocks/any_number_of_times_spec.rb +1 -1
- data/spec/spec/mocks/at_least_spec.rb +1 -1
- data/spec/spec/mocks/at_most_spec.rb +1 -1
- data/spec/spec/mocks/bug_report_7611_spec.rb +1 -1
- data/spec/spec/mocks/bug_report_7805_spec.rb +1 -1
- data/spec/spec/mocks/bug_report_8165_spec.rb +1 -1
- data/spec/spec/mocks/bug_report_8302_spec.rb +1 -1
- data/spec/spec/mocks/mock_ordering_spec.rb +1 -1
- data/spec/spec/mocks/once_counts_spec.rb +1 -1
- data/spec/spec/mocks/partial_mock_spec.rb +1 -1
- data/spec/spec/mocks/partial_mock_using_mocks_directly_spec.rb +1 -1
- data/spec/spec/mocks/precise_counts_spec.rb +1 -1
- data/spec/spec/mocks/record_messages_spec.rb +1 -1
- data/spec/spec/mocks/stub_spec.rb +1 -1
- data/spec/spec/mocks/twice_counts_spec.rb +1 -1
- data/spec/spec/package/bin_spec_spec.rb +1 -1
- data/spec/spec/runner/context_matching_spec.rb +1 -1
- data/spec/spec/runner/example_matcher_spec.rb +1 -1
- data/spec/spec/runner/formatter/failing_behaviours_formatter_spec.rb +1 -1
- data/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +1 -1
- data/spec/spec/runner/formatter/html_formatter_spec.rb +0 -2
- data/spec/spec/runner/formatter/progress_bar_formatter_dry_run_spec.rb +1 -1
- data/spec/spec/runner/formatter/progress_bar_formatter_failure_dump_spec.rb +1 -1
- data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +1 -1
- data/spec/spec/runner/formatter/rdoc_formatter_dry_run_spec.rb +1 -1
- data/spec/spec/runner/formatter/rdoc_formatter_spec.rb +1 -1
- data/spec/spec/runner/formatter/snippet_extractor_spec.rb +1 -1
- data/spec/spec/runner/formatter/specdoc_formatter_dry_run_spec.rb +1 -1
- data/spec/spec/runner/heckle_runner_spec.rb +1 -1
- data/spec/spec/runner/heckler_spec.rb +1 -1
- data/spec/spec/runner/noisy_backtrace_tweaker_spec.rb +1 -1
- data/spec/spec/runner/quiet_backtrace_tweaker_spec.rb +1 -1
- data/spec/spec/runner/reporter_spec.rb +1 -1
- data/spec/spec/runner/spec_parser_spec.rb +1 -1
- data/spec/spec/translator_spec.rb +1 -1
- data/spec/spec_helper.rb +0 -29
- metadata +3 -4
- data/lib/autotest.rb +0 -1
data/lib/spec/mocks/methods.rb
CHANGED
data/lib/spec/mocks/mock.rb
CHANGED
data/lib/spec/mocks/proxy.rb
CHANGED
data/lib/spec/mocks/space.rb
CHANGED
@@ -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
|
data/lib/spec/translator.rb
CHANGED
@@ -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
|
data/lib/spec/version.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
module Spec
|
2
|
-
module VERSION
|
3
|
-
unless defined? MAJOR
|
4
|
-
MAJOR = 1
|
5
|
-
MINOR = 0
|
6
|
-
TINY =
|
7
|
-
RELEASE_CANDIDATE = nil
|
8
|
-
|
9
|
-
# RANDOM_TOKEN: 0.
|
10
|
-
REV = "$LastChangedRevision:
|
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
|
@@ -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
|
-
|
78
|
-
|
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
|
82
|
-
|
83
|
-
behaviour_class.add_shared_behaviour(
|
84
|
-
behaviour_class.add_shared_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") {}
|