assert 2.18.2 → 2.18.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -6
  3. data/assert.gemspec +1 -1
  4. data/lib/assert/actual_value.rb +127 -0
  5. data/lib/assert/assertions.rb +11 -20
  6. data/lib/assert/context.rb +13 -5
  7. data/lib/assert/context/let_dsl.rb +13 -0
  8. data/lib/assert/context/method_missing.rb +19 -0
  9. data/lib/assert/macros/methods.rb +4 -4
  10. data/lib/assert/stub.rb +4 -0
  11. data/lib/assert/version.rb +1 -1
  12. data/test/helper.rb +23 -25
  13. data/test/support/factory.rb +15 -0
  14. data/test/system/stub_tests.rb +348 -333
  15. data/test/system/test_tests.rb +111 -109
  16. data/test/unit/actual_value_tests.rb +335 -0
  17. data/test/unit/assert_tests.rb +84 -59
  18. data/test/unit/assertions/assert_block_tests.rb +32 -31
  19. data/test/unit/assertions/assert_empty_tests.rb +35 -32
  20. data/test/unit/assertions/assert_equal_tests.rb +81 -75
  21. data/test/unit/assertions/assert_file_exists_tests.rb +34 -33
  22. data/test/unit/assertions/assert_includes_tests.rb +40 -37
  23. data/test/unit/assertions/assert_instance_of_tests.rb +36 -33
  24. data/test/unit/assertions/assert_kind_of_tests.rb +36 -33
  25. data/test/unit/assertions/assert_match_tests.rb +36 -33
  26. data/test/unit/assertions/assert_nil_tests.rb +32 -31
  27. data/test/unit/assertions/assert_raises_tests.rb +55 -55
  28. data/test/unit/assertions/assert_respond_to_tests.rb +38 -35
  29. data/test/unit/assertions/assert_same_tests.rb +91 -80
  30. data/test/unit/assertions/assert_true_false_tests.rb +64 -60
  31. data/test/unit/assertions_tests.rb +15 -13
  32. data/test/unit/config_helpers_tests.rb +36 -35
  33. data/test/unit/config_tests.rb +33 -34
  34. data/test/unit/context/let_dsl_tests.rb +10 -0
  35. data/test/unit/context/setup_dsl_tests.rb +70 -81
  36. data/test/unit/context/subject_dsl_tests.rb +16 -43
  37. data/test/unit/context/suite_dsl_tests.rb +16 -16
  38. data/test/unit/context/test_dsl_tests.rb +50 -54
  39. data/test/unit/context_info_tests.rb +16 -15
  40. data/test/unit/context_tests.rb +170 -157
  41. data/test/unit/default_runner_tests.rb +2 -5
  42. data/test/unit/default_suite_tests.rb +51 -53
  43. data/test/unit/factory_tests.rb +3 -3
  44. data/test/unit/file_line_tests.rb +31 -33
  45. data/test/unit/macro_tests.rb +9 -10
  46. data/test/unit/result_tests.rb +150 -163
  47. data/test/unit/runner_tests.rb +63 -63
  48. data/test/unit/suite_tests.rb +57 -54
  49. data/test/unit/test_tests.rb +134 -126
  50. data/test/unit/utils_tests.rb +41 -45
  51. data/test/unit/view_helpers_tests.rb +55 -52
  52. data/test/unit/view_tests.rb +20 -22
  53. metadata +11 -4
@@ -13,13 +13,13 @@ module Assert
13
13
  should have_imeths :stubs, :stub, :unstub, :unstub!, :stub_send
14
14
 
15
15
  should "know its config instance" do
16
- assert_kind_of Assert::Config, subject.config
16
+ assert_that(subject.config).is_kind_of(Assert::Config)
17
17
  end
18
18
 
19
19
  should "map its view, suite and runner to its config" do
20
- assert_same subject.config.view, subject.view
21
- assert_same subject.config.suite, subject.suite
22
- assert_same subject.config.runner, subject.runner
20
+ assert_that(subject.view).is_the_same_as(subject.config.view)
21
+ assert_that(subject.suite).is_the_same_as(subject.config.suite)
22
+ assert_that(subject.runner).is_the_same_as(subject.config.runner)
23
23
  end
24
24
 
25
25
  # Note: don't really need to explicitly test the configure method as
@@ -27,57 +27,80 @@ module Assert
27
27
  end
28
28
 
29
29
  class StubTests < UnitTests
30
- setup do
31
- @orig_value = Factory.string
32
- @stub_value = Factory.string
33
-
34
- @myclass = Class.new do
30
+ # setup do
31
+ # orig_value1 = Factory.string
32
+ # stub_value1 = Factory.string
33
+
34
+ # @myclass =
35
+ # Class.new do
36
+ # def initialize(value); @value = value; end
37
+ # def mymeth; @value; end
38
+ # end
39
+ # object1 = @myclass.new(orig_value1)
40
+ # end
41
+
42
+ let(:class1) {
43
+ Class.new do
35
44
  def initialize(value); @value = value; end
36
45
  def mymeth; @value; end
37
46
  end
38
- @myobj = @myclass.new(@orig_value)
39
- end
47
+ }
48
+ let(:object1) { class1.new(orig_value1) }
49
+ let(:orig_value1) { Factory.string }
50
+ let(:stub_value1) { Factory.string }
40
51
 
41
52
  should "build a stub" do
42
- stub1 = Assert.stub(@myobj, :mymeth)
53
+ stub1 = Assert.stub(object1, :mymeth)
54
+ assert_that(stub1).is_kind_of(MuchStub::Stub)
55
+ end
56
+
57
+ should "build a stub with an on_call block" do
58
+ my_meth_called_with = nil
59
+ stub1 =
60
+ Assert.stub_on_call(object1, :mymeth) { |call|
61
+ my_meth_called_with = call
62
+ }
63
+
64
+ object1.mymeth
43
65
  assert_kind_of MuchStub::Stub, stub1
66
+ assert_equal [], my_meth_called_with.args
44
67
  end
45
68
 
46
69
  should "lookup stubs that have been called before" do
47
- stub1 = Assert.stub(@myobj, :mymeth)
48
- stub2 = Assert.stub(@myobj, :mymeth)
49
- assert_same stub1, stub2
70
+ stub1 = Assert.stub(object1, :mymeth)
71
+ stub2 = Assert.stub(object1, :mymeth)
72
+ assert_that(stub2).is_the_same_as(stub1)
50
73
  end
51
74
 
52
75
  should "set the stub's do block if given a block" do
53
- Assert.stub(@myobj, :mymeth)
54
- assert_raises(MuchStub::NotStubbedError){ @myobj.mymeth }
55
- Assert.stub(@myobj, :mymeth){ @stub_value }
56
- assert_equal @stub_value, @myobj.mymeth
76
+ Assert.stub(object1, :mymeth)
77
+ assert_that(-> { object1.mymeth }).raises(MuchStub::NotStubbedError)
78
+ Assert.stub(object1, :mymeth){ stub_value1 }
79
+ assert_that(object1.mymeth).equals(stub_value1)
57
80
  end
58
81
 
59
82
  should "teardown stubs" do
60
- assert_equal @orig_value, @myobj.mymeth
61
- Assert.unstub(@myobj, :mymeth)
62
- assert_equal @orig_value, @myobj.mymeth
63
-
64
- assert_equal @orig_value, @myobj.mymeth
65
- Assert.stub(@myobj, :mymeth){ @stub_value }
66
- assert_equal @stub_value, @myobj.mymeth
67
- Assert.unstub(@myobj, :mymeth)
68
- assert_equal @orig_value, @myobj.mymeth
83
+ assert_that(object1.mymeth).equals(orig_value1)
84
+ Assert.unstub(object1, :mymeth)
85
+ assert_that(object1.mymeth).equals(orig_value1)
86
+
87
+ assert_that(object1.mymeth).equals(orig_value1)
88
+ Assert.stub(object1, :mymeth){ stub_value1 }
89
+ assert_that(object1.mymeth).equals(stub_value1)
90
+ Assert.unstub(object1, :mymeth)
91
+ assert_that(object1.mymeth).equals(orig_value1)
69
92
  end
70
93
 
71
94
  should "know and teardown all stubs" do
72
- assert_equal @orig_value, @myobj.mymeth
95
+ assert_that(object1.mymeth).equals(orig_value1)
73
96
 
74
- Assert.stub(@myobj, :mymeth){ @stub_value }
75
- assert_equal @stub_value, @myobj.mymeth
76
- assert_equal 1, Assert.stubs.size
97
+ Assert.stub(object1, :mymeth){ stub_value1 }
98
+ assert_that(object1.mymeth).equals(stub_value1)
99
+ assert_that(Assert.stubs.size).equals(1)
77
100
 
78
101
  Assert.unstub!
79
- assert_equal @orig_value, @myobj.mymeth
80
- assert_empty Assert.stubs
102
+ assert_that(object1.mymeth).equals(orig_value1)
103
+ assert_that(Assert.stubs).is_empty
81
104
  end
82
105
 
83
106
  should "auto-unstub any stubs on teardown" do
@@ -88,41 +111,43 @@ module Assert
88
111
  end
89
112
 
90
113
  context_class.run_setups("scope")
91
- assert_equal 1, Assert.stubs.size
114
+ assert_that(Assert.stubs.size).equals(1)
92
115
 
93
116
  context_class.run_teardowns("scope")
94
- assert_empty Assert.stubs
117
+ assert_that(Assert.stubs).is_empty
95
118
  end
96
119
 
97
120
  should "be able to call a stub's original method" do
98
- err = assert_raises(MuchStub::NotStubbedError){ Assert.stub_send(@myobj, :mymeth) }
99
- assert_includes "not stubbed.", err.message
100
- assert_includes "test/unit/assert_tests.rb", err.backtrace.first
121
+ err =
122
+ assert_that(-> { Assert.stub_send(object1, :mymeth) }).
123
+ raises(MuchStub::NotStubbedError)
124
+ assert_that(err.message).includes("not stubbed.")
125
+ assert_that(err.backtrace.first).includes("test/unit/assert_tests.rb")
101
126
 
102
- Assert.stub(@myobj, :mymeth){ @stub_value }
127
+ Assert.stub(object1, :mymeth){ stub_value1 }
103
128
 
104
- assert_equal @stub_value, @myobj.mymeth
105
- assert_equal @orig_value, Assert.stub_send(@myobj, :mymeth)
129
+ assert_that(object1.mymeth).equals(stub_value1)
130
+ assert_that(Assert.stub_send(object1, :mymeth)).equals(orig_value1)
106
131
  end
107
132
 
108
133
  should "be able to add a stub tap" do
109
134
  my_meth_called_with = nil
110
- Assert.stub_tap(@myobj, :mymeth){ |value, *args, &block|
135
+ Assert.stub_tap(object1, :mymeth){ |value, *args, &block|
111
136
  my_meth_called_with = args
112
137
  }
113
138
 
114
- assert_equal @orig_value, @myobj.mymeth
115
- assert_equal [], my_meth_called_with
139
+ assert_that(object1.mymeth).equals(orig_value1)
140
+ assert_that(my_meth_called_with).equals([])
116
141
  end
117
142
 
118
143
  should "be able to add a stub tap with an on_call block" do
119
144
  my_meth_called_with = nil
120
- Assert.stub_tap_on_call(@myobj, :mymeth){ |value, call|
145
+ Assert.stub_tap_on_call(object1, :mymeth){ |value, call|
121
146
  my_meth_called_with = call
122
147
  }
123
148
 
124
- assert_equal @orig_value, @myobj.mymeth
125
- assert_equal [], my_meth_called_with.args
149
+ assert_that(object1.mymeth).equals(orig_value1)
150
+ assert_that(my_meth_called_with.args).equals([])
126
151
  end
127
152
 
128
153
  should "be able to add a stubbed spy" do
@@ -142,19 +167,19 @@ module Assert
142
167
  :three,
143
168
  ready?: true)
144
169
 
145
- assert_equal spy, myobj.one
146
- assert_equal spy, myobj.two("a")
147
- assert_equal spy, myobj.three
170
+ assert_that(myobj.one).equals(spy)
171
+ assert_that(myobj.two("a")).equals(spy)
172
+ assert_that(myobj.three).equals(spy)
148
173
 
149
- assert_true myobj.one.two("b").three.ready?
174
+ assert_that(myobj.one.two("b").three.ready?).is_true
150
175
 
151
- assert_kind_of MuchStub::CallSpy, spy
152
- assert_equal 2, spy.one_call_count
153
- assert_equal 2, spy.two_call_count
154
- assert_equal 2, spy.three_call_count
155
- assert_equal 1, spy.ready_predicate_call_count
156
- assert_equal ["b"], spy.two_last_called_with.args
157
- assert_true spy.ready_predicate_called?
176
+ assert_that(spy).is_kind_of(MuchStub::CallSpy)
177
+ assert_that(spy.one_call_count).equals(2)
178
+ assert_that(spy.two_call_count).equals(2)
179
+ assert_that(spy.three_call_count).equals(2)
180
+ assert_that(spy.ready_predicate_call_count).equals(1)
181
+ assert_that(spy.two_last_called_with.args).equals(["b"])
182
+ assert_that(spy.ready_predicate_called?).is_true
158
183
  end
159
184
  end
160
185
  end
@@ -6,25 +6,26 @@ module Assert::Assertions
6
6
  include Assert::Test::TestHelpers
7
7
 
8
8
  desc "`assert_block`"
9
- setup do
10
- desc = @desc = "assert block fail desc"
11
- @test = Factory.test do
12
- assert_block{ true } # pass
13
- assert_block(desc){ false } # fail
9
+ subject { test1 }
10
+
11
+ let(:desc1) { "assert block fail desc" }
12
+ let(:test1) {
13
+ desc = desc1
14
+ Factory.test do
15
+ assert_block { true } # pass
16
+ assert_block(desc) { false } # fail
14
17
  end
15
- @test.run(&test_run_callback)
16
- end
17
- subject{ @test }
18
+ }
18
19
 
19
20
  should "produce results as expected" do
20
- assert_equal 2, test_run_result_count
21
- assert_equal 1, test_run_result_count(:pass)
22
- assert_equal 1, test_run_result_count(:fail)
23
- end
21
+ subject.run(&test_run_callback)
24
22
 
25
- should "have a fail message with custom and generic explanations" do
26
- exp = "#{@desc}\nExpected block to return a true value."
27
- assert_equal exp, test_run_results(:fail).first.message
23
+ assert_that(test_run_result_count).equals(2)
24
+ assert_that(test_run_result_count(:pass)).equals(1)
25
+ assert_that(test_run_result_count(:fail)).equals(1)
26
+
27
+ exp = "#{desc1}\nExpected block to return a true value."
28
+ assert_that(test_run_results(:fail).first.message).equals(exp)
28
29
  end
29
30
  end
30
31
 
@@ -32,26 +33,26 @@ module Assert::Assertions
32
33
  include Assert::Test::TestHelpers
33
34
 
34
35
  desc "`assert_not_block`"
35
- setup do
36
- desc = @desc = "assert not block fail desc"
37
- @test = Factory.test do
38
- assert_not_block(desc){ true } # fail
39
- assert_not_block{ false } # pass
36
+ subject { test1 }
37
+
38
+ let(:desc1) { "assert not block fail desc" }
39
+ let(:test1) {
40
+ desc = desc1
41
+ Factory.test do
42
+ assert_not_block(desc) { true } # fail
43
+ assert_not_block { false } # pass
40
44
  end
41
- @test.run(&test_run_callback)
42
- end
43
- subject{ @test }
45
+ }
44
46
 
45
47
  should "produce results as expected" do
46
- assert_equal 2, test_run_result_count
47
- assert_equal 1, test_run_result_count(:pass)
48
- assert_equal 1, test_run_result_count(:fail)
49
- end
48
+ subject.run(&test_run_callback)
49
+
50
+ assert_that(test_run_result_count).equals(2)
51
+ assert_that(test_run_result_count(:pass)).equals(1)
52
+ assert_that(test_run_result_count(:fail)).equals(1)
50
53
 
51
- should "have a fail message with custom and generic explanations" do
52
- exp = "#{@desc}\nExpected block to not return a true value."
53
- assert_equal exp, test_run_results(:fail).first.message
54
+ exp = "#{desc1}\nExpected block to not return a true value."
55
+ assert_that(test_run_results(:fail).first.message).equals(exp)
54
56
  end
55
57
  end
56
58
  end
57
-
@@ -8,56 +8,59 @@ module Assert::Assertions
8
8
  include Assert::Test::TestHelpers
9
9
 
10
10
  desc "`assert_empty`"
11
- setup do
12
- desc = @desc = "assert empty fail desc"
13
- args = @args = [[1], desc]
14
- @test = Factory.test do
11
+ subject { test1 }
12
+
13
+ let(:desc1) { "assert empty fail desc" }
14
+ let(:args1) { [[1], desc1] }
15
+ let(:test1) {
16
+ args = args1
17
+ Factory.test do
15
18
  assert_empty([]) # pass
16
19
  assert_empty(*args) # fail
17
20
  end
18
- @c = @test.config
19
- @test.run(&test_run_callback)
20
- end
21
- subject{ @test }
21
+ }
22
+ let(:config1) { test1.config }
22
23
 
23
24
  should "produce results as expected" do
24
- assert_equal 2, test_run_result_count
25
- assert_equal 1, test_run_result_count(:pass)
26
- assert_equal 1, test_run_result_count(:fail)
27
- end
25
+ subject.run(&test_run_callback)
28
26
 
29
- should "have a fail message with custom and generic explanations" do
30
- exp = "#{@args[1]}\nExpected #{Assert::U.show(@args[0], @c)} to be empty."
31
- assert_equal exp, test_run_results(:fail).first.message
32
- end
27
+ assert_that(test_run_result_count).equals(2)
28
+ assert_that(test_run_result_count(:pass)).equals(1)
29
+ assert_that(test_run_result_count(:fail)).equals(1)
33
30
 
31
+ exp =
32
+ "#{args1[1]}\nExpected #{Assert::U.show(args1[0], config1)} to be empty."
33
+ assert_that(test_run_results(:fail).first.message).equals(exp)
34
+ end
34
35
  end
35
36
 
36
37
  class AssertNotEmptyTests < Assert::Context
37
38
  include Assert::Test::TestHelpers
38
39
 
39
40
  desc "`assert_not_empty`"
40
- setup do
41
- desc = @desc = "assert not empty fail desc"
42
- args = @args = [[], desc]
43
- @test = Factory.test do
44
- assert_not_empty([1]) # pass
41
+ subject { test1 }
42
+
43
+ let(:desc1) { "assert not empty fail desc" }
44
+ let(:args1) { [[], desc1] }
45
+ let(:test1) {
46
+ args = args1
47
+ Factory.test do
48
+ assert_not_empty([1]) # pass
45
49
  assert_not_empty(*args) # fail
46
50
  end
47
- @c = @test.config
48
- @test.run(&test_run_callback)
49
- end
50
- subject{ @test }
51
+ }
52
+ let(:config1) { test1.config }
51
53
 
52
54
  should "produce results as expected" do
53
- assert_equal 2, test_run_result_count
54
- assert_equal 1, test_run_result_count(:pass)
55
- assert_equal 1, test_run_result_count(:fail)
56
- end
55
+ subject.run(&test_run_callback)
56
+
57
+ assert_that(test_run_result_count).equals(2)
58
+ assert_that(test_run_result_count(:pass)).equals(1)
59
+ assert_that(test_run_result_count(:fail)).equals(1)
57
60
 
58
- should "have a fail message with custom and generic explanations" do
59
- exp = "#{@args[1]}\nExpected #{Assert::U.show(@args[0], @c)} to not be empty."
60
- assert_equal exp, test_run_results(:fail).first.message
61
+ exp =
62
+ "#{args1[1]}\nExpected #{Assert::U.show(args1[0], config1)} to not be empty."
63
+ assert_that(test_run_results(:fail).first.message).equals(exp)
61
64
  end
62
65
  end
63
66
  end
@@ -8,28 +8,30 @@ module Assert::Assertions
8
8
  include Assert::Test::TestHelpers
9
9
 
10
10
  desc "`assert_equal`"
11
- setup do
12
- desc = @desc = "assert equal fail desc"
13
- a = @a = ["1", "2", desc]
14
- @test = Factory.test do
15
- assert_equal(1, 1) # pass
16
- assert_equal(*a) # fail
11
+ subject { test1 }
12
+
13
+ let(:desc1) { "assert equal fail desc" }
14
+ let(:args1) { ["1", "2", desc1] }
15
+ let(:test1) {
16
+ args = args1
17
+ Factory.test do
18
+ assert_equal(1, 1) # pass
19
+ assert_equal(*args) # fail
17
20
  end
18
- @c = @test.config
19
- @test.run(&test_run_callback)
20
- end
21
- subject{ @test }
21
+ }
22
+ let(:config1) { test1.config }
22
23
 
23
24
  should "produce results as expected" do
24
- assert_equal 2, test_run_result_count
25
- assert_equal 1, test_run_result_count(:pass)
26
- assert_equal 1, test_run_result_count(:fail)
27
- end
25
+ subject.run(&test_run_callback)
26
+
27
+ assert_that(test_run_result_count).equals(2)
28
+ assert_that(test_run_result_count(:pass)).equals(1)
29
+ assert_that(test_run_result_count(:fail)).equals(1)
28
30
 
29
- should "have a fail message with custom and generic explanations" do
30
- exp = "#{@a[2]}\nExpected #{Assert::U.show(@a[1], @c)}"\
31
- " to be equal to #{Assert::U.show(@a[0], @c)}."
32
- assert_equal exp, test_run_results(:fail).first.message
31
+ exp =
32
+ "#{args1[2]}\nExpected #{Assert::U.show(args1[1], config1)}"\
33
+ " to be equal to #{Assert::U.show(args1[0], config1)}."
34
+ assert_that(test_run_results(:fail).first.message).equals(exp)
33
35
  end
34
36
  end
35
37
 
@@ -37,28 +39,30 @@ module Assert::Assertions
37
39
  include Assert::Test::TestHelpers
38
40
 
39
41
  desc "`assert_not_equal`"
40
- setup do
41
- desc = @desc = "assert not equal fail desc"
42
- a = @a = ["1", "1", desc]
43
- @test = Factory.test do
44
- assert_not_equal(*a) # fail
45
- assert_not_equal(1, 2) # pass
42
+ subject { test1 }
43
+
44
+ let(:desc1) { "assert not equal fail desc" }
45
+ let(:args1) { ["1", "1", desc1] }
46
+ let(:test1) {
47
+ args = args1
48
+ Factory.test do
49
+ assert_not_equal(*args) # fail
50
+ assert_not_equal(1, 2) # pass
46
51
  end
47
- @c = @test.config
48
- @test.run(&test_run_callback)
49
- end
50
- subject{ @test }
52
+ }
53
+ let(:config1) { test1.config }
51
54
 
52
55
  should "produce results as expected" do
53
- assert_equal 2, test_run_result_count
54
- assert_equal 1, test_run_result_count(:pass)
55
- assert_equal 1, test_run_result_count(:fail)
56
- end
56
+ subject.run(&test_run_callback)
57
57
 
58
- should "have a fail message with custom and generic explanations" do
59
- exp = "#{@a[2]}\nExpected #{Assert::U.show(@a[1], @c)}"\
60
- " to not be equal to #{Assert::U.show(@a[0], @c)}."
61
- assert_equal exp, test_run_results(:fail).first.message
58
+ assert_that(test_run_result_count).equals(2)
59
+ assert_that(test_run_result_count(:pass)).equals(1)
60
+ assert_that(test_run_result_count(:fail)).equals(1)
61
+
62
+ exp =
63
+ "#{args1[2]}\nExpected #{Assert::U.show(args1[1], config1)}"\
64
+ " to not be equal to #{Assert::U.show(args1[0], config1)}."
65
+ assert_that(test_run_results(:fail).first.message).equals(exp)
62
66
  end
63
67
  end
64
68
 
@@ -66,21 +70,16 @@ module Assert::Assertions
66
70
  include Assert::Test::TestHelpers
67
71
 
68
72
  desc "with objects that define custom equality operators"
69
- setup do
70
- is_class = Class.new do
71
- def ==(other); true; end
72
- end
73
- @is = is_class.new
74
73
 
75
- is_not_class = Class.new do
76
- def ==(other); false; end
77
- end
78
- @is_not = is_not_class.new
79
- end
74
+ let(:is_class) { Class.new do; def ==(other); true; end; end }
75
+ let(:is_not_class) { Class.new do; def ==(other); false; end; end }
76
+
77
+ let(:is1) { is_class.new }
78
+ let(:is_not1) { is_not_class.new }
80
79
 
81
80
  should "use the equality operator of the exp value" do
82
- assert_equal @is, @is_not
83
- assert_not_equal @is_not, @is
81
+ assert_that(is1).equals(is_not1)
82
+ assert_that(is_not1).does_not_equal(is1)
84
83
  end
85
84
  end
86
85
 
@@ -88,52 +87,59 @@ module Assert::Assertions
88
87
  include Assert::Test::TestHelpers
89
88
 
90
89
  desc "with objects that should use diff when showing"
91
- setup do
92
- @exp_obj = "I'm a\nstring"
93
- @act_obj = "I am a \nstring"
94
90
 
95
- @c = Factory.modes_off_config
96
- @c.use_diff_proc(Assert::U.default_use_diff_proc)
97
- @c.run_diff_proc(Assert::U.syscmd_diff_proc)
91
+ let(:config1) {
92
+ Factory.modes_off_config.tap do |config|
93
+ config.use_diff_proc(Assert::U.default_use_diff_proc)
94
+ config.run_diff_proc(Assert::U.syscmd_diff_proc)
95
+ end
96
+ }
98
97
 
99
- @exp_obj_show = Assert::U.show_for_diff(@exp_obj, @c)
100
- @act_obj_show = Assert::U.show_for_diff(@act_obj, @c)
101
- end
98
+ let(:exp_obj1) { "I'm a\nstring" }
99
+ let(:act_obj1) { "I am a \nstring" }
100
+ let(:exp_obj_show1) { Assert::U.show_for_diff(exp_obj1, config1) }
101
+ let(:act_obj_show1) { Assert::U.show_for_diff(act_obj1, config1) }
102
102
  end
103
103
 
104
104
  class AssertEqualDiffTests < DiffTests
105
105
  desc "`assert_equal`"
106
- setup do
107
- exp_obj, act_obj = @exp_obj, @act_obj
108
- @test = Factory.test(@c) do
106
+ subject { test1 }
107
+
108
+ let(:test1) {
109
+ exp_obj, act_obj = exp_obj1, act_obj1
110
+ Factory.test(config1) do
109
111
  assert_equal(exp_obj, act_obj)
110
112
  end
111
- @test.run(&test_run_callback)
112
- end
113
- subject{ @test }
113
+ }
114
114
 
115
115
  should "include diff output in the fail messages" do
116
- exp = "Expected does not equal actual, diff:\n"\
117
- "#{Assert::U.syscmd_diff_proc.call(@exp_obj_show, @act_obj_show)}"
118
- assert_equal exp, test_run_results(:fail).first.message
116
+ subject.run(&test_run_callback)
117
+
118
+ exp =
119
+ "Expected does not equal actual, diff:\n"\
120
+ "#{Assert::U.syscmd_diff_proc.call(exp_obj_show1, act_obj_show1)}"
121
+ assert_that(test_run_results(:fail).first.message).equals(exp)
119
122
  end
120
123
  end
121
124
 
122
125
  class AssertNotEqualDiffTests < DiffTests
123
126
  desc "`assert_not_equal`"
124
- setup do
125
- exp_obj, act_obj = @exp_obj, @act_obj
126
- @test = Factory.test(@c) do
127
+ subject { test1 }
128
+
129
+ let(:test1) {
130
+ exp_obj = exp_obj1
131
+ Factory.test(config1) do
127
132
  assert_not_equal(exp_obj, exp_obj)
128
133
  end
129
- @test.run(&test_run_callback)
130
- end
131
- subject{ @test }
134
+ }
132
135
 
133
136
  should "include diff output in the fail messages" do
134
- exp = "Expected equals actual, diff:\n"\
135
- "#{Assert::U.syscmd_diff_proc.call(@exp_obj_show, @exp_obj_show)}"
136
- assert_equal exp, test_run_results(:fail).first.message
137
+ subject.run(&test_run_callback)
138
+
139
+ exp =
140
+ "Expected equals actual, diff:\n"\
141
+ "#{Assert::U.syscmd_diff_proc.call(exp_obj_show1, exp_obj_show1)}"
142
+ assert_that(test_run_results(:fail).first.message).equals(exp)
137
143
  end
138
144
  end
139
145
  end