assert 2.17.0 → 2.18.4

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