assert 2.19.2 → 2.19.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/assert.gemspec +10 -7
  3. data/lib/assert.rb +18 -6
  4. data/lib/assert/actual_value.rb +8 -6
  5. data/lib/assert/assert_runner.rb +36 -17
  6. data/lib/assert/assertions.rb +83 -50
  7. data/lib/assert/cli.rb +17 -66
  8. data/lib/assert/clirb.rb +55 -0
  9. data/lib/assert/config.rb +7 -7
  10. data/lib/assert/config_helpers.rb +55 -22
  11. data/lib/assert/context.rb +14 -18
  12. data/lib/assert/context/let_dsl.rb +5 -2
  13. data/lib/assert/context/setup_dsl.rb +21 -16
  14. data/lib/assert/context/subject_dsl.rb +6 -7
  15. data/lib/assert/context/suite_dsl.rb +2 -1
  16. data/lib/assert/context/test_dsl.rb +55 -19
  17. data/lib/assert/default_suite.rb +25 -15
  18. data/lib/assert/default_view.rb +47 -30
  19. data/lib/assert/file_line.rb +6 -6
  20. data/lib/assert/macro.rb +1 -1
  21. data/lib/assert/macros/methods.rb +71 -45
  22. data/lib/assert/result.rb +111 -62
  23. data/lib/assert/runner.rb +68 -51
  24. data/lib/assert/stub.rb +4 -4
  25. data/lib/assert/suite.rb +67 -28
  26. data/lib/assert/test.rb +40 -35
  27. data/lib/assert/utils.rb +19 -10
  28. data/lib/assert/version.rb +1 -1
  29. data/lib/assert/view.rb +44 -18
  30. data/lib/assert/view_helpers.rb +100 -92
  31. data/test/helper.rb +3 -1
  32. data/test/support/factory.rb +38 -21
  33. data/test/system/stub_tests.rb +180 -144
  34. data/test/system/test_tests.rb +86 -60
  35. data/test/unit/actual_value_tests.rb +69 -50
  36. data/test/unit/assert_tests.rb +39 -22
  37. data/test/unit/assertions/assert_block_tests.rb +10 -10
  38. data/test/unit/assertions/assert_changes_tests.rb +25 -21
  39. data/test/unit/assertions/assert_empty_tests.rb +14 -12
  40. data/test/unit/assertions/assert_equal_tests.rb +26 -26
  41. data/test/unit/assertions/assert_file_exists_tests.rb +15 -13
  42. data/test/unit/assertions/assert_includes_tests.rb +10 -10
  43. data/test/unit/assertions/assert_instance_of_tests.rb +14 -14
  44. data/test/unit/assertions/assert_is_a_tests.rb +128 -0
  45. data/test/unit/assertions/assert_match_tests.rb +10 -10
  46. data/test/unit/assertions/assert_nil_tests.rb +16 -12
  47. data/test/unit/assertions/assert_raises_tests.rb +27 -20
  48. data/test/unit/assertions/assert_respond_to_tests.rb +10 -10
  49. data/test/unit/assertions/assert_same_tests.rb +24 -24
  50. data/test/unit/assertions/assert_true_false_tests.rb +32 -24
  51. data/test/unit/assertions_tests.rb +14 -9
  52. data/test/unit/config_helpers_tests.rb +15 -10
  53. data/test/unit/config_tests.rb +10 -9
  54. data/test/unit/context/setup_dsl_tests.rb +24 -14
  55. data/test/unit/context/subject_dsl_tests.rb +3 -3
  56. data/test/unit/context/suite_dsl_tests.rb +4 -4
  57. data/test/unit/context/test_dsl_tests.rb +37 -17
  58. data/test/unit/context_info_tests.rb +4 -4
  59. data/test/unit/context_tests.rb +110 -54
  60. data/test/unit/default_suite_tests.rb +10 -6
  61. data/test/unit/factory_tests.rb +2 -2
  62. data/test/unit/file_line_tests.rb +7 -7
  63. data/test/unit/macro_tests.rb +11 -11
  64. data/test/unit/result_tests.rb +47 -41
  65. data/test/unit/runner_tests.rb +29 -16
  66. data/test/unit/suite_tests.rb +37 -15
  67. data/test/unit/test_tests.rb +63 -50
  68. data/test/unit/utils_tests.rb +48 -35
  69. data/test/unit/view_helpers_tests.rb +21 -14
  70. data/test/unit/view_tests.rb +5 -5
  71. metadata +26 -11
  72. data/test/unit/assertions/assert_kind_of_tests.rb +0 -68
@@ -4,13 +4,14 @@ module Assert; end
4
4
  class Assert::Context; end
5
5
 
6
6
  module Assert::Context::SubjectDSL
7
- # Add a piece of description text or return the full description for the context
7
+ # Add a piece of description text or return the full description
8
+ # for the context.
8
9
  def description(text = nil)
9
10
  if text
10
- self.descriptions << text.to_s
11
+ descriptions << text.to_s
11
12
  else
12
- parent = self.superclass.desc if self.superclass.respond_to?(:desc)
13
- own = self.descriptions
13
+ parent = superclass.desc if superclass.respond_to?(:desc)
14
+ own = descriptions
14
15
  [parent, *own].compact.reject(&:empty?).join(" ")
15
16
  end
16
17
  end
@@ -21,9 +22,7 @@ module Assert::Context::SubjectDSL
21
22
  if block_given?
22
23
  @subject = block
23
24
  else
24
- @subject || if superclass.respond_to?(:subject)
25
- superclass.subject
26
- end
25
+ @subject || (superclass.subject if superclass.respond_to?(:subject))
27
26
  end
28
27
  end
29
28
 
@@ -8,7 +8,8 @@ class Assert::Context
8
8
  if suite_obj
9
9
  @suite = suite_obj
10
10
  else
11
- @suite || if superclass.respond_to?(:suite)
11
+ @suite ||
12
+ if superclass.respond_to?(:suite)
12
13
  superclass.suite
13
14
  else
14
15
  Assert.suite
@@ -10,45 +10,81 @@ module Assert; end
10
10
  class Assert::Context
11
11
  module TestDSL
12
12
  def test(desc_or_macro, called_from = nil, first_caller = nil, &block)
13
- if desc_or_macro.kind_of?(Assert::Macro)
13
+ if desc_or_macro.is_a?(Assert::Macro)
14
14
  instance_eval(&desc_or_macro)
15
15
  elsif block_given?
16
16
  # create a test from the given code block
17
- self.suite.on_test(Assert::Test.for_block(
18
- desc_or_macro.kind_of?(Assert::Macro) ? desc_or_macro.name : desc_or_macro,
19
- Assert::ContextInfo.new(self, called_from, first_caller || caller_locations.first),
20
- self.suite.config,
21
- &block
22
- ))
17
+ desc =
18
+ if desc_or_macro.is_a?(Assert::Macro)
19
+ desc_or_macro.name
20
+ else
21
+ desc_or_macro
22
+ end
23
+ suite.on_test(
24
+ Assert::Test.for_block(
25
+ desc,
26
+ Assert::ContextInfo.new(
27
+ self,
28
+ called_from,
29
+ first_caller || caller_locations.first,
30
+ ),
31
+ suite.config,
32
+ &block
33
+ ),
34
+ )
23
35
  else
24
- test_eventually(desc_or_macro, called_from, first_caller || caller_locations.first, &block)
36
+ test_eventually(
37
+ desc_or_macro,
38
+ called_from,
39
+ first_caller || caller_locations.first,
40
+ &block
41
+ )
25
42
  end
26
43
  end
27
44
 
28
- def test_eventually(desc_or_macro, called_from = nil, first_caller = nil, &block)
45
+ def test_eventually(desc_or_macro, called_from = nil, first_caller = nil)
29
46
  # create a test from a proc that just skips
30
- ci = Assert::ContextInfo.new(self, called_from, first_caller || caller_locations.first)
31
- self.suite.on_test(Assert::Test.for_block(
32
- desc_or_macro.kind_of?(Assert::Macro) ? desc_or_macro.name : desc_or_macro,
47
+ ci =
48
+ Assert::ContextInfo.new(
49
+ self,
50
+ called_from,
51
+ first_caller || caller_locations.first,
52
+ )
53
+ suite.on_test(Assert::Test.for_block(
54
+ desc_or_macro.is_a?(Assert::Macro) ? desc_or_macro.name : desc_or_macro,
33
55
  ci,
34
- self.suite.config,
35
- &proc { skip("TODO", [ci.called_from.to_s]) }
56
+ suite.config,
57
+ &proc{ skip("TODO", [ci.called_from.to_s]) }
36
58
  ))
37
59
  end
38
60
  alias_method :test_skip, :test_eventually
39
61
 
40
62
  def should(desc_or_macro, called_from = nil, first_caller = nil, &block)
41
- if !desc_or_macro.kind_of?(Assert::Macro)
63
+ unless desc_or_macro.is_a?(Assert::Macro)
42
64
  desc_or_macro = "should #{desc_or_macro}"
43
65
  end
44
- test(desc_or_macro, called_from, first_caller || caller_locations.first, &block)
66
+ test(
67
+ desc_or_macro,
68
+ called_from,
69
+ first_caller || caller_locations.first,
70
+ &block
71
+ )
45
72
  end
46
73
 
47
- def should_eventually(desc_or_macro, called_from = nil, first_caller = nil, &block)
48
- if !desc_or_macro.kind_of?(Assert::Macro)
74
+ def should_eventually(
75
+ desc_or_macro,
76
+ called_from = nil,
77
+ first_caller = nil,
78
+ &block)
79
+ unless desc_or_macro.is_a?(Assert::Macro)
49
80
  desc_or_macro = "should #{desc_or_macro}"
50
81
  end
51
- test_eventually(desc_or_macro, called_from, first_caller || caller_locations.first, &block)
82
+ test_eventually(
83
+ desc_or_macro,
84
+ called_from,
85
+ first_caller || caller_locations.first,
86
+ &block
87
+ )
52
88
  end
53
89
  alias_method :should_skip, :should_eventually
54
90
  end
@@ -7,41 +7,51 @@ module Assert
7
7
  # behavior, it accumulates test/result counts in memory. This data is used
8
8
  # by the runner/view for handling and presentation purposes.
9
9
  class DefaultSuite < Assert::Suite
10
+ attr_reader :test_count, :result_count, :pass_result_count
11
+ attr_reader :fail_result_count, :error_result_count
12
+ attr_reader :skip_result_count, :ignore_result_count
13
+
10
14
  def initialize(config)
11
15
  super
12
16
  reset_run_data
13
17
  end
14
18
 
15
- def test_count; @test_count; end
16
- def result_count; @result_count; end
17
- def pass_result_count; @pass_result_count; end
18
- def fail_result_count; @fail_result_count; end
19
- def error_result_count; @error_result_count; end
20
- def skip_result_count; @skip_result_count; end
21
- def ignore_result_count; @ignore_result_count; end
22
-
23
19
  # Callbacks
24
20
 
25
21
  def on_start
26
22
  reset_run_data
27
23
  end
28
24
 
29
- def before_test(test)
25
+ def before_test(_test)
30
26
  @test_count += 1
31
27
  end
32
28
 
33
29
  def on_result(result)
34
30
  @result_count += 1
35
- self.send("increment_#{result.type}_result_count")
31
+ send("increment_#{result.type}_result_count")
36
32
  end
37
33
 
38
34
  private
39
35
 
40
- def increment_pass_result_count; @pass_result_count += 1; end
41
- def increment_fail_result_count; @fail_result_count += 1; end
42
- def increment_error_result_count; @error_result_count += 1; end
43
- def increment_skip_result_count; @skip_result_count += 1; end
44
- def increment_ignore_result_count; @ignore_result_count += 1; end
36
+ def increment_pass_result_count
37
+ @pass_result_count += 1
38
+ end
39
+
40
+ def increment_fail_result_count
41
+ @fail_result_count += 1
42
+ end
43
+
44
+ def increment_error_result_count
45
+ @error_result_count += 1
46
+ end
47
+
48
+ def increment_skip_result_count
49
+ @skip_result_count += 1
50
+ end
51
+
52
+ def increment_ignore_result_count
53
+ @ignore_result_count += 1
54
+ end
45
55
 
46
56
  def reset_run_data
47
57
  @test_count = 0
@@ -31,26 +31,28 @@ module Assert
31
31
  end
32
32
 
33
33
  def on_finish
34
- if self.test_count > 0
35
- dump_test_results
36
- end
34
+ dump_test_results if test_count > 0
37
35
 
38
36
  # show profile output
39
37
  if show_test_profile_info?
40
38
  # sort the test datas fastest to slowest
41
- @test_datas.values.sort{ |a, b| a.run_time <=> b.run_time }.each do |test_data|
42
- puts "#{formatted_run_time(test_data.run_time)} seconds,"\
43
- " #{test_data.result_count} results,"\
44
- " #{formatted_result_rate(test_data.result_rate)} results/s --"\
45
- " #{test_data.context}: #{test_data.name.inspect}"
46
- end
39
+ @test_datas
40
+ .values
41
+ .sort{ |a, b| a.run_time <=> b.run_time }
42
+ .each do |test_data|
43
+ puts "#{formatted_run_time(test_data.run_time)} seconds,"\
44
+ " #{test_data.result_count} results,"\
45
+ " #{formatted_result_rate(test_data.result_rate)} results/s "\
46
+ "-- #{test_data.context}: #{test_data.name.inspect}"
47
+ end
47
48
  puts
48
49
  end
49
50
 
50
51
  # style the summaries of each result set
51
- styled_results_sentence = results_summary_sentence do |summary, result_type|
52
- ansi_styled_msg(summary, result_type)
53
- end
52
+ styled_results_sentence =
53
+ results_summary_sentence do |summary, result_type|
54
+ ansi_styled_msg(summary, result_type)
55
+ end
54
56
 
55
57
  puts "#{result_count_statement}: #{styled_results_sentence}"
56
58
  puts
@@ -68,7 +70,7 @@ module Assert
68
70
  puts
69
71
  end
70
72
 
71
- def on_interrupt(err)
73
+ def on_interrupt(_err)
72
74
  dump_test_results
73
75
  end
74
76
 
@@ -82,7 +84,7 @@ module Assert
82
84
  def set_callbacks
83
85
  @metaclass = class << self; self; end
84
86
  if accumulate_test_data?
85
- @metaclass.class_eval <<-callbacks
87
+ @metaclass.class_eval <<-RUBY
86
88
  def before_test(test)
87
89
  test_data = get_test_data(test)
88
90
  puts "\#{test_data.name.inspect} (\#{test_data.context})"
@@ -91,32 +93,46 @@ module Assert
91
93
  end
92
94
 
93
95
  def on_result(result)
94
- print ansi_styled_msg(self.send("\#{result.to_sym}_abbrev"), result.type)
95
- @results_to_dump << ResultData.for_result(result) if dumpable_result?(result)
96
+ print(
97
+ ansi_styled_msg(
98
+ self.send("\#{result.to_sym}_abbrev"),
99
+ result.type,
100
+ )
101
+ )
102
+ @results_to_dump <<
103
+ ResultData.for_result(result) if dumpable_result?(result)
96
104
  find_test_data(result.test_file_line).result_count += 1
97
105
  end
98
106
 
99
107
  def after_test(test)
100
108
  test_data = find_test_data(test.file_line)
101
- test_data.run_time = test.run_time
102
- test_data.result_rate = get_rate(test_data.result_count, test_data.run_time)
109
+ test_data.run_time = test.run_time
110
+ test_data.result_rate =
111
+ get_rate(test_data.result_count, test_data.run_time)
103
112
 
104
113
  if show_test_verbose_info?
105
114
  print " \#{formatted_run_time(test_data.run_time)} seconds,"\
106
115
  " \#{test_data.result_count} results,"\
107
- " \#{formatted_result_rate(test_data.result_rate)} results/s\n"
116
+ " \#{formatted_result_rate(test_data.result_rate)} "\
117
+ "results/s\n"
108
118
  else
109
119
  print "\n"
110
120
  end
111
121
  end
112
- callbacks
122
+ RUBY
113
123
  else
114
- @metaclass.class_eval <<-callbacks
124
+ @metaclass.class_eval <<-RUBY
115
125
  def on_result(result)
116
- print ansi_styled_msg(self.send("\#{result.to_sym}_abbrev"), result.type)
117
- @results_to_dump << ResultData.for_result(result) if dumpable_result?(result)
126
+ print(
127
+ ansi_styled_msg(
128
+ self.send("\#{result.to_sym}_abbrev"),
129
+ result.type
130
+ )
131
+ )
132
+ @results_to_dump <<
133
+ ResultData.for_result(result) if dumpable_result?(result)
118
134
  end
119
- callbacks
135
+ RUBY
120
136
  end
121
137
  end
122
138
 
@@ -158,27 +174,28 @@ module Assert
158
174
  end
159
175
  end
160
176
 
161
- attrs = [:name, :context, :file_line, :result_count, :run_time, :result_rate]
177
+ attrs =
178
+ [:name, :context, :file_line, :result_count, :run_time, :result_rate]
162
179
  class TestData < Struct.new(*attrs)
163
180
  def self.for_test(t)
164
- self.new(t.name, t.context_class, t.file_line.to_s, 0, 0.0, 0.0)
181
+ new(t.name, t.context_class, t.file_line.to_s, 0, 0.0, 0.0)
165
182
  end
166
183
  end
167
184
 
168
185
  attrs = [:type, :details, :output, :test_id, :sort_by]
169
186
  class ResultData < Struct.new(*attrs)
170
187
  def self.for_result(r)
171
- self.new(r.type, r.to_s, r.output, r.test_id, self.sort_by(r))
188
+ new(r.type, r.to_s, r.output, r.test_id, sort_by(r))
172
189
  end
173
190
 
174
191
  def self.sort_by(r)
175
192
  [r.test_file_name, r.test_line_num, r.file_name, r.line_num]
176
193
  end
177
194
 
178
- def <=>(other_rd)
195
+ def <=>(other)
179
196
  # show in reverse definition order
180
- if other_rd.kind_of?(ResultData)
181
- other_rd.sort_by <=> self.sort_by
197
+ if other.is_a?(ResultData)
198
+ other.sort_by <=> sort_by
182
199
  else
183
200
  super
184
201
  end
@@ -3,7 +3,7 @@
3
3
  module Assert
4
4
  class FileLine
5
5
  def self.parse(file_line_path)
6
- self.new(*(file_line_path.to_s.match(/(^[^\:]*)\:*(\d*).*$/) || [])[1..2])
6
+ new(*(file_line_path.to_s.match(/(^[^\:]*)\:*(\d*).*$/) || [])[1..2])
7
7
  end
8
8
 
9
9
  attr_reader :file, :line
@@ -13,13 +13,13 @@ module Assert
13
13
  end
14
14
 
15
15
  def to_s
16
- "#{self.file}:#{self.line}"
16
+ "#{file}:#{line}"
17
17
  end
18
18
 
19
- def ==(other_file_line)
20
- if other_file_line.kind_of?(FileLine)
21
- self.file == other_file_line.file &&
22
- self.line == other_file_line.line
19
+ def ==(other)
20
+ if other.is_a?(FileLine)
21
+ file == other.file &&
22
+ line == other.line
23
23
  else
24
24
  super
25
25
  end
@@ -7,7 +7,7 @@ module Assert
7
7
  # will be instance_eval'd in that Assert::Context.
8
8
  attr_accessor :name
9
9
 
10
- def initialize(name = nil, *args, &block)
10
+ def initialize(name = nil, *_args)
11
11
  raise ArgumentError unless block_given?
12
12
  @name = name || "run this macro"
13
13
  super()
@@ -10,9 +10,12 @@ module Assert::Macros
10
10
 
11
11
  module ClassMethods
12
12
  def have_instance_method(*methods)
13
- called_from = (methods.last.kind_of?(Array) ? methods.pop : caller_locations).first
13
+ called_from =
14
+ (methods.last.is_a?(Array) ? methods.pop : caller_locations).first
14
15
  Assert::Macro.new do
15
- methods.each{ |m| _methods_macro_instance_methods << [m, called_from] }
16
+ methods.each do |m|
17
+ _methods_macro_instance_methods << [m, called_from]
18
+ end
16
19
  _methods_macro_test called_from
17
20
  end
18
21
  end
@@ -21,9 +24,12 @@ module Assert::Macros
21
24
  alias_method :have_imeths, :have_instance_method
22
25
 
23
26
  def not_have_instance_method(*methods)
24
- called_from = (methods.last.kind_of?(Array) ? methods.pop : caller_locations).first
27
+ called_from =
28
+ (methods.last.is_a?(Array) ? methods.pop : caller_locations).first
25
29
  Assert::Macro.new do
26
- methods.each{ |m| _methods_macro_not_instance_methods << [m, called_from] }
30
+ methods.each do |m|
31
+ _methods_macro_not_instance_methods << [m, called_from]
32
+ end
27
33
  _methods_macro_test called_from
28
34
  end
29
35
  end
@@ -32,7 +38,8 @@ module Assert::Macros
32
38
  alias_method :not_have_imeths, :not_have_instance_method
33
39
 
34
40
  def have_class_method(*methods)
35
- called_from = (methods.last.kind_of?(Array) ? methods.pop : caller_locations).first
41
+ called_from =
42
+ (methods.last.is_a?(Array) ? methods.pop : caller_locations).first
36
43
  Assert::Macro.new do
37
44
  methods.each{ |m| _methods_macro_class_methods << [m, called_from] }
38
45
  _methods_macro_test called_from
@@ -43,9 +50,12 @@ module Assert::Macros
43
50
  alias_method :have_cmeths, :have_class_method
44
51
 
45
52
  def not_have_class_method(*methods)
46
- called_from = (methods.last.kind_of?(Array) ? methods.pop : caller_locations).first
53
+ called_from =
54
+ (methods.last.is_a?(Array) ? methods.pop : caller_locations).first
47
55
  Assert::Macro.new do
48
- methods.each{ |m| _methods_macro_not_class_methods << [m, called_from] }
56
+ methods.each do |m|
57
+ _methods_macro_not_class_methods << [m, called_from]
58
+ end
49
59
  _methods_macro_test called_from
50
60
  end
51
61
  end
@@ -54,44 +64,44 @@ module Assert::Macros
54
64
  alias_method :not_have_cmeths, :not_have_class_method
55
65
 
56
66
  def have_reader(*methods)
57
- methods << caller_locations if !methods.last.kind_of?(Array)
67
+ methods << caller_locations unless methods.last.is_a?(Array)
58
68
  have_instance_methods(*methods)
59
69
  end
60
70
  alias_method :have_readers, :have_reader
61
71
 
62
72
  def not_have_reader(*methods)
63
- methods << caller_locations if !methods.last.kind_of?(Array)
73
+ methods << caller_locations unless methods.last.is_a?(Array)
64
74
  not_have_instance_methods(*methods)
65
75
  end
66
76
  alias_method :not_have_readers, :not_have_reader
67
77
 
68
78
  def have_writer(*methods)
69
- called = methods.last.kind_of?(Array) ? methods.pop : caller_locations
70
- writer_meths = methods.collect{|m| "#{m}="}
79
+ called = methods.last.is_a?(Array) ? methods.pop : caller_locations
80
+ writer_meths = methods.collect{ |m| "#{m}=" }
71
81
  writer_meths << called
72
82
  have_instance_methods(*writer_meths)
73
83
  end
74
84
  alias_method :have_writers, :have_writer
75
85
 
76
86
  def not_have_writer(*methods)
77
- called = methods.last.kind_of?(Array) ? methods.pop : caller_locations
78
- writer_meths = methods.collect{|m| "#{m}="}
87
+ called = methods.last.is_a?(Array) ? methods.pop : caller_locations
88
+ writer_meths = methods.collect{ |m| "#{m}=" }
79
89
  writer_meths << called
80
90
  not_have_instance_methods(*writer_meths)
81
91
  end
82
92
  alias_method :not_have_writers, :not_have_writer
83
93
 
84
94
  def have_accessor(*methods)
85
- called = methods.last.kind_of?(Array) ? methods.pop : caller_locations
86
- accessor_meths = methods.collect{|m| [m, "#{m}="]}.flatten
95
+ called = methods.last.is_a?(Array) ? methods.pop : caller_locations
96
+ accessor_meths = methods.collect{ |m| [m, "#{m}="] }.flatten
87
97
  accessor_meths << called
88
98
  have_instance_methods(*accessor_meths)
89
99
  end
90
100
  alias_method :have_accessors, :have_accessor
91
101
 
92
102
  def not_have_accessor(*methods)
93
- called = methods.last.kind_of?(Array) ? methods.pop : caller_locations
94
- accessor_meths = methods.collect{|m| [m, "#{m}="]}.flatten
103
+ called = methods.last.is_a?(Array) ? methods.pop : caller_locations
104
+ accessor_meths = methods.collect{ |m| [m, "#{m}="] }.flatten
95
105
  accessor_meths << called
96
106
  not_have_instance_methods(*accessor_meths)
97
107
  end
@@ -100,35 +110,51 @@ module Assert::Macros
100
110
  # private
101
111
 
102
112
  def _methods_macro_test(called_from)
103
- @_methods_macro_test ||= test "should respond to methods", called_from do
104
- self.class._methods_macro_instance_methods.each do |(method, called_from)|
105
- msg = "#{subject.class.name} does not have instance method ##{method}"
106
- with_backtrace([called_from]) do
107
- assert_that(subject).responds_to(method, msg)
108
- end
109
- end
110
-
111
- self.class._methods_macro_class_methods.each do |(method, called_from)|
112
- msg = "#{subject.class.name} does not have class method ##{method}"
113
- with_backtrace([called_from]) do
114
- assert_that(subject.class).responds_to(method, msg)
115
- end
113
+ @_methods_macro_test ||=
114
+ test "should respond to methods", called_from do
115
+ self
116
+ .class
117
+ ._methods_macro_instance_methods
118
+ .each do |(method, called_from)|
119
+ msg =
120
+ "#{subject.class.name} does not have "\
121
+ "instance method ##{method}"
122
+ with_backtrace([called_from]) do
123
+ assert_that(subject).responds_to(method, msg)
124
+ end
125
+ end
126
+
127
+ self
128
+ .class
129
+ ._methods_macro_class_methods
130
+ .each do |(method, called_from)|
131
+ msg =
132
+ "#{subject.class.name} does not have class method ##{method}"
133
+ with_backtrace([called_from]) do
134
+ assert_that(subject.class).responds_to(method, msg)
135
+ end
136
+ end
137
+
138
+ self
139
+ .class
140
+ ._methods_macro_not_instance_methods
141
+ .each do |(method, called_from)|
142
+ msg = "#{subject.class.name} has instance method ##{method}"
143
+ with_backtrace([called_from]) do
144
+ assert_that(subject).does_not_respond_to(method, msg)
145
+ end
146
+ end
147
+
148
+ self
149
+ .class
150
+ ._methods_macro_not_class_methods
151
+ .each do |(method, called_from)|
152
+ msg = "#{subject.class.name} has class method ##{method}"
153
+ with_backtrace([called_from]) do
154
+ assert_that(subject.class).does_not_respond_to(method, msg)
155
+ end
156
+ end
116
157
  end
117
-
118
- self.class._methods_macro_not_instance_methods.each do |(method, called_from)|
119
- msg = "#{subject.class.name} has instance method ##{method}"
120
- with_backtrace([called_from]) do
121
- assert_that(subject).does_not_respond_to(method, msg)
122
- end
123
- end
124
-
125
- self.class._methods_macro_not_class_methods.each do |(method, called_from)|
126
- msg = "#{subject.class.name} has class method ##{method}"
127
- with_backtrace([called_from]) do
128
- assert_that(subject.class).does_not_respond_to(method, msg)
129
- end
130
- end
131
- end
132
158
  end
133
159
 
134
160
  def _methods_macro_instance_methods