Permalink
Browse files

bump

  • Loading branch information...
1 parent 6804719 commit 9ee313abd44352e895a39c81643408ced6476658 @kachick committed Aug 26, 2012
Showing with 56 additions and 50 deletions.
  1. +10 −0 History.md
  2. +0 −5 History.rdoc
  3. +1 −1 Manifest.txt
  4. +3 −3 README.md
  5. +2 −2 examples/mixed.rb
  6. +22 −23 lib/test/declare/assertions.rb
  7. +16 −14 lib/test/declare/singleton_class.rb
  8. +1 −1 lib/test/declare/version.rb
  9. +1 −1 test-declare.gemspec
View
@@ -0,0 +1,10 @@
+0.0.2 2012-08-27
+================
+
+* Fix when declared same test-case name
+
+0.0.1 2012-08-26
+================
+
+* Initial release
+
View
@@ -1,5 +0,0 @@
-=== 0.0.1 2012-08-26
-
-* 1 major enhancement:
- * Initial release
-
View
@@ -1,6 +1,6 @@
README.md
LICENSE
-History.rdoc
+History.md
Manifest.txt
Rakefile
Gemfile
View
@@ -35,10 +35,10 @@ The Person.new('John') do |john|
is_a Person
kind_of Object
- The john.name do |name|
+ The john.name do
kind_of String
is_a String
- is 'Taro' # failer
+ is 'Taro' # failure
match /J/
end
@@ -54,7 +54,7 @@ test_"John"_is_"Taro" #bidirectional(#<Class:0x91f5690>)
<"Taro"> expected but was
<"John">.
-12 tests, 12 assertions, 1 failures, 0 errors, 0 skips
+7 tests, 12 assertions, 1 failures, 0 errors, 0 skips
```
Requirements
View
@@ -17,10 +17,10 @@ def initialize(name)
is_a Person
kind_of Object
- The john.name do |name|
+ The john.name do
kind_of String
is_a String
- is 'Taro' # failer
+ is 'Taro' # failure
match /J/
end
@@ -10,23 +10,23 @@ module Assertions
def is(other, desc=nil)
target = it
- define_method :"test_#{summary_for target}_#{__callee__}_#{summary_for other} #bidirectional" do
+ define_method format_testname("#{summary_for target}_#{__callee__}_#{summary_for other}_(bidirectional)") do
assert_equal other, target, desc
assert_equal target, other, desc
end
end
def is_not(other, desc=nil)
target = it
- define_method :"test_#{summary_for target}_#{__callee__}_#{summary_for other} #bidirectional" do
+ define_method format_testname("#{summary_for target}_#{__callee__}_#{summary_for other}_(bidirectional)") do
assert_not_equal other, target, desc
assert_not_equal target, other, desc
end
end
def same(other, desc=nil)
target = it
- define_method :"test_#{summary_for target}_#{__callee__}_#{summary_for other} #bidirectional" do
+ define_method format_testname("#{summary_for target}_#{__callee__}_#{summary_for other}_(bidirectional)") do
assert_same other, target, desc
assert_same target, other, desc
end
@@ -35,7 +35,7 @@ def same(other, desc=nil)
# @param [#eql?, #hash] other
def eql(other, desc=nil)
target = it
- define_method :"test_#{summary_for target}_is_eql_#{summary_for other},that_under_hash-key_matcher #bidirectional" do
+ define_method format_testname("#{summary_for target}_is_#{__callee__}_#{summary_for other},that_under_hash-key_matcher_(bidirectional)") do
assert_same true, target.eql?(other), desc
assert_same target.hash, other.hash, desc
assert_same true, other.eql?(target), desc
@@ -46,7 +46,7 @@ def eql(other, desc=nil)
# @param [#===] other
def match(other, desc=UNASSIGNED)
target = it
- define_method :"test_#{summary_for target}_#{__callee__}_under_#{summary_for other}" do
+ define_method format_testname("#{summary_for target}_#{__callee__}_under_#{summary_for other}") do
assert(other === target, desc)
end
end
@@ -55,56 +55,46 @@ def match(other, desc=UNASSIGNED)
def can(message, desc=nil)
target = it
message = message.to_sym
-
- define_method :"test_#{summary_for target}_is_respond_to_#{message}" do
+ define_method format_testname("#{summary_for target}_is_respond_to_#{message}") do
assert_respond_to target, message, desc
end
end
# @param [Module] mod
def kind_of(mod, desc=nil)
target = it
- define_method :"test_#{summary_for target}_is_#{__callee__}_#{summary_for mod}" do
+ define_method format_testname("#{summary_for target}_is_#{__callee__}_#{summary_for mod}") do
assert_kind_of mod, target, desc
- end
-
- define_method \
- :"test_#{summary_for target}'s class_is_member_of_#{summary_for mod}'s ancestors" do
assert_same true, target.class.ancestors.include?(mod), desc
end
end
# @param [Class] cls
def is_a(cls, desc=nil)
target = it
- define_method :"test_#{summary_for target}_#{__callee__}_#{summary_for cls}" do
+ define_method format_testname("#{summary_for target}_#{__callee__}_#{summary_for cls}") do
assert_instance_of cls, target, desc
- end
-
- define_method :"test_#{summary_for target}'s class_is_#{summary_for cls}" do
assert_same cls, target.class, desc
- end
+ end
end
def ok(desc=UNASSIGNED, &block)
target = it
- define_method \
- :"test_pass_a_block(#{block.source_location})_in_the_#{summary_for target}'s_context" do
+ define_method format_testname("block(#{block.source_location})_pass_in_the_#{summary_for target}'s_context") do
assert target.instance_exec(&block), desc
- end
+ end
end
def ng(desc=UNASSIGNED, &block)
target = it
- define_method \
- :"test_fail_a_block(#{block.source_location})_in_the_#{summary_for target}'s_context" do
+ define_method format_testname("block(#{block.source_location})_fail_in_the_#{summary_for target}'s_context") do
assert !(target.instance_exec(&block)), desc
end
end
# @param [Exception] error
def CATCH(error, desc='', &block)
- define_method :"test_the_block(#{block.source_location})_must_catch_a_exception \"#{error}\"" do
+ define_method format_testname("block(#{block.source_location})_must_catch_a_exception \"#{error}\"") do
assert_raise error, desc, &block
end
end
@@ -116,6 +106,15 @@ def summary_for(obj)
$2.empty? ? $1 : $~.captures.join('...')
end
+ def called_from
+ dirname = File.dirname __FILE__
+ caller.reject{|s|s.include?(dirname)}[-2]
+ end
+
+ def format_testname(body)
+ :"test_#{body} ##{called_from}"
+ end
+
end
end; end
@@ -2,29 +2,31 @@
require_relative 'exceptions'
require_relative 'assertions'
-module Test; module Declare
+module Test
- class << self
+ module Declare
- # @return [Test::Unit::TestCase]
- def new_test_case(target, &block)
- Class.new ::Test::Unit::TestCase do
+ class << self
- extend Assertions
-
- singleton_class.class_eval do
+ # @return [Test::Unit::TestCase]
+ def new_test_case(target, &block)
+ Class.new ::Test::Unit::TestCase do
+ extend Assertions
- define_method :it do
- target
+ singleton_class.class_eval do
+
+ define_method :it do
+ target
+ end
+
end
+ class_exec target, &block
end
-
- class_exec target, &block
-
end
+
end
end
-end; end
+end
@@ -1,5 +1,5 @@
module Test; module Declare
- VERSION = '0.0.1'.freeze
+ VERSION = '0.0.2'.freeze
end; end
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
gem.authors = ['Kenichi Kamiya']
gem.email = ['kachick1+ruby@gmail.com']
gem.summary = %q{DSL wrapper for the "test/unit".}
- gem.description = %q{Tiny DSL and nosey define test cases :)}
+ gem.description = %q{DSL wrapper for the "test/unit".}
gem.homepage = 'https://github.com/kachick/test-declare'
gem.files = `git ls-files`.split($\)

0 comments on commit 9ee313a

Please sign in to comment.