rspec 0.7.2 → 0.7.5.1
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 +72 -1
- data/EXAMPLES.rd +6 -0
- data/README +27 -6
- data/Rakefile +32 -81
- data/bin/drbspec +3 -0
- data/bin/spec +2 -3
- data/examples/file_accessor_spec.rb +1 -1
- data/examples/greeter_spec.rb +30 -0
- data/examples/helper_method_example.rb +1 -1
- data/examples/io_processor_spec.rb +1 -1
- data/examples/mocking_example.rb +1 -1
- data/examples/partial_mock_example.rb +1 -1
- data/examples/predicate_example.rb +1 -1
- data/examples/setup_teardown_example.rb +34 -0
- data/examples/spec_helper.rb +1 -0
- data/examples/stack_spec.rb +1 -1
- data/examples/stubbing_example.rb +1 -1
- data/examples/test_case_spec.rb +1 -1
- 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/callback.rb +3 -0
- data/lib/spec/expectations/diff.rb +10 -14
- data/lib/spec/expectations/extensions/numeric.rb +17 -3
- data/lib/spec/expectations/extensions/object.rb +145 -0
- data/lib/spec/expectations/extensions/proc.rb +57 -0
- data/lib/spec/expectations/extensions/string.rb +22 -0
- data/lib/spec/expectations/extensions.rb +2 -2
- data/lib/spec/expectations/message_builder.rb +13 -0
- data/lib/spec/expectations/should/base.rb +29 -10
- data/lib/spec/expectations/should/change.rb +69 -0
- data/lib/spec/expectations/should/have.rb +94 -37
- data/lib/spec/expectations/should/not.rb +6 -2
- data/lib/spec/expectations/should/should.rb +9 -5
- data/lib/spec/expectations/should.rb +1 -0
- data/lib/spec/expectations/sugar.rb +2 -2
- data/lib/spec/expectations.rb +28 -0
- data/lib/spec/mocks/error_generator.rb +23 -12
- data/lib/spec/mocks/message_expectation.rb +18 -15
- data/lib/spec/mocks/mock_handler.rb +10 -9
- data/lib/spec/mocks/mock_methods.rb +1 -1
- data/lib/spec/rake/spectask.rb +8 -2
- data/lib/spec/runner/backtrace_tweaker.rb +34 -25
- data/lib/spec/runner/context.rb +56 -7
- data/lib/spec/runner/context_eval.rb +33 -3
- data/lib/spec/runner/context_runner.rb +24 -11
- data/lib/spec/runner/drb_command_line.rb +21 -0
- data/lib/spec/runner/execution_context.rb +1 -0
- data/lib/spec/runner/extensions/kernel.rb +2 -0
- data/lib/spec/runner/extensions/object.rb +26 -18
- 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/heckle_runner.rb +55 -0
- data/lib/spec/runner/option_parser.rb +15 -3
- data/lib/spec/runner/reporter.rb +13 -8
- data/lib/spec/runner/specification.rb +67 -42
- data/lib/spec/runner.rb +1 -1
- data/lib/spec/version.rb +6 -5
- data/lib/spec.rb +1 -0
- metadata +20 -19
- data/lib/spec/expectations/extensions/inspect_for_expectation_not_met_error.rb +0 -14
- data/lib/spec/expectations/extensions/symbol.rb +0 -5
- data/vendor/selenium/README.txt +0 -23
- data/vendor/selenium/find_rspecs_home_page.rb +0 -23
- data/vendor/selenium/rspec_selenium.rb +0 -33
- data/vendor/selenium/start_browser_once.patch +0 -65
- data/vendor/watir/README.txt +0 -32
- data/vendor/watir/find_rspecs_home_page.rb +0 -21
- data/vendor/watir/find_rspecs_home_page.txt +0 -15
- data/vendor/watir/rspec_watir.rb +0 -45
data/CHANGES
CHANGED
@@ -1,6 +1,77 @@
|
|
1
1
|
= RSpec Changelog
|
2
2
|
|
3
|
-
== Version 0.7.
|
3
|
+
== Version 0.7.5.1
|
4
|
+
|
5
|
+
Bug fix release to allow downloads of rspec gem using rubygems 0.9.1.
|
6
|
+
|
7
|
+
== Version 0.7.5
|
8
|
+
|
9
|
+
This release adds support for Heckle - Seattle'rb's code mutation tool.
|
10
|
+
There are also several bug fixes to the RSpec core and the RSpec on Rails plugin.
|
11
|
+
|
12
|
+
* Removed svn:externals on rails versions and plugins
|
13
|
+
* Applied [#7345] Adding context_setup and context_teardown, with specs and 100% rcov
|
14
|
+
* Applied [#7320] [PATCH] Allow XHR requests in controller specs to render RJS templates
|
15
|
+
* Applied [#7319] Migration code uses drop_column when it should use remove_column (patch from Pat Maddox)
|
16
|
+
* Added support for Heckle
|
17
|
+
* Applied [#7282] dump results even if spec is interrupted (patch from Kouhei Sutou)
|
18
|
+
* Applied [#7277] model.should_have(n).errors_on(:attribute) (patch from Wilson Bilkovich)
|
19
|
+
* Applied [#7270] RSpec render_partial colliding with simply_helpful (patch from David Goodlad)
|
20
|
+
* Added [#7250] stubs should support throwing
|
21
|
+
* Added [#7249] stubs should support yielding
|
22
|
+
* Fixed [#6760] fatal error when accessing nested finders in rspec
|
23
|
+
* Fixed [#7179] script/generate rspec_resource generates incorrect helper name
|
24
|
+
* Added preliminary support for assert_select (response.should_have)
|
25
|
+
* Fixed [#6971] and_yield does not work when the arity is -1
|
26
|
+
* Fixed [#6898] Can we separate rspec from the plugins?
|
27
|
+
* Added [#7025] should_change should accept a block
|
28
|
+
* Applied [#6989] partials with locals (patch from Micah Martin)
|
29
|
+
* Applied [#7023] Typo in team.page
|
30
|
+
|
31
|
+
== Version 0.7.4
|
32
|
+
|
33
|
+
This release features a complete redesign of the reports generated with --format html.
|
34
|
+
As usual there are many bug fixes - mostly related to spec/rails.
|
35
|
+
|
36
|
+
* Applied [#7010] Fixes :spacer_template does not work w/ view spec (patch from Shintaro Kakutani)
|
37
|
+
* Applied [#6798] ensure two ':' in the first backtrace line for Emacs's 'next-error' command (patch from Kouhei Sutou)
|
38
|
+
* Added Much nicer reports to generated website
|
39
|
+
* Much nicer reports with --format --html (patch from Luke Redpath)
|
40
|
+
* Applied [#6959] Calls to render and redirect in controllers should return true
|
41
|
+
* Fixed [#6981] helper method is not available in partial template.
|
42
|
+
* Added [#6978] mock should tell you the expected and actual args when receiving the right message with the wrong args
|
43
|
+
* Added the possibility to tweak the output of the HtmlFormatter (by overriding extra_failure_content).
|
44
|
+
* Fixed [#6936] View specs don't include ApplicationHelper by default
|
45
|
+
* Fixed [#6903] Rendering a partial in a view makes the view spec blow up
|
46
|
+
* Added callback library from Brian Takita
|
47
|
+
* Added [#6925] support controller.should_render :action_name
|
48
|
+
* Fixed [#6884] intermittent errors related to method binding
|
49
|
+
* Fixed [#6870] rspec on edge rails spec:controller fixture loading fails
|
50
|
+
* Using obj.inspect for all messages
|
51
|
+
* Improved performance by getting rid of instance_exec (instance_eval is good enough because we never need to pass it args)
|
52
|
+
|
53
|
+
== Version 0.7.3
|
54
|
+
|
55
|
+
Almost normal bug fix/new feature release.
|
56
|
+
|
57
|
+
A couple of things you need to change in your rails specs:
|
58
|
+
# spec_helper.rb is a little different (see http://rspec.rubyforge.org/upgrade.html)
|
59
|
+
# use controller.should_render before OR after the action (controller.should_have_rendered is deprecated)
|
60
|
+
|
61
|
+
* Applied [#6577] messy mock backtrace when frozen to edge rails (patch from Jay Levitt)
|
62
|
+
* Fixed [#6674] rspec_on_rails fails on @session deprecation warning
|
63
|
+
* Fixed [#6780] routing() was failing...fix included - works for 1.1.6 and edge (1.2)
|
64
|
+
* Fixed [#6835] bad message with arbitrary predicate
|
65
|
+
* Added [#6731] Partial templates rendered
|
66
|
+
* Fixed [#6713] helper methods not rendered in view tests?
|
67
|
+
* Fixed [#6707] cannot run controller / helper tests via rails_spec or spec only works with rake
|
68
|
+
* Applied [#6417] lambda {...}.should_change(receiver, :message) (patch from Wilson Bilkovich)
|
69
|
+
* Eliminated dependency on ZenTest
|
70
|
+
* Fixed [#6650] Reserved characters in the TextMate bundle break svn on Win32
|
71
|
+
* Fixed [#6643] script/generate rspec_controller: invalid symbol generation for 'controller_name' for *modularized* controllers
|
72
|
+
* The script/rails_spec command has been moved to bin/drbspec in RSpec core (installed by the gem)
|
73
|
+
|
74
|
+
== Version 0.7.2
|
4
75
|
|
5
76
|
This release introduces a brand new RSpec bundle for TextMate, plus some small bugfixes.
|
6
77
|
|
data/EXAMPLES.rd
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# A FileAccessor
|
2
2
|
# * should open a file and pass it to the processor's process method
|
3
|
+
# Greeter
|
4
|
+
# * should say Hi to person
|
5
|
+
# * should say Hi to nobody
|
3
6
|
# a context with helper a method
|
4
7
|
# * should make that method available to specs
|
5
8
|
# An IoProcessor
|
@@ -17,6 +20,9 @@
|
|
17
20
|
# BDD framework
|
18
21
|
# * should be adopted quickly
|
19
22
|
# * should be intuitive
|
23
|
+
# State created in context_setup
|
24
|
+
# * should be accessible from spec
|
25
|
+
# * should not have sideffects
|
20
26
|
# A stack which is neither empty nor full
|
21
27
|
# * should add to the top when sent 'push'
|
22
28
|
# * should return the top item when sent 'peek'
|
data/README
CHANGED
@@ -1,4 +1,28 @@
|
|
1
|
-
==
|
1
|
+
== RSpec
|
2
|
+
|
3
|
+
RSpec is a framework for developing ruby applications using Behaviour Driven Development.
|
4
|
+
|
5
|
+
== Expectations
|
6
|
+
|
7
|
+
RSpec adds expectation methods to every object, with specific types of expectations
|
8
|
+
set on specific classes. For example ...
|
9
|
+
|
10
|
+
<code>
|
11
|
+
@message = "some message"
|
12
|
+
@message.should == "some message"
|
13
|
+
</code>
|
14
|
+
|
15
|
+
... will be available on every object, whereas ...
|
16
|
+
|
17
|
+
<code>
|
18
|
+
proc { @number = @number + 1 }.should_change{ @number }.by(1)
|
19
|
+
</code>
|
20
|
+
|
21
|
+
... will only be available for proc objects.
|
22
|
+
|
23
|
+
See Spec::Expectations for details on the different expectations you can set.
|
24
|
+
|
25
|
+
== Building the RSpec gem
|
2
26
|
rake gem
|
3
27
|
gem install pkg/rspec-0.x.x.gem (you may have to sudo)
|
4
28
|
|
@@ -13,16 +37,13 @@ In order to run RSpec's full suite of specs (rake pre_commit) you must install t
|
|
13
37
|
* diff-lcs # Required if you use the --diff switch
|
14
38
|
* win32console # Required by the --colour switch if you're on Windows
|
15
39
|
* meta_project # Required in order to make releases at RubyForge
|
16
|
-
*
|
17
|
-
* ZenTest # Required by RSpec on Rails specs
|
18
|
-
* Rails # Required by RSpec on Rails specs
|
19
|
-
|
20
|
-
You must also install SQLite - which is needed to test the Rails plugin.
|
40
|
+
* heckle # Required if you use the --heckle switch
|
21
41
|
|
22
42
|
Note that RSpec itself - once built - doesn't have any dependencies outside the Ruby core
|
23
43
|
and stdlib - with a few exceptions:
|
24
44
|
|
25
45
|
* The spec command line uses diff-lcs when --diff is specified.
|
46
|
+
* The spec command line uses heckle when --heckle is specified.
|
26
47
|
* The Spec::Rake::SpecTask needs RCov if RCov is enabled in the task.
|
27
48
|
* RSpec on Rails needs the ZenTest gem to be installed (and Rails and its dependencies of course)
|
28
49
|
|
data/Rakefile
CHANGED
@@ -21,11 +21,9 @@ PKG_FILES = FileList[
|
|
21
21
|
'lib/**/*.rb',
|
22
22
|
'test/**/*.rb',
|
23
23
|
'examples/**/*',
|
24
|
-
'
|
25
|
-
'
|
26
|
-
'
|
27
|
-
'vendor/selenium/*.patch',
|
28
|
-
'vendor/selenium/*.txt'
|
24
|
+
File.dirname(__FILE__) + '../web_spec/**/*.rb',
|
25
|
+
File.dirname(__FILE__) + '../web_spec/**/*.txt',
|
26
|
+
File.dirname(__FILE__) + '../web_spec/**/*.patch'
|
29
27
|
]
|
30
28
|
|
31
29
|
task :default => [:spec, :verify_rcov]
|
@@ -33,10 +31,16 @@ 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
|
-
t.rcov_dir = 'doc/output/coverage'
|
39
|
-
t.rcov_opts = ['--exclude', 'spec\/spec,bin\/spec,examples']
|
36
|
+
t.rcov_dir = '../doc/output/coverage'
|
37
|
+
t.rcov_opts = ['--exclude', 'spec\/spec,bin\/spec,bin\/drbspec,examples']
|
38
|
+
end
|
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']
|
40
44
|
end
|
41
45
|
|
42
46
|
desc "Run all failing examples"
|
@@ -48,26 +52,28 @@ desc 'Verify that no warnings occur'
|
|
48
52
|
task :verify_warnings do
|
49
53
|
`ruby -w #{File.dirname(__FILE__) + '/bin/spec'} --help 2> warnings.txt`
|
50
54
|
warnings = File.open('warnings.txt').read
|
51
|
-
File.rm 'warnings.txt'
|
55
|
+
File.rm 'warnings.txt' rescue nil
|
52
56
|
raise "There were warnings:\n#{warnings}" if warnings =~ /warning/n
|
53
57
|
end
|
54
58
|
|
55
59
|
desc 'Generate HTML documentation for website'
|
56
60
|
task :webgen do
|
57
|
-
Dir.chdir 'doc' do
|
61
|
+
Dir.chdir '../doc' do
|
58
62
|
output = nil
|
59
63
|
IO.popen('webgen 2>&1') do |io|
|
60
64
|
output = io.read
|
61
65
|
end
|
62
66
|
raise "ERROR while running webgen: #{output}" if output =~ /ERROR/n || $? != 0
|
63
67
|
end
|
68
|
+
spec_page = File.open(File.dirname(__FILE__) + '/../doc/output/tools/spec.html').read
|
69
|
+
raise "It seems like the output in the generated documentation is broken" unless spec_page =~/\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\./m
|
64
70
|
end
|
65
71
|
|
66
72
|
desc 'Generate RDoc'
|
67
73
|
rd = Rake::RDocTask.new do |rdoc|
|
68
|
-
rdoc.rdoc_dir = 'doc/output/rdoc'
|
74
|
+
rdoc.rdoc_dir = '../doc/output/rdoc'
|
69
75
|
rdoc.options << '--title' << 'RSpec' << '--line-numbers' << '--inline-source' << '--main' << 'README'
|
70
|
-
rdoc.rdoc_files.include('README', 'CHANGES', 'EXAMPLES.rd', 'lib/**/*.rb')
|
76
|
+
rdoc.rdoc_files.include('README', 'CHANGES', 'MIT-LICENSE', 'EXAMPLES.rd', 'lib/**/*.rb')
|
71
77
|
end
|
72
78
|
task :rdoc => :examples_specdoc # We generate EXAMPLES.rd
|
73
79
|
|
@@ -89,13 +95,11 @@ spec = Gem::Specification.new do |s|
|
|
89
95
|
s.rdoc_options = rd.options
|
90
96
|
s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$|^EXAMPLES.rd$/ }.to_a
|
91
97
|
|
92
|
-
s.test_files = Dir.glob('test/*_test.rb')
|
93
|
-
s.require_path = 'lib'
|
94
98
|
s.autorequire = 'spec'
|
95
|
-
s.bindir =
|
96
|
-
s.executables = [
|
97
|
-
s.default_executable =
|
98
|
-
s.author = ["
|
99
|
+
s.bindir = 'bin'
|
100
|
+
s.executables = ['spec', 'drbspec']
|
101
|
+
s.default_executable = 'spec'
|
102
|
+
s.author = ["RSpec Development Team"]
|
99
103
|
s.email = "rspec-devel@rubyforge.org"
|
100
104
|
s.homepage = "http://rspec.rubyforge.org"
|
101
105
|
s.rubyforge_project = "rspec"
|
@@ -126,40 +130,10 @@ task :todo do
|
|
126
130
|
end
|
127
131
|
|
128
132
|
task :clobber do
|
129
|
-
rm_rf 'doc/output'
|
130
|
-
end
|
131
|
-
|
132
|
-
desc "Touches files storing revisions so that svn will update $LastChangedRevision"
|
133
|
-
task :touch_revision_storing_files do
|
134
|
-
# See http://svnbook.red-bean.com/en/1.0/ch07s02.html - the section on svn:keywords
|
135
|
-
files = [
|
136
|
-
'lib/spec/version.rb',
|
137
|
-
'vendor/rspec_on_rails/vendor/plugins/rspec/lib/spec/rails/version.rb'
|
138
|
-
]
|
139
|
-
touch_needed = false
|
140
|
-
IO.popen('svn stat') do |io|
|
141
|
-
io.each_line do |line|
|
142
|
-
if line =~ /^M\s*(.*)/
|
143
|
-
touch_needed = !files.index($1)
|
144
|
-
break if touch_needed
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
if touch_needed
|
150
|
-
new_token = rand
|
151
|
-
files.each do |path|
|
152
|
-
abs_path = File.join(File.dirname(__FILE__), path)
|
153
|
-
content = File.open(abs_path).read
|
154
|
-
touched_content = content.gsub(/# RANDOM_TOKEN: (.*)\n/n, "# RANDOM_TOKEN: #{new_token}\n")
|
155
|
-
File.open(abs_path, 'w') do |io|
|
156
|
-
io.write touched_content
|
157
|
-
end
|
158
|
-
end
|
159
|
-
end
|
133
|
+
rm_rf '../doc/output'
|
160
134
|
end
|
161
135
|
|
162
|
-
task :release => [:clobber, :verify_committed, :verify_user, :
|
136
|
+
task :release => [:clobber, :verify_committed, :verify_user, :spec, :publish_packages, :tag, :publish_website, :publish_news]
|
163
137
|
|
164
138
|
desc "Verifies that there is no uncommitted code"
|
165
139
|
task :verify_committed do
|
@@ -179,46 +153,25 @@ end
|
|
179
153
|
|
180
154
|
desc "Run this task before you commit. You should see 'OK TO COMMIT'"
|
181
155
|
task :pre_commit => [
|
182
|
-
:touch_revision_storing_files,
|
183
156
|
:verify_warnings,
|
184
|
-
:website,
|
185
|
-
:examples,
|
157
|
+
:website,
|
158
|
+
:examples,
|
186
159
|
:failing_examples_with_html,
|
187
|
-
|
188
|
-
:commit_ok]
|
189
|
-
|
190
|
-
task :rails_pre_commit do
|
191
|
-
Dir.chdir 'vendor/rspec_on_rails' do
|
192
|
-
IO.popen("rake pre_commit --verbose") do |io|
|
193
|
-
io.each do |line|
|
194
|
-
puts line
|
195
|
-
end
|
196
|
-
end
|
197
|
-
raise "RSpec on Rails pre_commit failed" if $? != 0
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
task :commit_ok do |t|
|
202
|
-
puts "OK TO COMMIT"
|
203
|
-
end
|
160
|
+
]
|
204
161
|
|
205
162
|
desc "Build the website, but do not publish it"
|
206
|
-
task :website => [:clobber, :verify_rcov, :
|
163
|
+
task :website => [:clobber, :verify_rcov, :spec_html, :webgen, :failing_examples_with_html, :examples_specdoc, :rdoc]
|
207
164
|
|
208
165
|
task :verify_user do
|
209
166
|
raise "RUBYFORGE_USER environment variable not set!" unless ENV['RUBYFORGE_USER']
|
210
167
|
end
|
211
168
|
|
212
|
-
task :verify_password do
|
213
|
-
raise "RUBYFORGE_PASSWORD environment variable not set!" unless ENV['RUBYFORGE_PASSWORD']
|
214
|
-
end
|
215
|
-
|
216
169
|
desc "Upload Website to RubyForge"
|
217
170
|
task :publish_website => [:verify_user, :website] do
|
218
171
|
publisher = Rake::SshDirPublisher.new(
|
219
172
|
"rspec-website@rubyforge.org",
|
220
173
|
"/var/www/gforge-projects/#{PKG_NAME}",
|
221
|
-
"doc/output"
|
174
|
+
"../doc/output"
|
222
175
|
)
|
223
176
|
|
224
177
|
publisher.upload
|
@@ -227,7 +180,7 @@ end
|
|
227
180
|
desc "Package the RSpec.tmbundle"
|
228
181
|
task :package_tmbundle => :pkg do
|
229
182
|
rm_rf 'pkg/RSpec.tmbundle'
|
230
|
-
`svn export
|
183
|
+
`svn export ../RSpec.tmbundle pkg/RSpec.tmbundle`
|
231
184
|
Dir.chdir 'pkg' do
|
232
185
|
`tar cvzf RSpec-#{PKG_VERSION}.tmbundle.tgz RSpec.tmbundle`
|
233
186
|
end
|
@@ -235,7 +188,7 @@ end
|
|
235
188
|
task :package => :package_tmbundle
|
236
189
|
|
237
190
|
desc "Publish gem+tgz+zip on RubyForge. You must make sure lib/version.rb is aligned with the CHANGELOG file"
|
238
|
-
task :publish_packages => [:verify_user, :
|
191
|
+
task :publish_packages => [:verify_user, :package] do
|
239
192
|
require 'meta_project'
|
240
193
|
require 'rake/contrib/xforge'
|
241
194
|
release_files = FileList[
|
@@ -248,19 +201,17 @@ task :publish_packages => [:verify_user, :verify_password, :package] do
|
|
248
201
|
Rake::XForge::Release.new(MetaProject::Project::XForge::RubyForge.new(PKG_NAME)) do |xf|
|
249
202
|
# Never hardcode user name and password in the Rakefile!
|
250
203
|
xf.user_name = ENV['RUBYFORGE_USER']
|
251
|
-
xf.password = ENV['RUBYFORGE_PASSWORD']
|
252
204
|
xf.files = release_files.to_a
|
253
205
|
xf.release_name = "RSpec #{PKG_VERSION}"
|
254
206
|
end
|
255
207
|
end
|
256
208
|
|
257
209
|
desc "Publish news on RubyForge"
|
258
|
-
task :publish_news => [:verify_user
|
210
|
+
task :publish_news => [:verify_user] do
|
259
211
|
require 'meta_project'
|
260
212
|
require 'rake/contrib/xforge'
|
261
213
|
Rake::XForge::NewsPublisher.new(MetaProject::Project::XForge::RubyForge.new(PKG_NAME)) do |news|
|
262
214
|
# Never hardcode user name and password in the Rakefile!
|
263
215
|
news.user_name = ENV['RUBYFORGE_USER']
|
264
|
-
news.password = ENV['RUBYFORGE_PASSWORD']
|
265
216
|
end
|
266
217
|
end
|
data/bin/drbspec
ADDED
data/bin/spec
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
$LOAD_PATH.
|
3
|
-
require
|
2
|
+
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
|
3
|
+
require 'spec'
|
4
4
|
::Spec::Runner::CommandLine.run(ARGV, STDERR, STDOUT, true, true)
|
5
|
-
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# greeter.rb
|
2
|
+
#
|
3
|
+
# Based on http://glu.ttono.us/articles/2006/12/19/tormenting-your-tests-with-heckle
|
4
|
+
#
|
5
|
+
# Run with:
|
6
|
+
#
|
7
|
+
# spec greeter_spec.rb --heckle Greeter
|
8
|
+
#
|
9
|
+
class Greeter
|
10
|
+
def initialize(person = nil)
|
11
|
+
@person = person
|
12
|
+
end
|
13
|
+
|
14
|
+
def greet
|
15
|
+
@person.nil? ? "Hi there!" : "Hi #{@person}!"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "Greeter" do
|
20
|
+
specify "should say Hi to person" do
|
21
|
+
greeter = Greeter.new("Kevin")
|
22
|
+
greeter.greet.should == "Hi Kevin!"
|
23
|
+
end
|
24
|
+
|
25
|
+
specify "should say Hi to nobody" do
|
26
|
+
greeter = Greeter.new
|
27
|
+
# Uncomment the next line to make Heckle happy
|
28
|
+
#greeter.greet.should == "Hi there!"
|
29
|
+
end
|
30
|
+
end
|
data/examples/mocking_example.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
$global = 0
|
2
|
+
|
3
|
+
context "State created in context_setup" do
|
4
|
+
context_setup do
|
5
|
+
@sideeffect = 1
|
6
|
+
$global +=1
|
7
|
+
end
|
8
|
+
|
9
|
+
setup do
|
10
|
+
@isolated = 1
|
11
|
+
end
|
12
|
+
|
13
|
+
specify "should be accessible from spec" do
|
14
|
+
@sideeffect.should == 1
|
15
|
+
$global.should == 1
|
16
|
+
@isolated.should == 1
|
17
|
+
|
18
|
+
@sideeffect += 1
|
19
|
+
@isolated += 1
|
20
|
+
end
|
21
|
+
|
22
|
+
specify "should not have sideffects" do
|
23
|
+
@sideeffect.should == 1
|
24
|
+
$global.should == 1
|
25
|
+
@isolated.should == 1
|
26
|
+
|
27
|
+
@sideeffect += 1
|
28
|
+
@isolated += 1
|
29
|
+
end
|
30
|
+
|
31
|
+
context_teardown do
|
32
|
+
$global = 0
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../lib/spec'
|
data/examples/stack_spec.rb
CHANGED
data/examples/test_case_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
|