assert 2.19.2 → 2.19.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -16,7 +16,7 @@ module Assert
16
16
  def option(name, *default_vals)
17
17
  default = default_vals.size > 1 ? default_vals : default_vals.first
18
18
  define_method(name) do |*args|
19
- if !(value = args.size > 1 ? args : args.first).nil?
19
+ unless (value = args.size > 1 ? args : args.first).nil?
20
20
  instance_variable_set("@#{name}", value)
21
21
  end
22
22
  (val = instance_variable_get("@#{name}")).nil? ? default : val
@@ -38,11 +38,11 @@ module Assert
38
38
  end
39
39
 
40
40
  def tests_to_run_count_statement
41
- "#{self.tests_to_run_count} test#{"s" if self.tests_to_run_count != 1}"
41
+ "#{tests_to_run_count} test#{"s" if tests_to_run_count != 1}"
42
42
  end
43
43
 
44
44
  def result_count_statement
45
- "#{self.result_count} result#{"s" if self.result_count != 1}"
45
+ "#{result_count} result#{"s" if result_count != 1}"
46
46
  end
47
47
 
48
48
  # generate a comma-seperated sentence fragment given a list of items
@@ -56,9 +56,9 @@ module Assert
56
56
 
57
57
  # generate an appropriate result summary msg for all tests passing
58
58
  def all_pass_result_summary_msg
59
- if self.result_count < 1
59
+ if result_count < 1
60
60
  "uhh..."
61
- elsif self.result_count == 1
61
+ elsif result_count == 1
62
62
  "pass"
63
63
  else
64
64
  "all pass"
@@ -67,112 +67,120 @@ module Assert
67
67
 
68
68
  # print a result summary message for a given result type
69
69
  def result_summary_msg(result_type)
70
- if result_type == :pass && self.all_pass?
71
- self.all_pass_result_summary_msg
70
+ if result_type == :pass && all_pass?
71
+ all_pass_result_summary_msg
72
72
  else
73
- "#{self.send("#{result_type}_result_count")} #{result_type}"
73
+ "#{send("#{result_type}_result_count")} #{result_type}"
74
74
  end
75
75
  end
76
76
 
77
77
  # generate a sentence fragment describing the breakdown of test results
78
- # if a block is given, yield each msg in the breakdown for custom formatting
78
+ # if a block is given, yield each msg in the breakdown for custom
79
+ # formatting.
79
80
  def results_summary_sentence
80
- summaries = self.ocurring_result_types.map do |result_type|
81
- summary_msg = self.result_summary_msg(result_type)
81
+ summaries = ocurring_result_types.map do |result_type|
82
+ summary_msg = result_summary_msg(result_type)
82
83
  block_given? ? yield(summary_msg, result_type) : summary_msg
83
84
  end
84
- self.to_sentence(summaries)
85
+ to_sentence(summaries)
85
86
  end
86
87
  end
87
88
 
88
89
  module Ansi
89
- # Table of supported styles/codes (http://en.wikipedia.org/wiki/ANSI_escape_code)
90
+ # Table of supported styles/codes
91
+ # (http://en.wikipedia.org/wiki/ANSI_escape_code).
90
92
  CODES = {
91
- :clear => 0,
92
- :reset => 0,
93
- :bright => 1,
94
- :bold => 1,
95
- :faint => 2,
96
- :dark => 2,
97
- :italic => 3,
98
- :underline => 4,
99
- :underscore => 4,
100
- :blink => 5,
101
- :slow_blink => 5,
102
- :rapid => 6,
103
- :rapid_blink => 6,
104
- :invert => 7,
105
- :inverse => 7,
106
- :reverse => 7,
107
- :negative => 7,
108
- :swap => 7,
109
- :conceal => 8,
110
- :concealed => 8,
111
- :hide => 9,
112
- :strike => 9,
113
-
114
- :default_font => 10,
115
- :font_default => 10,
116
- :font0 => 10,
117
- :font1 => 11,
118
- :font2 => 12,
119
- :font3 => 13,
120
- :font4 => 14,
121
- :font5 => 15,
122
- :font6 => 16,
123
- :font7 => 17,
124
- :font8 => 18,
125
- :font9 => 19,
126
- :fraktur => 20,
127
- :bright_off => 21,
128
- :bold_off => 21,
129
- :double_underline => 21,
130
- :clean => 22,
131
- :italic_off => 23,
132
- :fraktur_off => 23,
133
- :underline_off => 24,
134
- :blink_off => 25,
135
- :inverse_off => 26,
136
- :positive => 26,
137
- :conceal_off => 27,
138
- :show => 27,
139
- :reveal => 27,
140
- :crossed_off => 29,
141
- :crossed_out_off => 29,
142
-
143
- :black => 30,
144
- :red => 31,
145
- :green => 32,
146
- :yellow => 33,
147
- :blue => 34,
148
- :magenta => 35,
149
- :cyan => 36,
150
- :white => 37,
151
-
152
- :on_black => 40,
153
- :on_red => 41,
154
- :on_green => 42,
155
- :on_yellow => 43,
156
- :on_blue => 44,
157
- :on_magenta => 45,
158
- :on_cyan => 46,
159
- :on_white => 47,
160
-
161
- :frame => 51,
162
- :encircle => 52,
163
- :overline => 53,
164
- :frame_off => 54,
165
- :encircle_off => 54,
166
- :overline_off => 55,
93
+ clear: 0,
94
+ reset: 0,
95
+ bright: 1,
96
+ bold: 1,
97
+ faint: 2,
98
+ dark: 2,
99
+ italic: 3,
100
+ underline: 4,
101
+ underscore: 4,
102
+ blink: 5,
103
+ slow_blink: 5,
104
+ rapid: 6,
105
+ rapid_blink: 6,
106
+ invert: 7,
107
+ inverse: 7,
108
+ reverse: 7,
109
+ negative: 7,
110
+ swap: 7,
111
+ conceal: 8,
112
+ concealed: 8,
113
+ hide: 9,
114
+ strike: 9,
115
+
116
+ default_font: 10,
117
+ font_default: 10,
118
+ font0: 10,
119
+ font1: 11,
120
+ font2: 12,
121
+ font3: 13,
122
+ font4: 14,
123
+ font5: 15,
124
+ font6: 16,
125
+ font7: 17,
126
+ font8: 18,
127
+ font9: 19,
128
+ fraktur: 20,
129
+ bright_off: 21,
130
+ bold_off: 21,
131
+ double_underline: 21,
132
+ clean: 22,
133
+ italic_off: 23,
134
+ fraktur_off: 23,
135
+ underline_off: 24,
136
+ blink_off: 25,
137
+ inverse_off: 26,
138
+ positive: 26,
139
+ conceal_off: 27,
140
+ show: 27,
141
+ reveal: 27,
142
+ crossed_off: 29,
143
+ crossed_out_off: 29,
144
+
145
+ black: 30,
146
+ red: 31,
147
+ green: 32,
148
+ yellow: 33,
149
+ blue: 34,
150
+ magenta: 35,
151
+ cyan: 36,
152
+ white: 37,
153
+
154
+ on_black: 40,
155
+ on_red: 41,
156
+ on_green: 42,
157
+ on_yellow: 43,
158
+ on_blue: 44,
159
+ on_magenta: 45,
160
+ on_cyan: 46,
161
+ on_white: 47,
162
+
163
+ frame: 51,
164
+ encircle: 52,
165
+ overline: 53,
166
+ frame_off: 54,
167
+ encircle_off: 54,
168
+ overline_off: 55,
167
169
  }
168
170
 
169
171
  def self.code_for(*style_names)
170
- style_names.map{ |n| "\e[#{CODES[n]}m" if CODES.key?(n) }.compact.join("")
172
+ style_names
173
+ .map{ |n| "\e[#{CODES[n]}m" if CODES.key?(n) }
174
+ .compact
175
+ .join("")
171
176
  end
172
177
 
173
178
  def ansi_styled_msg(msg, result_type)
174
- return msg if !self.is_tty? || !self.styled
175
- code = Assert::ViewHelpers::Ansi.code_for(*self.send("#{result_type}_styles"))
179
+ return msg if !is_tty? || !styled
180
+ code =
181
+ Assert::ViewHelpers::Ansi.code_for(
182
+ *send("#{result_type}_styles"),
183
+ )
176
184
  return msg if code.empty?
177
185
  code + msg + Assert::ViewHelpers::Ansi.code_for(:reset)
178
186
  end
@@ -16,12 +16,13 @@ module Assert::Test::TestHelpers
16
16
  receiver.class_eval do
17
17
  setup do
18
18
  @test_run_results = []
19
- @run_callback = proc { |result| @test_run_results << result }
19
+ @run_callback = proc{ |result| @test_run_results << result }
20
20
  end
21
21
  end
22
22
 
23
23
  private
24
24
 
25
+ # rubocop:disable Lint/NestedMethodDefinition
25
26
  def test_run_callback
26
27
  @run_callback
27
28
  end
@@ -42,5 +43,6 @@ module Assert::Test::TestHelpers
42
43
  def last_test_run_result
43
44
  @test_run_results.last
44
45
  end
46
+ # rubocop:enable Lint/NestedMethodDefinition
45
47
  end
46
48
  end
@@ -10,11 +10,17 @@ module Factory
10
10
  extend Assert::Factory
11
11
 
12
12
  def self.context_info_called_from
13
- File.expand_path("#{Factory.path}_tests.rb:#{Factory.integer}", Dir.pwd)
13
+ File.expand_path(
14
+ "#{Factory.path}_tests.rb:#{Factory.integer}",
15
+ Dir.pwd,
16
+ )
14
17
  end
15
18
 
16
19
  def self.context_info(context_klass = nil)
17
- Assert::ContextInfo.new(context_klass || self.context_class, context_info_called_from)
20
+ Assert::ContextInfo.new(
21
+ context_klass || context_class,
22
+ context_info_called_from,
23
+ )
18
24
  end
19
25
 
20
26
  # Generate an anonymous `Context` inherited from `Assert::Context` by default.
@@ -24,9 +30,8 @@ module Factory
24
30
  klass = Class.new(inherit_from || Assert::Context, &block)
25
31
  default = const_name = "FactoryAssertContext"
26
32
 
27
- while(Object.const_defined?(const_name)) do
28
- const_name = "#{default}#{rand(Time.now.to_i)}"
29
- end
33
+ const_name =
34
+ "#{default}#{rand(Time.now.to_i)}" while Object.const_defined?(const_name)
30
35
  Object.const_set(const_name, klass)
31
36
  klass
32
37
  end
@@ -35,9 +40,9 @@ module Factory
35
40
 
36
41
  def self.test(*args, &block)
37
42
  config, context_info, name = [
38
- args.last.kind_of?(Assert::Config) ? args.pop : self.modes_off_config,
39
- args.last.kind_of?(Assert::ContextInfo) ? args.pop : self.context_info,
40
- args.last.kind_of?(::String) ? args.pop : "a test"
43
+ args.last.is_a?(Assert::Config) ? args.pop : modes_off_config,
44
+ args.last.is_a?(Assert::ContextInfo) ? args.pop : self.context_info,
45
+ args.last.is_a?(::String) ? args.pop : "a test",
41
46
  ]
42
47
  Assert::Test.for_block(name, context_info, config, &block)
43
48
  end
@@ -45,15 +50,27 @@ module Factory
45
50
  # Generate results for use in testing.
46
51
 
47
52
  def self.pass_result(msg = nil)
48
- Assert::Result::Pass.for_test(Factory.test(Factory.string), msg || Factory.string, [])
53
+ Assert::Result::Pass.for_test(
54
+ Factory.test(Factory.string),
55
+ msg || Factory.string,
56
+ [],
57
+ )
49
58
  end
50
59
 
51
60
  def self.ignore_result(msg = nil)
52
- Assert::Result::Ignore.for_test(Factory.test(Factory.string), msg || Factory.string, [])
61
+ Assert::Result::Ignore.for_test(
62
+ Factory.test(Factory.string),
63
+ msg || Factory.string,
64
+ [],
65
+ )
53
66
  end
54
67
 
55
68
  def self.fail_result(msg = nil)
56
- Assert::Result::Fail.for_test(Factory.test(Factory.string), msg || Factory.string, [])
69
+ Assert::Result::Fail.for_test(
70
+ Factory.test(Factory.string),
71
+ msg || Factory.string,
72
+ [],
73
+ )
57
74
  end
58
75
 
59
76
  def self.skip_result(exception = nil)
@@ -68,23 +85,23 @@ module Factory
68
85
 
69
86
  def self.modes_off_config
70
87
  Assert::Config.new({
71
- :capture_output => false,
72
- :halt_on_fail => false,
73
- :changed_only => false,
74
- :pp_objects => false,
75
- :debug => false
88
+ capture_output: false,
89
+ halt_on_fail: false,
90
+ changed_only: false,
91
+ pp_objects: false,
92
+ debug: false,
76
93
  })
77
94
  end
78
95
 
79
96
  def self.modes_off_suite
80
- Assert::DefaultSuite.new(self.modes_off_config)
97
+ Assert::DefaultSuite.new(modes_off_config)
81
98
  end
82
99
 
83
100
  def self.modes_off_context_class(*args, &block)
84
- suite_obj = self.modes_off_suite
85
- self.context_class(*args) do
101
+ suite_obj = modes_off_suite
102
+ context_class(*args) do
86
103
  suite(suite_obj)
87
- instance_eval(&block) if !block.nil?
104
+ instance_eval(&block) unless block.nil?
88
105
  end
89
106
  end
90
107
 
@@ -93,7 +110,7 @@ module Factory
93
110
  Factory.modes_off_context_class.new(
94
111
  test,
95
112
  test.config,
96
- result_block || proc { |r| }
113
+ result_block || proc{ |r| },
97
114
  )
98
115
  end
99
116
 
@@ -10,7 +10,7 @@ class Assert::Stub
10
10
 
11
11
  class InstanceTests < SystemTests
12
12
  desc "for instance methods"
13
- subject { TestClass.new }
13
+ subject{ TestClass.new }
14
14
 
15
15
  setup do
16
16
  Assert.stub(subject, :noargs){ "default" }
@@ -56,33 +56,33 @@ class Assert::Stub
56
56
  end
57
57
 
58
58
  should "not allow stubbing methods with invalid arity" do
59
- assert_that { Assert.stub(subject, :noargs).with(1){ } }.raises
59
+ assert_that{ Assert.stub(subject, :noargs).with(1){} }.raises
60
60
 
61
- assert_that { Assert.stub(subject, :withargs).with{ } }.raises
62
- assert_that { Assert.stub(subject, :withargs).with(1, 2){ } }.raises
61
+ assert_that{ Assert.stub(subject, :withargs).with{} }.raises
62
+ assert_that{ Assert.stub(subject, :withargs).with(1, 2){} }.raises
63
63
 
64
- assert_that { Assert.stub(subject, :minargs).with{ } }.raises
65
- assert_that { Assert.stub(subject, :minargs).with(1){ } }.raises
64
+ assert_that{ Assert.stub(subject, :minargs).with{} }.raises
65
+ assert_that{ Assert.stub(subject, :minargs).with(1){} }.raises
66
66
 
67
- assert_that { Assert.stub(subject, :withblock).with(1){ } }.raises
67
+ assert_that{ Assert.stub(subject, :withblock).with(1){} }.raises
68
68
  end
69
69
 
70
70
  should "not allow calling methods with invalid arity" do
71
- assert_that { subject.noargs(1) }.raises
71
+ assert_that{ subject.noargs(1) }.raises
72
72
 
73
- assert_that { subject.withargs }.raises
74
- assert_that { subject.withargs(1, 2) }.raises
73
+ assert_that{ subject.withargs }.raises
74
+ assert_that{ subject.withargs(1, 2) }.raises
75
75
 
76
- assert_that { subject.minargs }.raises
77
- assert_that { subject.minargs(1) }.raises
76
+ assert_that{ subject.minargs }.raises
77
+ assert_that{ subject.minargs(1) }.raises
78
78
 
79
- assert_that { subject.withblock(1) }.raises
79
+ assert_that{ subject.withblock(1) }.raises
80
80
  end
81
81
  end
82
82
 
83
83
  class ClassTests < SystemTests
84
84
  desc "for singleton methods on a class"
85
- subject { TestClass }
85
+ subject{ TestClass }
86
86
 
87
87
  setup do
88
88
  Assert.stub(subject, :noargs){ "default" }
@@ -129,33 +129,33 @@ class Assert::Stub
129
129
  end
130
130
 
131
131
  should "not allow stubbing methods with invalid arity" do
132
- assert_that { Assert.stub(subject, :noargs).with(1){ } }.raises
132
+ assert_that{ Assert.stub(subject, :noargs).with(1){} }.raises
133
133
 
134
- assert_that { Assert.stub(subject, :withargs).with{ } }.raises
135
- assert_that { Assert.stub(subject, :withargs).with(1, 2){ } }.raises
134
+ assert_that{ Assert.stub(subject, :withargs).with{} }.raises
135
+ assert_that{ Assert.stub(subject, :withargs).with(1, 2){} }.raises
136
136
 
137
- assert_that { Assert.stub(subject, :minargs).with{ } }.raises
138
- assert_that { Assert.stub(subject, :minargs).with(1){ } }.raises
137
+ assert_that{ Assert.stub(subject, :minargs).with{} }.raises
138
+ assert_that{ Assert.stub(subject, :minargs).with(1){} }.raises
139
139
 
140
- assert_that { Assert.stub(subject, :withblock).with(1){ } }.raises
140
+ assert_that{ Assert.stub(subject, :withblock).with(1){} }.raises
141
141
  end
142
142
 
143
143
  should "not allow calling methods with invalid arity" do
144
- assert_that { subject.noargs(1) }.raises
144
+ assert_that{ subject.noargs(1) }.raises
145
145
 
146
- assert_that { subject.withargs }.raises
147
- assert_that { subject.withargs(1, 2) }.raises
146
+ assert_that{ subject.withargs }.raises
147
+ assert_that{ subject.withargs(1, 2) }.raises
148
148
 
149
- assert_that { subject.minargs }.raises
150
- assert_that { subject.minargs(1) }.raises
149
+ assert_that{ subject.minargs }.raises
150
+ assert_that{ subject.minargs(1) }.raises
151
151
 
152
- assert_that { subject.withblock(1) }.raises
152
+ assert_that{ subject.withblock(1) }.raises
153
153
  end
154
154
  end
155
155
 
156
156
  class ModuleTests < SystemTests
157
157
  desc "for singleton methods on a module"
158
- subject { TestModule }
158
+ subject{ TestModule }
159
159
 
160
160
  setup do
161
161
  Assert.stub(subject, :noargs){ "default" }
@@ -202,33 +202,33 @@ class Assert::Stub
202
202
  end
203
203
 
204
204
  should "not allow stubbing methods with invalid arity" do
205
- assert_that { Assert.stub(subject, :noargs).with(1){ } }.raises
205
+ assert_that{ Assert.stub(subject, :noargs).with(1){} }.raises
206
206
 
207
- assert_that { Assert.stub(subject, :withargs).with{ } }.raises
208
- assert_that { Assert.stub(subject, :withargs).with(1, 2){ } }.raises
207
+ assert_that{ Assert.stub(subject, :withargs).with{} }.raises
208
+ assert_that{ Assert.stub(subject, :withargs).with(1, 2){} }.raises
209
209
 
210
- assert_that { Assert.stub(subject, :minargs).with{ } }.raises
211
- assert_that { Assert.stub(subject, :minargs).with(1){ } }.raises
210
+ assert_that{ Assert.stub(subject, :minargs).with{} }.raises
211
+ assert_that{ Assert.stub(subject, :minargs).with(1){} }.raises
212
212
 
213
- assert_that { Assert.stub(subject, :withblock).with(1){ } }.raises
213
+ assert_that{ Assert.stub(subject, :withblock).with(1){} }.raises
214
214
  end
215
215
 
216
216
  should "not allow calling methods with invalid arity" do
217
- assert_that { subject.noargs(1) }.raises
217
+ assert_that{ subject.noargs(1) }.raises
218
218
 
219
- assert_that { subject.withargs }.raises
220
- assert_that { subject.withargs(1, 2) }.raises
219
+ assert_that{ subject.withargs }.raises
220
+ assert_that{ subject.withargs(1, 2) }.raises
221
221
 
222
- assert_that { subject.minargs }.raises
223
- assert_that { subject.minargs(1) }.raises
222
+ assert_that{ subject.minargs }.raises
223
+ assert_that{ subject.minargs(1) }.raises
224
224
 
225
- assert_that { subject.withblock(1) }.raises
225
+ assert_that{ subject.withblock(1) }.raises
226
226
  end
227
227
  end
228
228
 
229
229
  class ExtendedTests < SystemTests
230
230
  desc "for extended methods"
231
- subject { Class.new{ extend TestMixin } }
231
+ subject{ Class.new{ extend TestMixin } }
232
232
 
233
233
  setup do
234
234
  Assert.stub(subject, :noargs){ "default" }
@@ -275,35 +275,35 @@ class Assert::Stub
275
275
  end
276
276
 
277
277
  should "not allow stubbing methods with invalid arity" do
278
- assert_that { Assert.stub(subject, :noargs).with(1){ } }.raises
278
+ assert_that{ Assert.stub(subject, :noargs).with(1){} }.raises
279
279
 
280
- assert_that { Assert.stub(subject, :withargs).with{ } }.raises
281
- assert_that { Assert.stub(subject, :withargs).with(1, 2){ } }.raises
280
+ assert_that{ Assert.stub(subject, :withargs).with{} }.raises
281
+ assert_that{ Assert.stub(subject, :withargs).with(1, 2){} }.raises
282
282
 
283
- assert_that { Assert.stub(subject, :minargs).with{ } }.raises
284
- assert_that { Assert.stub(subject, :minargs).with(1){ } }.raises
283
+ assert_that{ Assert.stub(subject, :minargs).with{} }.raises
284
+ assert_that{ Assert.stub(subject, :minargs).with(1){} }.raises
285
285
 
286
- assert_that { Assert.stub(subject, :withblock).with(1){ } }.raises
286
+ assert_that{ Assert.stub(subject, :withblock).with(1){} }.raises
287
287
  end
288
288
 
289
289
  should "not allow calling methods with invalid arity" do
290
- assert_that { subject.noargs(1) }.raises
290
+ assert_that{ subject.noargs(1) }.raises
291
291
 
292
- assert_that { subject.withargs }.raises
293
- assert_that { subject.withargs(1, 2) }.raises
292
+ assert_that{ subject.withargs }.raises
293
+ assert_that{ subject.withargs(1, 2) }.raises
294
294
 
295
- assert_that { subject.minargs }.raises
296
- assert_that { subject.minargs(1) }.raises
295
+ assert_that{ subject.minargs }.raises
296
+ assert_that{ subject.minargs(1) }.raises
297
297
 
298
- assert_that { subject.withblock(1) }.raises
298
+ assert_that{ subject.withblock(1) }.raises
299
299
  end
300
300
  end
301
301
 
302
302
  class IncludedTests < SystemTests
303
303
  desc "for an included method"
304
- subject {
305
- Class.new { include TestMixin }.new
306
- }
304
+ subject do
305
+ Class.new{ include TestMixin }.new
306
+ end
307
307
 
308
308
  setup do
309
309
  Assert.stub(subject, :noargs){ "default" }
@@ -350,33 +350,33 @@ class Assert::Stub
350
350
  end
351
351
 
352
352
  should "not allow stubbing methods with invalid arity" do
353
- assert_that { Assert.stub(subject, :noargs).with(1){ } }.raises
353
+ assert_that{ Assert.stub(subject, :noargs).with(1){} }.raises
354
354
 
355
- assert_that { Assert.stub(subject, :withargs).with{ } }.raises
356
- assert_that { Assert.stub(subject, :withargs).with(1, 2){ } }.raises
355
+ assert_that{ Assert.stub(subject, :withargs).with{} }.raises
356
+ assert_that{ Assert.stub(subject, :withargs).with(1, 2){} }.raises
357
357
 
358
- assert_that { Assert.stub(subject, :minargs).with{ } }.raises
359
- assert_that { Assert.stub(subject, :minargs).with(1){ } }.raises
358
+ assert_that{ Assert.stub(subject, :minargs).with{} }.raises
359
+ assert_that{ Assert.stub(subject, :minargs).with(1){} }.raises
360
360
 
361
- assert_that { Assert.stub(subject, :withblock).with(1){ } }.raises
361
+ assert_that{ Assert.stub(subject, :withblock).with(1){} }.raises
362
362
  end
363
363
 
364
364
  should "not allow calling methods with invalid arity" do
365
- assert_that { subject.noargs(1) }.raises
365
+ assert_that{ subject.noargs(1) }.raises
366
366
 
367
- assert_that { subject.withargs }.raises
368
- assert_that { subject.withargs(1, 2) }.raises
367
+ assert_that{ subject.withargs }.raises
368
+ assert_that{ subject.withargs(1, 2) }.raises
369
369
 
370
- assert_that { subject.minargs }.raises
371
- assert_that { subject.minargs(1) }.raises
370
+ assert_that{ subject.minargs }.raises
371
+ assert_that{ subject.minargs(1) }.raises
372
372
 
373
- assert_that { subject.withblock(1) }.raises
373
+ assert_that{ subject.withblock(1) }.raises
374
374
  end
375
375
  end
376
376
 
377
377
  class InheritedClassTests < SystemTests
378
378
  desc "for an inherited class method"
379
- subject { Class.new(TestClass) }
379
+ subject{ Class.new(TestClass) }
380
380
 
381
381
  setup do
382
382
  Assert.stub(subject, :noargs){ "default" }
@@ -423,33 +423,33 @@ class Assert::Stub
423
423
  end
424
424
 
425
425
  should "not allow stubbing methods with invalid arity" do
426
- assert_that { Assert.stub(subject, :noargs).with(1){ } }.raises
426
+ assert_that{ Assert.stub(subject, :noargs).with(1){} }.raises
427
427
 
428
- assert_that { Assert.stub(subject, :withargs).with{ } }.raises
429
- assert_that { Assert.stub(subject, :withargs).with(1, 2){ } }.raises
428
+ assert_that{ Assert.stub(subject, :withargs).with{} }.raises
429
+ assert_that{ Assert.stub(subject, :withargs).with(1, 2){} }.raises
430
430
 
431
- assert_that { Assert.stub(subject, :minargs).with{ } }.raises
432
- assert_that { Assert.stub(subject, :minargs).with(1){ } }.raises
431
+ assert_that{ Assert.stub(subject, :minargs).with{} }.raises
432
+ assert_that{ Assert.stub(subject, :minargs).with(1){} }.raises
433
433
 
434
- assert_that { Assert.stub(subject, :withblock).with(1){ } }.raises
434
+ assert_that{ Assert.stub(subject, :withblock).with(1){} }.raises
435
435
  end
436
436
 
437
437
  should "not allow calling methods with invalid arity" do
438
- assert_that { subject.noargs(1) }.raises
438
+ assert_that{ subject.noargs(1) }.raises
439
439
 
440
- assert_that { subject.withargs }.raises
441
- assert_that { subject.withargs(1, 2) }.raises
440
+ assert_that{ subject.withargs }.raises
441
+ assert_that{ subject.withargs(1, 2) }.raises
442
442
 
443
- assert_that { subject.minargs }.raises
444
- assert_that { subject.minargs(1) }.raises
443
+ assert_that{ subject.minargs }.raises
444
+ assert_that{ subject.minargs(1) }.raises
445
445
 
446
- assert_that { subject.withblock(1) }.raises
446
+ assert_that{ subject.withblock(1) }.raises
447
447
  end
448
448
  end
449
449
 
450
450
  class InheritedInstanceTests < SystemTests
451
451
  desc "for an inherited instance method"
452
- subject { Class.new(TestClass).new }
452
+ subject{ Class.new(TestClass).new }
453
453
 
454
454
  setup do
455
455
  Assert.stub(subject, :noargs){ "default" }
@@ -496,33 +496,33 @@ class Assert::Stub
496
496
  end
497
497
 
498
498
  should "not allow stubbing methods with invalid arity" do
499
- assert_that { Assert.stub(subject, :noargs).with(1){ } }.raises
499
+ assert_that{ Assert.stub(subject, :noargs).with(1){} }.raises
500
500
 
501
- assert_that { Assert.stub(subject, :withargs).with{ } }.raises
502
- assert_that { Assert.stub(subject, :withargs).with(1, 2){ } }.raises
501
+ assert_that{ Assert.stub(subject, :withargs).with{} }.raises
502
+ assert_that{ Assert.stub(subject, :withargs).with(1, 2){} }.raises
503
503
 
504
- assert_that { Assert.stub(subject, :minargs).with{ } }.raises
505
- assert_that { Assert.stub(subject, :minargs).with(1){ } }.raises
504
+ assert_that{ Assert.stub(subject, :minargs).with{} }.raises
505
+ assert_that{ Assert.stub(subject, :minargs).with(1){} }.raises
506
506
 
507
- assert_that { Assert.stub(subject, :withblock).with(1){ } }.raises
507
+ assert_that{ Assert.stub(subject, :withblock).with(1){} }.raises
508
508
  end
509
509
 
510
510
  should "not allow calling methods with invalid arity" do
511
- assert_that { subject.noargs(1) }.raises
511
+ assert_that{ subject.noargs(1) }.raises
512
512
 
513
- assert_that { subject.withargs }.raises
514
- assert_that { subject.withargs(1, 2) }.raises
513
+ assert_that{ subject.withargs }.raises
514
+ assert_that{ subject.withargs(1, 2) }.raises
515
515
 
516
- assert_that { subject.minargs }.raises
517
- assert_that { subject.minargs(1) }.raises
516
+ assert_that{ subject.minargs }.raises
517
+ assert_that{ subject.minargs(1) }.raises
518
518
 
519
- assert_that { subject.withblock(1) }.raises
519
+ assert_that{ subject.withblock(1) }.raises
520
520
  end
521
521
  end
522
522
 
523
523
  class DelegateClassTests < SystemTests
524
524
  desc "a class that delegates another object"
525
- subject { DelegateClass }
525
+ subject{ DelegateClass }
526
526
 
527
527
  setup do
528
528
  Assert.stub(subject, :noargs){ "default" }
@@ -569,33 +569,33 @@ class Assert::Stub
569
569
  end
570
570
 
571
571
  should "allow stubbing methods with invalid arity" do
572
- assert_that { Assert.stub(subject, :noargs).with(1){ } }.does_not_raise
572
+ assert_that{ Assert.stub(subject, :noargs).with(1){} }.does_not_raise
573
573
 
574
- assert_that { Assert.stub(subject, :withargs).with{ } }.does_not_raise
575
- assert_that { Assert.stub(subject, :withargs).with(1, 2){ } }.does_not_raise
574
+ assert_that{ Assert.stub(subject, :withargs).with{} }.does_not_raise
575
+ assert_that{ Assert.stub(subject, :withargs).with(1, 2){} }.does_not_raise
576
576
 
577
- assert_that { Assert.stub(subject, :minargs).with{ } }.does_not_raise
578
- assert_that { Assert.stub(subject, :minargs).with(1){ } }.does_not_raise
577
+ assert_that{ Assert.stub(subject, :minargs).with{} }.does_not_raise
578
+ assert_that{ Assert.stub(subject, :minargs).with(1){} }.does_not_raise
579
579
 
580
- assert_that { Assert.stub(subject, :withblock).with(1){ } }.does_not_raise
580
+ assert_that{ Assert.stub(subject, :withblock).with(1){} }.does_not_raise
581
581
  end
582
582
 
583
583
  should "allow calling methods with invalid arity" do
584
- assert_that { subject.noargs(1) }.does_not_raise
584
+ assert_that{ subject.noargs(1) }.does_not_raise
585
585
 
586
- assert_that { subject.withargs }.does_not_raise
587
- assert_that { subject.withargs(1, 2) }.does_not_raise
586
+ assert_that{ subject.withargs }.does_not_raise
587
+ assert_that{ subject.withargs(1, 2) }.does_not_raise
588
588
 
589
- assert_that { subject.minargs }.does_not_raise
590
- assert_that { subject.minargs(1) }.does_not_raise
589
+ assert_that{ subject.minargs }.does_not_raise
590
+ assert_that{ subject.minargs(1) }.does_not_raise
591
591
 
592
- assert_that { subject.withblock(1) }.does_not_raise
592
+ assert_that{ subject.withblock(1) }.does_not_raise
593
593
  end
594
594
  end
595
595
 
596
596
  class DelegateInstanceTests < SystemTests
597
597
  desc "an instance that delegates another object"
598
- subject { DelegateClass.new }
598
+ subject{ DelegateClass.new }
599
599
 
600
600
  setup do
601
601
  Assert.stub(subject, :noargs){ "default" }
@@ -642,27 +642,27 @@ class Assert::Stub
642
642
  end
643
643
 
644
644
  should "allow stubbing methods with invalid arity" do
645
- assert_that { Assert.stub(subject, :noargs).with(1){ } }.does_not_raise
645
+ assert_that{ Assert.stub(subject, :noargs).with(1){} }.does_not_raise
646
646
 
647
- assert_that { Assert.stub(subject, :withargs).with{ } }.does_not_raise
648
- assert_that { Assert.stub(subject, :withargs).with(1, 2){ } }.does_not_raise
647
+ assert_that{ Assert.stub(subject, :withargs).with{} }.does_not_raise
648
+ assert_that{ Assert.stub(subject, :withargs).with(1, 2){} }.does_not_raise
649
649
 
650
- assert_that { Assert.stub(subject, :minargs).with{ } }.does_not_raise
651
- assert_that { Assert.stub(subject, :minargs).with(1){ } }.does_not_raise
650
+ assert_that{ Assert.stub(subject, :minargs).with{} }.does_not_raise
651
+ assert_that{ Assert.stub(subject, :minargs).with(1){} }.does_not_raise
652
652
 
653
- assert_that { Assert.stub(subject, :withblock).with(1){ } }.does_not_raise
653
+ assert_that{ Assert.stub(subject, :withblock).with(1){} }.does_not_raise
654
654
  end
655
655
 
656
656
  should "allow calling methods with invalid arity" do
657
- assert_that { subject.noargs(1) }.does_not_raise
657
+ assert_that{ subject.noargs(1) }.does_not_raise
658
658
 
659
- assert_that { subject.withargs }.does_not_raise
660
- assert_that { subject.withargs(1, 2) }.does_not_raise
659
+ assert_that{ subject.withargs }.does_not_raise
660
+ assert_that{ subject.withargs(1, 2) }.does_not_raise
661
661
 
662
- assert_that { subject.minargs }.does_not_raise
663
- assert_that { subject.minargs(1) }.does_not_raise
662
+ assert_that{ subject.minargs }.does_not_raise
663
+ assert_that{ subject.minargs(1) }.does_not_raise
664
664
 
665
- assert_that { subject.withblock(1) }.does_not_raise
665
+ assert_that{ subject.withblock(1) }.does_not_raise
666
666
  end
667
667
  end
668
668
 
@@ -673,8 +673,8 @@ class Assert::Stub
673
673
  Assert.stub(child_class, :new){ "child" }
674
674
  end
675
675
 
676
- let(:parent_class) { Class.new }
677
- let(:child_class) { Class.new(parent_class) }
676
+ let(:parent_class){ Class.new }
677
+ let(:child_class){ Class.new(parent_class) }
678
678
 
679
679
  should "allow stubbing the methods individually" do
680
680
  assert_that(parent_class.new).equals("parent")
@@ -683,37 +683,73 @@ class Assert::Stub
683
683
  end
684
684
 
685
685
  class TestClass
686
- def self.noargs; end
687
- def self.withargs(a); end
688
- def self.anyargs(*args); end
689
- def self.minargs(a, b, *args); end
690
- def self.withblock(&block); end
691
-
692
- def noargs; end
693
- def withargs(a); end
694
- def anyargs(*args); end
695
- def minargs(a, b, *args); end
696
- def withblock(&block); end
686
+ def self.noargs
687
+ end
688
+
689
+ def self.withargs(a)
690
+ end
691
+
692
+ def self.anyargs(*args)
693
+ end
694
+
695
+ def self.minargs(a, b, *args)
696
+ end
697
+
698
+ def self.withblock(&block)
699
+ end
700
+
701
+ def noargs
702
+ end
703
+
704
+ def withargs(a)
705
+ end
706
+
707
+ def anyargs(*args)
708
+ end
709
+
710
+ def minargs(a, b, *args)
711
+ end
712
+
713
+ def withblock(&block)
714
+ end
697
715
  end
698
716
 
699
717
  module TestModule
700
- def self.noargs; end
701
- def self.withargs(a); end
702
- def self.anyargs(*args); end
703
- def self.minargs(a, b, *args); end
704
- def self.withblock(&block); end
718
+ def self.noargs
719
+ end
720
+
721
+ def self.withargs(a)
722
+ end
723
+
724
+ def self.anyargs(*args)
725
+ end
726
+
727
+ def self.minargs(a, b, *args)
728
+ end
729
+
730
+ def self.withblock(&block)
731
+ end
705
732
  end
706
733
 
707
734
  module TestMixin
708
- def noargs; end
709
- def withargs(a); end
710
- def anyargs(*args); end
711
- def minargs(a, b, *args); end
712
- def withblock(&block); end
735
+ def noargs
736
+ end
737
+
738
+ def withargs(a)
739
+ end
740
+
741
+ def anyargs(*args)
742
+ end
743
+
744
+ def minargs(a, b, *args)
745
+ end
746
+
747
+ def withblock(&block)
748
+ end
713
749
  end
714
750
 
715
751
  class DelegateClass
716
- def self.respond_to?(*args)
752
+ def self.respond_to_missing?(*args)
717
753
  TestClass.respond_to?(*args) || super
718
754
  end
719
755
 
@@ -725,7 +761,7 @@ class Assert::Stub
725
761
  @delegate = TestClass.new
726
762
  end
727
763
 
728
- def respond_to?(*args)
764
+ def respond_to_missing?(*args)
729
765
  @delegate.respond_to?(*args) || super
730
766
  end
731
767