assert 2.16.5 → 2.17.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 +7 -7
- data/Gemfile +3 -1
- data/README.md +20 -20
- data/assert.gemspec +5 -3
- data/bin/assert +4 -4
- data/lib/assert.rb +8 -8
- data/lib/assert/assert_runner.rb +7 -7
- data/lib/assert/assertions.rb +5 -5
- data/lib/assert/cli.rb +35 -35
- data/lib/assert/config.rb +8 -8
- data/lib/assert/config_helpers.rb +6 -6
- data/lib/assert/context.rb +17 -17
- data/lib/assert/context/test_dsl.rb +5 -5
- data/lib/assert/context_info.rb +2 -2
- data/lib/assert/default_runner.rb +1 -1
- data/lib/assert/default_suite.rb +1 -1
- data/lib/assert/default_view.rb +8 -8
- data/lib/assert/factory.rb +1 -1
- data/lib/assert/macro.rb +1 -1
- data/lib/assert/macros/methods.rb +1 -1
- data/lib/assert/result.rb +17 -17
- data/lib/assert/runner.rb +12 -8
- data/lib/assert/stub.rb +1 -1
- data/lib/assert/suite.rb +3 -3
- data/lib/assert/test.rb +11 -11
- data/lib/assert/utils.rb +8 -8
- data/lib/assert/version.rb +1 -1
- data/lib/assert/view.rb +19 -19
- data/lib/assert/view_helpers.rb +6 -6
- data/test/helper.rb +2 -11
- data/test/support/factory.rb +6 -6
- data/test/system/stub_tests.rb +204 -204
- data/test/system/test_tests.rb +13 -13
- data/test/unit/assert_tests.rb +9 -9
- data/test/unit/assertions/assert_block_tests.rb +2 -2
- data/test/unit/assertions/assert_empty_tests.rb +6 -6
- data/test/unit/assertions/assert_equal_tests.rb +5 -5
- data/test/unit/assertions/assert_file_exists_tests.rb +6 -6
- data/test/unit/assertions/assert_includes_tests.rb +7 -7
- data/test/unit/assertions/assert_instance_of_tests.rb +5 -5
- data/test/unit/assertions/assert_kind_of_tests.rb +5 -5
- data/test/unit/assertions/assert_match_tests.rb +5 -5
- data/test/unit/assertions/assert_nil_tests.rb +5 -5
- data/test/unit/assertions/assert_raises_tests.rb +2 -2
- data/test/unit/assertions/assert_respond_to_tests.rb +5 -5
- data/test/unit/assertions/assert_same_tests.rb +13 -13
- data/test/unit/assertions/assert_true_false_tests.rb +7 -7
- data/test/unit/assertions_tests.rb +2 -2
- data/test/unit/config_helpers_tests.rb +5 -5
- data/test/unit/config_tests.rb +12 -12
- data/test/unit/context/setup_dsl_tests.rb +7 -7
- data/test/unit/context/subject_dsl_tests.rb +3 -3
- data/test/unit/context/suite_dsl_tests.rb +3 -3
- data/test/unit/context/test_dsl_tests.rb +8 -8
- data/test/unit/context_info_tests.rb +6 -6
- data/test/unit/context_tests.rb +16 -16
- data/test/unit/default_runner_tests.rb +3 -3
- data/test/unit/default_suite_tests.rb +3 -3
- data/test/unit/factory_tests.rb +3 -3
- data/test/unit/file_line_tests.rb +12 -12
- data/test/unit/macro_tests.rb +2 -2
- data/test/unit/result_tests.rb +18 -18
- data/test/unit/runner_tests.rb +9 -9
- data/test/unit/suite_tests.rb +5 -5
- data/test/unit/test_tests.rb +19 -19
- data/test/unit/utils_tests.rb +18 -18
- data/test/unit/view_helpers_tests.rb +15 -15
- data/test/unit/view_tests.rb +11 -11
- data/tmp/.gitkeep +0 -0
- metadata +46 -44
- data/.assert.rb +0 -3
- data/.gitignore +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
---
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
SHA512:
|
6
|
-
|
7
|
-
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9f64c7aa2c506b0fcf989763e437a103dd5401213f88bce9b7f4e7712db7fbe0
|
4
|
+
data.tar.gz: 3f5c30459a2528888dc24e356e626939e1fd204e1d287f06bbedf909c2d7eee9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6e9f3644f6c86856e3fd5c13560ecd6f7cadf194b158ccb3526267476745de34ca8ac87968cc5bf5f8d08d690a8cea40547e2a4dace29607916c6b558403d3c9
|
7
|
+
data.tar.gz: 80eb01f4d6aa450203c6db05a33f48bc515dc8e9a71b8532cead71439dabb373455b6cfa78c718e96364a3d7562027c6dd878a2393bca50fc9a614825c2e7a8d
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
```ruby
|
6
6
|
# in test/my_tests.rb
|
7
7
|
|
8
|
-
require
|
8
|
+
require "assert"
|
9
9
|
|
10
10
|
class MyTests < Assert::Context
|
11
11
|
|
@@ -77,13 +77,13 @@ Assert comes with a stubbing API - all it does is replace method calls. In gene
|
|
77
77
|
|
78
78
|
```ruby
|
79
79
|
myclass = Class.new do
|
80
|
-
def mymeth;
|
80
|
+
def mymeth; "meth"; end
|
81
81
|
def myval(val); val; end
|
82
82
|
end
|
83
83
|
myobj = myclass.new
|
84
84
|
|
85
85
|
myobj.mymeth
|
86
|
-
# =>
|
86
|
+
# => "meth"
|
87
87
|
myobj.myval(123)
|
88
88
|
# => 123
|
89
89
|
myobj.myval(456)
|
@@ -92,23 +92,23 @@ myobj.myval(456)
|
|
92
92
|
Assert.stub(myobj, :mymeth)
|
93
93
|
myobj.mymeth
|
94
94
|
# => StubError: `mymeth` not stubbed.
|
95
|
-
Assert.stub(myobj, :mymeth){
|
95
|
+
Assert.stub(myobj, :mymeth){ "stub-meth" }
|
96
96
|
myobj.mymeth
|
97
|
-
# =>
|
97
|
+
# => "stub-meth"
|
98
98
|
myobj.mymeth(123)
|
99
99
|
# => StubError: arity mismatch
|
100
|
-
Assert.stub(myobj, :mymeth).with(123){
|
100
|
+
Assert.stub(myobj, :mymeth).with(123){ "stub-meth" }
|
101
101
|
# => StubError: arity mismatch
|
102
102
|
Assert.stub_send(myobj, :mymeth) # call to the original method post-stub
|
103
|
-
# =>
|
103
|
+
# => "meth"
|
104
104
|
|
105
|
-
Assert.stub(myobj, :myval){
|
105
|
+
Assert.stub(myobj, :myval){ "stub-meth" }
|
106
106
|
# => StubError: arity mismatch
|
107
107
|
Assert.stub(myobj, :myval).with(123){ |val| val.to_s }
|
108
108
|
myobj.myval
|
109
109
|
# => StubError: arity mismatch
|
110
110
|
myobj.myval(123)
|
111
|
-
# =>
|
111
|
+
# => "123"
|
112
112
|
myobj.myval(456)
|
113
113
|
# => StubError: `myval(456)` not stubbed.
|
114
114
|
Assert.stub_send(myobj, :myval, 123) # call to the original method post-stub
|
@@ -120,7 +120,7 @@ Assert.unstub(myobj, :mymeth)
|
|
120
120
|
Assert.unstub(myobj, :myval)
|
121
121
|
|
122
122
|
myobj.mymeth
|
123
|
-
# =>
|
123
|
+
# => "meth"
|
124
124
|
myobj.myval(123)
|
125
125
|
# => 123
|
126
126
|
myobj.myval(456)
|
@@ -130,7 +130,7 @@ myobj.myval(456)
|
|
130
130
|
## Factory
|
131
131
|
|
132
132
|
```ruby
|
133
|
-
require
|
133
|
+
require "assert/factory"
|
134
134
|
|
135
135
|
Assert::Factory.integer #=> 15742
|
136
136
|
Assert::Factory.integer(3) #=> 2
|
@@ -197,7 +197,7 @@ As an example, say your test folder has a file structure like so:
|
|
197
197
|
| | - slow_tests.rb
|
198
198
|
```
|
199
199
|
|
200
|
-
* `$ assert` - runs all tests (
|
200
|
+
* `$ assert` - runs all tests ("./test" is used if no paths are given)
|
201
201
|
* `$ assert test/basic` - run all tests in basic_tests.rb
|
202
202
|
* `$ assert test/complex/fast_tests.rb` - runs all tests in fast_tests.rb
|
203
203
|
* `$ assert test/basic test/comp` - runs all tests in basic_tests.rb, complex_tests.rb, fast_tests.rb and slow_tests.rb
|
@@ -237,7 +237,7 @@ Assert accepts options from its CLI. Use these options to specify absolute runt
|
|
237
237
|
Assert uses its [`Assert::Runner`](/lib/assert/runner.rb) to run tests. You can extend this default runner or use your own runner implementation. Specify it in your user/local settings:
|
238
238
|
|
239
239
|
```ruby
|
240
|
-
require
|
240
|
+
require "my_awesome_runner_class"
|
241
241
|
|
242
242
|
Assert.configure do |config|
|
243
243
|
config.runner MyAwesomeRunnerClass.new
|
@@ -326,7 +326,7 @@ $ assert [-v|--verbose|--no-verbose]
|
|
326
326
|
|
327
327
|
### Capture Output
|
328
328
|
|
329
|
-
By default, Assert shows any output on `$stdout` produced while running a test. It provides a setting to override whether to show this output or to
|
329
|
+
By default, Assert shows any output on `$stdout` produced while running a test. It provides a setting to override whether to show this output or to "capture" it and display it in the test result details:
|
330
330
|
|
331
331
|
In user/local settings file:
|
332
332
|
|
@@ -404,7 +404,7 @@ This, of course, assumes you are working in a git repository. If you are not or
|
|
404
404
|
```ruby
|
405
405
|
Assert.configure do |config|
|
406
406
|
config.changed_proc Proc.new do |config, test_paths|
|
407
|
-
`git diff --name-only master -- #{test_paths.join(
|
407
|
+
`git diff --name-only master -- #{test_paths.join(" ")}`.split("\n") # or whatever
|
408
408
|
end
|
409
409
|
end
|
410
410
|
```
|
@@ -571,7 +571,7 @@ Beyond that, each view can do as it sees fit. Initialize how you wish, take wha
|
|
571
571
|
To use a 3rd party custom view, first require it in and then configure it. Assert provides a helper for requiring in views. It can be used in two ways. You can pass a fully qualified path to the helper and if it exists, will require it in.
|
572
572
|
|
573
573
|
```ruby
|
574
|
-
Assert::View.require_user_view
|
574
|
+
Assert::View.require_user_view "/path/to/my/view"
|
575
575
|
```
|
576
576
|
|
577
577
|
Alternatively, you can install/clone/copy/write your view implementations in `~/.assert/views` and require it in by name. To have assert require it by name, have it installed at `~/assert/views/view_name/lib/view_name.rb` (this structure is compatible with popular conventions for rubygem development). For example:
|
@@ -579,7 +579,7 @@ Alternatively, you can install/clone/copy/write your view implementations in `~/
|
|
579
579
|
```ruby
|
580
580
|
# assuming ~/.assert/views/my-custom-view/lib/my-custom-view.rb exists
|
581
581
|
# this will require it in
|
582
|
-
Assert::View.require_user_view
|
582
|
+
Assert::View.require_user_view "my-custom-view"
|
583
583
|
```
|
584
584
|
|
585
585
|
Once your view class is required in, use it and configure it just as you would any view.
|
@@ -592,7 +592,7 @@ A `Suite` object is reponsible for collecting and structuring tests and defines
|
|
592
592
|
|
593
593
|
### Runner
|
594
594
|
|
595
|
-
A `Runner` object is responsible for running a suite of tests and firing event callbacks to the `View`. Any runner object should take the test suite and view as arguments and should provide a
|
595
|
+
A `Runner` object is responsible for running a suite of tests and firing event callbacks to the `View`. Any runner object should take the test suite and view as arguments and should provide a "run" method that runs the tests and renders the view.
|
596
596
|
|
597
597
|
### Context
|
598
598
|
|
@@ -620,7 +620,7 @@ A `View` object is responsible for rendering test result output. Assert provide
|
|
620
620
|
|
621
621
|
### Macro
|
622
622
|
|
623
|
-
Macros are procs that define sets of test code and make it available for easy reuse. Macros work nicely with the
|
623
|
+
Macros are procs that define sets of test code and make it available for easy reuse. Macros work nicely with the "should" and "test" context methods.
|
624
624
|
|
625
625
|
## Installation
|
626
626
|
|
@@ -636,7 +636,7 @@ If submitting a Pull Request, please:
|
|
636
636
|
|
637
637
|
1. Fork it
|
638
638
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
639
|
-
3. Commit your changes (`git commit -am
|
639
|
+
3. Commit your changes (`git commit -am "Added some feature"`)
|
640
640
|
4. Push to the branch (`git push origin my-new-feature`)
|
641
641
|
5. Create new Pull Request
|
642
642
|
|
data/assert.gemspec
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
lib = File.expand_path(
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
4
|
require "assert/version"
|
5
5
|
|
@@ -11,13 +11,15 @@ Gem::Specification.new do |gem|
|
|
11
11
|
gem.summary = %q{Assertion style testing framework.}
|
12
12
|
gem.description = %q{Assertion style testing framework.}
|
13
13
|
gem.homepage = "http://github.com/redding/assert"
|
14
|
-
gem.license =
|
14
|
+
gem.license = "MIT"
|
15
15
|
|
16
|
-
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.files = `git ls-files | grep "^[^.]"`.split($/)
|
17
17
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
19
|
gem.require_paths = ["lib"]
|
20
20
|
|
21
|
+
gem.required_ruby_version = '> 1.8'
|
22
|
+
|
21
23
|
gem.add_dependency("much-factory", ["~> 0.1.0"])
|
22
24
|
gem.add_dependency("much-stub", ["~> 0.1.0"])
|
23
25
|
|
data/bin/assert
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
# Copyright (c) 2011-Present Kelly Redding and Collin Redding
|
4
4
|
#
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
6
|
+
require "assert"
|
7
|
+
require "assert/cli"
|
8
8
|
|
9
|
-
Assert.config.debug ENV[
|
9
|
+
Assert.config.debug ENV["ASSERT_DEBUG"] == "true" || Assert::CLI.debug?(ARGV)
|
10
10
|
|
11
|
-
Assert::CLI.bench(
|
11
|
+
Assert::CLI.bench("CLI init and parse"){ @cli = Assert::CLI.new(*ARGV) }
|
12
12
|
@cli.run
|
data/lib/assert.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
require
|
1
|
+
require "assert/version"
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
3
|
+
require "assert/config"
|
4
|
+
require "assert/context"
|
5
|
+
require "assert/runner"
|
6
|
+
require "assert/stub"
|
7
|
+
require "assert/suite"
|
8
|
+
require "assert/utils"
|
9
|
+
require "assert/view"
|
10
10
|
|
11
11
|
module Assert
|
12
12
|
|
data/lib/assert/assert_runner.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "assert/cli"
|
2
2
|
|
3
3
|
module Assert
|
4
4
|
|
@@ -10,7 +10,7 @@ module Assert
|
|
10
10
|
|
11
11
|
def initialize(config, test_paths, test_options)
|
12
12
|
@config = config
|
13
|
-
Assert::CLI.bench(
|
13
|
+
Assert::CLI.bench("Applying settings") do
|
14
14
|
apply_user_settings
|
15
15
|
apply_local_settings
|
16
16
|
apply_env_settings
|
@@ -25,7 +25,7 @@ module Assert
|
|
25
25
|
def init(test_files, test_dir)
|
26
26
|
# load any test helper file
|
27
27
|
if test_dir && (h = File.join(test_dir, self.config.test_helper)) && File.exists?(h)
|
28
|
-
Assert::CLI.bench(
|
28
|
+
Assert::CLI.bench("Requiring test helper"){ require h }
|
29
29
|
end
|
30
30
|
|
31
31
|
if self.config.list
|
@@ -61,15 +61,15 @@ module Assert
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def apply_user_settings
|
64
|
-
safe_require("#{ENV[
|
64
|
+
safe_require("#{ENV["HOME"]}/#{USER_SETTINGS_FILE}") if ENV["HOME"]
|
65
65
|
end
|
66
66
|
|
67
67
|
def apply_local_settings
|
68
|
-
safe_require(ENV[
|
68
|
+
safe_require(ENV["ASSERT_LOCALFILE"] || path_of(LOCAL_SETTINGS_FILE, Dir.pwd))
|
69
69
|
end
|
70
70
|
|
71
71
|
def apply_env_settings
|
72
|
-
self.config.runner_seed ENV[
|
72
|
+
self.config.runner_seed ENV["ASSERT_RUNNER_SEED"].to_i if ENV["ASSERT_RUNNER_SEED"]
|
73
73
|
end
|
74
74
|
|
75
75
|
def apply_option_settings(options)
|
@@ -111,7 +111,7 @@ module Assert
|
|
111
111
|
|
112
112
|
def path_of(segment, a_path)
|
113
113
|
# this method inspects a test path and finds the test dir path.
|
114
|
-
full_path = File.expand_path(a_path ||
|
114
|
+
full_path = File.expand_path(a_path || ".", Dir.pwd)
|
115
115
|
seg_pos = full_path.index(segment_regex(segment))
|
116
116
|
File.join(seg_pos && (seg_pos > 0) ? full_path[0..(seg_pos-1)] : full_path, segment)
|
117
117
|
end
|
data/lib/assert/assertions.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "assert/utils"
|
2
2
|
|
3
3
|
module Assert
|
4
4
|
|
@@ -214,8 +214,8 @@ module Assert
|
|
214
214
|
c = __assert_config__
|
215
215
|
exp_show = Assert::U.show_for_diff(exp, c)
|
216
216
|
act_show = Assert::U.show_for_diff(act, c)
|
217
|
-
exp_id = "#<#{exp.class}:#{
|
218
|
-
act_id = "#<#{act.class}:#{
|
217
|
+
exp_id = "#<#{exp.class}:#{"0x0%x" % (exp.object_id << 1)}>"
|
218
|
+
act_id = "#<#{act.class}:#{"0x0%x" % (act.object_id << 1)}>"
|
219
219
|
|
220
220
|
if c.use_diff_proc.call(exp_show, act_show)
|
221
221
|
"Expected #{act_id} to be the same as #{exp_id}, diff:\n"\
|
@@ -232,8 +232,8 @@ module Assert
|
|
232
232
|
c = __assert_config__
|
233
233
|
exp_show = Assert::U.show_for_diff(exp, c)
|
234
234
|
act_show = Assert::U.show_for_diff(act, c)
|
235
|
-
exp_id = "#<#{exp.class}:#{
|
236
|
-
act_id = "#<#{act.class}:#{
|
235
|
+
exp_id = "#<#{exp.class}:#{"0x0%x" % (exp.object_id << 1)}>"
|
236
|
+
act_id = "#<#{act.class}:#{"0x0%x" % (act.object_id << 1)}>"
|
237
237
|
|
238
238
|
if c.use_diff_proc.call(exp_show, act_show)
|
239
239
|
"Expected #{act_id} to not be the same as #{exp_id}, diff:\n"\
|
data/lib/assert/cli.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require "benchmark"
|
2
|
+
require "set"
|
3
|
+
require "assert/assert_runner"
|
4
|
+
require "assert/version"
|
5
5
|
|
6
6
|
module Assert
|
7
7
|
|
8
8
|
class CLI
|
9
9
|
|
10
10
|
def self.debug?(args)
|
11
|
-
args.include?(
|
11
|
+
args.include?("-d") || args.include?("--debug")
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.debug_msg(msg)
|
@@ -36,39 +36,39 @@ module Assert
|
|
36
36
|
def initialize(*args)
|
37
37
|
@args = args
|
38
38
|
@cli = CLIRB.new do
|
39
|
-
option
|
40
|
-
:abbrev =>
|
39
|
+
option "runner_seed", "use a given seed to run tests", {
|
40
|
+
:abbrev => "s", :value => Fixnum
|
41
41
|
}
|
42
|
-
option
|
43
|
-
:abbrev =>
|
42
|
+
option "changed_only", "only run test files with changes", {
|
43
|
+
:abbrev => "c"
|
44
44
|
}
|
45
|
-
option
|
46
|
-
:abbrev =>
|
45
|
+
option "changed_ref", "reference for changes, use with `-c` opt", {
|
46
|
+
:abbrev => "r", :value => ""
|
47
47
|
}
|
48
|
-
option
|
49
|
-
:abbrev =>
|
48
|
+
option "single_test", "only run the test on the given file/line", {
|
49
|
+
:abbrev => "t", :value => ""
|
50
50
|
}
|
51
|
-
option
|
52
|
-
:abbrev =>
|
51
|
+
option "pp_objects", "pretty-print objects in fail messages", {
|
52
|
+
:abbrev => "p"
|
53
53
|
}
|
54
|
-
option
|
55
|
-
:abbrev =>
|
54
|
+
option "capture_output", "capture stdout and display in result details", {
|
55
|
+
:abbrev => "o"
|
56
56
|
}
|
57
|
-
option
|
58
|
-
:abbrev =>
|
57
|
+
option "halt_on_fail", "halt a test when it fails", {
|
58
|
+
:abbrev => "h"
|
59
59
|
}
|
60
|
-
option
|
61
|
-
:abbrev =>
|
60
|
+
option "profile", "output test profile info", {
|
61
|
+
:abbrev => "e"
|
62
62
|
}
|
63
|
-
option
|
64
|
-
:abbrev =>
|
63
|
+
option "verbose", "output verbose runtime test info", {
|
64
|
+
:abbrev => "v"
|
65
65
|
}
|
66
|
-
option
|
67
|
-
:abbrev =>
|
66
|
+
option "list", "list test files on $stdout", {
|
67
|
+
:abbrev => "l"
|
68
68
|
}
|
69
69
|
# show loaded test files, cli err backtraces, etc
|
70
|
-
option
|
71
|
-
:abbrev =>
|
70
|
+
option "debug", "run in debug mode", {
|
71
|
+
:abbrev => "d"
|
72
72
|
}
|
73
73
|
end
|
74
74
|
end
|
@@ -118,13 +118,13 @@ module Assert
|
|
118
118
|
|
119
119
|
def initialize(&block)
|
120
120
|
@options = []; instance_eval(&block) if block
|
121
|
-
require
|
121
|
+
require "optparse"
|
122
122
|
@data, @args, @opts = [], [], {}; @parser = OptionParser.new do |p|
|
123
|
-
p.banner =
|
123
|
+
p.banner = ""; @options.each do |o|
|
124
124
|
@opts[o.name] = o.value; p.on(*o.parser_args){ |v| @opts[o.name] = v }
|
125
125
|
end
|
126
|
-
p.on_tail(
|
127
|
-
p.on_tail(
|
126
|
+
p.on_tail("--version", ""){ |v| raise VersionExit, v.to_s }
|
127
|
+
p.on_tail("--help", ""){ |v| raise HelpExit, v.to_s }
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
@@ -137,14 +137,14 @@ module Assert
|
|
137
137
|
end
|
138
138
|
def to_s; @parser.to_s; end
|
139
139
|
def inspect
|
140
|
-
"#<#{self.class}:#{
|
140
|
+
"#<#{self.class}:#{"0x0%x" % (object_id << 1)} @data=#{@data.inspect}>"
|
141
141
|
end
|
142
142
|
|
143
143
|
class Option
|
144
144
|
attr_reader :name, :opt_name, :desc, :abbrev, :value, :klass, :parser_args
|
145
145
|
|
146
146
|
def initialize(name, *args)
|
147
|
-
settings, @desc = args.last.kind_of?(::Hash) ? args.pop : {}, args.pop ||
|
147
|
+
settings, @desc = args.last.kind_of?(::Hash) ? args.pop : {}, args.pop || ""
|
148
148
|
@name, @opt_name, @abbrev = parse_name_values(name, settings[:abbrev])
|
149
149
|
@value, @klass = gvalinfo(settings[:value])
|
150
150
|
@parser_args = if [TrueClass, FalseClass, NilClass].include?(@klass)
|
@@ -157,8 +157,8 @@ module Assert
|
|
157
157
|
private
|
158
158
|
|
159
159
|
def parse_name_values(name, custom_abbrev)
|
160
|
-
[ (processed_name = name.to_s.strip.downcase), processed_name.gsub(
|
161
|
-
custom_abbrev || processed_name.gsub(/[^a-z]/,
|
160
|
+
[ (processed_name = name.to_s.strip.downcase), processed_name.gsub("_", "-"),
|
161
|
+
custom_abbrev || processed_name.gsub(/[^a-z]/, "").chars.first || "a"
|
162
162
|
]
|
163
163
|
end
|
164
164
|
def gvalinfo(v); v.kind_of?(Class) ? [nil,gklass(v)] : [v,gklass(v.class)]; end
|
data/lib/assert/config.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
1
|
+
require "assert/default_runner"
|
2
|
+
require "assert/default_suite"
|
3
|
+
require "assert/default_view"
|
4
|
+
require "assert/file_line"
|
5
|
+
require "assert/utils"
|
6
6
|
|
7
7
|
module Assert
|
8
8
|
|
@@ -33,7 +33,7 @@ module Assert
|
|
33
33
|
|
34
34
|
@test_dir = "test"
|
35
35
|
@test_helper = "helper.rb"
|
36
|
-
@test_file_suffixes = [
|
36
|
+
@test_file_suffixes = ["_tests.rb", "_test.rb"]
|
37
37
|
|
38
38
|
@changed_proc = Assert::U.git_changed_proc
|
39
39
|
@pp_proc = Assert::U.stdlib_pp_proc
|
@@ -43,8 +43,8 @@ module Assert
|
|
43
43
|
# option settings
|
44
44
|
@runner_seed = begin; srand; srand % 0xFFFF; end.to_i
|
45
45
|
@changed_only = false
|
46
|
-
@changed_ref =
|
47
|
-
@single_test =
|
46
|
+
@changed_ref = ""
|
47
|
+
@single_test = ""
|
48
48
|
@pp_objects = false
|
49
49
|
@capture_output = false
|
50
50
|
@halt_on_fail = true
|