rspec 0.5.3 → 0.5.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 +57 -32
- data/EXAMPLES.rd +0 -0
- data/Rakefile +22 -21
- data/bin/spec +9 -11
- data/doc/README +1 -3
- data/doc/plugin/syntax.rb +27 -5
- data/doc/src/core_team.page +22 -0
- data/doc/src/default.css +11 -11
- data/doc/src/default.template +0 -1
- data/doc/src/documentation/index.page +183 -8
- data/doc/src/documentation/meta.info +7 -7
- data/doc/src/documentation/mocks.page +168 -109
- data/doc/src/documentation/underscores.page +20 -0
- data/doc/src/examples.page +2 -1
- data/doc/src/images/David_and_Aslak.jpg +0 -0
- data/doc/src/images/Whats_That_Dude.jpg +0 -0
- data/doc/src/index.page +70 -3
- data/doc/src/meta.info +18 -11
- data/doc/src/tools/index.page +40 -134
- data/doc/src/tools/meta.info +9 -3
- data/doc/src/tools/rails.page +3 -1
- data/doc/src/tools/rake.page +20 -3
- data/doc/src/tools/rcov.page +19 -0
- data/doc/src/tools/spec.page +99 -0
- data/doc/src/tools/test2rspec.page +2 -4
- data/doc/src/tutorials/index.page +52 -0
- data/doc/src/tutorials/meta.info +31 -0
- data/doc/src/tutorials/notes.txt +252 -0
- data/doc/src/tutorials/stack.rb +11 -0
- data/doc/src/tutorials/stack_01.page +224 -0
- data/doc/src/tutorials/stack_02.page +180 -0
- data/doc/src/tutorials/stack_03.page +291 -0
- data/doc/src/tutorials/stack_04.page +203 -0
- data/doc/src/tutorials/stack_04.page.orig +123 -0
- data/doc/src/tutorials/stack_05.page +90 -0
- data/doc/src/tutorials/stack_05.page.orig +124 -0
- data/doc/src/tutorials/stack_06.page +359 -0
- data/doc/src/tutorials/stack_06.page.orig +359 -0
- data/doc/src/tutorials/stack_spec.rb +41 -0
- data/examples/airport_spec.rb +4 -4
- data/examples/{spec_framework_spec.rb → bdd_framework_spec.rb} +6 -7
- data/examples/mocking_spec.rb +0 -5
- data/examples/stack_spec.rb +6 -7
- data/examples/sugar_spec.rb +14 -0
- data/lib/spec/api.rb +5 -2
- data/lib/spec/api/helper/should_base.rb +17 -22
- data/lib/spec/api/helper/should_helper.rb +4 -3
- data/lib/spec/api/helper/should_negator.rb +3 -2
- data/lib/spec/api/mocks/argument_expectation.rb +104 -0
- data/lib/spec/api/{mock.rb → mocks/message_expectation.rb} +47 -96
- data/lib/spec/api/mocks/mock.rb +63 -0
- data/lib/spec/api/mocks/order_group.rb +21 -0
- data/lib/spec/api/sugar.rb +47 -0
- data/lib/spec/rake/rcov_verify.rb +45 -0
- data/lib/spec/rake/spectask.rb +41 -56
- data/lib/spec/runner.rb +4 -1
- data/lib/spec/runner/backtrace_tweaker.rb +24 -3
- data/lib/spec/runner/base_text_formatter.rb +28 -0
- data/lib/spec/runner/context.rb +21 -18
- data/lib/spec/runner/context_runner.rb +20 -31
- data/lib/spec/runner/execution_context.rb +3 -3
- data/lib/spec/runner/kernel_ext.rb +10 -1
- data/lib/spec/runner/option_parser.rb +32 -14
- data/lib/spec/runner/progress_bar_formatter.rb +21 -0
- data/lib/spec/runner/rdoc_formatter.rb +15 -5
- data/lib/spec/runner/reporter.rb +100 -0
- data/lib/spec/runner/specdoc_formatter.rb +20 -0
- data/lib/spec/runner/specification.rb +42 -22
- data/lib/spec/version.rb +1 -1
- data/test/rcov/rcov_testtask.rb +1 -0
- data/test/spec/api/duck_type_test.rb +4 -4
- data/test/spec/api/helper/raising_test.rb +37 -17
- data/test/spec/api/{mock_arg_constraints_test.rb → mocks/mock_arg_constraints_test.rb} +10 -4
- data/test/spec/api/mocks/mock_ordering_test.rb +62 -0
- data/test/spec/api/{mock_test.rb → mocks/mock_test.rb} +30 -7
- data/test/spec/api/mocks/null_object_test.rb +31 -0
- data/test/spec/api/sugar_test.rb +71 -0
- data/test/spec/runner/backtrace_tweaker_test.rb +52 -4
- data/test/spec/runner/context_runner_test.rb +41 -21
- data/test/spec/runner/context_test.rb +60 -32
- data/test/spec/runner/execution_context_test.rb +4 -3
- data/test/spec/runner/failure_dump_test.rb +92 -0
- data/test/spec/runner/kernel_ext_test.rb +1 -2
- data/test/spec/runner/option_parser_test.rb +48 -28
- data/test/spec/runner/progress_bar_formatter_test.rb +48 -0
- data/test/spec/runner/rdoc_formatter_test.rb +31 -4
- data/test/spec/runner/reporter_test.rb +103 -0
- data/test/spec/runner/specdoc_formatter_test.rb +50 -0
- data/test/spec/runner/specification_test.rb +49 -11
- data/test/test_helper.rb +1 -4
- metadata +46 -15
- data/doc/src/community.page +0 -7
- data/doc/src/documentation/api.page +0 -185
- data/doc/src/why_rspec.page +0 -7
- data/examples/empty_stack_spec.rb +0 -22
- data/examples/team_spec.rb +0 -30
- data/lib/spec/api/duck_type.rb +0 -16
- data/lib/spec/runner/simple_text_reporter.rb +0 -88
- data/test/rcov/rcov_verify.rb +0 -28
- data/test/spec/runner/simple_text_reporter_test.rb +0 -123
data/CHANGES
CHANGED
@@ -1,30 +1,55 @@
|
|
1
1
|
= RSpec Changelog
|
2
2
|
|
3
|
+
== Version 0.5.4 (in SVN)
|
4
|
+
Release notes go here
|
5
|
+
|
6
|
+
* Support for running a single spec with --spec
|
7
|
+
* Exitcode is now 1 unless all specs pass, in which case it's 0.
|
8
|
+
* -v, --version now both mean the same thing
|
9
|
+
* For what was verbose output (-v), use --format specdoc or -f s
|
10
|
+
* --format rdoc always runs in dry-run mode
|
11
|
+
* Removed --doc and added --format and --dry-run
|
12
|
+
* Refactored towards more pluggable formatters
|
13
|
+
* Use webgen's execute tag when generating website (more accurate)
|
14
|
+
* Fixed incorrect quoting of spec_opts in SpecTask
|
15
|
+
* Added patch to enable underscored shoulds like 1.should_equal(1) - patch from Rich Kilmer
|
16
|
+
* Removed most inherited instance method from Mock, making more methods mockable.
|
17
|
+
* Made the RCovVerify task part of the standard toolset.
|
18
|
+
* Documented Rake task and how to use it with Rcov
|
19
|
+
* Implemented <ruby></ruby> tags for website (hooking into ERB, RedCloth and syntax)
|
20
|
+
* RSpec Rake task now takes spec_opts and out params so it can be used for doc generation
|
21
|
+
* RCov integration for RSpec Rake task (#4058)
|
22
|
+
* Group all results instead of printing them several times (#4057)
|
23
|
+
* Mocks can now yield
|
24
|
+
* Various improvements to error reporting (including #4191)
|
25
|
+
* backtrace excludes rspec code - use -b to include it
|
26
|
+
* split examples into examples (passing) and failing_examples
|
27
|
+
|
3
28
|
== Version 0.5.3
|
4
29
|
The "hurry up, CoR is in two days" release.
|
5
30
|
|
6
|
-
* Don't run rcov by default
|
7
|
-
* Make separate task for running tests with RCov
|
8
|
-
* Added Rake task to fail build if coverage drops below a certain threshold
|
9
|
-
* Even more failure output cleanup (simplification)
|
10
|
-
* Added duck_type constraint for mocks
|
31
|
+
* Don't run rcov by default
|
32
|
+
* Make separate task for running tests with RCov
|
33
|
+
* Added Rake task to fail build if coverage drops below a certain threshold
|
34
|
+
* Even more failure output cleanup (simplification)
|
35
|
+
* Added duck_type constraint for mocks
|
11
36
|
|
12
37
|
== Version 0.5.2
|
13
38
|
This release has minor improvements to the commandline and fixes some gem warnings
|
14
39
|
|
15
|
-
* Readded README to avoid RDoc warnings
|
16
|
-
* Added --version switch to commandline
|
17
|
-
* More changes to the mock API
|
40
|
+
* Readded README to avoid RDoc warnings
|
41
|
+
* Added --version switch to commandline
|
42
|
+
* More changes to the mock API
|
18
43
|
|
19
44
|
== Version 0.5.1
|
20
45
|
This release is the first release of RSpec with a new website. It will look better soon.
|
21
46
|
|
22
|
-
* Added initial documentation for API
|
23
|
-
* Added website based on webgen
|
24
|
-
* Modified test task to use rcov
|
25
|
-
* Deleted unused code (thanks, rcov!)
|
26
|
-
* Various changes to the mock API
|
27
|
-
* Various improvements to failure reporting
|
47
|
+
* Added initial documentation for API
|
48
|
+
* Added website based on webgen
|
49
|
+
* Modified test task to use rcov
|
50
|
+
* Deleted unused code (thanks, rcov!)
|
51
|
+
* Various changes to the mock API,
|
52
|
+
* Various improvements to failure reporting
|
28
53
|
|
29
54
|
== Version 0.5.0
|
30
55
|
This release introduces a new API and obsolesces previous versions.
|
@@ -74,23 +99,23 @@ This release improves installation and documentation, mock integration and error
|
|
74
99
|
* Comparison errors now print the class name too.
|
75
100
|
* Mocks now take an optional +options+ parameter to specify behaviour.
|
76
101
|
* Removed __expects in favour of should_receive
|
77
|
-
* Added line number reporting in mock error messages for unreceived message expectations
|
78
|
-
* Added should_match and should_not_match
|
79
|
-
* Added a +mock+ method to Spec::Context which will create mocks that autoverify (no need to call __verify)
|
80
|
-
* Mocks now require names in the constructor to ensure sensible error messages
|
81
|
-
* Made 'spec' executable and updated usage instructions in README accordingly
|
82
|
-
* Made more parts of the Spec::Context API private to avoid accidental usage
|
102
|
+
* Added line number reporting in mock error messages for unreceived message expectations.
|
103
|
+
* Added should_match and should_not_match.
|
104
|
+
* Added a +mock+ method to Spec::Context which will create mocks that autoverify (no need to call __verify).
|
105
|
+
* Mocks now require names in the constructor to ensure sensible error messages.
|
106
|
+
* Made 'spec' executable and updated usage instructions in README accordingly.
|
107
|
+
* Made more parts of the Spec::Context API private to avoid accidental usage.
|
83
108
|
* Added more RDoc to Spec::Context.
|
84
109
|
|
85
110
|
== Version 0.1.6
|
86
111
|
|
87
112
|
More should methods.
|
88
113
|
|
89
|
-
* Added should_match and should_not_match
|
114
|
+
* Added should_match and should_not_match.
|
90
115
|
|
91
116
|
== Version 0.1.5
|
92
117
|
|
93
|
-
Included examples and tests in gem
|
118
|
+
Included examples and tests in gem.
|
94
119
|
|
95
120
|
== Version 0.1.4
|
96
121
|
|
@@ -106,23 +131,23 @@ Improved mocking:
|
|
106
131
|
|
107
132
|
This release adds some improvements to the mock API and minor syntax improvements
|
108
133
|
|
109
|
-
* Added Mock.should_expect for a more consistent DSL
|
110
|
-
* Added MockExpectation.and_returns for a better DSL
|
111
|
-
* Made Mock behave as a null object after a call to Mock.ignore_missing
|
112
|
-
* Internal syntax improvements
|
113
|
-
* Improved exception trace by adding exception class name to error message
|
114
|
-
* Renamed some tests for better consistency
|
134
|
+
* Added Mock.should_expect for a more consistent DSL.
|
135
|
+
* Added MockExpectation.and_returns for a better DSL.
|
136
|
+
* Made Mock behave as a null object after a call to Mock.ignore_missing
|
137
|
+
* Internal syntax improvements.
|
138
|
+
* Improved exception trace by adding exception class name to error message.
|
139
|
+
* Renamed some tests for better consistency.
|
115
140
|
|
116
141
|
== Version 0.1.1
|
117
142
|
|
118
143
|
This release adds some shoulds and improves error reporting
|
119
144
|
|
120
|
-
* Added should_be_same_as and should_not_be_same_as
|
121
|
-
* Improved error reporting for comparison expectations
|
145
|
+
* Added should_be_same_as and should_not_be_same_as.
|
146
|
+
* Improved error reporting for comparison expectations.
|
122
147
|
|
123
148
|
== Version 0.1.0
|
124
149
|
|
125
150
|
This is the first preview release of RSpec, a Behaviour-Driven Development library for Ruby
|
126
151
|
|
127
|
-
* Added Rake script with tasks for gems, rdoc etc
|
128
|
-
* Added an XForge task to make release go easier
|
152
|
+
* Added Rake script with tasks for gems, rdoc etc.
|
153
|
+
* Added an XForge task to make release go easier.
|
data/EXAMPLES.rd
ADDED
File without changes
|
data/Rakefile
CHANGED
@@ -5,10 +5,16 @@ require 'rake/contrib/rubyforgepublisher'
|
|
5
5
|
require 'rake/clean'
|
6
6
|
require 'rake/testtask'
|
7
7
|
require 'rake/rdoctask'
|
8
|
-
require '
|
9
|
-
require '
|
8
|
+
require 'spec/version'
|
9
|
+
require 'spec/rake/spectask'
|
10
|
+
require 'spec/rake/rcov_verify'
|
10
11
|
require 'test/rcov/rcov_testtask'
|
11
|
-
|
12
|
+
|
13
|
+
# Some of the tasks are in separate files since they are also part of the website documentation
|
14
|
+
load File.dirname(__FILE__) + '/test/tasks/examples.rake'
|
15
|
+
load File.dirname(__FILE__) + '/test/tasks/examples_specdoc.rake'
|
16
|
+
load File.dirname(__FILE__) + '/test/tasks/examples_with_rcov.rake'
|
17
|
+
load File.dirname(__FILE__) + '/test/tasks/rcov_verify.rake'
|
12
18
|
|
13
19
|
PKG_NAME = "rspec"
|
14
20
|
# Versioning scheme: MAJOR.MINOR.PATCH
|
@@ -27,11 +33,11 @@ PKG_FILES = FileList[
|
|
27
33
|
'doc/**/*'
|
28
34
|
]
|
29
35
|
|
30
|
-
task :default => [:test]
|
36
|
+
task :default => [:test]
|
31
37
|
|
32
|
-
|
33
|
-
|
34
|
-
t.
|
38
|
+
desc "Run all failing examples"
|
39
|
+
Spec::Rake::SpecTask.new('failing_examples') do |t|
|
40
|
+
t.spec_files = FileList['failing_examples/**/*_spec.rb']
|
35
41
|
end
|
36
42
|
|
37
43
|
Rake::TestTask.new do |t|
|
@@ -46,7 +52,7 @@ end
|
|
46
52
|
|
47
53
|
desc 'Generate HTML documentation'
|
48
54
|
task :doc do
|
49
|
-
sh %{pushd doc; webgen; popd
|
55
|
+
sh %{pushd doc; webgen; popd}
|
50
56
|
end
|
51
57
|
|
52
58
|
desc 'Generate RDoc'
|
@@ -54,8 +60,7 @@ rd = Rake::RDocTask.new("rdoc") do |rdoc|
|
|
54
60
|
rdoc.rdoc_dir = 'doc/output/rdoc'
|
55
61
|
rdoc.title = "RSpec"
|
56
62
|
rdoc.options << '--line-numbers' << '--inline-source' << '--main' << 'README'
|
57
|
-
rdoc.rdoc_files.include('README', 'CHANGES')
|
58
|
-
rdoc.rdoc_files.include('lib/**/*.rb', 'doc/**/*.rdoc')
|
63
|
+
rdoc.rdoc_files.include('README', 'CHANGES', 'EXAMPLES.rd', 'lib/**/*.rb')
|
59
64
|
end
|
60
65
|
|
61
66
|
spec = Gem::Specification.new do |s|
|
@@ -120,15 +125,10 @@ task :clobber do
|
|
120
125
|
rm_rf 'doc/output'
|
121
126
|
end
|
122
127
|
|
123
|
-
task :release => [:clobber, :verify_user, :verify_password, :test, :
|
128
|
+
task :release => [:clobber, :verify_user, :verify_password, :test, :publish_packages, :publish_website, :publish_news]
|
124
129
|
|
125
130
|
desc "Build the website with rdoc and rcov, but do not publish it"
|
126
|
-
task :website => [:clobber, :copy_rcov_report, :doc, :rdoc]
|
127
|
-
|
128
|
-
RCov::VerifyTask.new do |t|
|
129
|
-
t.threshold = 99.1 # Don't make it lower unless you have a damn good reason.
|
130
|
-
t.index_html = 'coverage/index.html'
|
131
|
-
end
|
131
|
+
task :website => [:clobber, :copy_rcov_report, :doc, :examples_specdoc, :rdoc]
|
132
132
|
|
133
133
|
task :copy_rcov_report => [:test_with_rcov, :rcov_verify] do
|
134
134
|
rm_rf 'doc/output/coverage'
|
@@ -138,6 +138,7 @@ end
|
|
138
138
|
|
139
139
|
task :verify_user do
|
140
140
|
raise "RUBYFORGE_USER environment variable not set!" unless ENV['RUBYFORGE_USER']
|
141
|
+
raise "BEHAVIOURDRIVEN_USER environment variable not set!" unless ENV['BEHAVIOURDRIVEN_USER']
|
141
142
|
end
|
142
143
|
|
143
144
|
task :verify_password do
|
@@ -147,16 +148,16 @@ end
|
|
147
148
|
desc "Upload Website to RubyForge"
|
148
149
|
task :publish_website => [:verify_user, :website] do
|
149
150
|
publisher = Rake::SshDirPublisher.new(
|
150
|
-
"#{ENV['
|
151
|
-
"/var/www/
|
151
|
+
"#{ENV['BEHAVIOURDRIVEN_USER']}@www.behaviourdriven.org",
|
152
|
+
"/var/www/behaviourdriven.org/htdocs/#{PKG_NAME}",
|
152
153
|
"doc/output"
|
153
154
|
)
|
154
155
|
|
155
156
|
publisher.upload
|
156
157
|
end
|
157
158
|
|
158
|
-
desc "
|
159
|
-
task :
|
159
|
+
desc "Publish gem+tgz+zip on RubyForge. You must make sure lib/version.rb is aligned with the CHANGELOG file"
|
160
|
+
task :publish_packages => [:verify_user, :verify_password, :package] do
|
160
161
|
require 'meta_project'
|
161
162
|
require 'rake/contrib/xforge'
|
162
163
|
release_files = FileList[
|
data/bin/spec
CHANGED
@@ -1,18 +1,16 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require File.dirname(__FILE__) + "/../lib/spec"
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + "/../lib/spec") # better stack traces this way
|
5
4
|
|
6
|
-
context_runner = Spec::Runner::
|
7
|
-
Spec::Runner::Context.context_runner = context_runner
|
5
|
+
$context_runner = ::Spec::Runner::OptionParser.create_context_runner(ARGV, false, STDERR, STDOUT)
|
8
6
|
|
9
|
-
ARGV.each do |
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
7
|
+
ARGV.each do |file_or_dir|
|
8
|
+
if File.lstat(file_or_dir).directory? then
|
9
|
+
(Dir.open(file_or_dir).select {|f| f =~ /.*\.rb/}).each {|file| require "#{file_or_dir}/#{file}"}
|
10
|
+
else
|
11
|
+
require file_or_dir
|
12
|
+
end
|
15
13
|
end
|
16
14
|
|
17
|
-
context_runner.run
|
15
|
+
$context_runner.run(true)
|
18
16
|
|
data/doc/README
CHANGED
data/doc/plugin/syntax.rb
CHANGED
@@ -1,6 +1,29 @@
|
|
1
|
+
# gem install syntax
|
2
|
+
require 'syntax/convertors/html'
|
3
|
+
RUBY2HTML = Syntax::Convertors::HTML.for_syntax "ruby"
|
4
|
+
|
5
|
+
class ERB
|
6
|
+
class Compiler
|
7
|
+
alias old_compile compile
|
8
|
+
|
9
|
+
def compile(s)
|
10
|
+
s.gsub! /<ruby>/n, "<notextile><%= ruby <<-EOR"
|
11
|
+
s.gsub! /<\/ruby>/n, "EOR\n%></notextile>"
|
12
|
+
s.gsub! /<ruby\s+file="(.*)"\s*\/>/, "{ruby_inline: {filename: \\1}}"
|
13
|
+
old_compile(s)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
module FileHandlers
|
19
|
+
class PageFileHandler < DefaultFileHandler
|
20
|
+
def ruby(code)
|
21
|
+
RUBY2HTML.convert(code)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
1
26
|
module Tags
|
2
|
-
# gem install syntax
|
3
|
-
require 'syntax/convertors/html'
|
4
27
|
|
5
28
|
# prints out nicely formatted ruby code in html
|
6
29
|
class RubyInliner < DefaultTag
|
@@ -9,11 +32,10 @@ module Tags
|
|
9
32
|
add_param 'filename', nil, 'The File to insert'
|
10
33
|
set_mandatory 'filename', true
|
11
34
|
|
12
|
-
CONVERTOR = Syntax::Convertors::HTML.for_syntax "ruby"
|
13
35
|
|
14
36
|
def initialize
|
15
37
|
super
|
16
|
-
register_tag(
|
38
|
+
register_tag('ruby_inline')
|
17
39
|
end
|
18
40
|
|
19
41
|
def process_tag(tag, node, ref_node)
|
@@ -32,7 +54,7 @@ module Tags
|
|
32
54
|
rescue
|
33
55
|
self.logger.error { "Given file <#{filename}> does not exist (tag specified in <#{ref_node.recursive_value( 'src' )}>" }
|
34
56
|
end
|
35
|
-
|
57
|
+
RUBY2HTML.convert(content)
|
36
58
|
end
|
37
59
|
end
|
38
60
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
---
|
2
|
+
title: The Core Team
|
3
|
+
inMenu: true
|
4
|
+
---
|
5
|
+
|
6
|
+
h2. The Core Team
|
7
|
+
|
8
|
+
* Dave Astels
|
9
|
+
* Steve Baker
|
10
|
+
* David Chelimsky
|
11
|
+
* Aslak Hellesoy
|
12
|
+
|
13
|
+
<table>
|
14
|
+
<tr>
|
15
|
+
<td><img src="images/David_and_Aslak.jpg"></td>
|
16
|
+
<td><img src="images/Whats_That_Dude.jpg"></td>
|
17
|
+
</tr>
|
18
|
+
<tr>
|
19
|
+
<td align="center">David and Aslak getting ready for 1.0</td>
|
20
|
+
<td align="center">What's that, Dude?</td>
|
21
|
+
</tr>
|
22
|
+
</table>
|
data/doc/src/default.css
CHANGED
@@ -21,7 +21,7 @@ acronym {
|
|
21
21
|
}
|
22
22
|
#container {
|
23
23
|
font-size:1.2em;
|
24
|
-
width:
|
24
|
+
width:94%;
|
25
25
|
margin:0 auto;
|
26
26
|
border-right:3px double #000;
|
27
27
|
}
|
@@ -42,7 +42,7 @@ acronym {
|
|
42
42
|
color:#c00;
|
43
43
|
}
|
44
44
|
#header h2 {
|
45
|
-
margin:
|
45
|
+
margin:30px 0 0 0;
|
46
46
|
font-size:1em;
|
47
47
|
font-weight:normal;
|
48
48
|
color:#999;
|
@@ -52,10 +52,7 @@ acronym {
|
|
52
52
|
}
|
53
53
|
#navigation {
|
54
54
|
text-align:right;
|
55
|
-
margin:
|
56
|
-
}
|
57
|
-
#navigation {
|
58
|
-
margin:0 10px 0 0;
|
55
|
+
margin:0 18px 10px auto;
|
59
56
|
padding:0;
|
60
57
|
}
|
61
58
|
#navigation li {
|
@@ -76,6 +73,9 @@ acronym {
|
|
76
73
|
color:#C00;
|
77
74
|
border-bottom:1px solid #ddd;
|
78
75
|
}
|
76
|
+
#navigation li.webgen-menu-item-selected a, #naviation li.webgen-menu-item-selected a:hover {
|
77
|
+
color: #000;
|
78
|
+
}
|
79
79
|
#content {
|
80
80
|
margin:20px 0 20px 10px;
|
81
81
|
padding:0;
|
@@ -98,7 +98,7 @@ acronym {
|
|
98
98
|
}
|
99
99
|
#content h2 {
|
100
100
|
display:block;
|
101
|
-
margin:20px
|
101
|
+
margin:20px 20px 0 0px;
|
102
102
|
padding:0;
|
103
103
|
font-family:"Trebuchet MS",arial,sans-serif;
|
104
104
|
font-size:1.1em;
|
@@ -137,9 +137,9 @@ acronym {
|
|
137
137
|
text-indent:0;
|
138
138
|
}
|
139
139
|
#content code {
|
140
|
-
font-family:
|
141
|
-
color:#
|
142
|
-
font-
|
140
|
+
font-family:monospace;
|
141
|
+
color:#222;
|
142
|
+
font-size:1.3em;
|
143
143
|
}
|
144
144
|
#content pre {
|
145
145
|
padding:10px;
|
@@ -160,7 +160,7 @@ acronym {
|
|
160
160
|
#footer {
|
161
161
|
font-size:0.9em;
|
162
162
|
font-family:arial,sans-serif;
|
163
|
-
margin:
|
163
|
+
margin:60px 18px 20px 0;
|
164
164
|
padding:5px;
|
165
165
|
border-top:1px solid #c00;
|
166
166
|
}
|
data/doc/src/default.template
CHANGED
@@ -1,13 +1,188 @@
|
|
1
1
|
---
|
2
|
-
title:
|
2
|
+
title: Core API
|
3
3
|
inMenu: true
|
4
|
+
ordering: 5
|
4
5
|
---
|
5
|
-
h2.
|
6
|
+
h2. Core API
|
6
7
|
|
7
|
-
|
8
|
+
When RSpec executes specifications, it defines a method <code>should</code> on every object in the system. This <code>should</code> method is your entry to the magic of RSpec.
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
Almost all expectation forms have a corresponding negated form. It is listed when it is supported and, unless otherwise stated, is met when ever the non-negated form would be violated.
|
11
|
+
|
12
|
+
h3. General
|
13
|
+
|
14
|
+
h4. Arbitrary Block
|
15
|
+
|
16
|
+
<ruby>
|
17
|
+
target.should.satisfy {|arg| ...}
|
18
|
+
target.should.not.satisfy {|arg| ...}
|
19
|
+
</ruby>
|
20
|
+
|
21
|
+
The supplied block is evaluated, passing <code>target</code> as the sole argument. If the block evaluates to <code>false</code>, <code>ExpectationNotMetError</code> is raised.
|
22
|
+
|
23
|
+
<ruby>
|
24
|
+
target.should.satisfy {|arg| arg > 0}
|
25
|
+
</ruby>
|
26
|
+
|
27
|
+
h4. Equality
|
28
|
+
|
29
|
+
<ruby>
|
30
|
+
target.should.equal <value>
|
31
|
+
target.should.not.equal <value>
|
32
|
+
</ruby>
|
33
|
+
|
34
|
+
The target object is compared to <code>value</code> using ==. If the result is <code>false</code>, <code>ExpectationNotMetError</code> is raised.
|
35
|
+
|
36
|
+
h4. Floating Point Comparison
|
37
|
+
|
38
|
+
<ruby>
|
39
|
+
target.should.be.close <value>, <tolerance>
|
40
|
+
target.should.not.be.close <value>, <tolerance>
|
41
|
+
</ruby>
|
42
|
+
|
43
|
+
The target object is compared to <code>value</code>. If they differ by more that <code>tolerance</code>, <code>ExpectationNotMetError</code> is raised. In the negated case, <code>ExpectationNotMetError</code> is raised if they differ by less than <code>tolerance</code>.
|
44
|
+
|
45
|
+
<ruby>
|
46
|
+
target.should.be.close 27.35, 0.05
|
47
|
+
</ruby>
|
48
|
+
|
49
|
+
h4. Identity
|
50
|
+
|
51
|
+
<ruby>
|
52
|
+
target.should.be <value>
|
53
|
+
target.should.not.be <value>
|
54
|
+
</ruby>
|
55
|
+
|
56
|
+
The target object is compared to <code>value</code> using <code>equal?</code>. If the result is <code>false</code>, <code>ExpectationNotMetError</code> is raised.
|
57
|
+
|
58
|
+
h4. Arbitrary Predicate
|
59
|
+
|
60
|
+
<ruby>
|
61
|
+
target.should.predicate [optional args]
|
62
|
+
target.should.be.predicate [optional args]
|
63
|
+
target.should.not.predicate [optional args]
|
64
|
+
target.should.not.be.predicate [optional args]
|
65
|
+
</ruby>
|
66
|
+
|
67
|
+
The message <code>predicate?</code> is sent to <code>target</code> with any supplied arguments. If the result is <code>false</code>, <code>ExpectationNotMetError</code> is raised.
|
68
|
+
|
69
|
+
For example:
|
70
|
+
|
71
|
+
<ruby>
|
72
|
+
container.should.include('a') => container.include?('a')
|
73
|
+
container.should.be.empty => container.empty?
|
74
|
+
</ruby>
|
75
|
+
|
76
|
+
h4. Pattern Matching
|
77
|
+
|
78
|
+
<ruby>
|
79
|
+
target.should.match <regex>
|
80
|
+
target.should.not.match <regex>
|
81
|
+
</ruby>
|
82
|
+
|
83
|
+
The <code>target</code> is matched against <code>regex</code>. An <code>ExpectationNotMetError</code> is raised if the match fails.
|
84
|
+
|
85
|
+
h3. Class/Type
|
86
|
+
|
87
|
+
h4. Direct Instance
|
88
|
+
|
89
|
+
<ruby>
|
90
|
+
target.should.be.an.instance.of <class>
|
91
|
+
target.should.not.be.an.instance.of <class>
|
92
|
+
</ruby>
|
93
|
+
|
94
|
+
An <code>ExpectationNotMetError</code> is raised if <code>target</code> is not or is, respectively, an direct instance of <code>class</code>. As expected this correlates to <code>target.instance_of? class</code>.
|
95
|
+
|
96
|
+
h4. Ancestor Class
|
97
|
+
|
98
|
+
<ruby>
|
99
|
+
target.should.be.a.kind.of <class>
|
100
|
+
target.should.not.be.a.kind.of <class>
|
101
|
+
</ruby>
|
102
|
+
|
103
|
+
As above, but uses <code>target.kind_of? class</code>: checking whether <code>class</code> is the direct class of <code>target</code>, or an ancestor of <code>target</code>'s direct class.
|
104
|
+
|
105
|
+
h4. Type
|
106
|
+
|
107
|
+
<ruby>
|
108
|
+
target.should.respond.to <symbol>
|
109
|
+
target.should.not.respond.to <symbol>
|
110
|
+
</ruby>
|
111
|
+
|
112
|
+
Uses <code>target.respond_to?(symbol)</code> to check whether <code>symbol</code> is the name of a message that <code>target</code> understands.
|
113
|
+
|
114
|
+
h3. Procs
|
115
|
+
|
116
|
+
h4. Raising
|
117
|
+
|
118
|
+
<ruby>
|
119
|
+
proc.should.raise <exception>
|
120
|
+
proc.should.not.raise <exception>
|
121
|
+
</ruby>
|
122
|
+
|
123
|
+
Checks that <code>proc</code> causes the named exception to be raised or not. The latter is actually one of two cases: some other exception is raised, or no exception is raised. Typically the <code>proc</code> is created in place using <code>lambda</code>. For example:
|
124
|
+
|
125
|
+
<ruby>
|
126
|
+
lambda { 3 / 0 }.should.raise ZeroDivisionError
|
127
|
+
</ruby>
|
128
|
+
|
129
|
+
There is a more general form as well.
|
130
|
+
|
131
|
+
<ruby>
|
132
|
+
proc.should.raise
|
133
|
+
proc.should.not.raise
|
134
|
+
</ruby>
|
135
|
+
|
136
|
+
These forms don't worry about what exception is raised (or not). All they are concerned with is that some except was raised, or that no exception was.
|
137
|
+
|
138
|
+
h4. Throwing
|
139
|
+
|
140
|
+
<ruby>
|
141
|
+
proc.should.throw <symbol>
|
142
|
+
proc.should.not.throw <symbol>
|
143
|
+
</ruby>
|
144
|
+
|
145
|
+
Similar to the above, but checks that <code>symbol</code> is thrown from within <code>proc</code>, or not. The latter is actually one of two cases: some other symbol is thrown, or no symbol is thrown.
|
146
|
+
|
147
|
+
<ruby>
|
148
|
+
proc.should.not.throw
|
149
|
+
</ruby>
|
150
|
+
|
151
|
+
This form is more specific. It checks that no symbol is thrown from within <code>proc</code>.
|
152
|
+
|
153
|
+
h3. Collections
|
154
|
+
|
155
|
+
h4. Containment
|
156
|
+
|
157
|
+
<ruby>
|
158
|
+
target.should.include <object>
|
159
|
+
target.should.not.include <object>
|
160
|
+
</ruby>
|
161
|
+
|
162
|
+
This is simply a specific case of the arbitrary predicate form. It uses <code>target.include?(object)</code> and raises an <code>ExpectationNotMetError</code> if that returns false.
|
163
|
+
|
164
|
+
The remaining collection forms are a little more involved. They rely on two things: 1) <code>target</code> responds to the message <code>things</code> by returning an object that 2) responds to either <code>length</code> or <code>size</code>, which return a number that is a measure of size. Currently <code>length</code> is used if is appropriate, otherwise <code>size</code> is attempted.
|
165
|
+
|
166
|
+
h4. Exact Size
|
167
|
+
|
168
|
+
<ruby>
|
169
|
+
target.should.have(<number>).things
|
170
|
+
</ruby>
|
171
|
+
|
172
|
+
The <code>things</code> of <code>target</code> has a length/size of exactly <code>number</code>.
|
173
|
+
|
174
|
+
h4. Lower Bound
|
175
|
+
|
176
|
+
<ruby>
|
177
|
+
target.should.have.at.least(<number>).things
|
178
|
+
</ruby>
|
179
|
+
|
180
|
+
The <code>things</code> of <code>target</code> has a length/size of no less than <code>number</code>.
|
181
|
+
|
182
|
+
h4. Upper Bound
|
183
|
+
|
184
|
+
<ruby>
|
185
|
+
target.should.have.at.most(<number>).things
|
186
|
+
</ruby>
|
187
|
+
|
188
|
+
The <code>things</code> of <code>target</code> has a length/size of no more than <code>number</code>.
|