assert 2.18.0 → 2.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/README.md +66 -37
 - data/assert.gemspec +4 -3
 - data/lib/assert/actual_value.rb +140 -0
 - data/lib/assert/assertions.rb +80 -20
 - data/lib/assert/context.rb +31 -37
 - data/lib/assert/context/let_dsl.rb +13 -0
 - data/lib/assert/context/method_missing.rb +19 -0
 - data/lib/assert/context/subject_dsl.rb +23 -24
 - data/lib/assert/macros/methods.rb +4 -4
 - data/lib/assert/result.rb +5 -1
 - data/lib/assert/stub.rb +16 -0
 - data/lib/assert/suite.rb +7 -10
 - data/lib/assert/test.rb +0 -8
 - data/lib/assert/version.rb +1 -1
 - data/test/helper.rb +23 -25
 - data/test/support/factory.rb +15 -0
 - data/test/system/stub_tests.rb +332 -333
 - data/test/system/test_tests.rb +99 -109
 - data/test/unit/actual_value_tests.rb +371 -0
 - data/test/unit/assert_tests.rb +111 -43
 - data/test/unit/assertions/assert_block_tests.rb +30 -31
 - data/test/unit/assertions/assert_changes_tests.rb +97 -0
 - data/test/unit/assertions/assert_empty_tests.rb +33 -32
 - data/test/unit/assertions/assert_equal_tests.rb +94 -74
 - data/test/unit/assertions/assert_file_exists_tests.rb +32 -33
 - data/test/unit/assertions/assert_includes_tests.rb +38 -37
 - data/test/unit/assertions/assert_instance_of_tests.rb +34 -33
 - data/test/unit/assertions/assert_kind_of_tests.rb +34 -33
 - data/test/unit/assertions/assert_match_tests.rb +34 -33
 - data/test/unit/assertions/assert_nil_tests.rb +30 -31
 - data/test/unit/assertions/assert_raises_tests.rb +55 -55
 - data/test/unit/assertions/assert_respond_to_tests.rb +36 -35
 - data/test/unit/assertions/assert_same_tests.rb +86 -81
 - data/test/unit/assertions/assert_true_false_tests.rb +60 -60
 - data/test/unit/assertions_tests.rb +26 -24
 - data/test/unit/config_helpers_tests.rb +43 -38
 - data/test/unit/config_tests.rb +38 -34
 - data/test/unit/context/let_dsl_tests.rb +10 -0
 - data/test/unit/context/setup_dsl_tests.rb +70 -81
 - data/test/unit/context/subject_dsl_tests.rb +15 -43
 - data/test/unit/context/suite_dsl_tests.rb +15 -16
 - data/test/unit/context/test_dsl_tests.rb +50 -52
 - data/test/unit/context_info_tests.rb +23 -15
 - data/test/unit/context_tests.rb +184 -179
 - data/test/unit/default_runner_tests.rb +2 -5
 - data/test/unit/default_suite_tests.rb +57 -53
 - data/test/unit/factory_tests.rb +5 -3
 - data/test/unit/file_line_tests.rb +33 -35
 - data/test/unit/macro_tests.rb +14 -10
 - data/test/unit/result_tests.rb +159 -183
 - data/test/unit/runner_tests.rb +64 -64
 - data/test/unit/suite_tests.rb +56 -59
 - data/test/unit/test_tests.rb +118 -139
 - data/test/unit/utils_tests.rb +43 -45
 - data/test/unit/view_helpers_tests.rb +54 -52
 - data/test/unit/view_tests.rb +22 -23
 - metadata +29 -7
 
| 
         @@ -6,19 +6,24 @@ require "assert/config" 
     | 
|
| 
       6 
6 
     | 
    
         
             
            module Assert::ConfigHelpers
         
     | 
| 
       7 
7 
     | 
    
         
             
              class UnitTests < Assert::Context
         
     | 
| 
       8 
8 
     | 
    
         
             
                desc "Assert::ConfigHelpers"
         
     | 
| 
       9 
     | 
    
         
            -
                 
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
      
 9 
     | 
    
         
            +
                subject { unit_class }
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                let(:unit_class) {
         
     | 
| 
      
 12 
     | 
    
         
            +
                  Class.new do
         
     | 
| 
       11 
13 
     | 
    
         
             
                    include Assert::ConfigHelpers
         
     | 
| 
       12 
14 
     | 
    
         | 
| 
       13 
15 
     | 
    
         
             
                    def config
         
     | 
| 
       14 
16 
     | 
    
         
             
                      # use the assert config since it has tests, contexts, etc
         
     | 
| 
       15 
     | 
    
         
            -
                      # also  
     | 
| 
      
 17 
     | 
    
         
            +
                      # also use a fresh config that is empty
         
     | 
| 
       16 
18 
     | 
    
         
             
                      @config ||= [Assert.config, Assert::Config.new].sample
         
     | 
| 
       17 
19 
     | 
    
         
             
                    end
         
     | 
| 
       18 
20 
     | 
    
         
             
                  end
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
      
 21 
     | 
    
         
            +
                }
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              class InitTests < UnitTests
         
     | 
| 
      
 25 
     | 
    
         
            +
                desc "when init"
         
     | 
| 
      
 26 
     | 
    
         
            +
                subject { unit_class.new }
         
     | 
| 
       22 
27 
     | 
    
         | 
| 
       23 
28 
     | 
    
         
             
                should have_imeths :runner, :suite, :view
         
     | 
| 
       24 
29 
     | 
    
         
             
                should have_imeths :runner_seed, :single_test?, :single_test_file_line
         
     | 
| 
         @@ -34,67 +39,67 @@ module Assert::ConfigHelpers 
     | 
|
| 
       34 
39 
     | 
    
         
             
                should have_imeths :ocurring_result_types
         
     | 
| 
       35 
40 
     | 
    
         | 
| 
       36 
41 
     | 
    
         
             
                should "know the config's runner, suite and view" do
         
     | 
| 
       37 
     | 
    
         
            -
                   
     | 
| 
       38 
     | 
    
         
            -
                   
     | 
| 
       39 
     | 
    
         
            -
                   
     | 
| 
      
 42 
     | 
    
         
            +
                  assert_that(subject.runner).equals(subject.config.runner)
         
     | 
| 
      
 43 
     | 
    
         
            +
                  assert_that(subject.suite).equals(subject.config.suite)
         
     | 
| 
      
 44 
     | 
    
         
            +
                  assert_that(subject.view).equals(subject.config.view)
         
     | 
| 
       40 
45 
     | 
    
         
             
                end
         
     | 
| 
       41 
46 
     | 
    
         | 
| 
       42 
47 
     | 
    
         
             
                should "know its runner seed" do
         
     | 
| 
       43 
     | 
    
         
            -
                   
     | 
| 
      
 48 
     | 
    
         
            +
                  assert_that(subject.runner_seed).equals(subject.config.runner_seed)
         
     | 
| 
       44 
49 
     | 
    
         
             
                end
         
     | 
| 
       45 
50 
     | 
    
         | 
| 
       46 
51 
     | 
    
         
             
                should "know if it is in single test mode" do
         
     | 
| 
       47 
     | 
    
         
            -
                  Assert.stub(subject.config, :single_test?){ true }
         
     | 
| 
       48 
     | 
    
         
            -
                   
     | 
| 
      
 52 
     | 
    
         
            +
                  Assert.stub(subject.config, :single_test?) { true }
         
     | 
| 
      
 53 
     | 
    
         
            +
                  assert_that(subject.single_test?).is_true
         
     | 
| 
       49 
54 
     | 
    
         | 
| 
       50 
     | 
    
         
            -
                  Assert.stub(subject.config, :single_test?){ false }
         
     | 
| 
       51 
     | 
    
         
            -
                   
     | 
| 
      
 55 
     | 
    
         
            +
                  Assert.stub(subject.config, :single_test?) { false }
         
     | 
| 
      
 56 
     | 
    
         
            +
                  assert_that(subject.single_test?).is_false
         
     | 
| 
       52 
57 
     | 
    
         
             
                end
         
     | 
| 
       53 
58 
     | 
    
         | 
| 
       54 
59 
     | 
    
         
             
                should "know its single test file line" do
         
     | 
| 
       55 
60 
     | 
    
         
             
                  exp = subject.config.single_test_file_line
         
     | 
| 
       56 
     | 
    
         
            -
                   
     | 
| 
      
 61 
     | 
    
         
            +
                  assert_that(subject.single_test_file_line).equals(exp)
         
     | 
| 
       57 
62 
     | 
    
         
             
                end
         
     | 
| 
       58 
63 
     | 
    
         | 
| 
       59 
64 
     | 
    
         
             
                should "know its tests-to-run attrs" do
         
     | 
| 
       60 
65 
     | 
    
         
             
                  exp = subject.config.suite.tests_to_run?
         
     | 
| 
       61 
     | 
    
         
            -
                   
     | 
| 
      
 66 
     | 
    
         
            +
                  assert_that(subject.tests_to_run?).equals(exp)
         
     | 
| 
       62 
67 
     | 
    
         | 
| 
       63 
68 
     | 
    
         
             
                  exp = subject.config.suite.tests_to_run_count
         
     | 
| 
       64 
     | 
    
         
            -
                   
     | 
| 
      
 69 
     | 
    
         
            +
                  assert_that(subject.tests_to_run_count).equals(exp)
         
     | 
| 
       65 
70 
     | 
    
         
             
                end
         
     | 
| 
       66 
71 
     | 
    
         | 
| 
       67 
72 
     | 
    
         
             
                should "know its test/result counts" do
         
     | 
| 
       68 
73 
     | 
    
         
             
                  exp = subject.config.suite.test_count
         
     | 
| 
       69 
     | 
    
         
            -
                   
     | 
| 
      
 74 
     | 
    
         
            +
                  assert_that(subject.test_count).equals(exp)
         
     | 
| 
       70 
75 
     | 
    
         | 
| 
       71 
76 
     | 
    
         
             
                  exp = subject.config.suite.result_count
         
     | 
| 
       72 
     | 
    
         
            -
                   
     | 
| 
      
 77 
     | 
    
         
            +
                  assert_that(subject.result_count).equals(exp)
         
     | 
| 
       73 
78 
     | 
    
         | 
| 
       74 
79 
     | 
    
         
             
                  exp = subject.config.suite.pass_result_count
         
     | 
| 
       75 
     | 
    
         
            -
                   
     | 
| 
      
 80 
     | 
    
         
            +
                  assert_that(subject.pass_result_count).equals(exp)
         
     | 
| 
       76 
81 
     | 
    
         | 
| 
       77 
82 
     | 
    
         
             
                  exp = subject.config.suite.fail_result_count
         
     | 
| 
       78 
     | 
    
         
            -
                   
     | 
| 
      
 83 
     | 
    
         
            +
                  assert_that(subject.fail_result_count).equals(exp)
         
     | 
| 
       79 
84 
     | 
    
         | 
| 
       80 
85 
     | 
    
         
             
                  exp = subject.config.suite.error_result_count
         
     | 
| 
       81 
     | 
    
         
            -
                   
     | 
| 
      
 86 
     | 
    
         
            +
                  assert_that(subject.error_result_count).equals(exp)
         
     | 
| 
       82 
87 
     | 
    
         | 
| 
       83 
88 
     | 
    
         
             
                  exp = subject.config.suite.skip_result_count
         
     | 
| 
       84 
     | 
    
         
            -
                   
     | 
| 
      
 89 
     | 
    
         
            +
                  assert_that(subject.skip_result_count).equals(exp)
         
     | 
| 
       85 
90 
     | 
    
         | 
| 
       86 
91 
     | 
    
         
             
                  exp = subject.config.suite.ignore_result_count
         
     | 
| 
       87 
     | 
    
         
            -
                   
     | 
| 
      
 92 
     | 
    
         
            +
                  assert_that(subject.ignore_result_count).equals(exp)
         
     | 
| 
       88 
93 
     | 
    
         
             
                end
         
     | 
| 
       89 
94 
     | 
    
         | 
| 
       90 
95 
     | 
    
         
             
                should "know if all tests are passing or not" do
         
     | 
| 
       91 
96 
     | 
    
         
             
                  result_count = Factory.integer
         
     | 
| 
       92 
97 
     | 
    
         
             
                  Assert.stub(subject, :result_count){ result_count }
         
     | 
| 
       93 
98 
     | 
    
         
             
                  Assert.stub(subject, :pass_result_count){ result_count }
         
     | 
| 
       94 
     | 
    
         
            -
                   
     | 
| 
      
 99 
     | 
    
         
            +
                  assert_that(subject.all_pass?).is_true
         
     | 
| 
       95 
100 
     | 
    
         | 
| 
       96 
101 
     | 
    
         
             
                  Assert.stub(subject, :pass_result_count){ Factory.integer }
         
     | 
| 
       97 
     | 
    
         
            -
                   
     | 
| 
      
 102 
     | 
    
         
            +
                  assert_that(subject.all_pass?).is_false
         
     | 
| 
       98 
103 
     | 
    
         
             
                end
         
     | 
| 
       99 
104 
     | 
    
         | 
| 
       100 
105 
     | 
    
         
             
                should "know its formatted run time, test rate and result rate" do
         
     | 
| 
         @@ -102,39 +107,39 @@ module Assert::ConfigHelpers 
     | 
|
| 
       102 
107 
     | 
    
         | 
| 
       103 
108 
     | 
    
         
             
                  run_time = Factory.float
         
     | 
| 
       104 
109 
     | 
    
         
             
                  exp = format % run_time
         
     | 
| 
       105 
     | 
    
         
            -
                   
     | 
| 
       106 
     | 
    
         
            -
                   
     | 
| 
      
 110 
     | 
    
         
            +
                  assert_that(subject.formatted_run_time(run_time, format)).equals(exp)
         
     | 
| 
      
 111 
     | 
    
         
            +
                  assert_that(subject.formatted_run_time(run_time)).equals(exp)
         
     | 
| 
       107 
112 
     | 
    
         | 
| 
       108 
113 
     | 
    
         
             
                  test_rate = Factory.float
         
     | 
| 
       109 
114 
     | 
    
         
             
                  exp = format % test_rate
         
     | 
| 
       110 
     | 
    
         
            -
                   
     | 
| 
       111 
     | 
    
         
            -
                   
     | 
| 
      
 115 
     | 
    
         
            +
                  assert_that(subject.formatted_result_rate(test_rate, format)).equals(exp)
         
     | 
| 
      
 116 
     | 
    
         
            +
                  assert_that(subject.formatted_result_rate(test_rate)).equals(exp)
         
     | 
| 
       112 
117 
     | 
    
         | 
| 
       113 
118 
     | 
    
         
             
                  result_rate = Factory.float
         
     | 
| 
       114 
119 
     | 
    
         
             
                  exp = format % result_rate
         
     | 
| 
       115 
     | 
    
         
            -
                   
     | 
| 
       116 
     | 
    
         
            -
                   
     | 
| 
      
 120 
     | 
    
         
            +
                  assert_that(subject.formatted_result_rate(result_rate, format)).equals(exp)
         
     | 
| 
      
 121 
     | 
    
         
            +
                  assert_that(subject.formatted_result_rate(result_rate)).equals(exp)
         
     | 
| 
       117 
122 
     | 
    
         
             
                end
         
     | 
| 
       118 
123 
     | 
    
         | 
| 
       119 
124 
     | 
    
         
             
                should "know its formatted suite run time, test rate and result rate" do
         
     | 
| 
       120 
125 
     | 
    
         
             
                  format = "%.6f"
         
     | 
| 
       121 
126 
     | 
    
         | 
| 
       122 
127 
     | 
    
         
             
                  exp = format % subject.config.suite.run_time
         
     | 
| 
       123 
     | 
    
         
            -
                   
     | 
| 
      
 128 
     | 
    
         
            +
                  assert_that(subject.formatted_suite_run_time(format)).equals(exp)
         
     | 
| 
       124 
129 
     | 
    
         | 
| 
       125 
130 
     | 
    
         
             
                  exp = format % subject.config.suite.test_rate
         
     | 
| 
       126 
     | 
    
         
            -
                   
     | 
| 
      
 131 
     | 
    
         
            +
                  assert_that(subject.formatted_suite_test_rate(format)).equals(exp)
         
     | 
| 
       127 
132 
     | 
    
         | 
| 
       128 
133 
     | 
    
         
             
                  exp = format % subject.config.suite.result_rate
         
     | 
| 
       129 
     | 
    
         
            -
                   
     | 
| 
      
 134 
     | 
    
         
            +
                  assert_that(subject.formatted_suite_result_rate(format)).equals(exp)
         
     | 
| 
       130 
135 
     | 
    
         
             
                end
         
     | 
| 
       131 
136 
     | 
    
         | 
| 
       132 
137 
     | 
    
         
             
                should "know whether to show test profile info" do
         
     | 
| 
       133 
     | 
    
         
            -
                   
     | 
| 
      
 138 
     | 
    
         
            +
                  assert_that(subject.show_test_profile_info?).equals(!!subject.config.profile)
         
     | 
| 
       134 
139 
     | 
    
         
             
                end
         
     | 
| 
       135 
140 
     | 
    
         | 
| 
       136 
141 
     | 
    
         
             
                should "know whether to show verbose info" do
         
     | 
| 
       137 
     | 
    
         
            -
                   
     | 
| 
      
 142 
     | 
    
         
            +
                  assert_that(subject.show_test_verbose_info?).equals(!!subject.config.verbose)
         
     | 
| 
       138 
143 
     | 
    
         
             
                end
         
     | 
| 
       139 
144 
     | 
    
         | 
| 
       140 
145 
     | 
    
         
             
                should "know what result types occur in a suite's results" do
         
     | 
| 
         @@ -145,7 +150,7 @@ module Assert::ConfigHelpers 
     | 
|
| 
       145 
150 
     | 
    
         
             
                  exp = result_types.select do |type_sym|
         
     | 
| 
       146 
151 
     | 
    
         
             
                    subject.send("#{type_sym}_result_count") > 0
         
     | 
| 
       147 
152 
     | 
    
         
             
                  end
         
     | 
| 
       148 
     | 
    
         
            -
                   
     | 
| 
      
 153 
     | 
    
         
            +
                  assert_that(subject.ocurring_result_types).equals(exp)
         
     | 
| 
       149 
154 
     | 
    
         
             
                end
         
     | 
| 
       150 
155 
     | 
    
         
             
              end
         
     | 
| 
       151 
156 
     | 
    
         
             
            end
         
     | 
    
        data/test/unit/config_tests.rb
    CHANGED
    
    | 
         @@ -10,10 +10,14 @@ require "assert/runner" 
     | 
|
| 
       10 
10 
     | 
    
         
             
            class Assert::Config
         
     | 
| 
       11 
11 
     | 
    
         
             
              class UnitTests < Assert::Context
         
     | 
| 
       12 
12 
     | 
    
         
             
                desc "Assert::Config"
         
     | 
| 
       13 
     | 
    
         
            -
                 
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
                 
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
      
 13 
     | 
    
         
            +
                subject { unit_class }
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                let(:unit_class) { Assert::Config }
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              class InitTests < UnitTests
         
     | 
| 
      
 19 
     | 
    
         
            +
                desc "when init"
         
     | 
| 
      
 20 
     | 
    
         
            +
                subject { unit_class.new }
         
     | 
| 
       17 
21 
     | 
    
         | 
| 
       18 
22 
     | 
    
         
             
                should have_imeths :view, :suite, :runner
         
     | 
| 
       19 
23 
     | 
    
         
             
                should have_imeths :test_dir, :test_helper, :test_file_suffixes
         
     | 
| 
         @@ -25,73 +29,73 @@ class Assert::Config 
     | 
|
| 
       25 
29 
     | 
    
         
             
                should have_imeths :single_test_file_line, :single_test_file_path
         
     | 
| 
       26 
30 
     | 
    
         | 
| 
       27 
31 
     | 
    
         
             
                should "default the view, suite, and runner" do
         
     | 
| 
       28 
     | 
    
         
            -
                   
     | 
| 
       29 
     | 
    
         
            -
                   
     | 
| 
       30 
     | 
    
         
            -
                   
     | 
| 
      
 32 
     | 
    
         
            +
                  assert_that(subject.view).is_kind_of(Assert::DefaultView)
         
     | 
| 
      
 33 
     | 
    
         
            +
                  assert_that(subject.suite).is_kind_of(Assert::DefaultSuite)
         
     | 
| 
      
 34 
     | 
    
         
            +
                  assert_that(subject.runner).is_kind_of(Assert::DefaultRunner)
         
     | 
| 
       31 
35 
     | 
    
         
             
                end
         
     | 
| 
       32 
36 
     | 
    
         | 
| 
       33 
37 
     | 
    
         
             
                should "default the test dir/helper/suffixes" do
         
     | 
| 
       34 
     | 
    
         
            -
                   
     | 
| 
       35 
     | 
    
         
            -
                   
     | 
| 
       36 
     | 
    
         
            -
                   
     | 
| 
      
 38 
     | 
    
         
            +
                  assert_that(subject.test_dir).equals("test")
         
     | 
| 
      
 39 
     | 
    
         
            +
                  assert_that(subject.test_helper).equals("helper.rb")
         
     | 
| 
      
 40 
     | 
    
         
            +
                  assert_that(subject.test_file_suffixes).equals(["_tests.rb", "_test.rb"])
         
     | 
| 
       37 
41 
     | 
    
         
             
                end
         
     | 
| 
       38 
42 
     | 
    
         | 
| 
       39 
43 
     | 
    
         
             
                should "default the procs" do
         
     | 
| 
       40 
     | 
    
         
            -
                   
     | 
| 
       41 
     | 
    
         
            -
                   
     | 
| 
       42 
     | 
    
         
            -
                   
     | 
| 
       43 
     | 
    
         
            -
                   
     | 
| 
      
 44 
     | 
    
         
            +
                  assert_that(subject.changed_proc).is_not_nil
         
     | 
| 
      
 45 
     | 
    
         
            +
                  assert_that(subject.pp_proc).is_not_nil
         
     | 
| 
      
 46 
     | 
    
         
            +
                  assert_that(subject.use_diff_proc).is_not_nil
         
     | 
| 
      
 47 
     | 
    
         
            +
                  assert_that(subject.run_diff_proc).is_not_nil
         
     | 
| 
       44 
48 
     | 
    
         
             
                end
         
     | 
| 
       45 
49 
     | 
    
         | 
| 
       46 
50 
     | 
    
         
             
                should "default the option settings" do
         
     | 
| 
       47 
     | 
    
         
            -
                   
     | 
| 
       48 
     | 
    
         
            -
                   
     | 
| 
       49 
     | 
    
         
            -
                   
     | 
| 
       50 
     | 
    
         
            -
                   
     | 
| 
       51 
     | 
    
         
            -
                   
     | 
| 
       52 
     | 
    
         
            -
                   
     | 
| 
       53 
     | 
    
         
            -
                   
     | 
| 
       54 
     | 
    
         
            -
                   
     | 
| 
       55 
     | 
    
         
            -
                   
     | 
| 
       56 
     | 
    
         
            -
                   
     | 
| 
       57 
     | 
    
         
            -
                   
     | 
| 
      
 51 
     | 
    
         
            +
                  assert_that(subject.runner_seed).is_not_nil
         
     | 
| 
      
 52 
     | 
    
         
            +
                  assert_that(subject.changed_only).is_false
         
     | 
| 
      
 53 
     | 
    
         
            +
                  assert_that(subject.changed_ref).is_empty
         
     | 
| 
      
 54 
     | 
    
         
            +
                  assert_that(subject.single_test).is_empty
         
     | 
| 
      
 55 
     | 
    
         
            +
                  assert_that(subject.pp_objects).is_false
         
     | 
| 
      
 56 
     | 
    
         
            +
                  assert_that(subject.capture_output).is_false
         
     | 
| 
      
 57 
     | 
    
         
            +
                  assert_that(subject.halt_on_fail).is_true
         
     | 
| 
      
 58 
     | 
    
         
            +
                  assert_that(subject.profile).is_false
         
     | 
| 
      
 59 
     | 
    
         
            +
                  assert_that(subject.verbose).is_false
         
     | 
| 
      
 60 
     | 
    
         
            +
                  assert_that(subject.list).is_false
         
     | 
| 
      
 61 
     | 
    
         
            +
                  assert_that(subject.debug).is_false
         
     | 
| 
       58 
62 
     | 
    
         
             
                end
         
     | 
| 
       59 
63 
     | 
    
         | 
| 
       60 
64 
     | 
    
         
             
                should "apply settings given from a hash" do
         
     | 
| 
       61 
65 
     | 
    
         
             
                  assert subject.halt_on_fail
         
     | 
| 
       62 
66 
     | 
    
         
             
                  subject.apply(:halt_on_fail => false)
         
     | 
| 
       63 
     | 
    
         
            -
                   
     | 
| 
      
 67 
     | 
    
         
            +
                  assert_that(subject.halt_on_fail).is_false
         
     | 
| 
       64 
68 
     | 
    
         | 
| 
       65 
     | 
    
         
            -
                   
     | 
| 
       66 
     | 
    
         
            -
                   
     | 
| 
      
 69 
     | 
    
         
            +
                  assert_that(Assert::Config.new.halt_on_fail).is_true
         
     | 
| 
      
 70 
     | 
    
         
            +
                  assert_that(Assert::Config.new(:halt_on_fail => false).halt_on_fail).is_false
         
     | 
| 
       67 
71 
     | 
    
         
             
                end
         
     | 
| 
       68 
72 
     | 
    
         | 
| 
       69 
73 
     | 
    
         
             
                should "know if it is in single test mode" do
         
     | 
| 
       70 
     | 
    
         
            -
                   
     | 
| 
      
 74 
     | 
    
         
            +
                  assert_that(subject.single_test?).is_false
         
     | 
| 
       71 
75 
     | 
    
         | 
| 
       72 
76 
     | 
    
         
             
                  subject.apply(:single_test => Factory.string)
         
     | 
| 
       73 
     | 
    
         
            -
                   
     | 
| 
      
 77 
     | 
    
         
            +
                  assert_that(subject.single_test?).is_true
         
     | 
| 
       74 
78 
     | 
    
         
             
                end
         
     | 
| 
       75 
79 
     | 
    
         | 
| 
       76 
80 
     | 
    
         
             
                should "know its single test file line" do
         
     | 
| 
       77 
81 
     | 
    
         
             
                  exp = Assert::FileLine.parse(File.expand_path("", Dir.pwd))
         
     | 
| 
       78 
     | 
    
         
            -
                   
     | 
| 
      
 82 
     | 
    
         
            +
                  assert_that(subject.single_test_file_line).equals(exp)
         
     | 
| 
       79 
83 
     | 
    
         | 
| 
       80 
84 
     | 
    
         
             
                  file_line_path = "#{Factory.path}_tests.rb:#{Factory.integer}"
         
     | 
| 
       81 
85 
     | 
    
         
             
                  subject.apply(:single_test => file_line_path)
         
     | 
| 
       82 
86 
     | 
    
         | 
| 
       83 
87 
     | 
    
         
             
                  exp = Assert::FileLine.parse(File.expand_path(file_line_path, Dir.pwd))
         
     | 
| 
       84 
     | 
    
         
            -
                   
     | 
| 
      
 88 
     | 
    
         
            +
                  assert_that(subject.single_test_file_line).equals(exp)
         
     | 
| 
       85 
89 
     | 
    
         
             
                end
         
     | 
| 
       86 
90 
     | 
    
         | 
| 
       87 
91 
     | 
    
         
             
                should "know its single test file path" do
         
     | 
| 
       88 
92 
     | 
    
         
             
                  exp = Assert::FileLine.parse(File.expand_path("", Dir.pwd)).file
         
     | 
| 
       89 
     | 
    
         
            -
                   
     | 
| 
      
 93 
     | 
    
         
            +
                  assert_that(subject.single_test_file_path).equals(exp)
         
     | 
| 
       90 
94 
     | 
    
         | 
| 
       91 
95 
     | 
    
         
             
                  path = "#{Factory.path}_tests.rb"
         
     | 
| 
       92 
96 
     | 
    
         
             
                  file_line_path = "#{path}:#{Factory.integer}"
         
     | 
| 
       93 
97 
     | 
    
         
             
                  subject.apply(:single_test => file_line_path)
         
     | 
| 
       94 
     | 
    
         
            -
                   
     | 
| 
      
 98 
     | 
    
         
            +
                  assert_that(subject.single_test_file_path).equals(File.expand_path(path, Dir.pwd))
         
     | 
| 
       95 
99 
     | 
    
         
             
                end
         
     | 
| 
       96 
100 
     | 
    
         
             
              end
         
     | 
| 
       97 
101 
     | 
    
         
             
            end
         
     | 
| 
         @@ -4,77 +4,65 @@ require "assert/context/setup_dsl" 
     | 
|
| 
       4 
4 
     | 
    
         
             
            module Assert::Context::SetupDSL
         
     | 
| 
       5 
5 
     | 
    
         
             
              class UnitTests < Assert::Context
         
     | 
| 
       6 
6 
     | 
    
         
             
                desc "Assert::Context::SetupDSL"
         
     | 
| 
       7 
     | 
    
         
            -
                subject{  
     | 
| 
      
 7 
     | 
    
         
            +
                subject { Factory.modes_off_context_class }
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                let(:block1) { ::Proc.new {} }
         
     | 
| 
       8 
10 
     | 
    
         
             
              end
         
     | 
| 
       9 
11 
     | 
    
         | 
| 
       10 
12 
     | 
    
         
             
              class SetupTeardownOnceMethodsTests < UnitTests
         
     | 
| 
       11 
13 
     | 
    
         
             
                desc "once methods"
         
     | 
| 
       12 
     | 
    
         
            -
                setup do
         
     | 
| 
       13 
     | 
    
         
            -
                  block = @block = ::Proc.new{ something_once = true }
         
     | 
| 
       14 
     | 
    
         
            -
                  @context_class = Factory.modes_off_context_class do
         
     | 
| 
       15 
     | 
    
         
            -
                    setup_once(&block)
         
     | 
| 
       16 
     | 
    
         
            -
                    teardown_once(&block)
         
     | 
| 
       17 
     | 
    
         
            -
                  end
         
     | 
| 
       18 
     | 
    
         
            -
                end
         
     | 
| 
       19 
14 
     | 
    
         | 
| 
       20 
15 
     | 
    
         
             
                should "add the block to the suite" do
         
     | 
| 
       21 
     | 
    
         
            -
                   
     | 
| 
       22 
     | 
    
         
            -
                   
     | 
| 
      
 16 
     | 
    
         
            +
                  subject.setup_once(&block1)
         
     | 
| 
      
 17 
     | 
    
         
            +
                  subject.teardown_once(&block1)
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                  assert_that(subject.suite.send(:setups)).includes(block1)
         
     | 
| 
      
 20 
     | 
    
         
            +
                  assert_that(subject.suite.send(:teardowns)).includes(block1)
         
     | 
| 
       23 
21 
     | 
    
         
             
                end
         
     | 
| 
       24 
22 
     | 
    
         
             
              end
         
     | 
| 
       25 
23 
     | 
    
         | 
| 
       26 
24 
     | 
    
         
             
              class SetupTeardownMethodsTests < UnitTests
         
     | 
| 
       27 
25 
     | 
    
         
             
                desc "methods"
         
     | 
| 
       28 
     | 
    
         
            -
                setup do
         
     | 
| 
       29 
     | 
    
         
            -
                  block = @block = ::Proc.new{ something = true }
         
     | 
| 
       30 
     | 
    
         
            -
                  @context_class = Factory.modes_off_context_class do
         
     | 
| 
       31 
     | 
    
         
            -
                    setup(&block)
         
     | 
| 
       32 
     | 
    
         
            -
                    teardown(&block)
         
     | 
| 
       33 
     | 
    
         
            -
                  end
         
     | 
| 
       34 
     | 
    
         
            -
                end
         
     | 
| 
       35 
26 
     | 
    
         | 
| 
       36 
27 
     | 
    
         
             
                should "add the block to the context" do
         
     | 
| 
       37 
     | 
    
         
            -
                   
     | 
| 
       38 
     | 
    
         
            -
                   
     | 
| 
      
 28 
     | 
    
         
            +
                  subject.setup(&block1)
         
     | 
| 
      
 29 
     | 
    
         
            +
                  subject.teardown(&block1)
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                  assert_that(subject.send(:setups)).includes(block1)
         
     | 
| 
      
 32 
     | 
    
         
            +
                  assert_that(subject.send(:teardowns)).includes(block1)
         
     | 
| 
       39 
33 
     | 
    
         
             
                end
         
     | 
| 
       40 
34 
     | 
    
         
             
              end
         
     | 
| 
       41 
35 
     | 
    
         | 
| 
       42 
36 
     | 
    
         
             
              class SetupTeardownWithMethodNameTests < UnitTests
         
     | 
| 
       43 
37 
     | 
    
         
             
                desc "methods given a method name"
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
                  @context_class = Factory.modes_off_context_class do
         
     | 
| 
       47 
     | 
    
         
            -
                    setup(method_name)
         
     | 
| 
       48 
     | 
    
         
            -
                    teardown(method_name)
         
     | 
| 
       49 
     | 
    
         
            -
                  end
         
     | 
| 
       50 
     | 
    
         
            -
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                let(:method_name1) { :something_amazing }
         
     | 
| 
       51 
40 
     | 
    
         | 
| 
       52 
41 
     | 
    
         
             
                should "add the method name to the context" do
         
     | 
| 
       53 
     | 
    
         
            -
                   
     | 
| 
       54 
     | 
    
         
            -
                   
     | 
| 
      
 42 
     | 
    
         
            +
                  subject.setup(method_name1)
         
     | 
| 
      
 43 
     | 
    
         
            +
                  subject.teardown(method_name1)
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                  assert_that(subject.send(:setups)).includes(method_name1)
         
     | 
| 
      
 46 
     | 
    
         
            +
                  assert_that(subject.send(:teardowns)).includes(method_name1)
         
     | 
| 
       55 
47 
     | 
    
         
             
                end
         
     | 
| 
       56 
48 
     | 
    
         
             
              end
         
     | 
| 
       57 
49 
     | 
    
         | 
| 
       58 
     | 
    
         
            -
              class  
     | 
| 
      
 50 
     | 
    
         
            +
              class ParentContextClassTests < UnitTests
         
     | 
| 
      
 51 
     | 
    
         
            +
                subject { Factory.modes_off_context_class(parent_class1) }
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                let(:parent_class1)  { Factory.modes_off_context_class }
         
     | 
| 
      
 54 
     | 
    
         
            +
              end
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
              class SetupTeardownMultipleTests < ParentContextClassTests
         
     | 
| 
       59 
57 
     | 
    
         
             
                desc "with multiple calls"
         
     | 
| 
       60 
     | 
    
         
            -
                setup do
         
     | 
| 
       61 
     | 
    
         
            -
                  parent_setup_block    = ::Proc.new{ self.setup_status    =  "the setup"    }
         
     | 
| 
       62 
     | 
    
         
            -
                  parent_teardown_block = ::Proc.new{ self.teardown_status += "the teardown" }
         
     | 
| 
       63 
     | 
    
         
            -
                  @parent_class = Factory.modes_off_context_class do
         
     | 
| 
       64 
     | 
    
         
            -
                    setup(&parent_setup_block)
         
     | 
| 
       65 
     | 
    
         
            -
                    teardown(&parent_teardown_block)
         
     | 
| 
       66 
     | 
    
         
            -
                  end
         
     | 
| 
       67 
58 
     | 
    
         | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
                    setup(:setup_something)
         
     | 
| 
       73 
     | 
    
         
            -
                    teardown(:teardown_something)
         
     | 
| 
       74 
     | 
    
         
            -
                    teardown(&context_teardown_block)
         
     | 
| 
       75 
     | 
    
         
            -
                  end
         
     | 
| 
      
 59 
     | 
    
         
            +
                let(:parent_setup_block1)     { ::Proc.new { self.setup_status     = "the setup"     } }
         
     | 
| 
      
 60 
     | 
    
         
            +
                let(:parent_teardown_block1)  { ::Proc.new { self.teardown_status += "the teardown"  } }
         
     | 
| 
      
 61 
     | 
    
         
            +
                let(:context_setup_block1)    { ::Proc.new { self.setup_status    += " has been run" } }
         
     | 
| 
      
 62 
     | 
    
         
            +
                let(:context_teardown_block1) { ::Proc.new { self.teardown_status += "has been run " } }
         
     | 
| 
       76 
63 
     | 
    
         | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
      
 64 
     | 
    
         
            +
                let(:test_status_class) {
         
     | 
| 
      
 65 
     | 
    
         
            +
                  Class.new do
         
     | 
| 
       78 
66 
     | 
    
         
             
                    attr_accessor :setup_status, :teardown_status
         
     | 
| 
       79 
67 
     | 
    
         
             
                    define_method(:setup_something) do
         
     | 
| 
       80 
68 
     | 
    
         
             
                      self.setup_status += " with something"
         
     | 
| 
         @@ -83,57 +71,58 @@ module Assert::Context::SetupDSL 
     | 
|
| 
       83 
71 
     | 
    
         
             
                      self.teardown_status = "with something "
         
     | 
| 
       84 
72 
     | 
    
         
             
                    end
         
     | 
| 
       85 
73 
     | 
    
         
             
                  end
         
     | 
| 
       86 
     | 
    
         
            -
                 
     | 
| 
      
 74 
     | 
    
         
            +
                }
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
                should "run its parent and its own blocks in the correct order" do
         
     | 
| 
      
 77 
     | 
    
         
            +
                  parent_class1.setup(&parent_setup_block1)
         
     | 
| 
      
 78 
     | 
    
         
            +
                  parent_class1.teardown(&parent_teardown_block1)
         
     | 
| 
      
 79 
     | 
    
         
            +
                  subject.setup(&context_setup_block1)
         
     | 
| 
      
 80 
     | 
    
         
            +
                  subject.setup(:setup_something)
         
     | 
| 
      
 81 
     | 
    
         
            +
                  subject.teardown(:teardown_something)
         
     | 
| 
      
 82 
     | 
    
         
            +
                  subject.teardown(&context_teardown_block1)
         
     | 
| 
       87 
83 
     | 
    
         | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
                   
     | 
| 
       90 
     | 
    
         
            -
                  assert_equal "the setup has been run with something", obj.setup_status
         
     | 
| 
      
 84 
     | 
    
         
            +
                  subject.send("run_setups", obj = test_status_class.new)
         
     | 
| 
      
 85 
     | 
    
         
            +
                  assert_that(obj.setup_status).equals("the setup has been run with something")
         
     | 
| 
       91 
86 
     | 
    
         | 
| 
       92 
     | 
    
         
            -
                  subject.send("run_teardowns", obj =  
     | 
| 
       93 
     | 
    
         
            -
                   
     | 
| 
      
 87 
     | 
    
         
            +
                  subject.send("run_teardowns", obj = test_status_class.new)
         
     | 
| 
      
 88 
     | 
    
         
            +
                  assert_that(obj.teardown_status).equals("with something has been run the teardown")
         
     | 
| 
       94 
89 
     | 
    
         
             
                end
         
     | 
| 
       95 
90 
     | 
    
         
             
              end
         
     | 
| 
       96 
91 
     | 
    
         | 
| 
       97 
     | 
    
         
            -
              class AroundMethodTests <  
     | 
| 
      
 92 
     | 
    
         
            +
              class AroundMethodTests < ParentContextClassTests
         
     | 
| 
       98 
93 
     | 
    
         
             
                desc "with multiple `around` calls"
         
     | 
| 
       99 
     | 
    
         
            -
                setup do
         
     | 
| 
       100 
     | 
    
         
            -
                  @parent_class = Factory.modes_off_context_class do
         
     | 
| 
       101 
     | 
    
         
            -
                    around do |block|
         
     | 
| 
       102 
     | 
    
         
            -
                      self.out_status ||= ""
         
     | 
| 
       103 
     | 
    
         
            -
                      self.out_status += "p-around start, "
         
     | 
| 
       104 
     | 
    
         
            -
                      block.call
         
     | 
| 
       105 
     | 
    
         
            -
                      self.out_status += "p-around end."
         
     | 
| 
       106 
     | 
    
         
            -
                    end
         
     | 
| 
       107 
     | 
    
         
            -
                  end
         
     | 
| 
       108 
94 
     | 
    
         | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
       110 
     | 
    
         
            -
             
     | 
| 
       111 
     | 
    
         
            -
             
     | 
| 
       112 
     | 
    
         
            -
             
     | 
| 
       113 
     | 
    
         
            -
             
     | 
| 
       114 
     | 
    
         
            -
                     
     | 
| 
       115 
     | 
    
         
            -
                     
     | 
| 
       116 
     | 
    
         
            -
             
     | 
| 
       117 
     | 
    
         
            -
                      block.call
         
     | 
| 
       118 
     | 
    
         
            -
                      self.out_status += "c-around2 end, "
         
     | 
| 
       119 
     | 
    
         
            -
                    end
         
     | 
| 
      
 95 
     | 
    
         
            +
                let(:test_status_class) { Class.new { attr_accessor :out_status } }
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
                should "run its parent and its own blocks in the correct order" do
         
     | 
| 
      
 98 
     | 
    
         
            +
                  parent_class1.around do |block|
         
     | 
| 
      
 99 
     | 
    
         
            +
                    self.out_status ||= ""
         
     | 
| 
      
 100 
     | 
    
         
            +
                    self.out_status += "p-around start, "
         
     | 
| 
      
 101 
     | 
    
         
            +
                    block.call
         
     | 
| 
      
 102 
     | 
    
         
            +
                    self.out_status += "p-around end."
         
     | 
| 
       120 
103 
     | 
    
         
             
                  end
         
     | 
| 
       121 
104 
     | 
    
         | 
| 
       122 
     | 
    
         
            -
                   
     | 
| 
       123 
     | 
    
         
            -
                     
     | 
| 
      
 105 
     | 
    
         
            +
                  subject.around do |block|
         
     | 
| 
      
 106 
     | 
    
         
            +
                    self.out_status += "c-around1 start, "
         
     | 
| 
      
 107 
     | 
    
         
            +
                    block.call
         
     | 
| 
      
 108 
     | 
    
         
            +
                    self.out_status += "c-around1 end, "
         
     | 
| 
      
 109 
     | 
    
         
            +
                  end
         
     | 
| 
      
 110 
     | 
    
         
            +
                  subject.around do |block|
         
     | 
| 
      
 111 
     | 
    
         
            +
                    self.out_status += "c-around2 start, "
         
     | 
| 
      
 112 
     | 
    
         
            +
                    block.call
         
     | 
| 
      
 113 
     | 
    
         
            +
                    self.out_status += "c-around2 end, "
         
     | 
| 
       124 
114 
     | 
    
         
             
                  end
         
     | 
| 
       125 
     | 
    
         
            -
                end
         
     | 
| 
       126 
115 
     | 
    
         | 
| 
       127 
     | 
    
         
            -
             
     | 
| 
       128 
     | 
    
         
            -
                  obj = @test_status_class.new
         
     | 
| 
      
 116 
     | 
    
         
            +
                  obj = test_status_class.new
         
     | 
| 
       129 
117 
     | 
    
         
             
                  subject.send("run_arounds", obj) do
         
     | 
| 
       130 
118 
     | 
    
         
             
                    obj.instance_eval{ self.out_status += "TEST, " }
         
     | 
| 
       131 
119 
     | 
    
         
             
                  end
         
     | 
| 
       132 
120 
     | 
    
         | 
| 
       133 
     | 
    
         
            -
                  exp = 
     | 
| 
       134 
     | 
    
         
            -
             
     | 
| 
       135 
     | 
    
         
            -
             
     | 
| 
       136 
     | 
    
         
            -
             
     | 
| 
      
 121 
     | 
    
         
            +
                  exp =
         
     | 
| 
      
 122 
     | 
    
         
            +
                    "p-around start, c-around1 start, c-around2 start, "\
         
     | 
| 
      
 123 
     | 
    
         
            +
                    "TEST, "\
         
     | 
| 
      
 124 
     | 
    
         
            +
                    "c-around2 end, c-around1 end, p-around end."
         
     | 
| 
      
 125 
     | 
    
         
            +
                  assert_that(obj.out_status).equals(exp)
         
     | 
| 
       137 
126 
     | 
    
         
             
                end
         
     | 
| 
       138 
127 
     | 
    
         
             
              end
         
     | 
| 
       139 
128 
     | 
    
         
             
            end
         
     |