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
@@ -6,10 +6,7 @@ require "assert/runner"
6
6
  class Assert::DefaultRunner
7
7
  class UnitTests < Assert::Context
8
8
  desc "Assert::DefaultRunner"
9
- setup do
10
- @config = Factory.modes_off_config
11
- @runner = Assert::DefaultRunner.new(@config)
12
- end
13
- subject{ @runner }
9
+
10
+ # This is tested implicitly by running Assert's test suite
14
11
  end
15
12
  end
@@ -6,89 +6,87 @@ require "assert/suite"
6
6
  class Assert::DefaultSuite
7
7
  class UnitTests < Assert::Context
8
8
  desc "Assert::DefaultSuite"
9
- setup do
10
- ci = Factory.context_info(Factory.modes_off_context_class)
11
- @test = Factory.test(Factory.string, ci){ }
9
+ subject { suite1 }
12
10
 
13
- @config = Factory.modes_off_config
14
- @suite = Assert::DefaultSuite.new(@config)
15
- end
16
- subject{ @suite }
11
+ let(:ci1) { Factory.context_info(Factory.modes_off_context_class) }
12
+ let(:test1) { Factory.test(Factory.string, ci1) { } }
13
+ let(:config1) { Factory.modes_off_config }
14
+ let(:suite1) { Assert::DefaultSuite.new(config1) }
17
15
 
18
16
  should "be a Suite" do
19
- assert_kind_of Assert::Suite, subject
17
+ assert_that(subject).is_kind_of(Assert::Suite)
20
18
  end
21
19
 
22
20
  should "default its test/result counts" do
23
- assert_equal 0, subject.test_count
24
- assert_equal 0, subject.result_count
25
- assert_equal 0, subject.pass_result_count
26
- assert_equal 0, subject.fail_result_count
27
- assert_equal 0, subject.error_result_count
28
- assert_equal 0, subject.skip_result_count
29
- assert_equal 0, subject.ignore_result_count
21
+ assert_that(subject.test_count).equals(0)
22
+ assert_that(subject.result_count).equals(0)
23
+ assert_that(subject.pass_result_count).equals(0)
24
+ assert_that(subject.fail_result_count).equals(0)
25
+ assert_that(subject.error_result_count).equals(0)
26
+ assert_that(subject.skip_result_count).equals(0)
27
+ assert_that(subject.ignore_result_count).equals(0)
30
28
  end
31
29
 
32
30
  should "increment its test count on `before_test`" do
33
31
  subject.before_test(@test)
34
- assert_equal 1, subject.test_count
32
+ assert_that(subject.test_count).equals(1)
35
33
  end
36
34
 
37
35
  should "increment its result counts on `on_result`" do
38
36
  subject.on_result(Factory.pass_result)
39
- assert_equal 1, subject.result_count
40
- assert_equal 1, subject.pass_result_count
41
- assert_equal 0, subject.fail_result_count
42
- assert_equal 0, subject.error_result_count
43
- assert_equal 0, subject.skip_result_count
44
- assert_equal 0, subject.ignore_result_count
37
+ assert_that(subject.result_count).equals(1)
38
+ assert_that(subject.pass_result_count).equals(1)
39
+ assert_that(subject.fail_result_count).equals(0)
40
+ assert_that(subject.error_result_count).equals(0)
41
+ assert_that(subject.skip_result_count).equals(0)
42
+ assert_that(subject.ignore_result_count).equals(0)
45
43
 
46
44
  subject.on_result(Factory.fail_result)
47
- assert_equal 2, subject.result_count
48
- assert_equal 1, subject.pass_result_count
49
- assert_equal 1, subject.fail_result_count
50
- assert_equal 0, subject.error_result_count
51
- assert_equal 0, subject.skip_result_count
52
- assert_equal 0, subject.ignore_result_count
45
+ assert_that(subject.result_count).equals(2)
46
+ assert_that(subject.pass_result_count).equals(1)
47
+ assert_that(subject.fail_result_count).equals(1)
48
+ assert_that(subject.error_result_count).equals(0)
49
+ assert_that(subject.skip_result_count).equals(0)
50
+ assert_that(subject.ignore_result_count).equals(0)
53
51
 
54
52
  subject.on_result(Factory.error_result)
55
- assert_equal 3, subject.result_count
56
- assert_equal 1, subject.pass_result_count
57
- assert_equal 1, subject.fail_result_count
58
- assert_equal 1, subject.error_result_count
59
- assert_equal 0, subject.skip_result_count
60
- assert_equal 0, subject.ignore_result_count
53
+ assert_that(subject.result_count).equals(3)
54
+ assert_that(subject.pass_result_count).equals(1)
55
+ assert_that(subject.fail_result_count).equals(1)
56
+ assert_that(subject.error_result_count).equals(1)
57
+ assert_that(subject.skip_result_count).equals(0)
58
+ assert_that(subject.ignore_result_count).equals(0)
61
59
 
62
60
  subject.on_result(Factory.skip_result)
63
- assert_equal 4, subject.result_count
64
- assert_equal 1, subject.pass_result_count
65
- assert_equal 1, subject.fail_result_count
66
- assert_equal 1, subject.error_result_count
67
- assert_equal 1, subject.skip_result_count
68
- assert_equal 0, subject.ignore_result_count
61
+ assert_that(subject.result_count).equals(4)
62
+ assert_that(subject.pass_result_count).equals(1)
63
+ assert_that(subject.fail_result_count).equals(1)
64
+ assert_that(subject.error_result_count).equals(1)
65
+ assert_that(subject.skip_result_count).equals(1)
66
+ assert_that(subject.ignore_result_count).equals(0)
69
67
 
70
68
  subject.on_result(Factory.ignore_result)
71
- assert_equal 5, subject.result_count
72
- assert_equal 1, subject.pass_result_count
73
- assert_equal 1, subject.fail_result_count
74
- assert_equal 1, subject.error_result_count
75
- assert_equal 1, subject.skip_result_count
76
- assert_equal 1, subject.ignore_result_count
69
+ assert_that(subject.result_count).equals(5)
70
+ assert_that(subject.pass_result_count).equals(1)
71
+ assert_that(subject.fail_result_count).equals(1)
72
+ assert_that(subject.error_result_count).equals(1)
73
+ assert_that(subject.skip_result_count).equals(1)
74
+ assert_that(subject.ignore_result_count).equals(1)
77
75
  end
78
76
 
79
77
  should "clear the run data on `on_start`" do
80
- subject.before_test(@test)
78
+ subject.before_test(test1)
81
79
  subject.on_result(Factory.pass_result)
82
80
 
83
- assert_equal 1, subject.test_count
84
- assert_equal 1, subject.result_count
85
- assert_equal 1, subject.pass_result_count
81
+ assert_that(subject.test_count).equals(1)
82
+ assert_that(subject.result_count).equals(1)
83
+ assert_that(subject.pass_result_count).equals(1)
86
84
 
87
85
  subject.on_start
88
86
 
89
- assert_equal 0, subject.test_count
90
- assert_equal 0, subject.result_count
91
- assert_equal 0, subject.pass_result_count
87
+ assert_that(subject.test_count).equals(0)
88
+ assert_that(subject.result_count).equals(0)
89
+ assert_that(subject.pass_result_count).equals(0)
92
90
  end
93
91
  end
94
92
  end
@@ -6,13 +6,13 @@ require "much-factory"
6
6
  module Assert::Factory
7
7
  class UnitTests < Assert::Context
8
8
  desc "Assert::Factory"
9
- subject{ Assert::Factory }
9
+ subject { Assert::Factory }
10
10
 
11
11
  should "include and extend MuchFactory" do
12
- assert_includes MuchFactory, subject
12
+ assert_that(subject).includes(MuchFactory)
13
13
 
14
14
  # https://stackoverflow.com/questions/5197166/ruby-get-a-list-of-extended-modules
15
- assert_includes MuchFactory, subject_metaclass.included_modules
15
+ assert_that(subject_metaclass.included_modules).includes(MuchFactory)
16
16
  end
17
17
 
18
18
  private
@@ -4,75 +4,73 @@ require "assert/file_line"
4
4
  class Assert::FileLine
5
5
  class UnitTests < Assert::Context
6
6
  desc "Assert::FileLine"
7
- setup do
8
- @file = "#{Factory.path}_tests.rb"
9
- @line = Factory.integer.to_s
10
- end
11
- subject{ Assert::FileLine }
7
+ subject { Assert::FileLine }
8
+
9
+ let(:file1) { "#{Factory.path}_tests.rb" }
10
+ let(:line1) { Factory.integer.to_s }
12
11
 
13
12
  should have_imeths :parse
14
13
 
15
14
  should "know how to parse and init from a file line path string" do
16
15
  file_line_path = [
17
- "#{@file}:#{@line}",
18
- "#{@file}:#{@line} #{Factory.string}"
16
+ "#{file1}:#{line1}",
17
+ "#{file1}:#{line1} #{Factory.string}"
19
18
  ].sample
20
19
  file_line = subject.parse(file_line_path)
21
20
 
22
- assert_equal @file, file_line.file
23
- assert_equal @line, file_line.line
21
+ assert_that(file_line.file).equals(file1)
22
+ assert_that(file_line.line).equals(line1)
24
23
  end
25
24
 
26
25
  should "handle parsing bad data gracefully" do
27
- file_line = subject.parse(@file)
28
- assert_equal @file, file_line.file
29
- assert_equal "", file_line.line
26
+ file_line = subject.parse(file1)
27
+ assert_that(file_line.file).equals(file1)
28
+ assert_that(file_line.line).equals("")
30
29
 
31
- file_line = subject.parse(@line)
32
- assert_equal @line, file_line.file
33
- assert_equal "", file_line.line
30
+ file_line = subject.parse(line1)
31
+ assert_that(file_line.file).equals(line1)
32
+ assert_that(file_line.line).equals("")
34
33
 
35
34
  file_line = subject.parse("")
36
- assert_equal "", file_line.file
37
- assert_equal "", file_line.line
35
+ assert_that(file_line.file).equals("")
36
+ assert_that(file_line.line).equals("")
38
37
 
39
38
  file_line = subject.parse(nil)
40
- assert_equal "", file_line.file
41
- assert_equal "", file_line.line
39
+ assert_that(file_line.file).equals("")
40
+ assert_that(file_line.line).equals("")
42
41
  end
43
42
  end
44
43
 
45
44
  class InitTests < UnitTests
46
45
  desc "when init"
47
- setup do
48
- @file_line = Assert::FileLine.new(@file, @line)
49
- end
50
- subject{ @file_line }
46
+ subject { file_line1 }
47
+
48
+ let(:file_line1) { Assert::FileLine.new(file1, line1) }
51
49
 
52
50
  should have_readers :file, :line
53
51
 
54
52
  should "know its file and line" do
55
- assert_equal @file, subject.file
56
- assert_equal @line, subject.line
53
+ assert_that(subject.file).equals(file1)
54
+ assert_that(subject.line).equals(line1)
57
55
 
58
- file_line = Assert::FileLine.new(@file)
59
- assert_equal @file, file_line.file
60
- assert_equal "", file_line.line
56
+ file_line = Assert::FileLine.new(file1)
57
+ assert_that(file_line.file).equals(file1)
58
+ assert_that(file_line.line).equals("")
61
59
 
62
60
  file_line = Assert::FileLine.new
63
- assert_equal "", file_line.file
64
- assert_equal "", file_line.line
61
+ assert_that(file_line.file).equals("")
62
+ assert_that(file_line.line).equals("")
65
63
  end
66
64
 
67
65
  should "know its string representation" do
68
- assert_equal "#{subject.file}:#{subject.line}", subject.to_s
66
+ assert_that(subject.to_s).equals("#{subject.file}:#{subject.line}")
69
67
  end
70
68
 
71
69
  should "know if it is equal to another file line" do
72
- yes = Assert::FileLine.new(@file, @line)
70
+ yes = Assert::FileLine.new(file1, line1)
73
71
  no = Assert::FileLine.new("#{Factory.path}_tests.rb", Factory.integer.to_s)
74
72
 
75
- assert_equal yes, subject
73
+ assert_that(subject).equals(yes)
76
74
  assert_not_equal no, subject
77
75
  end
78
76
  end
@@ -4,30 +4,29 @@ require "assert/macro"
4
4
  class Assert::Macro
5
5
  class UnitTests < Assert::Context
6
6
  desc "Assert::Macro"
7
- setup do
8
- @macro = Assert::Macro.new {}
9
- end
10
- subject { @macro }
7
+ subject { macro1 }
8
+
9
+ let(:macro1) { Assert::Macro.new {} }
11
10
 
12
11
  should "have an accessor for its (optional) name" do
13
- assert_respond_to :name, subject
14
- assert_respond_to :name=, subject
12
+ assert_that(subject).responds_to(:name)
13
+ assert_that(subject).responds_to(:name=)
15
14
  end
16
15
 
17
16
  should "default its name if no given" do
18
- assert_equal "run this macro", (Assert::Macro.new {}).name
17
+ assert_that((Assert::Macro.new {}).name).equals("run this macro")
19
18
  end
20
19
 
21
20
  should "initialize with a given name" do
22
- assert_equal "test", (Assert::Macro.new("test") {}).name
21
+ assert_that((Assert::Macro.new("test") {}).name).equals("test")
23
22
  end
24
23
 
25
24
  should "be a Proc" do
26
- assert_kind_of ::Proc, subject
25
+ assert_that(subject).is_kind_of(::Proc)
27
26
  end
28
27
 
29
28
  should "complain if you create a macro without a block" do
30
- assert_raises(ArgumentError) { Assert::Macro.new }
29
+ assert_that(-> { Assert::Macro.new }).raises(ArgumentError)
31
30
  end
32
31
  end
33
32
 
@@ -6,10 +6,9 @@ require "assert/file_line"
6
6
  module Assert::Result
7
7
  class UnitTests < Assert::Context
8
8
  desc "Assert::Result"
9
- setup do
10
- @test = Factory.test("a test name")
11
- end
12
- subject{ Assert::Result }
9
+ subject { Assert::Result }
10
+
11
+ let(:test1) { Factory.test("a test name") }
13
12
 
14
13
  should have_imeths :types, :new
15
14
 
@@ -21,40 +20,34 @@ module Assert::Result
21
20
  :skip => Skip,
22
21
  :error => Error
23
22
  }
24
- assert_equal exp, subject.types
23
+ assert_that(subject.types).equals(exp)
25
24
 
26
- assert_equal Base, subject.types[Factory.string]
25
+ assert_that(subject.types[Factory.string]).equals(Base)
27
26
  end
28
27
 
29
28
  should "create results from data hashes" do
30
29
  type = Assert::Result.types.keys.sample
31
30
  exp = Assert::Result.types[type].new(:type => type)
32
- assert_equal exp, Assert::Result.new(:type => type)
33
- end
34
-
35
- private
36
-
37
- def build_backtrace
38
- assert_lib_path = File.join(ROOT_PATH, "lib/#{Factory.string}:#{Factory.integer}")
39
- (Factory.integer(3).times.map{ Factory.string } + [assert_lib_path]).shuffle
31
+ assert_that(Assert::Result.new(:type => type)).equals(exp)
40
32
  end
41
33
  end
42
34
 
43
35
  class BaseTests < UnitTests
44
36
  desc "Base"
45
- setup do
46
- @given_data = {
37
+ subject { result1 }
38
+
39
+ let(:given_data1) {
40
+ {
47
41
  :type => Factory.string,
48
42
  :name => Factory.string,
49
43
  :test_name => Factory.string,
50
44
  :test_file_line => Assert::FileLine.new(Factory.string, Factory.integer),
51
45
  :message => Factory.string,
52
46
  :output => Factory.text,
53
- :backtrace => Backtrace.new(build_backtrace)
47
+ :backtrace => Backtrace.new(Factory.backtrace)
54
48
  }
55
- @result = Base.new(@given_data)
56
- end
57
- subject{ @result }
49
+ }
50
+ let(:result1) { Base.new(given_data1) }
58
51
 
59
52
  should have_cmeths :type, :name, :for_test
60
53
  should have_imeths :type, :name, :test_name, :test_file_line
@@ -63,69 +56,69 @@ module Assert::Result
63
56
  should have_imeths :backtrace, :trace
64
57
  should have_imeths :set_backtrace, :set_with_bt, :with_bt_set?
65
58
  should have_imeths :src_line, :file_line, :file_name, :line_num
66
- should have_imeths *Assert::Result.types.keys.map{ |k| "#{k}?" }
59
+ should have_imeths(*Assert::Result.types.keys.map{ |k| "#{k}?" })
67
60
  should have_imeths :to_sym, :to_s
68
61
 
69
62
  should "know its class-level type/name" do
70
- assert_equal :unknown, subject.class.type
71
- assert_equal "", subject.class.name
63
+ assert_that(subject.class.type).equals(:unknown)
64
+ assert_that(subject.class.name).equals("")
72
65
  end
73
66
 
74
67
  should "know how to build a result for a given test" do
75
68
  message = Factory.text
76
69
  bt = Factory.integer(3).times.map{ Factory.string }
77
- result = Base.for_test(@test, message, bt)
70
+ result = Base.for_test(test1, message, bt)
78
71
 
79
72
  exp_backtrace = Backtrace.new(bt)
80
73
  exp_trace = exp_backtrace.filtered.first.to_s
81
74
 
82
- assert_equal @test.name, result.test_name
83
- assert_equal @test.file_line.to_s, result.test_id
75
+ assert_that(result.test_name).equals(test1.name)
76
+ assert_that(result.test_id).equals(test1.file_line.to_s)
84
77
 
85
- assert_equal message, result.message
86
- assert_equal exp_backtrace, result.backtrace
87
- assert_equal exp_trace, result.trace
78
+ assert_that(result.message).equals(message)
79
+ assert_that(result.backtrace).equals(exp_backtrace)
80
+ assert_that(result.trace).equals(exp_trace)
88
81
 
89
- assert_false result.with_bt_set?
82
+ assert_that(result.with_bt_set?).is_false
90
83
  end
91
84
 
92
85
  should "use any given attrs" do
93
- assert_equal @given_data[:type].to_sym, subject.type
94
- assert_equal @given_data[:name], subject.name
95
- assert_equal @given_data[:test_name], subject.test_name
96
- assert_equal @given_data[:test_file_line], subject.test_file_line
97
- assert_equal @given_data[:message], subject.message
98
- assert_equal @given_data[:output], subject.output
99
- assert_equal @given_data[:backtrace], subject.backtrace
86
+ assert_that(subject.type).equals(given_data1[:type].to_sym)
87
+ assert_that(subject.name).equals(given_data1[:name])
88
+ assert_that(subject.test_name).equals(given_data1[:test_name])
89
+ assert_that(subject.test_file_line).equals(given_data1[:test_file_line])
90
+ assert_that(subject.message).equals(given_data1[:message])
91
+ assert_that(subject.output).equals(given_data1[:output])
92
+ assert_that(subject.backtrace).equals(given_data1[:backtrace])
100
93
  end
101
94
 
102
95
  should "default its attrs" do
103
96
  result = Base.new({})
104
97
 
105
- assert_equal :unknown, result.type
106
- assert_equal "", result.name
107
- assert_equal "", result.test_name
108
- assert_equal Assert::FileLine.parse(""), result.test_file_line
109
- assert_equal "", result.message
110
- assert_equal "", result.output
111
- assert_equal Backtrace.new([]), result.backtrace
112
- assert_equal "", result.trace
98
+ assert_that(result.type).equals(:unknown)
99
+ assert_that(result.name).equals("")
100
+ assert_that(result.test_name).equals("")
101
+ assert_that(result.test_file_line).equals(Assert::FileLine.parse(""))
102
+ assert_that(result.message).equals("")
103
+ assert_that(result.output).equals("")
104
+ assert_that(result.backtrace).equals(Backtrace.new([]))
105
+ assert_that(result.trace).equals("")
113
106
  end
114
107
 
115
108
  should "know its test file line attrs" do
116
- exp = @given_data[:test_file_line]
117
- assert_equal exp.file, subject.test_file_name
118
- assert_equal exp.line.to_i, subject.test_line_num
119
- assert_equal exp.to_s, subject.test_id
109
+ exp = given_data1[:test_file_line]
110
+ assert_that(subject.test_file_name).equals(exp.file)
111
+ assert_that(subject.test_line_num).equals(exp.line.to_i)
112
+ assert_that(subject.test_id).equals(exp.to_s)
120
113
  end
121
114
 
122
115
  should "allow setting a new backtrace" do
123
- new_bt = build_backtrace
116
+ new_bt = Factory.backtrace
124
117
  exp_backtrace = Backtrace.new(new_bt)
125
118
  exp_trace = exp_backtrace.filtered.first.to_s
126
119
  subject.set_backtrace(new_bt)
127
- assert_equal exp_backtrace, subject.backtrace
128
- assert_equal exp_trace, subject.trace
120
+ assert_that(subject.backtrace).equals(exp_backtrace)
121
+ assert_that(subject.trace).equals(exp_trace)
129
122
 
130
123
  # test that the first bt line is used if filtered is empty
131
124
  assert_lib_path = File.join(ROOT_PATH, "lib/#{Factory.string}:#{Factory.integer}")
@@ -133,46 +126,46 @@ module Assert::Result
133
126
  exp_backtrace = Backtrace.new(new_bt)
134
127
  exp_trace = exp_backtrace.first.to_s
135
128
  subject.set_backtrace(new_bt)
136
- assert_equal exp_backtrace, subject.backtrace
137
- assert_equal exp_trace, subject.trace
129
+ assert_that(subject.backtrace).equals(exp_backtrace)
130
+ assert_that(subject.trace).equals(exp_trace)
138
131
  end
139
132
 
140
133
  should "allow setting a with bt backtrace and know if one has been set" do
141
- assert_false subject.with_bt_set?
134
+ assert_that(subject.with_bt_set?).is_false
142
135
 
143
136
  orig_backtrace = subject.backtrace
144
- with_bt = build_backtrace
137
+ with_bt = Factory.backtrace
145
138
 
146
139
  subject.set_with_bt(with_bt)
147
140
 
148
- assert_true subject.with_bt_set?
149
- assert_equal orig_backtrace, subject.backtrace
150
- assert_equal with_bt.first, subject.src_line
141
+ assert_that(subject.with_bt_set?).is_true
142
+ assert_that(subject.backtrace).equals(orig_backtrace)
143
+ assert_that(subject.src_line).equals(with_bt.first)
151
144
 
152
145
  exp = Backtrace.to_s(with_bt + [orig_backtrace.filtered.first])
153
- assert_equal exp, subject.trace
146
+ assert_that(subject.trace).equals(exp)
154
147
  end
155
148
 
156
149
  should "know its src/file line attrs" do
157
- new_bt = build_backtrace
150
+ new_bt = Factory.backtrace
158
151
  subject.set_backtrace(new_bt)
159
152
 
160
153
  exp = Backtrace.new(new_bt).filtered.first.to_s
161
- assert_equal exp, subject.src_line
154
+ assert_that(subject.src_line).equals(exp)
162
155
 
163
156
  exp = Assert::FileLine.parse(subject.src_line)
164
- assert_equal exp, subject.file_line
165
- assert_equal exp.file, subject.file_name
166
- assert_equal exp.line.to_i, subject.line_num
157
+ assert_that(subject.file_line).equals(exp)
158
+ assert_that(subject.file_name).equals(exp.file)
159
+ assert_that(subject.line_num).equals(exp.line.to_i)
167
160
 
168
161
  # test you get the same file line attrs using `set_with_bt`
169
162
  subject.set_with_bt(new_bt)
170
- assert_equal new_bt.first.to_s, subject.src_line
163
+ assert_that(subject.src_line).equals(new_bt.first.to_s)
171
164
 
172
165
  exp = Assert::FileLine.parse(subject.src_line)
173
- assert_equal exp, subject.file_line
174
- assert_equal exp.file, subject.file_name
175
- assert_equal exp.line.to_i, subject.line_num
166
+ assert_that(subject.file_line).equals(exp)
167
+ assert_that(subject.file_name).equals(exp.file)
168
+ assert_that(subject.line_num).equals(exp.line.to_i)
176
169
 
177
170
  # test that the first bt line is used if filtered is empty
178
171
  assert_lib_path = File.join(ROOT_PATH, "lib/#{Factory.string}:#{Factory.integer}")
@@ -180,45 +173,45 @@ module Assert::Result
180
173
  subject.set_backtrace(new_bt)
181
174
 
182
175
  exp = new_bt.first.to_s
183
- assert_equal exp, subject.src_line
176
+ assert_that(subject.src_line).equals(exp)
184
177
 
185
178
  exp = Assert::FileLine.parse(subject.src_line)
186
- assert_equal exp, subject.file_line
187
- assert_equal exp.file, subject.file_name
188
- assert_equal exp.line.to_i, subject.line_num
179
+ assert_that(subject.file_line).equals(exp)
180
+ assert_that(subject.file_name).equals(exp.file)
181
+ assert_that(subject.line_num).equals(exp.line.to_i)
189
182
  end
190
183
 
191
184
  should "know if it is a certain type of result" do
192
185
  Assert::Result.types.keys.each do |type|
193
- assert_false subject.send("#{type}?")
186
+ assert_that(subject.send("#{type}?")).is_false
194
187
  Assert.stub(subject, :type){ type }
195
- assert_true subject.send("#{type}?")
188
+ assert_that(subject.send("#{type}?")).is_true
196
189
  end
197
190
  end
198
191
 
199
192
  should "know its symbol representation" do
200
- assert_equal subject.type, subject.to_sym
193
+ assert_that(subject.to_sym).equals(subject.type)
201
194
  end
202
195
 
203
196
  should "know its string representation" do
204
197
  str = subject.to_s
205
198
 
206
- assert_includes subject.name.upcase, str
207
- assert_includes subject.test_name, str
208
- assert_includes subject.message, str
209
- assert_includes subject.trace, str
199
+ assert_that(str).includes(subject.name.upcase)
200
+ assert_that(str).includes(subject.test_name)
201
+ assert_that(str).includes(subject.message)
202
+ assert_that(str).includes(subject.trace)
210
203
 
211
- assert_equal 3, str.split("\n").count
204
+ assert_that(str.split("\n").count).equals(3)
212
205
 
213
206
  Assert.stub(subject, :message){ "" }
214
207
  Assert.stub(subject, :trace){ "" }
215
208
 
216
- assert_equal 1, subject.to_s.split("\n").count
209
+ assert_that(subject.to_s.split("\n").count).equals(1)
217
210
  end
218
211
 
219
212
  should "know if it is equal to another result" do
220
- other = Assert::Result::Base.new(@given_data)
221
- assert_equal other, subject
213
+ other = Assert::Result::Base.new(given_data1)
214
+ assert_that(subject).equals(other)
222
215
 
223
216
  Assert.stub(other, [:type, :message].sample){ Factory.string }
224
217
  assert_not_equal other, subject
@@ -229,209 +222,203 @@ module Assert::Result
229
222
  "@message=#{subject.message.inspect} "\
230
223
  "@file_line=#{subject.file_line.to_s.inspect} "\
231
224
  "@test_file_line=#{subject.test_file_line.to_s.inspect}>"
232
- assert_equal exp, subject.inspect
225
+ assert_that(subject.inspect).equals(exp)
233
226
  end
234
227
  end
235
228
 
236
229
  class PassTests < UnitTests
237
230
  desc "Pass"
238
- setup do
239
- @result = Pass.new({})
240
- end
241
- subject { @result }
231
+ subject { result1 }
232
+
233
+ let(:result1) { Pass.new({}) }
242
234
 
243
235
  should "know its type/name" do
244
- assert_equal :pass, subject.type
245
- assert_equal :pass, subject.class.type
246
- assert_equal "Pass", subject.class.name
236
+ assert_that(subject.type).equals(:pass)
237
+ assert_that(subject.class.type).equals(:pass)
238
+ assert_that(subject.class.name).equals("Pass")
247
239
  end
248
240
  end
249
241
 
250
242
  class IgnoreTests < UnitTests
251
243
  desc "Ignore"
252
- setup do
253
- @result = Ignore.new({})
254
- end
255
- subject { @result }
244
+ subject { result1 }
245
+
246
+ let(:result1) { Ignore.new({}) }
256
247
 
257
248
  should "know its type/name" do
258
- assert_equal :ignore, subject.type
259
- assert_equal :ignore, subject.class.type
260
- assert_equal "Ignore", subject.class.name
249
+ assert_that(subject.type).equals(:ignore)
250
+ assert_that(subject.class.type).equals(:ignore)
251
+ assert_that(subject.class.name).equals("Ignore")
261
252
  end
262
253
  end
263
254
 
264
255
  class HaltingTestResultErrorTests < UnitTests
265
256
  desc "HaltingTestResultError"
266
- subject{ HaltingTestResultError.new }
257
+ subject { HaltingTestResultError.new }
267
258
 
268
259
  should have_accessors :assert_with_bt
269
260
 
270
261
  should "be a runtime error" do
271
- assert_kind_of RuntimeError, subject
262
+ assert_that(subject).is_kind_of(RuntimeError)
272
263
  end
273
264
  end
274
265
 
275
266
  class TestFailureTests < UnitTests
276
267
  desc "TestFailure"
277
- subject{ TestFailure }
268
+ subject { TestFailure }
278
269
 
279
270
  should "be a halting test result error" do
280
- assert_kind_of HaltingTestResultError, subject.new
271
+ assert_that(subject.new).is_kind_of(HaltingTestResultError)
281
272
  end
282
273
  end
283
274
 
284
275
  class FailTests < UnitTests
285
276
  desc "Fail"
286
- setup do
287
- @result = Fail.new({})
288
- end
289
- subject { @result }
277
+ subject { result1 }
278
+
279
+ let(:result1) { Fail.new({}) }
290
280
 
291
281
  should "know its type/name" do
292
- assert_equal :fail, subject.type
293
- assert_equal :fail, subject.class.type
294
- assert_equal "Fail", subject.class.name
282
+ assert_that(subject.type).equals(:fail)
283
+ assert_that(subject.class.type).equals(:fail)
284
+ assert_that(subject.class.name).equals("Fail")
295
285
  end
296
286
 
297
287
  should "allow creating for a test with TestFailure exceptions" do
298
288
  err = TestFailure.new
299
- err.set_backtrace(build_backtrace)
300
- result = Fail.for_test(@test, err)
289
+ err.set_backtrace(Factory.backtrace)
290
+ result = Fail.for_test(test1, err)
301
291
 
302
- assert_equal err.message, result.message
292
+ assert_that(result.message).equals(err.message)
303
293
 
304
294
  err_backtrace = Backtrace.new(err.backtrace)
305
- assert_equal err_backtrace, result.backtrace
295
+ assert_that(result.backtrace).equals(err_backtrace)
306
296
 
307
297
  # test assert with bt errors
308
- err.assert_with_bt = build_backtrace
309
- result = Fail.for_test(@test, err)
298
+ err.assert_with_bt = Factory.backtrace
299
+ result = Fail.for_test(test1, err)
310
300
 
311
- assert_equal err.message, result.message
312
- assert_equal err.backtrace, result.backtrace
313
- assert_equal err.assert_with_bt.first, result.src_line
301
+ assert_that(result.message).equals(err.message)
302
+ assert_that(result.backtrace).equals(err.backtrace)
303
+ assert_that(result.src_line).equals(err.assert_with_bt.first)
314
304
 
315
305
  exp = Backtrace.to_s(err.assert_with_bt + [err_backtrace.filtered.first])
316
- assert_equal exp, result.trace
306
+ assert_that(result.trace).equals(exp)
317
307
  end
318
308
 
319
309
  should "not allow creating for a test with non-TestFailure exceptions" do
320
- assert_raises(ArgumentError){ Fail.for_test(@test, RuntimeError.new) }
310
+ assert_that(-> { Fail.for_test(test1, RuntimeError.new) }).raises(ArgumentError)
321
311
  end
322
312
  end
323
313
 
324
314
  class TestSkippedTests < UnitTests
325
315
  desc "TestSkipped"
326
- subject{ TestSkipped }
316
+ subject { TestSkipped }
327
317
 
328
318
  should "be a halting test result error" do
329
- assert_kind_of HaltingTestResultError, subject.new
319
+ assert_that(subject.new).is_kind_of(HaltingTestResultError)
330
320
  end
331
321
  end
332
322
 
333
323
  class SkipTests < UnitTests
334
324
  desc "Skip"
335
- setup do
336
- @result = Skip.new({})
337
- end
338
- subject { @result }
325
+ subject { result1 }
326
+
327
+ let(:result1) { Skip.new({}) }
339
328
 
340
329
  should "know its type/name" do
341
- assert_equal :skip, subject.type
342
- assert_equal :skip, subject.class.type
343
- assert_equal "Skip", subject.class.name
330
+ assert_that(subject.type).equals(:skip)
331
+ assert_that(subject.class.type).equals(:skip)
332
+ assert_that(subject.class.name).equals("Skip")
344
333
  end
345
334
 
346
335
  should "allow creating for a test with TestSkipped exceptions" do
347
336
  err = TestSkipped.new
348
- err.set_backtrace(build_backtrace)
349
- result = Skip.for_test(@test, err)
337
+ err.set_backtrace(Factory.backtrace)
338
+ result = Skip.for_test(test1, err)
350
339
 
351
- assert_equal err.message, result.message
340
+ assert_that(result.message).equals(err.message)
352
341
 
353
342
  err_backtrace = Backtrace.new(err.backtrace)
354
- assert_equal err_backtrace, result.backtrace
343
+ assert_that(result.backtrace).equals(err_backtrace)
355
344
 
356
345
  # test assert with bt errors
357
- err.assert_with_bt = build_backtrace
358
- result = Skip.for_test(@test, err)
346
+ err.assert_with_bt = Factory.backtrace
347
+ result = Skip.for_test(test1, err)
359
348
 
360
- assert_equal err.message, result.message
361
- assert_equal err.backtrace, result.backtrace
362
- assert_equal err.assert_with_bt.first, result.src_line
349
+ assert_that(result.message).equals(err.message)
350
+ assert_that(result.backtrace).equals(err.backtrace)
351
+ assert_that(result.src_line).equals(err.assert_with_bt.first)
363
352
 
364
353
  exp = Backtrace.to_s(err.assert_with_bt + [err_backtrace.filtered.first])
365
- assert_equal exp, result.trace
354
+ assert_that(result.trace).equals(exp)
366
355
  end
367
356
 
368
357
  should "not allow creating for a test with non-TestSkipped exceptions" do
369
- assert_raises(ArgumentError){ Skip.for_test(@test, RuntimeError.new) }
358
+ assert_that(-> { Skip.for_test(test1, RuntimeError.new) }).raises(ArgumentError)
370
359
  end
371
360
  end
372
361
 
373
362
  class ErrorTests < UnitTests
374
363
  desc "Error"
375
- setup do
376
- @result = Error.new({})
377
- end
378
- subject { @result }
364
+ subject { result1 }
365
+
366
+ let(:result1) { Error.new({}) }
379
367
 
380
368
  should "know its class-level type/name" do
381
- assert_equal :error, subject.class.type
382
- assert_equal "Error", subject.class.name
369
+ assert_that(subject.class.type).equals(:error)
370
+ assert_that(subject.class.name).equals("Error")
383
371
  end
384
372
 
385
373
  should "allow creating for a test with exceptions" do
386
374
  err = Exception.new
387
- err.set_backtrace(build_backtrace)
388
- result = Error.for_test(@test, err)
375
+ err.set_backtrace(Factory.backtrace)
376
+ result = Error.for_test(test1, err)
389
377
 
390
378
  exp_msg = "#{err.message} (#{err.class.name})"
391
- assert_equal exp_msg, result.message
379
+ assert_that(result.message).equals(exp_msg)
392
380
 
393
381
  exp_bt = Backtrace.new(err.backtrace)
394
- assert_equal exp_bt, result.backtrace
395
- assert_equal Backtrace.to_s(exp_bt), result.trace
382
+ assert_that(result.backtrace).equals(exp_bt)
383
+ assert_that(result.trace).equals(Backtrace.to_s(exp_bt))
396
384
  end
397
385
 
398
386
  should "not allow creating for a test without an exception" do
399
- assert_raises(ArgumentError){ Error.for_test(@test, Factory.string) }
387
+ assert_that(-> { Error.for_test(test1, Factory.string) }).raises(ArgumentError)
400
388
  end
401
389
  end
402
390
 
403
391
  class BacktraceTests < UnitTests
404
392
  desc "Backtrace"
405
- setup do
406
- @backtrace = Backtrace.new(build_backtrace)
407
- end
408
- subject { @backtrace }
393
+ subject { backtrace1 }
394
+
395
+ let(:backtrace1) { Backtrace.new(Factory.backtrace) }
409
396
 
410
397
  should have_cmeths :parse, :to_s
411
398
  should have_imeths :filtered
412
399
 
413
400
  should "be parseable from its string representation" do
414
- assert_equal subject, Backtrace.parse(Backtrace.to_s(subject))
401
+ assert_that(Backtrace.parse(Backtrace.to_s(subject))).equals(subject)
415
402
  end
416
403
 
417
404
  should "render as a string by joining on the newline" do
418
- assert_equal subject.join(Backtrace::DELIM), Backtrace.to_s(subject)
405
+ assert_that(Backtrace.to_s(subject)).equals(subject.join(Backtrace::DELIM))
419
406
  end
420
407
 
421
408
  should "be an Array" do
422
- assert_kind_of ::Array, subject
409
+ assert_that(subject).is_kind_of(::Array)
423
410
  end
424
411
 
425
412
  should "know its DELIM" do
426
- assert_equal "\n", Backtrace::DELIM
413
+ assert_that(Backtrace::DELIM).equals("\n")
427
414
  end
428
415
 
429
416
  should "another backtrace when filtered" do
430
- assert_kind_of Backtrace, subject
417
+ assert_that(subject).is_kind_of(Backtrace)
431
418
  end
432
419
 
433
420
  should "default itself when created from nil" do
434
- assert_equal ["No backtrace"], Backtrace.new
421
+ assert_that(Backtrace.new).equals(["No backtrace"])
435
422
  end
436
423
  end
437
424
  end