assert 2.15.0 → 2.15.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +7 -7
  2. data/Gemfile +0 -1
  3. data/{LICENSE.txt → LICENSE} +0 -0
  4. data/README.md +106 -35
  5. data/assert.gemspec +2 -2
  6. data/lib/assert/assert_runner.rb +19 -12
  7. data/lib/assert/assertions.rb +1 -0
  8. data/lib/assert/cli.rb +3 -0
  9. data/lib/assert/config.rb +24 -6
  10. data/lib/assert/config_helpers.rb +15 -28
  11. data/lib/assert/context.rb +4 -3
  12. data/lib/assert/context/test_dsl.rb +3 -2
  13. data/lib/assert/context_info.rb +19 -0
  14. data/lib/assert/default_runner.rb +12 -0
  15. data/lib/assert/default_suite.rb +64 -0
  16. data/lib/assert/default_view.rb +17 -15
  17. data/lib/assert/file_line.rb +3 -2
  18. data/lib/assert/result.rb +6 -0
  19. data/lib/assert/runner.rb +58 -21
  20. data/lib/assert/suite.rb +61 -100
  21. data/lib/assert/test.rb +3 -3
  22. data/lib/assert/version.rb +1 -1
  23. data/lib/assert/view.rb +58 -74
  24. data/lib/assert/view_helpers.rb +10 -48
  25. data/test/helper.rb +9 -0
  26. data/test/support/factory.rb +5 -5
  27. data/test/unit/assertions/assert_raises_tests.rb +20 -0
  28. data/test/unit/config_helpers_tests.rb +29 -29
  29. data/test/unit/config_tests.rb +43 -10
  30. data/test/unit/context/suite_dsl_tests.rb +1 -1
  31. data/test/unit/context_info_tests.rb +55 -0
  32. data/test/unit/default_runner_tests.rb +18 -0
  33. data/test/unit/default_suite_tests.rb +74 -0
  34. data/test/unit/file_line_tests.rb +6 -2
  35. data/test/unit/result_tests.rb +15 -4
  36. data/test/unit/runner_tests.rb +128 -6
  37. data/test/unit/suite_tests.rb +73 -182
  38. data/test/unit/view_helpers_tests.rb +44 -38
  39. data/test/unit/view_tests.rb +15 -39
  40. metadata +42 -28
  41. data/Rakefile +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 977f66c154b34e18051876043c6ef149048f3c24
4
- data.tar.gz: 4ad230cae2d6fbe5895456d04f421843bbdb43e6
5
- SHA512:
6
- metadata.gz: 9ea117fae5c227ae573763287d76156b11b923afa80b50c63223deb6f001605eac1eb55302f08f85ecc134eedf49efb90973cec640b6e1a11c75509100a8ccad
7
- data.tar.gz: cf13653df60d7b5c295d2a43523923423998ae9c7b40f60bc95d95044af0577a96107d5d04a553d9de8c799bde111599d6656e2d678adcdee0ecb33750aa61e9
1
+ ---
2
+ SHA1:
3
+ data.tar.gz: 224cee40b0eced9582504764379f3f5dafae637c
4
+ metadata.gz: 5858e3f1715252601de72d47678dc9f215267254
5
+ SHA512:
6
+ data.tar.gz: 6b3d06c534eb907ae92c281b36de62967138bbc3788d536c92ad03b8d28d637dcf0ad0526fb66610dcc9b6cbc894a44e786c312bcfd6f93ae1ea29319f8aaf6f
7
+ metadata.gz: ed18f6eaea92fcec29d9b6b2200cb23704ad8b4090372493a81b67067b251176d71408231f8bc7e7c9de1a88c55cd854857d6fa153c67d79bf3a752b5fdb1df1
data/Gemfile CHANGED
@@ -2,5 +2,4 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rake', "~> 10.4.0"
6
5
  gem 'pry', "~> 0.9.0"
File without changes
data/README.md CHANGED
@@ -1,7 +1,5 @@
1
1
  # The Assert Testing Framework
2
2
 
3
- Test::Unit style testing framework, just better than Test::Unit.
4
-
5
3
  ## Usage
6
4
 
7
5
  ```ruby
@@ -34,29 +32,36 @@ Running tests in random order, seeded with "56382"
34
32
  * **Framework**: you define tests and the context they run in - Assert runs them. Everything is pure ruby so use any 3rd party testing tools you like. Create 3rd party tools that extend Assert behavior.
35
33
  * **First Class**: everything is a first class object and can be extended to your liking (and should be)
36
34
  * **MVC**: tests and how they are defined (M) and executed (C) are distinct from how you view the test results (V).
37
- * **Backwards compatible**: (assuming a few minor tweaks) with Test::Unit test suites
38
35
 
39
36
  ## What Assert is not
40
37
 
41
- * **Rspec**
42
- * **Unit/Functional/Integration/etc**: Assert is agnostic - you define whatever kinds of tests you like (one or more of the above) and assert runs them in context.
43
- * **Mock/Spec/BDD/etc**: Assert is the framework and there are a variety of 3rd party tools to do such things - feel free to use whatever you like.
38
+ * **RSpec/spec-anything**: define tests using assertion statements
39
+ * **Unit/Functional/Integration/etc**: Assert is agnostic - you define whatever kinds of tests you like (one or more of the above) and assert runs them in context
40
+ * **Mock/Spec/BDD/etc**: Assert is the framework and there are a variety of 3rd party tools to do such things - feel free to use whatever you like
44
41
 
45
42
  ## Description
46
43
 
47
- Assert is a Test::Unit style testing framework. This means you can write tests in Assert the same way you would with test-unit.
44
+ Assert is an assertion style testing framework, meaning you use assertion statements to define your tests and create results. Assert uses class-based contexts so if you want to nest your contexts, use inheritance.
48
45
 
49
- In addition, Assert adds some helpers and syntax sugar to enhance the way tests are written. Most are taken from ideas in [Shoulda](https://github.com/thoughtbot/shoulda) and [Leftright](https://github.com/jordi/leftright/). Assert uses class-based contexts so if you want to nest your contexts, use inheritance.
46
+ ### Features
50
47
 
51
- **Note**: Assert is tested using itself. The tests are a pretty good place to look for examples and usage patterns.
48
+ * `assert` [executable](https://github.com/redding/assert#cli) for running tests
49
+ * run tests by tab completing test file paths
50
+ * run only test files that have been modified
51
+ * random order test execution
52
+ * class-based contexts
53
+ * multiple before/setup & after/teardown blocks
54
+ * around blocks
55
+ * full backtrace for errors
56
+ * optionally pretty print objects in failure descriptions
57
+ * [stubbing API](https://github.com/redding/assert#stub)
58
+ * [factory API](https://github.com/redding/assert#factory)
59
+ * `skip` to skip tests
60
+ * `Ctrl+c` stops tests and prints failures
52
61
 
53
62
  ## Defining tests
54
63
 
55
- TODO
56
-
57
- ## Factory
58
-
59
- TODO
64
+ **Note**: Assert is tested using itself. The tests are a good place to look for examples and usage patterns.
60
65
 
61
66
  ## Stub
62
67
 
@@ -90,12 +95,13 @@ Assert.stub(myobj, :myval){ 'stub-meth' }
90
95
  Assert.stub(myobj, :myval).with(123){ |val| val.to_s }
91
96
  myobj.myval
92
97
  # => StubError: arity mismatch
93
- myobj.mymeth(123)
98
+ myobj.myval(123)
94
99
  # => '123'
95
- myobj.mymeth(456)
96
- # => StubError: `mymeth(456)` not stubbed.
100
+ myobj.myval(456)
101
+ # => StubError: `myval(456)` not stubbed.
97
102
 
98
103
  Assert.unstub(myobj, :mymeth)
104
+ Assert.unstub(myobj, :myval)
99
105
 
100
106
  myobj.mymeth
101
107
  # => 'meth'
@@ -105,15 +111,62 @@ myobj.myval(456)
105
111
  # => 456
106
112
  ```
107
113
 
108
- Assert comes with a simple stubbing API - all it does is replace method calls. In general it tries
109
- to be friendly and complain if stubbing doesn't match up with the object/method being stubbed:
114
+ Assert comes with a stubbing API - all it does is replace method calls. In general it tries to be friendly and complain if stubbing doesn't match up with the object/method being stubbed:
110
115
 
111
116
  * each stub takes a block that is called in place of the method
112
117
  * complains if you stub a method that the object doesn't respond to
113
118
  * complains if you stub with an arity mismatch
114
- * no methods added to `Object`
119
+ * no methods are added to `Object` to support stubbing
115
120
  * stubs are auto-unstubbed on test teardown
116
121
 
122
+ ## Factory
123
+
124
+ ```ruby
125
+ require 'assert/factory'
126
+
127
+ Assert::Factory.integer #=> 15742
128
+ Assert::Factory.integer(3) #=> 2
129
+ Assert::Factory.float #=> 87.2716908041922
130
+ Assert::Factory.float(3) #=> 2.5466638138805
131
+
132
+ Assert::Factory.date #=> #<Date: 4915123/2,0,2299161>
133
+ Assert::Factory.time #=> Wed Sep 07 10:37:22 -0500 2016
134
+ Assert::Factory.datetime #=> #<DateTime: 302518290593/43200,0,2299161>
135
+
136
+ Assert::Factory.string #=> "boxsrbazeq"
137
+ Assert::Factory.string(3) #=> "rja"
138
+ Assert::Factory.text #=> "khcwyizmymajfzzxlfwz"
139
+ Assert::Factory.text(3) #=> "qcy"
140
+ Assert::Factory.slug #=> "licia"
141
+ Assert::Factory.slug(3) #=> "luu"
142
+ Assert::Factory.hex #=> "48797adb33"
143
+ Assert::Factory.hex(3) #=> "2fe"
144
+ Assert::Factory.url #=> "/cdqz/hqeq/zbsl"
145
+ Assert::Factory.email #=> "vyojvtxght@gmrin.com"
146
+
147
+ Assert::Factory.file_name #=> "kagahm.ybb"
148
+ Assert::Factory.path #=> "jbzf/omyk/vbha"
149
+ Assert::Factory.dir_path #=> "fxai/lwnq/urqu"
150
+ Assert::Factory.file_path #=> "bcno/pzxg/gois/mpvlfo.wdr"
151
+
152
+ Assert::Factory.binary #=> "\000\000\003S"
153
+ Assert::Factory.boolean #=> false
154
+ ```
155
+
156
+ `Assert::Factory` is an API for generating randomized data. The randomization is tied to the runner seed so re-running tests with the same seed should produce the same random values.
157
+
158
+ You can also extend on your own factory class:
159
+
160
+ ```ruby
161
+ module Factory
162
+ extend Assert::Factory
163
+
164
+ def self.data
165
+ { Factory.string => Factory.string }
166
+ end
167
+ end
168
+ ```
169
+
117
170
  ## CLI
118
171
 
119
172
  ```sh
@@ -139,7 +192,7 @@ As an example, say your test folder has a file structure like so:
139
192
  * `$ assert test/complex/fast_tests.rb` - runs all tests in fast_tests.rb
140
193
  * `$ assert test/basic test/comp` - runs all tests in basic_tests.rb, complex_tests.rb, fast_tests.rb and slow_tests.rb
141
194
 
142
- All you need to do is pass some sort of existing file path (hint: use tab-completion) and Assert will find any test files and run the tests in them.
195
+ All you need to do is pass some sort of existing file path (use tab-completion!) and Assert will find any test files and run the tests in them.
143
196
 
144
197
  ## Configuring Assert
145
198
 
@@ -149,25 +202,25 @@ Assert.configure do |config|
149
202
  end
150
203
  ```
151
204
 
152
- Assert uses a config pattern for specifying settings. Using this pattern, you can configure settings, extensions, custom views, etc. Settings can be configured in 4 different scopes and are applied in this order: User, Local, CLI, ENV.
205
+ Assert uses a config pattern for specifying settings. Using this pattern, you can configure settings, extensions, custom views, etc. Settings can be configured in 4 different scopes and are applied in this order: User, Local, ENV, CLI.
153
206
 
154
207
  ### User settings
155
208
 
156
- Assert will look for and require the file `$HOME/.assert/init.rb`. Use this file to specify user settings. User settings can be overridden by Local, CLI, and ENV settings.
209
+ Assert will look for and require the file `$HOME/.assert/init.rb`. Use this file to specify user settings. User settings can be overridden by Local, ENV, and CLI settings.
157
210
 
158
211
  ### Local settings
159
212
 
160
- Assert will look for and require the file `./.assert.rb`. Use this file to specify project settings. Local settings can be overridden by CLI, and ENV settings.
213
+ Assert will look for and require the file `./.assert.rb`. Use this file to specify project settings. Local settings can be overridden by ENV, and CLI settings.
161
214
 
162
215
  To specify a custom local settings file path, use the `ASSERT_LOCALFILE` env var.
163
216
 
164
- ### CLI settings
217
+ ### ENV settings
165
218
 
166
- Assert accepts options from its CLI. Use these options to specify runtime settings. CLI settings can be overridden by ENV settings.
219
+ Assert uses ENV vars to drive certain settings. Use these vars to specify specific environment settings. ENV settings can be overridden by CLI settings.
167
220
 
168
- ### ENV settings
221
+ ### CLI settings
169
222
 
170
- Assert uses ENV vars to drive certain settings. Use these vars to specify absolute runtime settings. ENV settings are always applied last and cannot be overridden.
223
+ Assert accepts options from its CLI. Use these options to specify absolute runtime settings. CLI settings are always applied last and cannot be overridden.
171
224
 
172
225
  ## Running Tests
173
226
 
@@ -203,7 +256,7 @@ end
203
256
 
204
257
  ### Test Order
205
258
 
206
- The default runner object runs tests in random order. To run tests in a consistant order, specify a custom runner seed:
259
+ The default runner object runs tests in random order. To run tests in a consistant order, pass a custom runner seed:
207
260
 
208
261
  In user/local settings file:
209
262
 
@@ -213,16 +266,34 @@ Assert.configure do |config|
213
266
  end
214
267
  ```
215
268
 
269
+ Using an ENV var:
270
+
271
+ ```sh
272
+ $ ASSERT_RUNNER_SEED=1234 assert
273
+ ```
274
+
216
275
  Using the CLI:
217
276
 
218
277
  ```sh
219
278
  $ assert [-s|--runner-seed] 1234
220
279
  ```
221
280
 
222
- Using an ENV var:
281
+ ### Run a single test
282
+
283
+ You can choose to run just a single test so that you can focus on making it pass without the overhead/noise from the output of the other tests in the file.
284
+
285
+ It is recommended that you only use this setting from the CLI. To run just a single test, pass its file path and line number:
223
286
 
224
287
  ```sh
225
- $ ASSERT_RUNNER_SEED=1234 assert
288
+ $ assert [-t|--single-test] ./path/for/tests.rb:123
289
+ ```
290
+
291
+ **Note**: by default Assert outputs, in the details of each non-passing result, the cmd to re-run the result's test:
292
+
293
+ ```
294
+ FAIL: should pass
295
+ ./test/unit/test_tests.rb:124
296
+ assert -t ./test/unit/test_tests.rb:123
226
297
  ```
227
298
 
228
299
  ### Verbose Output
@@ -456,7 +527,7 @@ end
456
527
  However, the view handler you use is itself configurable. Define you own view handler class and specify it in your user/local settings:
457
528
 
458
529
  ```ruby
459
- class MyCustomView < Assert::View::Base
530
+ class MyCustomView < Assert::View
460
531
  # define your view here...
461
532
  end
462
533
 
@@ -467,7 +538,7 @@ end
467
538
 
468
539
  ### Anatomy of a View
469
540
 
470
- A view class handles the logic and templating of test result output. A view class should inherit from `Assert::View::Base`. This defines default callback handlers for the test runner and gives access to a bunch of common helpers for reading test result data.
541
+ A view class handles the logic and templating of test result output. A view class should inherit from `Assert::View`. This defines default callback handlers for the test runner and gives access to a bunch of common helpers for reading test result data.
471
542
 
472
543
  Each view should implement the callback handler methods to output information at different points during the running of a test suite. Callbacks have access to any view methods and should output information using `puts` and `prints`. See the `DefaultView` template for a usage example.
473
544
 
@@ -534,7 +605,7 @@ Tests produce results as they are executed. Every `assert` statement produces a
534
605
 
535
606
  ### View
536
607
 
537
- A `View` object is responsible for rendering test result output. Assert provides a `Assert::View::Base` object to provide common helpers and default runner callback handlers for building views. Assert also provides an `Assert::DefaultView` that it renders its output with. See the "Viewing Test Results" section below for more details.
608
+ A `View` object is responsible for rendering test result output. Assert provides a `Assert::View` object to provide common helpers and default runner callback handlers for building views. Assert also provides an `Assert::DefaultView` that it renders its output with. See the "Viewing Test Results" section below for more details.
538
609
 
539
610
  ### Macro
540
611
 
@@ -560,4 +631,4 @@ If submitting a Pull Request, please:
560
631
 
561
632
  One note: please respect that Assert itself is intended to be the flexible, base-level, framework-type logic that should change little if at all. Pull requests for niche functionality or personal testing philosphy stuff will likely not be accepted.
562
633
 
563
- If you wish to extend Assert for your niche purpose/desire/philosophy, please do so in it's own gem (preferrably named `assert-<whatever>`) that uses Assert as a dependency. When you do, tell us about it and we'll add it to this README with a short description.
634
+ If you wish to extend Assert for your niche purpose/desire/philosophy, please do so in it's own gem (preferrably named `assert-<whatever>`) that uses Assert as a dependency.
@@ -8,8 +8,8 @@ Gem::Specification.new do |gem|
8
8
  gem.version = Assert::VERSION
9
9
  gem.authors = ["Kelly Redding", "Collin Redding"]
10
10
  gem.email = ["kelly@kellyredding.com", "collin.redding@me.com"]
11
- gem.description = %q{Test::Unit style testing framework, just better than Test::Unit.}
12
- gem.summary = %q{Test::Unit style testing framework, just better than Test::Unit.}
11
+ gem.summary = %q{Assertion style testing framework.}
12
+ gem.description = %q{Assertion style testing framework.}
13
13
  gem.homepage = "http://github.com/redding/assert"
14
14
  gem.license = 'MIT'
15
15
 
@@ -13,11 +13,12 @@ module Assert
13
13
  Assert::CLI.bench('Apply settings') do
14
14
  apply_user_settings
15
15
  apply_local_settings
16
- apply_option_settings(test_options)
17
16
  apply_env_settings
17
+ apply_option_settings(test_options)
18
18
  end
19
19
 
20
- files = test_files(test_paths.empty? ? [*self.config.test_dir] : test_paths)
20
+ paths = test_paths.empty? ? [*self.config.test_dir] : test_paths
21
+ files = lookup_test_files(paths)
21
22
  init(files, path_of(self.config.test_dir, files.first))
22
23
  end
23
24
 
@@ -33,15 +34,20 @@ module Assert
33
34
  end
34
35
 
35
36
  # load the test files
36
- self.config.view.fire(:before_load, test_files)
37
- Assert::CLI.bench("Require #{test_files.count} test files") do
37
+ runner, suite, view = self.config.runner, self.config.suite, self.config.view
38
+ runner.before_load(test_files)
39
+ suite.before_load(test_files)
40
+ view.before_load(test_files)
41
+ Assert::CLI.bench("Require #{test_files.size} test files") do
38
42
  test_files.each{ |p| require p }
39
43
  end
40
44
  if self.config.debug
41
45
  puts Assert::CLI.debug_msg("Test files:")
42
46
  test_files.each{ |f| puts Assert::CLI.debug_msg(" #{f}") }
43
47
  end
44
- self.config.view.fire(:after_load)
48
+ runner.after_load
49
+ suite.after_load
50
+ view.after_load
45
51
  end
46
52
 
47
53
  def run
@@ -62,17 +68,19 @@ module Assert
62
68
  safe_require(ENV['ASSERT_LOCALFILE'] || path_of(LOCAL_SETTINGS_FILE, Dir.pwd))
63
69
  end
64
70
 
65
- def apply_option_settings(options)
66
- self.config.apply(options)
67
- end
68
-
69
71
  def apply_env_settings
70
72
  self.config.runner_seed ENV['ASSERT_RUNNER_SEED'].to_i if ENV['ASSERT_RUNNER_SEED']
71
73
  end
72
74
 
73
- def test_files(test_paths)
75
+ def apply_option_settings(options)
76
+ self.config.apply(options)
77
+ end
78
+
79
+ def lookup_test_files(test_paths)
74
80
  file_paths = if self.config.changed_only
75
81
  changed_test_files(test_paths)
82
+ elsif self.config.single_test?
83
+ globbed_test_files(self.config.single_test_file_path)
76
84
  else
77
85
  globbed_test_files(test_paths)
78
86
  end
@@ -101,9 +109,8 @@ module Assert
101
109
  require settings_file if File.exists?(settings_file)
102
110
  end
103
111
 
104
- # this method inspects a test path and finds the test dir path.
105
-
106
112
  def path_of(segment, a_path)
113
+ # this method inspects a test path and finds the test dir path.
107
114
  full_path = File.expand_path(a_path || '.', Dir.pwd)
108
115
  seg_pos = full_path.index(segment_regex(segment))
109
116
  File.join(seg_pos && (seg_pos > 0) ? full_path[0..(seg_pos-1)] : full_path, segment)
@@ -179,6 +179,7 @@ module Assert
179
179
  desc = exceptions.last.kind_of?(String) ? exceptions.pop : nil
180
180
  err = RaisedException.new(exceptions, &block)
181
181
  assert(err.raised?, desc){ err.msg }
182
+ err.exception
182
183
  end
183
184
  alias_method :assert_raise, :assert_raises
184
185
 
@@ -36,6 +36,9 @@ module Assert
36
36
  option 'changed_ref', 'reference for changes, use with `-c` opt', {
37
37
  :abbrev => 'r', :value => ''
38
38
  }
39
+ option 'single_test', 'only run the test on the given file/line', {
40
+ :abbrev => 't', :value => ''
41
+ }
39
42
  option 'pp_objects', 'pretty-print objects in fail messages', {
40
43
  :abbrev => 'p'
41
44
  }
@@ -1,6 +1,7 @@
1
+ require 'assert/default_runner'
2
+ require 'assert/default_suite'
1
3
  require 'assert/default_view'
2
- require 'assert/runner'
3
- require 'assert/suite'
4
+ require 'assert/file_line'
4
5
  require 'assert/utils'
5
6
 
6
7
  module Assert
@@ -21,13 +22,14 @@ module Assert
21
22
  settings :view, :suite, :runner
22
23
  settings :test_dir, :test_helper, :test_file_suffixes
23
24
  settings :changed_proc, :pp_proc, :use_diff_proc, :run_diff_proc
24
- settings :runner_seed, :changed_only, :changed_ref, :pp_objects
25
- settings :capture_output, :halt_on_fail, :profile, :verbose, :list, :debug
25
+ settings :runner_seed, :changed_only, :changed_ref, :single_test
26
+ settings :pp_objects, :capture_output, :halt_on_fail, :profile
27
+ settings :verbose, :list, :debug
26
28
 
27
29
  def initialize(settings = nil)
28
- @suite = Assert::Suite.new(self)
29
30
  @view = Assert::DefaultView.new(self, $stdout)
30
- @runner = Assert::Runner.new(self)
31
+ @suite = Assert::DefaultSuite.new(self)
32
+ @runner = Assert::DefaultRunner.new(self)
31
33
 
32
34
  @test_dir = "test"
33
35
  @test_helper = "helper.rb"
@@ -42,6 +44,7 @@ module Assert
42
44
  @runner_seed = begin; srand; srand % 0xFFFF; end.to_i
43
45
  @changed_only = false
44
46
  @changed_ref = ''
47
+ @single_test = ''
45
48
  @pp_objects = false
46
49
  @capture_output = false
47
50
  @halt_on_fail = true
@@ -59,6 +62,21 @@ module Assert
59
62
  self.send(name.to_s, settings[name])
60
63
  end
61
64
  end
65
+ @single_test_file_line = nil
66
+ end
67
+
68
+ def single_test?
69
+ !self.single_test.empty?
70
+ end
71
+
72
+ def single_test_file_line
73
+ @single_test_file_line ||= Assert::FileLine.parse(
74
+ File.expand_path(self.single_test, Dir.pwd)
75
+ )
76
+ end
77
+
78
+ def single_test_file_path
79
+ self.single_test_file_line.file if self.single_test_file_line
62
80
  end
63
81
 
64
82
  end
@@ -2,10 +2,22 @@ module Assert
2
2
 
3
3
  module ConfigHelpers
4
4
 
5
+ def runner; self.config.runner; end
6
+ def suite; self.config.suite; end
7
+ def view; self.config.view; end
8
+
5
9
  def runner_seed
6
10
  self.config.runner_seed
7
11
  end
8
12
 
13
+ def single_test?
14
+ self.config.single_test?
15
+ end
16
+
17
+ def single_test_file_line
18
+ self.config.single_test_file_line
19
+ end
20
+
9
21
  def count(type)
10
22
  self.config.suite.count(type)
11
23
  end
@@ -18,43 +30,18 @@ module Assert
18
30
  self.count(:pass) == self.count(:results)
19
31
  end
20
32
 
21
- # get the formatted suite run time
22
- def run_time(format = '%.6f')
33
+ def formatted_run_time(format = '%.6f')
23
34
  format % self.config.suite.run_time
24
35
  end
25
36
 
26
- # get the formatted suite test rate
27
- def test_rate(format = '%.6f')
37
+ def formatted_test_rate(format = '%.6f')
28
38
  format % self.config.suite.test_rate
29
39
  end
30
40
 
31
- # get the formatted suite result rate
32
- def result_rate(format = '%.6f')
41
+ def formatted_result_rate(format = '%.6f')
33
42
  format % self.config.suite.result_rate
34
43
  end
35
44
 
36
- # get a uniq list of contexts for the test suite
37
- def suite_contexts
38
- @suite_contexts ||= self.config.suite.tests.inject([]) do |contexts, test|
39
- contexts << test.context_info.klass
40
- end.uniq
41
- end
42
-
43
- def ordered_suite_contexts
44
- self.suite_contexts.sort{ |a,b| a.to_s <=> b.to_s }
45
- end
46
-
47
- # get a uniq list of files containing contexts for the test suite
48
- def suite_files
49
- @suite_files ||= self.config.suite.tests.inject([]) do |files, test|
50
- files << test.context_info.file
51
- end.uniq
52
- end
53
-
54
- def ordered_suite_files
55
- self.suite_files.sort{ |a,b| a.to_s <=> b.to_s }
56
- end
57
-
58
45
  def show_test_profile_info?
59
46
  !!self.config.profile
60
47
  end