Permalink
Browse files

add test (and fix) for divisible_by depreciated method, development d…

…epenendcies changed
  • Loading branch information...
1 parent 0a2c778 commit 388ffbfa86d07baf96761bbede0ae5ecbcd403e3 @vlado committed Feb 27, 2012
Showing with 27 additions and 7 deletions.
  1. +2 −1 .gitignore
  2. +1 −1 Gemfile
  3. +10 −1 Rakefile
  4. +4 −3 divisible.gemspec
  5. +1 −1 lib/divisible/core_ext.rb
  6. +9 −0 test/test_divisible.rb
View
3 .gitignore
@@ -1,2 +1,3 @@
pkg/*
-*.gem
+*.gem
+Gemfile.lock
View
2 Gemfile
@@ -1,4 +1,4 @@
-source :gemcutter
+source :rubygems
# Specify your gem's dependencies in divisible.gemspec
gemspec
View
11 Rakefile
@@ -1,2 +1,11 @@
require 'bundler'
-Bundler::GemHelper.install_tasks
+Bundler::GemHelper.install_tasks
+
+require 'rake/testtask'
+
+Rake::TestTask.new do |t|
+ t.libs << 'test'
+end
+
+desc "Run tests"
+task :default => :test
View
7 divisible.gemspec
@@ -1,5 +1,5 @@
# -*- encoding: utf-8 -*-
-$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
+$:.push File.expand_path("../lib", __FILE__)
require 'divisible/version'
Gem::Specification.new do |s|
@@ -14,10 +14,11 @@ Gem::Specification.new do |s|
s.required_rubygems_version = ">= 1.3.6"
s.rubyforge_project = "divisible"
-
- s.add_development_dependency "bundler", ">= 1.0.0.rc.5"
+
+ s.add_development_dependency "rake"
s.files = `git ls-files`.split("\n")
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files`.split("\n").select{|f| f =~ /^bin/}
s.require_path = 'lib'
end
View
2 lib/divisible/core_ext.rb
@@ -10,6 +10,6 @@ def divisible_by?(first,*args)
# <b>DEPRECATED:</b> Please use <tt>divisible_by?</tt> instead.
def divisible_by(*args)
warn "[DEPRECATION] `divisible_by` is deprecated. Please use `divisible_by?` instead."
- divisible_by?(args)
+ divisible_by?(*args)
end
end
View
9 test/test_divisible.rb
@@ -14,10 +14,12 @@ def check_module_call
def test_simple
assert 2.divisible_by?(2)
+ assert !4.divisible_by?(3)
end
def test_complex
assert 100.divisible_by?(2,4,5,10,20,25,50)
+ assert !100.divisible_by?(2,3)
end
def test_complex_with_zero
@@ -37,5 +39,12 @@ def test_division_by_zero
assert_equal false, 2.divisible_by?(0)
end
end
+
+ def test_that_divisible_by_still_works_as_deprecated_method
+ assert Fixnum.method_defined?(:divisible_by)
+ assert_equal 4.divisible_by(2), 4.divisible_by?(2)
+ assert_equal 4.divisible_by(3), 4.divisible_by?(3)
+ assert_equal 100.divisible_by(2,4,5,10,20,25,50), 100.divisible_by?(2,4,5,10,20,25,50)
+ end
end

0 comments on commit 388ffbf

Please sign in to comment.