abstract_type 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  ---
2
- threshold: 15
3
- total_score: 32
2
+ threshold: 18
3
+ total_score: 35
@@ -32,7 +32,7 @@ module AbstractType
32
32
  # @api public
33
33
  def new(*)
34
34
  if superclass.equal?(Object)
35
- raise NotImplementedError, "#{self} is an abstract type"
35
+ raise NotImplementedError, "#{inspect} is an abstract type"
36
36
  else
37
37
  super
38
38
  end
@@ -90,9 +90,9 @@ module AbstractType
90
90
  # @api private
91
91
  def create_abstract_singleton_method(name)
92
92
  class_eval <<-RUBY, __FILE__, __LINE__ + 1
93
- def self.#{name}(*) # def self.name(*)
94
- raise NotImplementedError, "\#{name}.\#{__method__} is not implemented" # raise NotImplementedError, 'MyClass#name is not implemented'
95
- end # end
93
+ def self.#{name}(*) # def self.name(*)
94
+ raise NotImplementedError, "\#{inspect}.#{name} is not implemented" # raise NotImplementedError, '\#{inspect}.name is not implemented'
95
+ end # end
96
96
  RUBY
97
97
  end
98
98
 
@@ -106,9 +106,9 @@ module AbstractType
106
106
  # @api private
107
107
  def create_abstract_instance_method(name)
108
108
  class_eval <<-RUBY, __FILE__, __LINE__ + 1
109
- def #{name}(*) # def name(*)
110
- raise NotImplementedError, "\#{self.class.name}#\#{__method__} is not implemented" # raise NotImplementedError, 'MyClass.name is not implemented'
111
- end # end
109
+ def #{name}(*) # def name(*)
110
+ raise NotImplementedError, "\#{self.class.inspect}##{name} is not implemented" # raise NotImplementedError, "\#{self.class.inspect}#name is not implemented"
111
+ end # end
112
112
  RUBY
113
113
  end
114
114
 
@@ -1,3 +1,3 @@
1
1
  module AbstractType
2
- VERSION = '0.0.1'.freeze
2
+ VERSION = '0.0.2'.freeze
3
3
  end
@@ -13,10 +13,16 @@ describe AbstractType::ClassMethods, '#abstract_method' do
13
13
  end
14
14
  end
15
15
 
16
- let(:class_under_test)do
17
- Class.new(abstract_type) do
18
- def self.name; 'TheClassName'; end
19
- end
16
+ let(:class_under_test) do
17
+ Class.new(abstract_type)
18
+ end
19
+
20
+ before do
21
+ TheClassName = class_under_test
22
+ end
23
+
24
+ after do
25
+ Object.class_eval { remove_const(:TheClassName) }
20
26
  end
21
27
 
22
28
  let(:object) { class_under_test.new }
@@ -10,11 +10,17 @@ describe AbstractType::ClassMethods, '#abstract_method' do
10
10
  include AbstractType
11
11
 
12
12
  abstract_singleton_method :some_method
13
-
14
- def self.name; 'TheClassName'; end
15
13
  end
16
14
  end
17
15
 
16
+ before do
17
+ TheClassName = object
18
+ end
19
+
20
+ after do
21
+ Object.class_eval { remove_const(:TheClassName) }
22
+ end
23
+
18
24
  it 'creates an abstract method' do
19
25
  expect { subject }.to raise_error(NotImplementedError, 'TheClassName.some_method is not implemented')
20
26
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abstract_type
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dan Kubb