defined 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile ADDED
@@ -0,0 +1,22 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task :default => :test
7
+
8
+ desc 'Test the defined gem.'
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.libs += ['lib', 'test']
11
+ t.pattern = 'test/**/*_test.rb'
12
+ t.verbose = true
13
+ end
14
+
15
+ desc 'Generate documentation for the defined gem.'
16
+ Rake::RDocTask.new(:rdoc) do |rdoc|
17
+ rdoc.rdoc_dir = 'rdoc'
18
+ rdoc.title = 'defined'
19
+ rdoc.options << '--line-numbers' << '--inline-source'
20
+ rdoc.rdoc_files.include('README*')
21
+ rdoc.rdoc_files.include('lib/**/*.rb')
22
+ end
data/lib/defined.rb CHANGED
@@ -37,7 +37,7 @@ module Defined
37
37
  # it calls <tt>Module#defined(file, line, method)</tt> if implemented
38
38
  def trace_function(event, file, line, method, binding, klass)
39
39
  if definition_start?(event, method, klass)
40
- definitions << binding.eval('self')
40
+ definitions << eval('self', binding)
41
41
  elsif definition_end?(event, method, klass)
42
42
  object = definitions.pop
43
43
  method ||= object.class.name.downcase.to_sym
@@ -3,7 +3,7 @@ module Defined
3
3
  module Version
4
4
  MAJOR = 0
5
5
  MINOR = 0
6
- PATCH = 0
6
+ PATCH = 1
7
7
 
8
8
  # Returns a version string by joining <tt>MAJOR</tt>, <tt>MINOR</tt>, and <tt>PATCH</tt> with <tt>'.'</tt>
9
9
  #
data/test/defined_test.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require File.expand_path('../test_helper', __FILE__)
2
2
 
3
3
  class DefinedTest < Test::Unit::TestCase
4
4
  module TestMethods
@@ -97,17 +97,19 @@ class DefinedTest < Test::Unit::TestCase
97
97
 
98
98
  def test_should_call_defined_when_module_is_defined_with_new
99
99
  mod = Module.new { extend TestMethods }
100
- assert mod.called
100
+ assert mod.called, 'Mock.defined was not called after calling Module.new'
101
101
  assert_equal :initialize, mod.method
102
102
  end
103
103
 
104
104
  %w(class instance module).each do |prefix|
105
105
  %w(eval exec).each do |suffix|
106
106
  method_name = [prefix, suffix].join('_').to_sym
107
- define_method "test_should_call_defined_when_module_is_defined_with_#{method_name}" do
108
- Mock.send(method_name) { @called = false }
109
- assert Mock.called
110
- assert_equal method_name, Mock.method
107
+ if respond_to?(method_name)
108
+ define_method "test_should_call_defined_when_module_is_defined_with_#{method_name}" do
109
+ Mock.send(method_name) { @called = false }
110
+ assert Mock.called, "Mock.defined was not called after calling #{method_name}"
111
+ assert_equal method_name, Mock.method
112
+ end
111
113
  end
112
114
  end
113
115
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: defined
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 0
10
- version: 0.0.0
9
+ - 1
10
+ version: 0.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sean Huber
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-23 00:00:00 -08:00
18
+ date: 2011-03-07 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -31,6 +31,7 @@ files:
31
31
  - lib/defined/version.rb
32
32
  - lib/defined.rb
33
33
  - MIT-LICENSE
34
+ - Rakefile
34
35
  - README.rdoc
35
36
  - test/defined_test.rb
36
37
  - test/test_helper.rb