assert 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- assert (0.2.0)
4
+ assert (0.2.1)
5
5
  ansi (~> 1.3)
6
6
 
7
7
  GEM
data/lib/assert.rb CHANGED
@@ -1,8 +1,5 @@
1
- require 'assert/setup/suite'
2
- require 'assert/setup/view'
3
-
4
- require 'assert/setup/helpers'
5
- require 'assert/setup/autorun'
1
+ require 'assert/setup'
2
+ require 'assert/autorun'
6
3
 
7
4
  Assert::Helpers.load(caller)
8
5
  Assert.autorun
@@ -1,3 +1,4 @@
1
+ require 'assert/setup'
1
2
  require 'assert/runner'
2
3
 
3
4
  module Assert
@@ -86,11 +86,17 @@ module Assert
86
86
  else
87
87
  raise ArgumentError, "please provide a test block" unless block_given?
88
88
  method_name = "test: should #{desc_or_macro}"
89
- if method_defined?(method_name)
89
+
90
+ # instead of using the typical 'method_defined?' pattern (which) checks
91
+ # all parent contexts, we really just need to make sure the method_name
92
+ # is not part of self's local_pulic_test_methods for this check
93
+ if Assert.suite.send(:local_public_test_methods, self).include?(method_name)
90
94
  from = caller.first
91
95
  puts "WARNING: should #{desc_or_macro.inspect} is redefining #{method_name}!"
92
96
  puts " from: #{from}"
97
+ puts " self: #{self.inspect}"
93
98
  end
99
+
94
100
  define_method(method_name, &block)
95
101
  end
96
102
  end
@@ -3,17 +3,13 @@ require 'rake/tasklib'
3
3
 
4
4
  module Assert; end
5
5
  module Assert::RakeTasks
6
+ include Rake::DSL if defined? Rake::DSL
6
7
 
7
8
  FILE_SUFFIX = "_test.rb"
8
9
 
9
10
  # Setup the rake tasks for testing
10
11
  # * add 'include Assert::RakeTasks' to your Rakefile
11
12
  def self.included(receiver)
12
- # get rid of rake warnings
13
- if defined?(::Rake::DSL)
14
- receiver.send :include, ::Rake::DSL
15
- end
16
-
17
13
  # auto-build rake tasks for the ./test files (if defined in ./test)
18
14
  self.for(:test) if File.exists?(File.expand_path('./test', Dir.pwd))
19
15
  end
@@ -0,0 +1,5 @@
1
+ require 'assert/setup/suite'
2
+ require 'assert/setup/view'
3
+ require 'assert/setup/helpers'
4
+
5
+ Assert::Helpers.load(caller)
@@ -15,7 +15,7 @@ module Assert
15
15
  PACKAGE_HELPER_FILE = "helper"
16
16
  TEST_REGEX = /^#{PACKAGE_TEST_DIR}$|^#{PACKAGE_TEST_DIR}\/|\/#{PACKAGE_TEST_DIR}\/|\/#{PACKAGE_TEST_DIR}$/
17
17
 
18
- USER_TEST_HELPER = "~/.assert"
18
+ USER_TEST_HELPER = "~/.assert/options"
19
19
 
20
20
  def load(caller_info)
21
21
  if (crp = caller_root_path(caller_info))
@@ -52,8 +52,9 @@ module Assert
52
52
  # parent dir of caller named TEST_DIR
53
53
  def caller_root_path(caller_info)
54
54
  caller_dirname = File.expand_path(File.dirname(caller_info[0]))
55
- if (test_dir_pos = caller_dirname.index(TEST_REGEX)) > 0
56
- root_dir = caller_dirname[0..(test_dir_pos-1)]
55
+ test_dir_pos = caller_dirname.index(TEST_REGEX)
56
+ if test_dir_pos && (test_dir_pos > 0)
57
+ caller_dirname[0..(test_dir_pos-1)]
57
58
  end
58
59
  end
59
60
  end
data/lib/assert/suite.rb CHANGED
@@ -97,11 +97,20 @@ module Assert
97
97
  end
98
98
 
99
99
  def local_public_test_methods(klass)
100
+ # start with all public meths, store off the local ones
100
101
  methods = klass.public_instance_methods
102
+ local_methods = klass.public_instance_methods(false)
103
+
104
+ # remove any from the superclass
101
105
  while (klass.superclass)
102
106
  methods -= (klass = klass.superclass).public_instance_methods
103
107
  end
104
- methods.delete_if {|method_name| method_name !~ /^test./ }
108
+
109
+ # add back in the local ones (to work around super having the same methods)
110
+ methods += local_methods
111
+
112
+ # uniq and remove any that don't start with 'test'
113
+ methods.uniq.delete_if {|method_name| method_name !~ /^test./ }
105
114
  end
106
115
 
107
116
  private
@@ -1,3 +1,3 @@
1
1
  module Assert
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -17,9 +17,17 @@ class SuperStuff
17
17
  "super not test meth"
18
18
  end
19
19
 
20
+ def test_from_super
21
+ "test from the super"
22
+ end
23
+
24
+ def test_repeated
25
+ "repeated test from super"
26
+ end
27
+
20
28
  end
21
29
 
22
- class SubStuff
30
+ class SubStuff < SuperStuff
23
31
  include MixinStuff
24
32
 
25
33
  def test_subclass_stuff
@@ -33,4 +41,9 @@ class SubStuff
33
41
  def more_other_stuff
34
42
  "more other stuff"
35
43
  end
44
+
45
+ def test_repeated
46
+ "repeated test from sub"
47
+ end
48
+
36
49
  end
data/test/helper.rb CHANGED
@@ -1,4 +1,4 @@
1
- # this file is automatically required in when you require 'test_belt'
1
+ # this file is automatically required in when you require 'assert'
2
2
  # put test helpers here
3
3
 
4
4
  require 'stringio'
data/test/irb.rb CHANGED
@@ -1,7 +1,5 @@
1
- require 'assert'
1
+ # require in any test helper and load user settings
2
+ require 'assert/setup'
2
3
 
3
4
  # this file is required in when the 'irb' rake test is run.
4
- # b/c 'assert' is required above, the test helper will be
5
- # required in.
6
-
7
5
  # put any IRB setup code here
data/test/suite_test.rb CHANGED
@@ -35,7 +35,7 @@ class Assert::Suite
35
35
 
36
36
  should "determine a klass' local public test methods" do
37
37
  assert_equal(
38
- ["test_subclass_stuff", "test_mixin_stuff"].sort,
38
+ ["test_subclass_stuff", "test_mixin_stuff", "test_repeated"].sort,
39
39
  subject.send(:local_public_test_methods, SubStuff).sort.collect(&:to_s)
40
40
  )
41
41
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assert
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kelly Redding
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-08-18 00:00:00 Z
19
+ date: 2011-08-22 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: bundler
@@ -64,11 +64,9 @@ files:
64
64
  - README.rdoc
65
65
  - Rakefile
66
66
  - assert.gemspec
67
- - examples/empty_test.rb
68
- - examples/results_test.rb
69
- - examples/single_test.rb
70
67
  - lib/assert.rb
71
68
  - lib/assert/assertions.rb
69
+ - lib/assert/autorun.rb
72
70
  - lib/assert/context.rb
73
71
  - lib/assert/macro.rb
74
72
  - lib/assert/macros/methods.rb
@@ -77,7 +75,7 @@ files:
77
75
  - lib/assert/result.rb
78
76
  - lib/assert/result_set.rb
79
77
  - lib/assert/runner.rb
80
- - lib/assert/setup/autorun.rb
78
+ - lib/assert/setup.rb
81
79
  - lib/assert/setup/helpers.rb
82
80
  - lib/assert/setup/suite.rb
83
81
  - lib/assert/setup/view.rb
@@ -1,5 +0,0 @@
1
- require 'assert'
2
-
3
- class EmptyTest < Assert::Context
4
-
5
- end
@@ -1,25 +0,0 @@
1
- require 'assert'
2
-
3
- class ResultsTest < Assert::Context
4
-
5
- def test_that_passes
6
- assert 1==1
7
- end
8
-
9
- def test_that_fails
10
- assert 1==0
11
- end
12
-
13
- def test_that_ignores
14
- ignore
15
- end
16
-
17
- def test_that_skips
18
- skip
19
- end
20
-
21
- def test_that_errors
22
- raise Exception
23
- end
24
-
25
- end
@@ -1,9 +0,0 @@
1
- require 'assert'
2
-
3
- class SingleTest < Assert::Context
4
-
5
- def test_this_thing
6
- assert 1==1
7
- end
8
-
9
- end