rspec 0.7.3 → 0.7.4
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 +23 -1
- data/Rakefile +11 -9
- data/bin/spec +0 -1
- data/lib/spec.rb +1 -0
- data/lib/spec/callback.rb +3 -0
- data/lib/spec/callback/callback_container.rb +60 -0
- data/lib/spec/callback/extensions/module.rb +24 -0
- data/lib/spec/callback/extensions/object.rb +33 -0
- data/lib/spec/expectations/diff.rb +10 -14
- data/lib/spec/expectations/extensions.rb +1 -3
- data/lib/spec/expectations/extensions/numeric.rb +6 -1
- data/lib/spec/expectations/extensions/object.rb +72 -18
- data/lib/spec/expectations/should/base.rb +27 -5
- data/lib/spec/expectations/should/have.rb +2 -2
- data/lib/spec/expectations/should/should.rb +5 -4
- data/lib/spec/mocks/error_generator.rb +23 -12
- data/lib/spec/mocks/message_expectation.rb +4 -0
- data/lib/spec/mocks/mock_handler.rb +9 -8
- data/lib/spec/rake/spectask.rb +2 -1
- data/lib/spec/runner.rb +0 -1
- data/lib/spec/runner/backtrace_tweaker.rb +1 -0
- data/lib/spec/runner/context_eval.rb +1 -1
- data/lib/spec/runner/formatter/base_text_formatter.rb +1 -1
- data/lib/spec/runner/formatter/html_formatter.rb +94 -74
- data/lib/spec/runner/option_parser.rb +5 -1
- data/lib/spec/runner/specification.rb +64 -37
- data/lib/spec/version.rb +3 -3
- data/vendor/{selenium → web_spec/selenium}/README.txt +0 -0
- data/vendor/{selenium → web_spec/selenium}/find_rspecs_home_page.rb +0 -0
- data/vendor/{selenium → web_spec/selenium}/rspec_selenium.rb +0 -0
- data/vendor/{selenium → web_spec/selenium}/start_browser_once.patch +0 -0
- data/vendor/{watir → web_spec/watir}/README.txt +2 -2
- data/vendor/web_spec/watir/find_rspecs_home_page.rb +27 -0
- data/vendor/{watir → web_spec/watir}/find_rspecs_home_page.txt +0 -0
- data/vendor/{watir → web_spec/watir}/rspec_watir.rb +13 -12
- data/vendor/web_spec/web_test_html_formatter.rb +8 -0
- data/vendor/web_spec/web_test_html_formatter_helper.rb +26 -0
- data/vendor/web_spec/web_test_html_formatter_osx_helper.rb +19 -0
- data/vendor/web_spec/web_test_html_formatter_win_helper.rb +14 -0
- metadata +19 -14
- data/lib/spec/expectations/extensions/inspect_for_expectation_not_met_error.rb +0 -15
- data/lib/spec/expectations/extensions/symbol.rb +0 -5
- data/lib/spec/runner/extensions/object.rb +0 -21
- data/vendor/watir/find_rspecs_home_page.rb +0 -21
data/CHANGES
CHANGED
@@ -1,6 +1,28 @@
|
|
1
1
|
= RSpec Changelog
|
2
2
|
|
3
|
-
== Version 0.7.
|
3
|
+
== Version 0.7.4
|
4
|
+
|
5
|
+
This release features a complete redesign of the reports generated with --format html.
|
6
|
+
As usual there are many bug fixes - mostly related to spec/rails.
|
7
|
+
|
8
|
+
* Applied [#7010] Fixes :spacer_template does not work w/ view spec (patch from Shintaro Kakutani)
|
9
|
+
* Applied [#6798] ensure two ':' in the first backtrace line for Emacs's 'next-error' command (patch from Kouhei Sutou)
|
10
|
+
* Added Much nicer reports to generated website
|
11
|
+
* Much nicer reports with --format --html (patch from Luke Redpath)
|
12
|
+
* Applied [#6959] Calls to render and redirect in controllers should return true
|
13
|
+
* Fixed [#6981] helper method is not available in partial template.
|
14
|
+
* Added [#6978] mock should tell you the expected and actual args when receiving the right message with the wrong args
|
15
|
+
* Added the possibility to tweak the output of the HtmlFormatter (by overriding extra_failure_content).
|
16
|
+
* Fixed [#6936] View specs don't include ApplicationHelper by default
|
17
|
+
* Fixed [#6903] Rendering a partial in a view makes the view spec blow up
|
18
|
+
* Added callback library from Brian Takita
|
19
|
+
* Added [#6925] support controller.should_render :action_name
|
20
|
+
* Fixed [#6884] intermittent errors related to method binding
|
21
|
+
* Fixed [#6870] rspec on edge rails spec:controller fixture loading fails
|
22
|
+
* Using obj.inspect for all messages
|
23
|
+
* Improved performance by getting rid of instance_exec (instance_eval is good enough because we never need to pass it args)
|
24
|
+
|
25
|
+
== Version 0.7.3
|
4
26
|
|
5
27
|
Almost normal bug fix/new feature release.
|
6
28
|
|
data/Rakefile
CHANGED
@@ -21,11 +21,9 @@ PKG_FILES = FileList[
|
|
21
21
|
'lib/**/*.rb',
|
22
22
|
'test/**/*.rb',
|
23
23
|
'examples/**/*',
|
24
|
-
'vendor/
|
25
|
-
'vendor/
|
26
|
-
'vendor/
|
27
|
-
'vendor/selenium/*.patch',
|
28
|
-
'vendor/selenium/*.txt'
|
24
|
+
'vendor/web_spec/**/*.rb',
|
25
|
+
'vendor/web_spec/**/*.txt',
|
26
|
+
'vendor/web_spec/**/*.patch'
|
29
27
|
]
|
30
28
|
|
31
29
|
task :default => [:spec, :verify_rcov]
|
@@ -33,12 +31,18 @@ task :default => [:spec, :verify_rcov]
|
|
33
31
|
desc "Run all specs"
|
34
32
|
Spec::Rake::SpecTask.new do |t|
|
35
33
|
t.spec_files = FileList['spec/**/*_spec.rb', 'vendor/RSpec.tmbundle/Support/spec/*_spec.rb']
|
36
|
-
t.spec_opts = ['--
|
34
|
+
t.spec_opts = ['--color','--backtrace']
|
37
35
|
t.rcov = true
|
38
36
|
t.rcov_dir = 'doc/output/coverage'
|
39
37
|
t.rcov_opts = ['--exclude', 'spec\/spec,bin\/spec,bin\/drbspec,examples']
|
40
38
|
end
|
41
39
|
|
40
|
+
desc "Run all specs and store html output in doc/output/report.html"
|
41
|
+
Spec::Rake::SpecTask.new('spec_html') do |t|
|
42
|
+
t.spec_files = FileList['spec/**/*_spec.rb', 'vendor/RSpec.tmbundle/Support/spec/*_spec.rb']
|
43
|
+
t.spec_opts = ['--diff','--format html','--backtrace','--out doc/output/report.html']
|
44
|
+
end
|
45
|
+
|
42
46
|
desc "Run all failing examples"
|
43
47
|
Spec::Rake::SpecTask.new('failing_examples') do |t|
|
44
48
|
t.spec_files = FileList['failing_examples/**/*_spec.rb']
|
@@ -203,7 +207,7 @@ task :commit_ok do |t|
|
|
203
207
|
end
|
204
208
|
|
205
209
|
desc "Build the website, but do not publish it"
|
206
|
-
task :website => [:clobber, :verify_rcov, :
|
210
|
+
task :website => [:clobber, :verify_rcov, :spec_html, :webgen, :failing_examples_with_html, :examples_specdoc, :rdoc]
|
207
211
|
|
208
212
|
task :verify_user do
|
209
213
|
raise "RUBYFORGE_USER environment variable not set!" unless ENV['RUBYFORGE_USER']
|
@@ -244,7 +248,6 @@ task :publish_packages => [:verify_user, :package] do
|
|
244
248
|
Rake::XForge::Release.new(MetaProject::Project::XForge::RubyForge.new(PKG_NAME)) do |xf|
|
245
249
|
# Never hardcode user name and password in the Rakefile!
|
246
250
|
xf.user_name = ENV['RUBYFORGE_USER']
|
247
|
-
xf.password = ENV['RUBYFORGE_PASSWORD']
|
248
251
|
xf.files = release_files.to_a
|
249
252
|
xf.release_name = "RSpec #{PKG_VERSION}"
|
250
253
|
end
|
@@ -257,6 +260,5 @@ task :publish_news => [:verify_user] do
|
|
257
260
|
Rake::XForge::NewsPublisher.new(MetaProject::Project::XForge::RubyForge.new(PKG_NAME)) do |news|
|
258
261
|
# Never hardcode user name and password in the Rakefile!
|
259
262
|
news.user_name = ENV['RUBYFORGE_USER']
|
260
|
-
news.password = ENV['RUBYFORGE_PASSWORD']
|
261
263
|
end
|
262
264
|
end
|
data/bin/spec
CHANGED
data/lib/spec.rb
CHANGED
@@ -0,0 +1,60 @@
|
|
1
|
+
module Callback
|
2
|
+
class CallbackContainer
|
3
|
+
def initialize
|
4
|
+
@callback_registry = Hash.new do |hash, key|
|
5
|
+
hash[key] = Array.new
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
# Defines the callback with the key in this container.
|
10
|
+
def define(key, callback_proc=nil, &callback_block)
|
11
|
+
callback = extract_callback(callback_block, callback_proc) do
|
12
|
+
raise "You must define the callback that accepts the call method."
|
13
|
+
end
|
14
|
+
@callback_registry[key] << callback
|
15
|
+
callback
|
16
|
+
end
|
17
|
+
|
18
|
+
# Undefines the callback with the key in this container.
|
19
|
+
def undefine(key, callback_proc)
|
20
|
+
callback = extract_callback(callback_proc) do
|
21
|
+
raise "You may only undefine callbacks that use the call method."
|
22
|
+
end
|
23
|
+
@callback_registry[key].delete callback
|
24
|
+
callback
|
25
|
+
end
|
26
|
+
|
27
|
+
# Notifies the callbacks for the key. Arguments may be passed.
|
28
|
+
# An error handler may be passed in as a block. If there is an error, the block is called with
|
29
|
+
# error object as an argument.
|
30
|
+
# An array of the return values of the callbacks is returned.
|
31
|
+
def notify(key, *args, &error_handler)
|
32
|
+
@callback_registry[key].collect do |callback|
|
33
|
+
begin
|
34
|
+
callback.call(*args)
|
35
|
+
rescue Exception => e
|
36
|
+
yield(e) if error_handler
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# Clears all of the callbacks in this container.
|
42
|
+
def clear
|
43
|
+
@callback_registry.clear
|
44
|
+
end
|
45
|
+
|
46
|
+
protected
|
47
|
+
def extract_callback(first_choice_callback, second_choice_callback = nil)
|
48
|
+
callback = nil
|
49
|
+
if first_choice_callback
|
50
|
+
callback = first_choice_callback
|
51
|
+
elsif second_choice_callback
|
52
|
+
callback = second_choice_callback
|
53
|
+
end
|
54
|
+
unless callback.respond_to? :call
|
55
|
+
yield
|
56
|
+
end
|
57
|
+
return callback
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Callback
|
2
|
+
module ModuleMethods
|
3
|
+
# For each event_name submitted, defines a callback event with this name.
|
4
|
+
# Client code can then register as a callback listener using object.event_name.
|
5
|
+
def callback_events(*event_names)
|
6
|
+
event_names.each do |event_name|
|
7
|
+
define_callback_event(event_name)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
def define_callback_event(event_name)
|
13
|
+
module_eval <<-EOS
|
14
|
+
def #{event_name}(&block)
|
15
|
+
register_callback(:#{event_name}, &block)
|
16
|
+
end
|
17
|
+
EOS
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class Module
|
23
|
+
include Callback::ModuleMethods
|
24
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Callback
|
2
|
+
module InstanceMethods
|
3
|
+
# Registers a callback for the event on the object. The callback can either be a block or a proc.
|
4
|
+
# When the callbacks are notified, the return value of the proc is passed to the caller.
|
5
|
+
def register_callback(event, callback_proc=nil, &callback_block)
|
6
|
+
callbacks.define(event, callback_proc, &callback_block)
|
7
|
+
end
|
8
|
+
|
9
|
+
# Removes the callback from the event. The callback proc must be the same
|
10
|
+
# object as the one that was passed to register_callback.
|
11
|
+
def unregister_callback(event, callback_proc)
|
12
|
+
callbacks.undefine(event, callback_proc)
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
# Notifies the callbacks registered with the event on the object. Arguments can be passed to the callbacks.
|
17
|
+
# An error handler may be passed in as a block. If there is an error, the block is called with
|
18
|
+
# error object as an argument.
|
19
|
+
# An array of the return values of the callbacks is returned.
|
20
|
+
def notify_callbacks(event, *args, &error_handler)
|
21
|
+
callbacks.notify(event, *args, &error_handler)
|
22
|
+
end
|
23
|
+
|
24
|
+
# The CallbackContainer for this object.
|
25
|
+
def callbacks
|
26
|
+
@callbacks ||= CallbackContainer.new
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class Object
|
32
|
+
include Callback::InstanceMethods
|
33
|
+
end
|
@@ -9,23 +9,19 @@ module Spec
|
|
9
9
|
@@differ = differ
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
elsif ! @target.is_a? Proc
|
21
|
-
result << "\nDiff:" << @@differ.diff_as_object(@target,expected)
|
22
|
-
end
|
12
|
+
alias old_default_message default_message
|
13
|
+
def default_message(expectation, expected=:no_expectation_specified)
|
14
|
+
result = old_default_message(expectation, expected)
|
15
|
+
if expected != :no_expectation_specified
|
16
|
+
if expected.is_a?(String)
|
17
|
+
result << "\nDiff:" << @@differ.diff_as_string(@target.to_s, expected) unless @@differ.nil?
|
18
|
+
elsif ! @target.is_a? Proc
|
19
|
+
result << "\nDiff:" << @@differ.diff_as_object(@target, expected) unless @@differ.nil?
|
23
20
|
end
|
24
|
-
|
25
|
-
result
|
26
21
|
end
|
27
|
-
end
|
28
22
|
|
23
|
+
result
|
24
|
+
end
|
29
25
|
end
|
30
26
|
end
|
31
27
|
end
|
@@ -1,49 +1,103 @@
|
|
1
1
|
module Spec
|
2
2
|
module Expectations
|
3
|
+
# rspec adds all of these expectations to every Object (and,
|
4
|
+
# implicitly, every Class).
|
3
5
|
module ObjectExpectations
|
6
|
+
|
7
|
+
# Supports the following expectations:
|
8
|
+
# receiver.should == expected #any value
|
9
|
+
# Passes if (target == expected)
|
10
|
+
#
|
11
|
+
# target.should =~ expected #a regexp
|
12
|
+
# Passes if (target =~ expected), where expected
|
13
|
+
# is a Regexp.
|
14
|
+
#
|
15
|
+
# NOTE that this does NOT support target.should != expected.
|
16
|
+
# Instead, use target.should_not == expected
|
4
17
|
def should
|
5
18
|
Should::Should.new self
|
6
19
|
end
|
7
20
|
|
21
|
+
# Supports the following expectations:
|
22
|
+
# target.should_not == expected #any value
|
23
|
+
# Passes unless (target == expected)
|
24
|
+
#
|
25
|
+
# target.should_not =~ expected #a regexp
|
26
|
+
# Passes unless (target =~ expected), where expected
|
27
|
+
# is a Regexp.
|
8
28
|
def should_not
|
9
29
|
should.not
|
10
30
|
end
|
11
31
|
|
12
|
-
|
13
|
-
|
32
|
+
# Passes if target.equal?(expected)
|
33
|
+
def should_equal(expected)
|
34
|
+
should.equal(expected)
|
14
35
|
end
|
15
36
|
|
16
|
-
|
17
|
-
|
37
|
+
# Passes unless target.equal?(expected)
|
38
|
+
def should_not_equal(expected)
|
39
|
+
should.not.equal(expected)
|
18
40
|
end
|
19
41
|
|
20
|
-
|
21
|
-
|
42
|
+
# Passes if target.eql?(expected)
|
43
|
+
def should_eql(expected)
|
44
|
+
should.eql(expected)
|
22
45
|
end
|
23
46
|
|
24
|
-
|
25
|
-
|
47
|
+
# Passes unless target.eql?(expected)
|
48
|
+
def should_not_eql(expected)
|
49
|
+
should.not.eql(expected)
|
26
50
|
end
|
27
51
|
|
28
|
-
|
29
|
-
|
52
|
+
# Specify that the receiver should have a
|
53
|
+
# specified number of items in a named collection. For example:
|
54
|
+
#
|
55
|
+
# team.should_have(40).players
|
56
|
+
#
|
57
|
+
# Passes if team.players.size == 40.
|
58
|
+
#
|
59
|
+
# Works for collections with size() and/or length() methods.
|
60
|
+
def should_have(expected)
|
61
|
+
should.have(expected)
|
30
62
|
end
|
31
63
|
alias_method :should_have_exactly, :should_have
|
32
64
|
|
33
|
-
|
34
|
-
|
65
|
+
# Specify that the receiver should have at least a
|
66
|
+
# specified number of items in a named collection. For example:
|
67
|
+
#
|
68
|
+
# team.should_have_at_least(10).players
|
69
|
+
#
|
70
|
+
# Passes if team.players.size == 10 (or more)
|
71
|
+
#
|
72
|
+
# Fails if team.players.size == 9 (or less)
|
73
|
+
#
|
74
|
+
# Works for collections with size() and/or length() methods.
|
75
|
+
def should_have_at_least(expected)
|
76
|
+
should.have.at_least(expected)
|
35
77
|
end
|
36
78
|
|
37
|
-
|
38
|
-
|
79
|
+
# Specify that the receiver should have at most a
|
80
|
+
# specified number of items in a named collection. For example:
|
81
|
+
#
|
82
|
+
# team.should_have_at_most(10).players
|
83
|
+
#
|
84
|
+
# Passes if team.players.size == 10 (or less)
|
85
|
+
#
|
86
|
+
# Fails if team.players.size == 11 (or more)
|
87
|
+
#
|
88
|
+
# Works for collections with size() and/or length() methods.
|
89
|
+
def should_have_at_most(expected)
|
90
|
+
should.have.at_most(expected)
|
39
91
|
end
|
40
92
|
|
41
|
-
|
42
|
-
|
93
|
+
# Passes if receiver.include?(expected)
|
94
|
+
def should_include(expected)
|
95
|
+
should.include(expected)
|
43
96
|
end
|
44
97
|
|
45
|
-
|
46
|
-
|
98
|
+
# Passes unless receiver.include?(expected)
|
99
|
+
def should_not_include(expected)
|
100
|
+
should.not.include(expected)
|
47
101
|
end
|
48
102
|
|
49
103
|
def should_change(receiver, message)
|
@@ -2,13 +2,35 @@ module Spec
|
|
2
2
|
module Expectations
|
3
3
|
module Should
|
4
4
|
class Base
|
5
|
-
|
6
|
-
|
5
|
+
|
6
|
+
def <(expected)
|
7
|
+
__delegate_method_missing_to_target "<", "<", expected
|
8
|
+
end
|
9
|
+
|
10
|
+
def <=(expected)
|
11
|
+
__delegate_method_missing_to_target "<=", "<=", expected
|
12
|
+
end
|
13
|
+
|
14
|
+
def ==(expected)
|
15
|
+
__delegate_method_missing_to_target "==", "==", expected
|
16
|
+
end
|
17
|
+
|
18
|
+
def =~(expected)
|
19
|
+
__delegate_method_missing_to_target "=~", "=~", expected
|
20
|
+
end
|
21
|
+
|
22
|
+
def >=(expected)
|
23
|
+
__delegate_method_missing_to_target ">=", ">=", expected
|
24
|
+
end
|
25
|
+
|
26
|
+
def >(expected)
|
27
|
+
__delegate_method_missing_to_target ">", ">", expected
|
28
|
+
end
|
7
29
|
|
8
30
|
def default_message(expectation, expected=:no_expectation_specified)
|
9
|
-
message = "#{@target.
|
31
|
+
message = "#{@target.inspect} #{expectation}"
|
10
32
|
if (expected != :no_expectation_specified)
|
11
|
-
message << " " << expected.
|
33
|
+
message << " " << expected.inspect
|
12
34
|
end
|
13
35
|
message
|
14
36
|
end
|
@@ -21,7 +43,7 @@ module Spec
|
|
21
43
|
["#{original_sym}?", "#{original_sym}s?"].each do |alternate_sym|
|
22
44
|
return alternate_sym.to_s if @target.respond_to?(alternate_sym.to_s)
|
23
45
|
end
|
24
|
-
return
|
46
|
+
return ["<","<=",">=",">","==","=~"].include?(original_sym) ? original_sym : "#{original_sym}?"
|
25
47
|
end
|
26
48
|
|
27
49
|
def method_missing(original_sym, *args, &block)
|