assert 2.18.2 → 2.19.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -2
  3. data/README.md +7 -6
  4. data/assert.gemspec +5 -2
  5. data/bin/assert +1 -0
  6. data/lib/assert.rb +2 -0
  7. data/lib/assert/actual_value.rb +143 -0
  8. data/lib/assert/assert_runner.rb +2 -0
  9. data/lib/assert/assertions.rb +82 -20
  10. data/lib/assert/cli.rb +2 -0
  11. data/lib/assert/config.rb +2 -0
  12. data/lib/assert/config_helpers.rb +2 -0
  13. data/lib/assert/context.rb +33 -37
  14. data/lib/assert/context/let_dsl.rb +16 -0
  15. data/lib/assert/context/method_missing.rb +22 -0
  16. data/lib/assert/context/setup_dsl.rb +3 -0
  17. data/lib/assert/context/subject_dsl.rb +26 -24
  18. data/lib/assert/context/suite_dsl.rb +3 -0
  19. data/lib/assert/context/test_dsl.rb +3 -0
  20. data/lib/assert/context_info.rb +2 -0
  21. data/lib/assert/default_runner.rb +2 -0
  22. data/lib/assert/default_suite.rb +2 -0
  23. data/lib/assert/default_view.rb +2 -0
  24. data/lib/assert/factory.rb +2 -0
  25. data/lib/assert/file_line.rb +2 -0
  26. data/lib/assert/macro.rb +2 -0
  27. data/lib/assert/macros/methods.rb +6 -4
  28. data/lib/assert/result.rb +8 -1
  29. data/lib/assert/runner.rb +2 -0
  30. data/lib/assert/stub.rb +45 -0
  31. data/lib/assert/suite.rb +9 -10
  32. data/lib/assert/test.rb +3 -9
  33. data/lib/assert/utils.rb +3 -1
  34. data/lib/assert/version.rb +3 -1
  35. data/lib/assert/view.rb +2 -0
  36. data/lib/assert/view_helpers.rb +2 -0
  37. data/test/helper.rb +28 -28
  38. data/test/support/factory.rb +17 -0
  39. data/test/support/inherited_stuff.rb +2 -0
  40. data/test/system/stub_tests.rb +334 -333
  41. data/test/system/test_tests.rb +101 -109
  42. data/test/unit/actual_value_tests.rb +373 -0
  43. data/test/unit/assert_tests.rb +79 -61
  44. data/test/unit/assertions/assert_block_tests.rb +32 -31
  45. data/test/unit/assertions/assert_changes_tests.rb +99 -0
  46. data/test/unit/assertions/assert_empty_tests.rb +35 -32
  47. data/test/unit/assertions/assert_equal_tests.rb +96 -74
  48. data/test/unit/assertions/assert_file_exists_tests.rb +34 -33
  49. data/test/unit/assertions/assert_includes_tests.rb +40 -37
  50. data/test/unit/assertions/assert_instance_of_tests.rb +36 -33
  51. data/test/unit/assertions/assert_kind_of_tests.rb +36 -33
  52. data/test/unit/assertions/assert_match_tests.rb +36 -33
  53. data/test/unit/assertions/assert_nil_tests.rb +32 -31
  54. data/test/unit/assertions/assert_raises_tests.rb +57 -55
  55. data/test/unit/assertions/assert_respond_to_tests.rb +38 -35
  56. data/test/unit/assertions/assert_same_tests.rb +88 -81
  57. data/test/unit/assertions/assert_true_false_tests.rb +62 -60
  58. data/test/unit/assertions_tests.rb +28 -24
  59. data/test/unit/config_helpers_tests.rb +45 -38
  60. data/test/unit/config_tests.rb +40 -34
  61. data/test/unit/context/let_dsl_tests.rb +12 -0
  62. data/test/unit/context/setup_dsl_tests.rb +72 -81
  63. data/test/unit/context/subject_dsl_tests.rb +17 -43
  64. data/test/unit/context/suite_dsl_tests.rb +17 -16
  65. data/test/unit/context/test_dsl_tests.rb +52 -52
  66. data/test/unit/context_info_tests.rb +25 -15
  67. data/test/unit/context_tests.rb +186 -179
  68. data/test/unit/default_runner_tests.rb +4 -5
  69. data/test/unit/default_suite_tests.rb +59 -53
  70. data/test/unit/factory_tests.rb +7 -3
  71. data/test/unit/file_line_tests.rb +35 -35
  72. data/test/unit/macro_tests.rb +16 -10
  73. data/test/unit/result_tests.rb +161 -183
  74. data/test/unit/runner_tests.rb +67 -65
  75. data/test/unit/suite_tests.rb +58 -59
  76. data/test/unit/test_tests.rb +120 -139
  77. data/test/unit/utils_tests.rb +45 -45
  78. data/test/unit/view_helpers_tests.rb +56 -52
  79. data/test/unit/view_tests.rb +24 -23
  80. metadata +29 -6
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "assert"
2
4
  require "assert/utils"
3
5
 
@@ -7,10 +9,11 @@ require "assert/config"
7
9
  module Assert::Utils
8
10
  class UnitTests < Assert::Context
9
11
  desc "Assert::Utils"
10
- subject{ Assert::Utils }
11
- setup do
12
- @objs = [1, "hi there", Hash.new, [:a, :b]]
13
- end
12
+ subject { unit_class }
13
+
14
+ let(:unit_class) { Assert::Utils }
15
+
16
+ let(:objs1) { [1, "hi there", Hash.new, [:a, :b]] }
14
17
 
15
18
  should have_imeths :show, :show_for_diff
16
19
  should have_imeths :tempfile
@@ -20,41 +23,41 @@ module Assert::Utils
20
23
 
21
24
  class ShowTests < UnitTests
22
25
  desc "`show`"
23
- setup do
24
- @pp_config = Assert::Config.new({
26
+
27
+ let(:pp_config1) {
28
+ Assert::Config.new({
25
29
  :pp_objects => true,
26
30
  :pp_proc => Proc.new{ |input| "herp derp" }
27
31
  })
28
- end
32
+ }
29
33
 
30
34
  should "use `inspect` to show objs when `pp_objects` setting is false" do
31
- @objs.each do |obj|
32
- assert_equal obj.inspect, subject.show(obj, Factory.modes_off_config)
35
+ objs1.each do |obj|
36
+ assert_that(subject.show(obj, Factory.modes_off_config)).equals(obj.inspect)
33
37
  end
34
38
  end
35
39
 
36
40
  should "use `pp_proc` to show objs when `pp_objects` setting is true" do
37
- @objs.each do |obj|
38
- assert_equal @pp_config.pp_proc.call(obj), subject.show(obj, @pp_config)
41
+ objs1.each do |obj|
42
+ assert_that(subject.show(obj, pp_config1)).equals(pp_config1.pp_proc.call(obj))
39
43
  end
40
44
  end
41
45
  end
42
46
 
43
47
  class ShowForDiffTests < ShowTests
44
48
  desc "`show_for_diff`"
45
- setup do
46
- @w_newlines = { :string => "herp derp, derp herp\nherpderpedia" }
47
- @w_obj_id = Class.new.new
48
- end
49
+
50
+ let(:w_newlines1) { { :string => "herp derp, derp herp\nherpderpedia" } }
51
+ let(:w_obj_id1) { Class.new.new }
49
52
 
50
53
  should "call show, escaping newlines" do
51
54
  exp_out = "{:string=>\"herp derp, derp herp\nherpderpedia\"}"
52
- assert_equal exp_out, subject.show_for_diff(@w_newlines, Factory.modes_off_config)
55
+ assert_that(subject.show_for_diff(w_newlines1, Factory.modes_off_config)).equals(exp_out)
53
56
  end
54
57
 
55
58
  should "make any obj ids generic" do
56
59
  exp_out = "#<#<Class:0xXXXXXX>:0xXXXXXX>"
57
- assert_equal exp_out, subject.show_for_diff(@w_obj_id, Factory.modes_off_config)
60
+ assert_that(subject.show_for_diff(w_obj_id1, Factory.modes_off_config)).equals(exp_out)
58
61
  end
59
62
  end
60
63
 
@@ -63,12 +66,12 @@ module Assert::Utils
63
66
 
64
67
  should "require tempfile, open a tempfile, write the given content, and yield it" do
65
68
  subject.tempfile("a-name", "some-content") do |tmpfile|
66
- assert_equal false, (require "tempfile")
69
+ assert_that((require "tempfile")).equals(false)
67
70
  assert tmpfile
68
- assert_kind_of Tempfile, tmpfile
71
+ assert_that(tmpfile).is_kind_of(Tempfile)
69
72
 
70
73
  tmpfile.pos = 0
71
- assert_equal "some-content\n", tmpfile.read
74
+ assert_that(tmpfile.read).equals("some-content\n")
72
75
  end
73
76
  end
74
77
  end
@@ -77,63 +80,60 @@ module Assert::Utils
77
80
  desc "`stdlib_pp_proc`"
78
81
 
79
82
  should "build a pp proc that uses stdlib `PP.pp` to pretty print objects" do
80
- exp_obj_pps = @objs.map{ |o| PP.pp(o, "", 79).strip }
81
- act_obj_pps = @objs.map{ |o| subject.stdlib_pp_proc.call(o) }
82
- assert_equal exp_obj_pps, act_obj_pps
83
+ exp_obj_pps = objs1.map{ |o| PP.pp(o, +"", 79).strip }
84
+ act_obj_pps = objs1.map{ |o| subject.stdlib_pp_proc.call(o) }
85
+ assert_that(act_obj_pps).equals(exp_obj_pps)
83
86
 
84
87
  cust_width = 1
85
- exp_obj_pps = @objs.map{ |o| PP.pp(o, "", cust_width).strip }
86
- act_obj_pps = @objs.map{ |o| subject.stdlib_pp_proc(cust_width).call(o) }
87
- assert_equal exp_obj_pps, act_obj_pps
88
+ exp_obj_pps = objs1.map{ |o| PP.pp(o, +"", cust_width).strip }
89
+ act_obj_pps = objs1.map{ |o| subject.stdlib_pp_proc(cust_width).call(o) }
90
+ assert_that(act_obj_pps).equals(exp_obj_pps)
88
91
  end
89
92
  end
90
93
 
91
94
  class DefaultUseDiffProcTests < UnitTests
92
95
  desc "`default_use_diff_proc`"
93
- setup do
94
- @longer = "i am a really long string output; use diff when working with me"
95
- @newlines = "i have\n newlines"
96
- end
96
+
97
+ let(:longer1) { "i am a really long string output; use diff when working with me" }
98
+ let(:newlines1) { "i have\n newlines" }
97
99
 
98
100
  should "be true if either output has newlines or is bigger than 29 chars" do
99
101
  proc = subject.default_use_diff_proc
100
102
 
101
103
  assert_not proc.call("", "")
102
- assert proc.call(@longer, "")
103
- assert proc.call(@newlines, "")
104
- assert proc.call("", @longer)
105
- assert proc.call("", @newlines)
106
- assert proc.call(@longer, @newlines)
104
+ assert proc.call(longer1, "")
105
+ assert proc.call(newlines1, "")
106
+ assert proc.call("", longer1)
107
+ assert proc.call("", newlines1)
108
+ assert proc.call(longer1, newlines1)
107
109
  end
108
110
  end
109
111
 
110
112
  class SyscmdDiffProc < UnitTests
111
113
  desc "`syscmd_diff_proc`"
112
- setup do
113
- @diff_a_file = File.join(ROOT_PATH, "test/support/diff_a.txt")
114
- @diff_b_file = File.join(ROOT_PATH, "test/support/diff_b.txt")
115
114
 
116
- @diff_a = File.read(@diff_a_file)
117
- @diff_b = File.read(@diff_b_file)
118
- end
115
+ let(:diff_a_file1) { File.join(ROOT_PATH, "test/support/diff_a.txt") }
116
+ let(:diff_b_file1) { File.join(ROOT_PATH, "test/support/diff_b.txt") }
117
+ let(:diff_a1) { File.read(diff_a_file1) }
118
+ let(:diff_b1) { File.read(diff_b_file1) }
119
119
 
120
120
  should "use the diff syscmd to output the diff between the exp/act show output" do
121
- exp_diff_out = `diff --unified=-1 #{@diff_a_file} #{@diff_b_file}`.strip.tap do |out|
121
+ exp_diff_out = `diff --unified=-1 #{diff_a_file1} #{diff_b_file1}`.strip.tap do |out|
122
122
  out.sub!(/^\-\-\- .+/, "--- expected")
123
123
  out.sub!(/^\+\+\+ .+/, "+++ actual")
124
124
  end
125
125
 
126
- assert_equal exp_diff_out, subject.syscmd_diff_proc.call(@diff_a, @diff_b)
126
+ assert_that(subject.syscmd_diff_proc.call(diff_a1, diff_b1)).equals(exp_diff_out)
127
127
  end
128
128
 
129
129
  should "allow you to specify a custom syscmd" do
130
130
  cust_syscmd = "diff"
131
- exp_diff_out = `#{cust_syscmd} #{@diff_a_file} #{@diff_b_file}`.strip.tap do |out|
131
+ exp_diff_out = `#{cust_syscmd} #{diff_a_file1} #{diff_b_file1}`.strip.tap do |out|
132
132
  out.sub!(/^\-\-\- .+/, "--- expected")
133
133
  out.sub!(/^\+\+\+ .+/, "+++ actual")
134
134
  end
135
135
 
136
- assert_equal exp_diff_out, subject.syscmd_diff_proc(cust_syscmd).call(@diff_a, @diff_b)
136
+ assert_that(subject.syscmd_diff_proc(cust_syscmd).call(diff_a1, diff_b1)).equals(exp_diff_out)
137
137
  end
138
138
  end
139
139
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "assert"
2
4
  require "assert/view_helpers"
3
5
 
@@ -10,9 +12,11 @@ require "assert/view"
10
12
  module Assert::ViewHelpers
11
13
  class UnitTests < Assert::Context
12
14
  desc "Assert::ViewHelpers"
13
- setup do
14
- test_opt_val = @test_opt_val = Factory.string
15
- @helpers_class = Class.new do
15
+ subject { unit_class }
16
+
17
+ let(:unit_class) {
18
+ test_opt_val = test_opt_val1
19
+ Class.new do
16
20
  include Assert::ViewHelpers
17
21
 
18
22
  option "test_opt", test_opt_val
@@ -23,35 +27,33 @@ module Assert::ViewHelpers
23
27
  @config ||= [Assert.config, Assert::Config.new].sample
24
28
  end
25
29
  end
26
- end
27
- subject{ @helpers_class }
30
+ }
31
+
32
+ let(:test_opt_val1) { Factory.string }
28
33
 
29
34
  should have_imeths :option
30
35
 
31
36
  should "include the config helpers" do
32
- assert_includes Assert::ConfigHelpers, subject
37
+ assert_that(subject).includes(Assert::ConfigHelpers)
33
38
  end
34
39
 
35
40
  should "write option values" do
36
- helpers = @helpers_class.new
37
- assert_equal @test_opt_val, helpers.test_opt
41
+ helpers = unit_class.new
42
+ assert_that(helpers.test_opt).equals(test_opt_val1)
38
43
 
39
44
  new_val = Factory.integer
40
45
  helpers.test_opt new_val
41
- assert_equal new_val, helpers.test_opt
46
+ assert_that(helpers.test_opt).equals(new_val)
42
47
 
43
48
  other_val = Factory.integer
44
49
  helpers.test_opt new_val, other_val
45
- assert_equal [new_val, other_val], helpers.test_opt
50
+ assert_that(helpers.test_opt).equals([new_val, other_val])
46
51
  end
47
52
  end
48
53
 
49
54
  class InitTests < UnitTests
50
55
  desc "when init"
51
- setup do
52
- @helpers = @helpers_class.new
53
- end
54
- subject{ @helpers }
56
+ subject { unit_class.new }
55
57
 
56
58
  should have_imeths :captured_output, :re_run_test_cmd
57
59
  should have_imeths :tests_to_run_count_statement, :result_count_statement
@@ -61,107 +63,109 @@ module Assert::ViewHelpers
61
63
 
62
64
  should "know how to build captured output" do
63
65
  output = Factory.string
64
- exp = "--- stdout ---\n"\
65
- "#{output}"\
66
- "--------------"
67
- assert_equal exp, subject.captured_output(output)
66
+ exp =
67
+ "--- stdout ---\n"\
68
+ "#{output}"\
69
+ "--------------"
70
+ assert_that(subject.captured_output(output)).equals(exp)
68
71
  end
69
72
 
70
73
  should "know how to build the re-run test cmd" do
71
74
  test_id = "#{Dir.pwd}/#{Factory.string}_tests.rb:#{Factory.integer}"
72
75
  exp = "assert -t #{test_id.gsub(Dir.pwd, ".")}"
73
- assert_equal exp, subject.re_run_test_cmd(test_id)
76
+ assert_that(subject.re_run_test_cmd(test_id)).equals(exp)
74
77
  end
75
78
 
76
79
  should "know its tests-to-run count and result count statements" do
77
80
  exp = "#{subject.tests_to_run_count} test#{"s" if subject.tests_to_run_count != 1}"
78
- assert_equal exp, subject.tests_to_run_count_statement
81
+ assert_that(subject.tests_to_run_count_statement).equals(exp)
79
82
 
80
83
  exp = "#{subject.result_count} result#{"s" if subject.result_count != 1}"
81
- assert_equal exp, subject.result_count_statement
84
+ assert_that(subject.result_count_statement).equals(exp)
82
85
  end
83
86
 
84
87
  should "know how to build a sentence from a list of items" do
85
88
  items = 1.times.map{ Factory.string }
86
- assert_equal items.first, subject.to_sentence(items)
89
+ assert_that(subject.to_sentence(items)).equals(items.first)
87
90
 
88
91
  items = 2.times.map{ Factory.string }
89
- assert_equal items.join(" and "), subject.to_sentence(items)
92
+ assert_that(subject.to_sentence(items)).equals(items.join(" and "))
90
93
 
91
94
  items = (Factory.integer(3)+2).times.map{ Factory.string }
92
95
  exp = [items[0..-2].join(", "), items.last].join(", and ")
93
- assert_equal exp, subject.to_sentence(items)
96
+ assert_that(subject.to_sentence(items)).equals(exp)
94
97
  end
95
98
 
96
99
  should "know its all pass result summary message" do
97
100
  Assert.stub(subject, :result_count){ 0 }
98
- assert_equal "uhh...", subject.all_pass_result_summary_msg
101
+ assert_that(subject.all_pass_result_summary_msg).equals("uhh...")
99
102
 
100
103
  Assert.stub(subject, :result_count){ 1 }
101
- assert_equal "pass", subject.all_pass_result_summary_msg
104
+ assert_that(subject.all_pass_result_summary_msg).equals("pass")
102
105
 
103
106
  Assert.stub(subject, :result_count){ Factory.integer(10)+1 }
104
- assert_equal "all pass", subject.all_pass_result_summary_msg
107
+ assert_that(subject.all_pass_result_summary_msg).equals("all pass")
105
108
  end
106
109
 
107
110
  should "know its result summary msg" do
108
111
  res_type = :pass
109
112
  Assert.stub(subject, :all_pass?){ true }
110
113
  exp = subject.all_pass_result_summary_msg
111
- assert_equal exp, subject.result_summary_msg(res_type)
114
+ assert_that(subject.result_summary_msg(res_type)).equals(exp)
112
115
 
113
116
  Assert.stub(subject, :all_pass?){ false }
114
117
  res_type = [:pass, :ignore, :fail, :skip, :error].sample
115
118
  exp = "#{subject.send("#{res_type}_result_count")} #{res_type.to_s}"
116
- assert_equal exp, subject.result_summary_msg(res_type)
119
+ assert_that(subject.result_summary_msg(res_type)).equals(exp)
117
120
  end
118
121
 
119
122
  should "know its results summary sentence" do
120
- items = subject.ocurring_result_types.map do |result_sym|
121
- subject.result_summary_msg(result_sym)
122
- end
123
+ items =
124
+ subject.ocurring_result_types.map do |result_sym|
125
+ subject.result_summary_msg(result_sym)
126
+ end
123
127
  exp = subject.to_sentence(items)
124
- assert_equal exp, subject.results_summary_sentence
128
+ assert_that(subject.results_summary_sentence).equals(exp)
125
129
 
126
130
  block = proc{ |summary, result| "#{summary}--#{result}" }
127
- items = subject.ocurring_result_types.map do |result_sym|
128
- block.call(subject.result_summary_msg(result_sym), result_sym)
129
- end
131
+ items =
132
+ subject.ocurring_result_types.map do |result_sym|
133
+ block.call(subject.result_summary_msg(result_sym), result_sym)
134
+ end
130
135
  exp = subject.to_sentence(items)
131
- assert_equal exp, subject.results_summary_sentence(&block)
136
+ assert_that(subject.results_summary_sentence(&block)).equals(exp)
132
137
  end
133
138
  end
134
139
 
135
140
  class AnsiTests < UnitTests
136
141
  desc "Ansi"
137
- subject{ Ansi }
142
+ subject { Ansi }
138
143
 
139
144
  should have_imeths :code_for
140
145
 
141
146
  should "know its codes" do
142
- assert_not_empty subject::CODES
147
+ assert_that(subject::CODES).is_not_empty
143
148
  end
144
149
 
145
150
  should "map its code style names to ansi code strings" do
146
151
  styles = Factory.integer(3).times.map{ subject::CODES.keys.sample }
147
152
  exp = styles.map{ |n| "\e[#{subject::CODES[n]}m" }.join("")
148
- assert_equal exp, subject.code_for(*styles)
153
+ assert_that(subject.code_for(*styles)).equals(exp)
149
154
 
150
155
  styles = Factory.integer(3).times.map{ Factory.string }
151
- assert_equal "", subject.code_for(*styles)
156
+ assert_that(subject.code_for(*styles)).equals("")
152
157
 
153
158
  styles = []
154
- assert_equal "", subject.code_for(*styles)
159
+ assert_that(subject.code_for(*styles)).equals("")
155
160
  end
156
161
  end
157
162
 
158
163
  class AnsiInitTests < UnitTests
159
164
  desc "when mixed in on a view"
160
- setup do
161
- view_class = Class.new(Assert::View){ include Ansi }
162
- @view = view_class.new(Factory.modes_off_config, StringIO.new("", "w+"))
163
- end
164
- subject{ @view }
165
+ subject { view1 }
166
+
167
+ let(:view_class1) { Class.new(Assert::View){ include Ansi } }
168
+ let(:view1) { view_class1.new(Factory.modes_off_config, StringIO.new(+"", "w+")) }
165
169
 
166
170
  should have_imeths :ansi_styled_msg
167
171
 
@@ -171,26 +175,26 @@ module Assert::ViewHelpers
171
175
 
172
176
  Assert.stub(subject, :is_tty?){ false }
173
177
  Assert.stub(subject, :styled){ false }
174
- assert_equal msg, subject.ansi_styled_msg(msg, result_type)
178
+ assert_that(subject.ansi_styled_msg(msg, result_type)).equals(msg)
175
179
 
176
180
  Assert.stub(subject, :is_tty?){ false }
177
181
  Assert.stub(subject, :styled){ true }
178
- assert_equal msg, subject.ansi_styled_msg(msg, result_type)
182
+ assert_that(subject.ansi_styled_msg(msg, result_type)).equals(msg)
179
183
 
180
184
  Assert.stub(subject, :is_tty?){ true }
181
185
  Assert.stub(subject, :styled){ false }
182
- assert_equal msg, subject.ansi_styled_msg(msg, result_type)
186
+ assert_that(subject.ansi_styled_msg(msg, result_type)).equals(msg)
183
187
 
184
188
  Assert.stub(subject, :is_tty?){ true }
185
189
  Assert.stub(subject, :styled){ true }
186
190
  Assert.stub(subject, "#{result_type}_styles"){ [] }
187
- assert_equal msg, subject.ansi_styled_msg(msg, result_type)
191
+ assert_that(subject.ansi_styled_msg(msg, result_type)).equals(msg)
188
192
 
189
193
  styles = Factory.integer(3).times.map{ Assert::ViewHelpers::Ansi::CODES.keys.sample }
190
194
  Assert.stub(subject, "#{result_type}_styles"){ styles }
191
195
  exp_code = Assert::ViewHelpers::Ansi.code_for(*styles)
192
196
  exp = exp_code + msg + Assert::ViewHelpers::Ansi.code_for(:reset)
193
- assert_equal exp, subject.ansi_styled_msg(msg, result_type)
197
+ assert_that(subject.ansi_styled_msg(msg, result_type)).equals(exp)
194
198
  end
195
199
  end
196
200
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "assert"
2
4
  require "assert/view"
3
5
 
@@ -9,28 +11,27 @@ require "assert/view_helpers"
9
11
  class Assert::View
10
12
  class UnitTests < Assert::Context
11
13
  desc "Assert::View"
12
- subject { Assert::View }
14
+ subject { unit_class }
15
+
16
+ let(:unit_class) { Assert::View }
13
17
 
14
18
  should have_instance_method :require_user_view
15
19
 
16
20
  should "include the config helpers" do
17
- assert_includes Assert::ConfigHelpers, subject
21
+ assert_that(subject).includes(Assert::ConfigHelpers)
18
22
  end
19
23
 
20
24
  should "include the view helpers" do
21
- assert_includes Assert::ViewHelpers, subject
25
+ assert_that(subject).includes(Assert::ViewHelpers)
22
26
  end
23
27
  end
24
28
 
25
29
  class InitTests < UnitTests
26
30
  desc "when init"
27
- setup do
28
- @io = StringIO.new("", "w+")
29
- @config = Factory.modes_off_config
31
+ subject { Assert::View.new(config1, io1) }
30
32
 
31
- @view = Assert::View.new(@config, @io)
32
- end
33
- subject{ @view }
33
+ let(:io1) { StringIO.new(+"", "w+") }
34
+ let(:config1) { Factory.modes_off_config }
34
35
 
35
36
  should have_readers :config
36
37
  should have_imeths :view, :is_tty?
@@ -39,33 +40,33 @@ class Assert::View
39
40
  should have_imeths :before_test, :after_test, :on_result
40
41
 
41
42
  should "default its style options" do
42
- assert_false subject.styled
43
+ assert_that(subject.styled).is_false
43
44
 
44
- assert_nil subject.pass_styles
45
- assert_nil subject.fail_styles
46
- assert_nil subject.error_styles
47
- assert_nil subject.skip_styles
48
- assert_nil subject.ignore_styles
45
+ assert_that(subject.pass_styles).is_nil
46
+ assert_that(subject.fail_styles).is_nil
47
+ assert_that(subject.error_styles).is_nil
48
+ assert_that(subject.skip_styles).is_nil
49
+ assert_that(subject.ignore_styles).is_nil
49
50
  end
50
51
 
51
52
  should "default its result abbreviations" do
52
- assert_equal ".", subject.pass_abbrev
53
- assert_equal "F", subject.fail_abbrev
54
- assert_equal "I", subject.ignore_abbrev
55
- assert_equal "S", subject.skip_abbrev
56
- assert_equal "E", subject.error_abbrev
53
+ assert_that(subject.pass_abbrev).equals(".")
54
+ assert_that(subject.fail_abbrev).equals("F")
55
+ assert_that(subject.ignore_abbrev).equals("I")
56
+ assert_that(subject.skip_abbrev).equals("S")
57
+ assert_that(subject.error_abbrev).equals("E")
57
58
  end
58
59
 
59
60
  should "know its config" do
60
- assert_equal @config, subject.config
61
+ assert_that(subject.config).equals(config1)
61
62
  end
62
63
 
63
64
  should "override the config helper's view value with itself" do
64
- assert_equal subject, subject.view
65
+ assert_that(subject.view).equals(subject)
65
66
  end
66
67
 
67
68
  should "know if it is a tty" do
68
- assert_equal !!@io.isatty, subject.is_tty?
69
+ assert_that(subject.is_tty?).equals(!!io1.isatty)
69
70
  end
70
71
  end
71
72
  end