rspec 0.6.4 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. data/CHANGES +90 -1
  2. data/EXAMPLES.rd +28 -6
  3. data/MIT-LICENSE +20 -0
  4. data/README +18 -12
  5. data/Rakefile +60 -54
  6. data/examples/custom_formatter.rb +4 -4
  7. data/examples/helper_method_example.rb +11 -0
  8. data/examples/mocking_example.rb +19 -2
  9. data/examples/partial_mock_example.rb +28 -0
  10. data/examples/stack_spec.rb +8 -8
  11. data/examples/stubbing_example.rb +50 -9
  12. data/examples/test_case_spec.rb +6 -6
  13. data/lib/spec.rb +1 -2
  14. data/lib/spec/callback.rb +0 -0
  15. data/lib/spec/expectations.rb +3 -6
  16. data/lib/spec/expectations/diff.rb +23 -47
  17. data/lib/spec/expectations/differs/default.rb +62 -0
  18. data/lib/spec/expectations/{exceptions.rb → errors.rb} +0 -0
  19. data/lib/spec/expectations/extensions.rb +4 -0
  20. data/lib/spec/expectations/extensions/inspect_for_expectation_not_met_error.rb +14 -0
  21. data/lib/spec/expectations/extensions/numeric.rb +5 -0
  22. data/lib/spec/expectations/{expectations.rb → extensions/object.rb} +3 -6
  23. data/lib/spec/expectations/extensions/symbol.rb +5 -0
  24. data/lib/spec/expectations/should.rb +4 -0
  25. data/lib/spec/expectations/should/base.rb +42 -0
  26. data/lib/spec/expectations/should/have.rb +79 -0
  27. data/lib/spec/expectations/should/not.rb +72 -0
  28. data/lib/spec/expectations/should/should.rb +83 -0
  29. data/lib/spec/expectations/sugar.rb +6 -25
  30. data/lib/spec/mocks.rb +5 -1
  31. data/lib/spec/mocks/argument_expectation.rb +15 -1
  32. data/lib/spec/mocks/error_generator.rb +72 -0
  33. data/lib/spec/mocks/{exceptions.rb → errors.rb} +0 -0
  34. data/lib/spec/mocks/extensions/object.rb +3 -0
  35. data/lib/spec/mocks/message_expectation.rb +80 -73
  36. data/lib/spec/mocks/mock.rb +4 -69
  37. data/lib/spec/mocks/mock_handler.rb +158 -0
  38. data/lib/spec/mocks/mock_methods.rb +44 -0
  39. data/lib/spec/mocks/order_group.rb +10 -2
  40. data/lib/spec/rake/spectask.rb +20 -18
  41. data/lib/spec/rake/{rcov_verify.rb → verify_rcov.rb} +2 -2
  42. data/lib/spec/runner.rb +3 -1
  43. data/lib/spec/runner/backtrace_tweaker.rb +2 -1
  44. data/lib/spec/runner/context.rb +10 -16
  45. data/lib/spec/runner/context_eval.rb +40 -40
  46. data/lib/spec/runner/execution_context.rb +1 -12
  47. data/lib/spec/runner/{kernel_ext.rb → extensions/kernel.rb} +2 -2
  48. data/lib/spec/runner/{instance_exec.rb → extensions/object.rb} +0 -0
  49. data/lib/spec/runner/formatter/base_text_formatter.rb +25 -18
  50. data/lib/spec/runner/formatter/html_formatter.rb +81 -101
  51. data/lib/spec/runner/formatter/progress_bar_formatter.rb +9 -9
  52. data/lib/spec/runner/formatter/rdoc_formatter.rb +6 -6
  53. data/lib/spec/runner/formatter/specdoc_formatter.rb +7 -6
  54. data/lib/spec/runner/option_parser.rb +41 -5
  55. data/lib/spec/runner/reporter.rb +3 -15
  56. data/lib/spec/runner/spec_should_raise_handler.rb +74 -0
  57. data/lib/spec/runner/specification.rb +33 -14
  58. data/lib/spec/version.rb +6 -3
  59. data/vendor/watir/README.txt +1 -1
  60. metadata +34 -68
  61. data/bin/test2spec +0 -112
  62. data/examples/helper_method_spec.rb +0 -12
  63. data/lib/spec/expectations/have_helper.rb +0 -41
  64. data/lib/spec/expectations/helper.rb +0 -4
  65. data/lib/spec/expectations/should_base.rb +0 -52
  66. data/lib/spec/expectations/should_helper.rb +0 -93
  67. data/lib/spec/expectations/should_negator.rb +0 -71
  68. data/lib/spec/test_to_spec/ruby2ruby.rb +0 -492
  69. data/lib/spec/test_to_spec/sexp_transformer.rb +0 -196
  70. data/lib/spec/test_to_spec/test_case_ext.rb +0 -22
  71. data/lib/spec/test_to_spec/translation_test_runner.rb +0 -147
  72. data/test/spec/expectations/arbitrary_operator_test.rb +0 -55
  73. data/test/spec/expectations/arbitrary_predicate_test.rb +0 -163
  74. data/test/spec/expectations/containment_test.rb +0 -129
  75. data/test/spec/expectations/diff_test.rb +0 -62
  76. data/test/spec/expectations/identity_test.rb +0 -75
  77. data/test/spec/expectations/object_equality_test.rb +0 -65
  78. data/test/spec/expectations/raising_test.rb +0 -106
  79. data/test/spec/expectations/regex_matching_test.rb +0 -36
  80. data/test/spec/expectations/should_have_test.rb +0 -169
  81. data/test/spec/expectations/should_satisfy_test.rb +0 -37
  82. data/test/spec/expectations/sugar_test.rb +0 -93
  83. data/test/spec/expectations/supported_symbols_test.rb +0 -33
  84. data/test/spec/expectations/throwing_test.rb +0 -55
  85. data/test/spec/expectations/true_false_special_case_test.rb +0 -85
  86. data/test/spec/expectations/typing_test.rb +0 -108
  87. data/test/spec/mocks/mock_arg_constraints_test.rb +0 -113
  88. data/test/spec/mocks/mock_counts_test.rb +0 -431
  89. data/test/spec/mocks/mock_ordering_test.rb +0 -109
  90. data/test/spec/mocks/mock_test.rb +0 -220
  91. data/test/spec/mocks/null_object_test.rb +0 -37
  92. data/test/spec/runner/backtrace_tweaker_test.rb +0 -90
  93. data/test/spec/runner/context_matching_test.rb +0 -35
  94. data/test/spec/runner/context_runner_test.rb +0 -62
  95. data/test/spec/runner/context_test.rb +0 -191
  96. data/test/spec/runner/execution_context_test.rb +0 -45
  97. data/test/spec/runner/formatter/failure_dump_test.rb +0 -94
  98. data/test/spec/runner/formatter/html_formatter_test.rb +0 -48
  99. data/test/spec/runner/formatter/progress_bar_formatter_test.rb +0 -56
  100. data/test/spec/runner/formatter/rdoc_formatter_test.rb +0 -51
  101. data/test/spec/runner/formatter/specdoc_formatter_test.rb +0 -57
  102. data/test/spec/runner/kernel_ext_test.rb +0 -13
  103. data/test/spec/runner/option_parser_test.rb +0 -141
  104. data/test/spec/runner/reporter_test.rb +0 -128
  105. data/test/spec/runner/spec_matcher_test.rb +0 -47
  106. data/test/spec/runner/specification_test.rb +0 -121
  107. data/test/spec/test_to_spec/ruby_to_ruby_test.rb +0 -79
  108. data/test/spec/test_to_spec/sexp_transformer_assertion_test.rb +0 -207
  109. data/test/spec/test_to_spec/sexp_transformer_test.rb +0 -303
  110. data/test/spec/test_to_spec/test_case_ext_test.rb +0 -25
  111. data/test/spec/test_to_spec/testfiles/test_unit_api_spec.rb +0 -75
  112. data/test/spec/test_to_spec/testfiles/test_unit_api_test.rb +0 -70
  113. data/test/test_classes.rb +0 -102
  114. data/test/test_helper.rb +0 -32
data/CHANGES CHANGED
@@ -1,10 +1,99 @@
1
1
  = RSpec Changelog
2
2
 
3
+ == Version 0.7.0 (in SVN)
4
+
5
+ This is the "Grow up and eat your own dog food release". RSpec is now used on itself and
6
+ we're no longer using Test::Unit to test it. Although, we are still extending Test::Unit
7
+ for the rails plugin (indirectly - through ZenTest)
8
+
9
+ IMPORTANT NOTE: THIS RELEASE IS NOT 100% BACKWARDS COMPATIBLE TO 0.6.x
10
+
11
+ There are a few changes that will require that you change your existing specs.
12
+
13
+ --------------------------------------------------
14
+ RSpec now handles equality exactly like ruby does:
15
+
16
+ # actual.should_equal(expected) will pass if actual.equal?(expected) returns true
17
+ # actual.should_eql(expected) will pass if actual.eql?(expected) returns true
18
+ # actual.should == expected will pass if actual == expected) returns true
19
+
20
+ At the high level, eql? implies equivalence, while equal? implies object identity. For more
21
+ information on how ruby deals w/ equality, you should do this:
22
+
23
+ ri equal?
24
+
25
+ or look at this:
26
+
27
+ http://www.ruby-doc.org/core/classes/Object.html#M001057
28
+
29
+ Also, we left in should_be as a synonym for should_equal, so the only specs that should break are the
30
+ ones using should_equal (which used to use <code>==</code> instead of <code>.equal?</code>).
31
+
32
+ Lastly, should_be used to handle true and false differently from any other values. We've removed
33
+ this special handling, so now actual.should_be true will fail for any value other than true (it
34
+ used to pass for any non-nil, non-false value), and actual.should_be false will fail for any
35
+ value other than false (it used to pass for nil or false).
36
+
37
+ Here's what you'll need to do to update your specs:
38
+ * search for "should_equal" and replace with "should_eql"
39
+ * run specs
40
+
41
+ If any specs still fail, they are probably related to should_be(true) or should_be(false) using
42
+ non-boolean values. Those you'll just have to inspect manually and adjust appropriately (sorry!).
43
+
44
+ --------------------------------------------------
45
+ Specifying multiple return values in mocks now works like this:
46
+
47
+ mock.should_receive(:message).and_return(1,2,3)
48
+
49
+ It used to work like this:
50
+
51
+ mock.should_receive(:message).and_return([1,2,3])
52
+
53
+ but we decided that was counter intuitive and otherwise lame.
54
+
55
+ Here's what you'll need to do to update your specs:
56
+ * search for "and_return(["
57
+ * get rid of the "[" and "]"
58
+
59
+ --------------------------------------------------
60
+ RSpec on Rails now supports the following (thanks to ZenTest upon which it is built):
61
+
62
+ * Separate specs for models, views, controllers and helpers
63
+ * Controller specs are completely decoupled from the views by default (though you can tell them to couple themselves if you prefer)
64
+ * View specs are completely decoupled from app-specific controllers
65
+
66
+ See http://rspec.rubyforge.org/documentation/rails/index.html for more information
67
+ --------------------------------------------------
68
+ As usual, there are also other new features and bug fixes:
69
+
70
+ * Added lots of documentation on mocks/stubs and the rails plugin.
71
+ * Added support for assigns[key] syntax for controller specs (to align w/ pre-existing syntax for view specs)
72
+ * Added support for controller.should_redirect_to
73
+ * RSpec on Rails automatically checks whether it's compatible with the installed RSpec
74
+ * Applied [#6393] rspec_on_rails uses deprecated '@response' instead of the accessor
75
+ * RSpec now has 100% spec coverage(!)
76
+ * Added support for stubbing and partial mocking
77
+ * Progress (....F..F.) is now coloured. Tweaked patch from KAKUTANI Shintaro.
78
+ * Backtrace now excludes the rcov runner (/usr/local/bin/rcov)
79
+ * Fixed [#5539] predicates do not work w/ rails
80
+ * Added [#6091] support for Regexp matching messages sent to should_raise
81
+ * Added [#6333] support for Regexp matching in mock arguments
82
+ * Applied [#6283] refactoring of diff support to allow selectable formats and custom differs
83
+ * Fixed [#5564] "ruby spec_file.rb" doesn't work the same way as "spec spec_file.rb"
84
+ * Fixed [#6056] Multiple output of failing-spec notice
85
+ * Fixed [#6233] Colours in specdoc
86
+ * Applied [#6207] Allows --diff option to diff target and expected's #inspect output (Patch by Lachie Cox)
87
+ * Fixed [#6203] Failure messages are misleading - consider using inspect.
88
+ * Added [#6334] subject.should_have_xyz will try to call subject.has_xyz? - use this for hash.should_have_key(key)
89
+ * Fixed [#6017] Rake task should ignore empty or non-existent spec-dirs
90
+
3
91
  == Version 0.6.4
4
92
 
5
93
  In addition to a number of bug fixes and patches, this release begins to formalize the support for
6
94
  RSpec on Rails.
7
95
 
96
+ * Added Christopher Petrilli's TextMate bundle to vendor/textmate/RSpec.tmbundle
8
97
  * Fixed [#5909], once again supporting multi_word_predicates
9
98
  * Applied [#5873] - response.should_have_rjs (initial patch from Jake Howerton, based on ARTS by Kevin Clark)
10
99
  * Added generation of view specs for rspec_on_rails
@@ -75,7 +164,7 @@ This release improves Rails support and test2spec translation.
75
164
  * Fixed underscore problems that occurred when RSpec was used in Rails
76
165
  * Simplified the Rails support by packaging it as a plugin instead of a generator gem.
77
166
  * Fixed [#5063] 'rspec_on_rails' require line in spec_helper.rb
78
- * Added pre_commit rake task to reduce risk of regressions. Useful for rspec developers and patchers.
167
+ * Added pre_commit rake task to reduce risk of regressions. Useful for RSpec developers and patchers.
79
168
  * Added failure_message to RSpec Rake task
80
169
  * test2spec now defines converted helper methods outside of the setup block (bug #5057).
81
170
 
@@ -1,11 +1,23 @@
1
1
  # A FileAccessor
2
2
  # * should open a file and pass it to the processor's process method
3
- # Rspec
4
- # * should allow you to define helper methods
3
+ # a context with helper a method
4
+ # * should make that method available to specs
5
5
  # An IoProcessor
6
6
  # * should raise nothing when the file is exactly 32 bytes
7
7
  # * should raise an exception when the file length is less than 32 bytes
8
- # A stack (in general)
8
+ # A consumer of a mock
9
+ # * should be able to send messages to the mock
10
+ # a mock
11
+ # * should be able to mock the same message twice w/ different args
12
+ # * should be able to mock the same message twice w/ different args in reverse order
13
+ # A partial mock
14
+ # * should work at the class level
15
+ # * should revert to the original after each spec
16
+ # * can be mocked w/ ordering
17
+ # BDD framework
18
+ # * should be adopted quickly
19
+ # * should be intuitive
20
+ # A stack which is neither empty nor full
9
21
  # * should add to the top when sent 'push'
10
22
  # * should return the top item when sent 'peek'
11
23
  # * should NOT remove the top item when sent 'peek'
@@ -28,7 +40,17 @@
28
40
  # * should remain full after 'peek'
29
41
  # * should no longer be full after 'pop'
30
42
  # * should complain on 'push'
31
- # Rspec should integrate with Test::Unit::TestCase
43
+ # A consumer of a stub
44
+ # * should be able to stub methods on any Object
45
+ # A stubbed method on a class
46
+ # * should return the stubbed value
47
+ # * should revert to the original method after each spec
48
+ # * can stub! and mock the same message
49
+ # A mock
50
+ # * can stub!
51
+ # * can stub! and mock
52
+ # * can stub! and mock the same message
53
+ # RSpec should integrate with Test::Unit::TestCase
32
54
  # * TestCase#setup should be called.
33
- # * Rspec should be able to access TestCase methods
34
- # * Rspec should be able to accept included modules
55
+ # * RSpec should be able to access TestCase methods
56
+ # * RSpec should be able to accept included modules
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2005-2006 The RSpec Development Team
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README CHANGED
@@ -1,15 +1,21 @@
1
- In order to run RSpec's full test suite (rake pre_commit) you must install the following gems:
1
+ == Building the RSpec gem ==
2
+ rake gem
3
+ gem install pkg/rspec-0.x.x.gem (you may have to sudo)
2
4
 
3
- * rake
4
- * rcov
5
- * ParseTree (Ignore the message: test/test_parse_tree.rb:190:38: ':' not followed by identified or operator)
6
- * RubyInline
7
- * webgen
8
- * RedCloth
9
- * syntax
10
- * diff-lcs
11
- * meta_project
12
- * sqlite3-ruby
5
+ == Running the specs ==
6
+ In order to run RSpec's full suite of specs (rake pre_commit) you must install the following gems:
7
+
8
+ * rake # Runs the build script
9
+ * rcov # Verifies that the code is 100% covered by specs
10
+ * webgen # Generates the static HTML website
11
+ * RedCloth # Required by webgen
12
+ * syntax # Required by our own custom webgen extension to highlight ruby code
13
+ * diff-lcs # Required if you use the --diff switch
14
+ * win32console # Required by the --colour switch if you're on Windows
15
+ * meta_project # Required in order to make releases at RubyForge
16
+ * sqlite3-ruby # Required by RSpec on Rails specs
17
+ * ZenTest # Required by RSpec on Rails specs
18
+ * Rails # Required by RSpec on Rails specs
13
19
 
14
20
  You must also install SQLite - which is needed to test the Rails plugin.
15
21
 
@@ -17,7 +23,7 @@ Note that RSpec itself - once built - doesn't have any dependencies outside the
17
23
  and stdlib - with a few exceptions:
18
24
 
19
25
  * The spec command line uses diff-lcs when --diff is specified.
20
- * The test2spec command line uses ParseTree and RubyInline.
21
26
  * The Spec::Rake::SpecTask needs RCov if RCov is enabled in the task.
27
+ * RSpec on Rails needs the ZenTest gem to be installed (and Rails and its dependencies of course)
22
28
 
23
29
  See http://rspec.rubyforge.org for further documentation.
data/Rakefile CHANGED
@@ -3,17 +3,15 @@ require 'rubygems'
3
3
  require 'rake/gempackagetask'
4
4
  require 'rake/contrib/rubyforgepublisher'
5
5
  require 'rake/clean'
6
- require 'rake/testtask'
7
6
  require 'rake/rdoctask'
8
7
  require 'spec/version'
9
- require 'rcov/rcovtask'
10
8
 
11
9
  # Some of the tasks are in separate files since they are also part of the website documentation
12
- load File.dirname(__FILE__) + '/test/tasks/examples.rake'
13
- load File.dirname(__FILE__) + '/test/tasks/examples_specdoc.rake'
14
- load File.dirname(__FILE__) + '/test/tasks/examples_with_rcov.rake'
15
- load File.dirname(__FILE__) + '/test/tasks/failing_examples_with_html.rake'
16
- load File.dirname(__FILE__) + '/test/tasks/rcov_verify.rake'
10
+ load File.dirname(__FILE__) + '/tasks/examples.rake'
11
+ load File.dirname(__FILE__) + '/tasks/examples_specdoc.rake'
12
+ load File.dirname(__FILE__) + '/tasks/examples_with_rcov.rake'
13
+ load File.dirname(__FILE__) + '/tasks/failing_examples_with_html.rake'
14
+ load File.dirname(__FILE__) + '/tasks/verify_rcov.rake'
17
15
 
18
16
  PKG_NAME = "rspec"
19
17
  PKG_VERSION = Spec::VERSION::STRING
@@ -29,50 +27,22 @@ PKG_FILES = FileList[
29
27
  'vendor/selenium/*.txt'
30
28
  ]
31
29
 
32
- task :default => :test
30
+ task :default => [:spec, :verify_rcov]
31
+
32
+ desc "Run all specs"
33
+ Spec::Rake::SpecTask.new do |t|
34
+ t.spec_files = FileList['spec/**/*_spec.rb']
35
+ t.spec_opts = ['--diff','--color','--backtrace']
36
+ t.rcov = true
37
+ t.rcov_dir = 'doc/output/coverage'
38
+ t.rcov_opts = ['--exclude', 'spec\/spec,bin\/spec']
39
+ end
33
40
 
34
41
  desc "Run all failing examples"
35
42
  Spec::Rake::SpecTask.new('failing_examples') do |t|
36
43
  t.spec_files = FileList['failing_examples/**/*_spec.rb']
37
44
  end
38
45
 
39
- require 'rbconfig'
40
- windows = Config::CONFIG['target_os'] == 'mswin32'
41
- Rake::TestTask.new do |t|
42
- tests = FileList['test/**/*_test.rb']
43
- tests.exclude 'test/spec/test_to_spec/*.rb' if windows
44
- t.test_files = tests
45
- t.verbose = true
46
- # t.warning = true
47
- end
48
-
49
- Rcov::RcovTask.new do |t|
50
- t.test_files = FileList['test/**/*_test.rb']
51
- t.output_dir = 'doc/output/coverage'
52
- t.rcov_opts = ['--text-report']
53
- end
54
-
55
- desc 'Translate our own tests to specs'
56
- task :test2spec => :create_test2spec_dir do
57
- rm_rf 'spec/translated'
58
- `bin/test2spec --force --template spec/test2spec.erb --specdir spec/translated test`
59
- # Remove the spec translations that we don't care about.
60
- rm 'spec/translated/spec/test_to_spec/sexp_transformer_assertion_spec.rb'
61
- rm 'spec/translated/spec/test_to_spec/sexp_transformer_spec.rb'
62
- rm 'spec/translated/r2_r_spec.rb'
63
- end
64
- task :create_test2spec_dir do
65
- mkdir_p 'doc/output/tools' unless File.exist? 'doc/output/tools'
66
- end
67
-
68
- desc 'Runs all RSpec specs - translated with test2spec from our own tests'
69
- Spec::Rake::SpecTask.new('test2spec_test' => :test2spec) do |t|
70
- t.spec_files = FileList['spec/**/*_spec.rb']
71
- t.spec_opts = ["--format", "html", "--diff"]
72
- t.out = 'doc/output/tools/rspec_specs.html'
73
- t.failure_message = "**** Translated specs failed. See doc/output/tools/rspec_specs.html ****"
74
- end
75
-
76
46
  desc 'Verify that no warnings occur'
77
47
  task :verify_warnings do
78
48
  `ruby -w #{File.dirname(__FILE__) + '/bin/spec'} --help 2> warnings.txt`
@@ -82,7 +52,7 @@ task :verify_warnings do
82
52
  end
83
53
 
84
54
  desc 'Generate HTML documentation for website'
85
- task :webgen => :test2spec do
55
+ task :webgen do
86
56
  Dir.chdir 'doc' do
87
57
  output = nil
88
58
  IO.popen('webgen 2>&1') do |io|
@@ -122,9 +92,9 @@ spec = Gem::Specification.new do |s|
122
92
  s.require_path = 'lib'
123
93
  s.autorequire = 'spec'
124
94
  s.bindir = "bin"
125
- s.executables = ["spec", "test2spec"]
95
+ s.executables = ["spec"]
126
96
  s.default_executable = "spec"
127
- s.author = "Steven Baker, Aslak Hellesoy, Dave Astels, David Chelimsky"
97
+ s.author = ["Steven Baker", "Aslak Hellesoy", "Dave Astels", "David Chelimsky", "Brian Takita"]
128
98
  s.email = "rspec-devel@rubyforge.org"
129
99
  s.homepage = "http://rspec.rubyforge.org"
130
100
  s.rubyforge_project = "rspec"
@@ -151,15 +121,44 @@ end
151
121
 
152
122
  desc "Look for TODO and FIXME tags in the code"
153
123
  task :todo do
154
- egrep /#.*(FIXME|TODO|TBD)/
124
+ egrep /(FIXME|TODO|TBD)/
155
125
  end
156
126
 
157
127
  task :clobber do
158
128
  rm_rf 'doc/output'
159
- rm_rf 'spec/translated'
160
129
  end
161
130
 
162
- task :release => [:clobber, :test2spec_test, :verify_committed, :verify_user, :verify_password, :test, :publish_packages, :tag, :publish_website, :publish_news]
131
+ desc "Touches files storing revisions so that svn will update $LastChangedRevision"
132
+ task :touch_revision_storing_files do
133
+ # See http://svnbook.red-bean.com/en/1.0/ch07s02.html - the section on svn:keywords
134
+ files = [
135
+ 'lib/spec/version.rb',
136
+ 'vendor/rspec_on_rails/vendor/plugins/rspec/lib/spec/rails/version.rb'
137
+ ]
138
+ touch_needed = false
139
+ IO.popen('svn stat') do |io|
140
+ io.each_line do |line|
141
+ if line =~ /^M\s*(.*)/
142
+ touch_needed = !files.index($1)
143
+ break if touch_needed
144
+ end
145
+ end
146
+ end
147
+
148
+ if touch_needed
149
+ new_token = rand
150
+ files.each do |path|
151
+ abs_path = File.join(File.dirname(__FILE__), path)
152
+ content = File.open(abs_path).read
153
+ touched_content = content.gsub(/# RANDOM_TOKEN: (.*)\n/n, "# RANDOM_TOKEN: #{new_token}\n")
154
+ File.open(abs_path, 'w') do |io|
155
+ io.write touched_content
156
+ end
157
+ end
158
+ end
159
+ end
160
+
161
+ task :release => [:clobber, :verify_committed, :verify_user, :verify_password, :spec, :publish_packages, :tag, :publish_website, :publish_news]
163
162
 
164
163
  desc "Verifies that there is no uncommitted code"
165
164
  task :verify_committed do
@@ -178,7 +177,14 @@ task :tag do
178
177
  end
179
178
 
180
179
  desc "Run this task before you commit. You should see 'OK TO COMMIT'"
181
- task :pre_commit => [:verify_warnings, :website, :examples, :failing_examples_with_html, :rails_pre_commit, :commit_ok]
180
+ task :pre_commit => [
181
+ :touch_revision_storing_files,
182
+ :verify_warnings,
183
+ :website,
184
+ :examples,
185
+ :failing_examples_with_html,
186
+ :rails_pre_commit,
187
+ :commit_ok]
182
188
 
183
189
  task :rails_pre_commit do
184
190
  Dir.chdir 'vendor/rspec_on_rails' do
@@ -191,8 +197,8 @@ task :commit_ok do |t|
191
197
  puts "OK TO COMMIT"
192
198
  end
193
199
 
194
- desc "Build the website with rdoc and rcov, but do not publish it"
195
- task :website => [:clobber, :rcov_verify, :webgen, :failing_examples_with_html, :test2spec_test, :examples_specdoc, :rdoc]
200
+ desc "Build the website, but do not publish it"
201
+ task :website => [:clobber, :verify_rcov, :webgen, :failing_examples_with_html, :spec, :examples_specdoc, :rdoc]
196
202
 
197
203
  task :verify_user do
198
204
  raise "RUBYFORGE_USER environment variable not set!" unless ENV['RUBYFORGE_USER']
@@ -5,18 +5,18 @@ require 'spec/runner/formatter/base_text_formatter'
5
5
  # bin/spec failing_examples -r examples/custom_formatter.rb -f CustomFormatter
6
6
  class CustomFormatter < Spec::Runner::Formatter::BaseTextFormatter
7
7
  def add_context(name, first)
8
- @output << "\n" if first
8
+ @output.print "\n" if first
9
9
  end
10
10
 
11
11
  def spec_failed(name, counter, failure)
12
- @output << 'X'
12
+ @output.print 'X'
13
13
  end
14
14
 
15
15
  def spec_passed(name)
16
- @output << '_'
16
+ @output.print '_'
17
17
  end
18
18
 
19
19
  def start_dump
20
- @output << "\n"
20
+ @output.print "\n"
21
21
  end
22
22
  end
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/../lib/spec'
2
+
3
+ context "a context with helper a method" do
4
+ def helper_method
5
+ "received call"
6
+ end
7
+
8
+ specify "should make that method available to specs" do
9
+ helper_method.should == "received call"
10
+ end
11
+ end
@@ -1,11 +1,28 @@
1
1
  require File.dirname(__FILE__) + '/../lib/spec'
2
2
 
3
3
  context "A consumer of a mock" do
4
-
5
4
  specify "should be able to send messages to the mock" do
6
5
  mock = mock("poke me")
7
6
  mock.should_receive(:poke)
8
7
  mock.poke
9
8
  end
9
+ end
10
+
11
+ context "a mock" do
12
+ specify "should be able to mock the same message twice w/ different args" do
13
+ mock = mock("mock")
14
+ mock.should_receive(:msg).with(:arg1).and_return(:val1)
15
+ mock.should_receive(:msg).with(:arg2).and_return(:val2)
16
+ mock.msg(:arg1).should_eql(:val1)
17
+ mock.msg(:arg2).should_eql(:val2)
18
+ end
10
19
 
11
- end
20
+ specify "should be able to mock the same message twice w/ different args in reverse order" do
21
+ mock = mock("mock")
22
+ mock.should_receive(:msg).with(:arg1).and_return(:val1)
23
+ mock.should_receive(:msg).with(:arg2).and_return(:val2)
24
+ mock.msg(:arg2).should_eql(:val2)
25
+ mock.msg(:arg1).should_eql(:val1)
26
+ end
27
+ end
28
+