diff options
| author | hukl <contact@smyck.org> | 2009-02-17 12:47:49 +0100 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-02-17 12:47:49 +0100 |
| commit | 3cdcb5ca02a94b2b342c30903a27d47d35d46e55 (patch) | |
| tree | ef3e1154fe262561b3955c07edcaee3824a21f47 /vendor/plugins/will_paginate/test/helper.rb | |
| parent | 7a282f2605f6fb3689940e5c7072b4801653deb2 (diff) | |
added will_paginate plugin
Diffstat (limited to 'vendor/plugins/will_paginate/test/helper.rb')
| -rw-r--r-- | vendor/plugins/will_paginate/test/helper.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/vendor/plugins/will_paginate/test/helper.rb b/vendor/plugins/will_paginate/test/helper.rb new file mode 100644 index 00000000..ad52b1b6 --- /dev/null +++ b/vendor/plugins/will_paginate/test/helper.rb | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | require 'test/unit' | ||
| 2 | require 'rubygems' | ||
| 3 | |||
| 4 | # gem install redgreen for colored test output | ||
| 5 | begin require 'redgreen'; rescue LoadError; end | ||
| 6 | |||
| 7 | require 'boot' unless defined?(ActiveRecord) | ||
| 8 | |||
| 9 | class Test::Unit::TestCase | ||
| 10 | protected | ||
| 11 | def assert_respond_to_all object, methods | ||
| 12 | methods.each do |method| | ||
| 13 | [method.to_s, method.to_sym].each { |m| assert_respond_to object, m } | ||
| 14 | end | ||
| 15 | end | ||
| 16 | |||
| 17 | def collect_deprecations | ||
| 18 | old_behavior = WillPaginate::Deprecation.behavior | ||
| 19 | deprecations = [] | ||
| 20 | WillPaginate::Deprecation.behavior = Proc.new do |message, callstack| | ||
| 21 | deprecations << message | ||
| 22 | end | ||
| 23 | result = yield | ||
| 24 | [result, deprecations] | ||
| 25 | ensure | ||
| 26 | WillPaginate::Deprecation.behavior = old_behavior | ||
| 27 | end | ||
| 28 | end | ||
| 29 | |||
| 30 | # Wrap tests that use Mocha and skip if unavailable. | ||
| 31 | def uses_mocha(test_name) | ||
| 32 | require 'mocha' unless Object.const_defined?(:Mocha) | ||
| 33 | rescue LoadError => load_error | ||
| 34 | $stderr.puts "Skipping #{test_name} tests. `gem install mocha` and try again." | ||
| 35 | else | ||
| 36 | yield | ||
| 37 | end | ||
