assert 2.16.4 → 2.18.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -7
- data/Gemfile +3 -1
- data/README.md +83 -55
- data/assert.gemspec +7 -3
- data/bin/assert +4 -4
- data/lib/assert.rb +8 -18
- data/lib/assert/assert_runner.rb +7 -10
- data/lib/assert/assertions.rb +5 -9
- data/lib/assert/cli.rb +41 -57
- data/lib/assert/config.rb +8 -12
- data/lib/assert/config_helpers.rb +6 -10
- data/lib/assert/context.rb +17 -19
- data/lib/assert/context/setup_dsl.rb +0 -4
- data/lib/assert/context/subject_dsl.rb +0 -4
- data/lib/assert/context/suite_dsl.rb +0 -4
- data/lib/assert/context/test_dsl.rb +5 -9
- data/lib/assert/context_info.rb +2 -6
- data/lib/assert/default_runner.rb +1 -5
- data/lib/assert/default_suite.rb +1 -6
- data/lib/assert/default_view.rb +8 -12
- data/lib/assert/factory.rb +3 -158
- data/lib/assert/file_line.rb +0 -4
- data/lib/assert/macro.rb +1 -4
- data/lib/assert/macros/methods.rb +1 -7
- data/lib/assert/result.rb +19 -34
- data/lib/assert/runner.rb +12 -11
- data/lib/assert/stub.rb +22 -184
- data/lib/assert/suite.rb +3 -7
- data/lib/assert/test.rb +13 -18
- data/lib/assert/utils.rb +8 -12
- data/lib/assert/version.rb +1 -1
- data/lib/assert/view.rb +18 -21
- data/lib/assert/view_helpers.rb +6 -17
- data/log/{.gitkeep → .keep} +0 -0
- data/test/helper.rb +2 -15
- data/test/support/factory.rb +6 -7
- data/test/support/inherited_stuff.rb +0 -2
- data/test/system/stub_tests.rb +204 -223
- data/test/system/test_tests.rb +13 -29
- data/test/unit/assert_tests.rb +63 -14
- data/test/unit/assertions/assert_block_tests.rb +2 -6
- data/test/unit/assertions/assert_empty_tests.rb +6 -9
- data/test/unit/assertions/assert_equal_tests.rb +5 -13
- data/test/unit/assertions/assert_file_exists_tests.rb +6 -9
- data/test/unit/assertions/assert_includes_tests.rb +7 -11
- data/test/unit/assertions/assert_instance_of_tests.rb +5 -9
- data/test/unit/assertions/assert_kind_of_tests.rb +5 -9
- data/test/unit/assertions/assert_match_tests.rb +5 -9
- data/test/unit/assertions/assert_nil_tests.rb +5 -9
- data/test/unit/assertions/assert_raises_tests.rb +4 -8
- data/test/unit/assertions/assert_respond_to_tests.rb +5 -9
- data/test/unit/assertions/assert_same_tests.rb +13 -20
- data/test/unit/assertions/assert_true_false_tests.rb +7 -13
- data/test/unit/assertions_tests.rb +2 -6
- data/test/unit/config_helpers_tests.rb +5 -8
- data/test/unit/config_tests.rb +12 -15
- data/test/unit/context/setup_dsl_tests.rb +7 -15
- data/test/unit/context/subject_dsl_tests.rb +3 -9
- data/test/unit/context/suite_dsl_tests.rb +3 -7
- data/test/unit/context/test_dsl_tests.rb +8 -11
- data/test/unit/context_info_tests.rb +6 -9
- data/test/unit/context_tests.rb +18 -34
- data/test/unit/default_runner_tests.rb +3 -6
- data/test/unit/default_suite_tests.rb +3 -6
- data/test/unit/factory_tests.rb +13 -155
- data/test/unit/file_line_tests.rb +12 -16
- data/test/unit/macro_tests.rb +2 -10
- data/test/unit/result_tests.rb +18 -31
- data/test/unit/runner_tests.rb +9 -16
- data/test/unit/suite_tests.rb +5 -9
- data/test/unit/test_tests.rb +19 -31
- data/test/unit/utils_tests.rb +18 -27
- data/test/unit/view_helpers_tests.rb +15 -21
- data/test/unit/view_tests.rb +11 -15
- metadata +52 -36
- data/.assert.rb +0 -3
- data/.gitignore +0 -19
- data/test/unit/stub_tests.rb +0 -375
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
---
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
SHA512:
|
6
|
-
|
7
|
-
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 93616ac8a1849d9f356088b0386907f946cf89465e84aaa6321ceff60f7012de
|
4
|
+
data.tar.gz: a4436d1c9d437cb56343318885b1a32d804ad2e71c956408cd877d695f3d9675
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 424110cb0d83c44fcdc66129532bc53859a74a0b2f63f2b08081955d6aee813a9df11f37afbdc325f464866ca0263fc98164992d08949fa2573410f9056334c6
|
7
|
+
data.tar.gz: 25b2980b91b9e4dddf9724f64cbdc81214c910008157f0ac88f3e3a1c6f4ae8162065d08ef4a2c2eb78ff2211cdc49fdac893397e50e04b5816174eb8293c01b
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -5,14 +5,12 @@
|
|
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
|
-
|
12
11
|
test "something" do
|
13
12
|
assert_equal 1, 1
|
14
13
|
end
|
15
|
-
|
16
14
|
end
|
17
15
|
```
|
18
16
|
|
@@ -65,70 +63,100 @@ Assert is an assertion style testing framework, meaning you use assertion statem
|
|
65
63
|
|
66
64
|
## Stub
|
67
65
|
|
66
|
+
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:
|
67
|
+
|
68
|
+
* each stub takes a block that is called in place of the method
|
69
|
+
* complains if you stub a method that the object doesn't respond to
|
70
|
+
* complains if you stub with an arity mismatch
|
71
|
+
* no methods are added to `Object` to support stubbing
|
72
|
+
* stubs are auto-unstubbed on test teardown
|
73
|
+
|
74
|
+
**Note**: Assert's stubbing logic has been extracted into a separate gem: [MuchStub](https://github.com/redding/much-stub/#muchstub). However, the main `Assert.{stub|unstub|stub_send|stub_tap|etc}` api is still available (it just proxies to MuchStub now).
|
75
|
+
|
68
76
|
```ruby
|
69
77
|
myclass = Class.new do
|
70
|
-
def
|
71
|
-
|
78
|
+
def my_method
|
79
|
+
"my_method"
|
80
|
+
end
|
81
|
+
|
82
|
+
def my_value(value)
|
83
|
+
value
|
84
|
+
end
|
72
85
|
end
|
73
|
-
|
86
|
+
my_object = myclass.new
|
74
87
|
|
75
|
-
|
76
|
-
# =>
|
77
|
-
|
88
|
+
my_object.my_method
|
89
|
+
# => "my_method"
|
90
|
+
my_object.my_value(123)
|
78
91
|
# => 123
|
79
|
-
|
92
|
+
my_object.my_value(456)
|
80
93
|
# => 456
|
81
94
|
|
82
|
-
Assert.stub(
|
83
|
-
|
84
|
-
# => StubError: `
|
85
|
-
Assert.stub(
|
86
|
-
|
87
|
-
# =>
|
88
|
-
|
95
|
+
Assert.stub(my_object, :my_method)
|
96
|
+
my_object.my_method
|
97
|
+
# => StubError: `my_method` not stubbed.
|
98
|
+
Assert.stub(my_object, :my_method){ "stub-meth" }
|
99
|
+
my_object.my_method
|
100
|
+
# => "stub-meth"
|
101
|
+
my_object.my_method(123)
|
89
102
|
# => StubError: arity mismatch
|
90
|
-
Assert.stub(
|
103
|
+
Assert.stub(my_object, :my_method).with(123){ "stub-meth" }
|
91
104
|
# => StubError: arity mismatch
|
92
|
-
Assert.stub_send(myobj, :mymeth) # call to the original method post-stub
|
93
|
-
# => 'meth'
|
94
105
|
|
95
|
-
|
106
|
+
# Call the original method after it has been stubbed.
|
107
|
+
Assert.stub_send(my_object, :my_method)
|
108
|
+
# => "my_method"
|
109
|
+
|
110
|
+
Assert.stub(my_object, :my_value){ "stub-meth" }
|
96
111
|
# => StubError: arity mismatch
|
97
|
-
Assert.stub(
|
98
|
-
|
112
|
+
Assert.stub(my_object, :my_value).with(123){ |val| val.to_s }
|
113
|
+
my_object.my_value
|
99
114
|
# => StubError: arity mismatch
|
100
|
-
|
101
|
-
# =>
|
102
|
-
|
103
|
-
# => StubError: `
|
104
|
-
|
115
|
+
my_object.my_value(123)
|
116
|
+
# => "123"
|
117
|
+
my_object.my_value(456)
|
118
|
+
# => StubError: `my_value(456)` not stubbed.
|
119
|
+
|
120
|
+
# Call the original method after it has been stubbed.
|
121
|
+
Assert.stub_send(my_object, :my_value, 123)
|
105
122
|
# => 123
|
106
|
-
Assert.stub_send(
|
123
|
+
Assert.stub_send(my_object, :my_value, 456)
|
107
124
|
# => 456
|
108
125
|
|
109
|
-
|
110
|
-
|
126
|
+
# Stub a method while preserving its behavior and return value.
|
127
|
+
my_value_called_with = nil
|
128
|
+
Assert.stub_tap(my_object, :my_value) { |value, *args|
|
129
|
+
my_value_called_with = args
|
130
|
+
Assert.stub(value, :to_s) { "FIREWORKS!" }
|
131
|
+
}
|
132
|
+
value = my_object.my_value(123)
|
133
|
+
# => 123
|
134
|
+
my_value_called_with
|
135
|
+
# => [123]
|
136
|
+
value.to_s
|
137
|
+
# =>"FIREWORKS!"
|
138
|
+
|
139
|
+
# Unstub individual stubs
|
140
|
+
Assert.unstub(my_object, :my_method)
|
141
|
+
Assert.unstub(my_object, :my_value)
|
142
|
+
|
143
|
+
# OR blanket unstub all stubs
|
144
|
+
Assert.unstub!
|
111
145
|
|
112
|
-
|
113
|
-
# =>
|
114
|
-
|
146
|
+
my_object.my_method
|
147
|
+
# => "my_method"
|
148
|
+
my_object.my_value(123)
|
115
149
|
# => 123
|
116
|
-
|
150
|
+
value = my_object.my_value(456)
|
117
151
|
# => 456
|
152
|
+
value.to_s
|
153
|
+
# => "456"
|
118
154
|
```
|
119
155
|
|
120
|
-
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:
|
121
|
-
|
122
|
-
* each stub takes a block that is called in place of the method
|
123
|
-
* complains if you stub a method that the object doesn't respond to
|
124
|
-
* complains if you stub with an arity mismatch
|
125
|
-
* no methods are added to `Object` to support stubbing
|
126
|
-
* stubs are auto-unstubbed on test teardown
|
127
|
-
|
128
156
|
## Factory
|
129
157
|
|
130
158
|
```ruby
|
131
|
-
require
|
159
|
+
require "assert/factory"
|
132
160
|
|
133
161
|
Assert::Factory.integer #=> 15742
|
134
162
|
Assert::Factory.integer(3) #=> 2
|
@@ -173,6 +201,8 @@ module Factory
|
|
173
201
|
end
|
174
202
|
```
|
175
203
|
|
204
|
+
**Note**: Assert's factory logic has been extracted into a separate gem: [MuchFactory](https://github.com/redding/much-factory/#muchfactory). However, the main api above is still available (it just delegates to MuchFactory now).
|
205
|
+
|
176
206
|
## CLI
|
177
207
|
|
178
208
|
```sh
|
@@ -193,7 +223,7 @@ As an example, say your test folder has a file structure like so:
|
|
193
223
|
| | - slow_tests.rb
|
194
224
|
```
|
195
225
|
|
196
|
-
* `$ assert` - runs all tests (
|
226
|
+
* `$ assert` - runs all tests ("./test" is used if no paths are given)
|
197
227
|
* `$ assert test/basic` - run all tests in basic_tests.rb
|
198
228
|
* `$ assert test/complex/fast_tests.rb` - runs all tests in fast_tests.rb
|
199
229
|
* `$ assert test/basic test/comp` - runs all tests in basic_tests.rb, complex_tests.rb, fast_tests.rb and slow_tests.rb
|
@@ -233,7 +263,7 @@ Assert accepts options from its CLI. Use these options to specify absolute runt
|
|
233
263
|
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:
|
234
264
|
|
235
265
|
```ruby
|
236
|
-
require
|
266
|
+
require "my_awesome_runner_class"
|
237
267
|
|
238
268
|
Assert.configure do |config|
|
239
269
|
config.runner MyAwesomeRunnerClass.new
|
@@ -322,7 +352,7 @@ $ assert [-v|--verbose|--no-verbose]
|
|
322
352
|
|
323
353
|
### Capture Output
|
324
354
|
|
325
|
-
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
|
355
|
+
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:
|
326
356
|
|
327
357
|
In user/local settings file:
|
328
358
|
|
@@ -400,7 +430,7 @@ This, of course, assumes you are working in a git repository. If you are not or
|
|
400
430
|
```ruby
|
401
431
|
Assert.configure do |config|
|
402
432
|
config.changed_proc Proc.new do |config, test_paths|
|
403
|
-
`git diff --name-only master -- #{test_paths.join(
|
433
|
+
`git diff --name-only master -- #{test_paths.join(" ")}`.split("\n") # or whatever
|
404
434
|
end
|
405
435
|
end
|
406
436
|
```
|
@@ -409,13 +439,11 @@ If you just want to disable this feature completely:
|
|
409
439
|
|
410
440
|
```ruby
|
411
441
|
Assert.configure do |config|
|
412
|
-
|
413
442
|
# run nothing if the `-c` flag is given
|
414
443
|
config.changed_proc Proc.new{ |config, test_paths| [] }
|
415
444
|
|
416
445
|
# run all test paths if the `-c` flag is given
|
417
446
|
config.changed_proc Proc.new{ |config, test_paths| test_paths }
|
418
|
-
|
419
447
|
end
|
420
448
|
```
|
421
449
|
|
@@ -567,7 +595,7 @@ Beyond that, each view can do as it sees fit. Initialize how you wish, take wha
|
|
567
595
|
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.
|
568
596
|
|
569
597
|
```ruby
|
570
|
-
Assert::View.require_user_view
|
598
|
+
Assert::View.require_user_view "/path/to/my/view"
|
571
599
|
```
|
572
600
|
|
573
601
|
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:
|
@@ -575,7 +603,7 @@ Alternatively, you can install/clone/copy/write your view implementations in `~/
|
|
575
603
|
```ruby
|
576
604
|
# assuming ~/.assert/views/my-custom-view/lib/my-custom-view.rb exists
|
577
605
|
# this will require it in
|
578
|
-
Assert::View.require_user_view
|
606
|
+
Assert::View.require_user_view "my-custom-view"
|
579
607
|
```
|
580
608
|
|
581
609
|
Once your view class is required in, use it and configure it just as you would any view.
|
@@ -588,7 +616,7 @@ A `Suite` object is reponsible for collecting and structuring tests and defines
|
|
588
616
|
|
589
617
|
### Runner
|
590
618
|
|
591
|
-
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
|
619
|
+
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.
|
592
620
|
|
593
621
|
### Context
|
594
622
|
|
@@ -616,7 +644,7 @@ A `View` object is responsible for rendering test result output. Assert provide
|
|
616
644
|
|
617
645
|
### Macro
|
618
646
|
|
619
|
-
Macros are procs that define sets of test code and make it available for easy reuse. Macros work nicely with the
|
647
|
+
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.
|
620
648
|
|
621
649
|
## Installation
|
622
650
|
|
@@ -632,7 +660,7 @@ If submitting a Pull Request, please:
|
|
632
660
|
|
633
661
|
1. Fork it
|
634
662
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
635
|
-
3. Commit your changes (`git commit -am
|
663
|
+
3. Commit your changes (`git commit -am "Added some feature"`)
|
636
664
|
4. Push to the branch (`git push origin my-new-feature`)
|
637
665
|
5. Create new Pull Request
|
638
666
|
|
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,11 +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 = "~> 2.5"
|
22
|
+
|
23
|
+
gem.add_dependency("much-factory", ["~> 0.1.0"])
|
24
|
+
gem.add_dependency("much-stub", ["~> 0.1.3"])
|
21
25
|
end
|
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,15 +1,14 @@
|
|
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
|
-
|
13
12
|
def self.config; @config ||= Config.new; end
|
14
13
|
def self.configure; yield self.config if block_given?; end
|
15
14
|
|
@@ -21,14 +20,5 @@ module Assert
|
|
21
20
|
class Context
|
22
21
|
teardown{ Assert.unstub! }
|
23
22
|
end
|
24
|
-
|
25
23
|
end
|
26
24
|
|
27
|
-
# Kernel#caller_locations polyfill for pre ruby 2.0.0
|
28
|
-
if RUBY_VERSION =~ /\A1\..+/ && !Kernel.respond_to?(:caller_locations)
|
29
|
-
module Kernel
|
30
|
-
def caller_locations(start = 1, length = nil)
|
31
|
-
length ? caller[start, length] : caller[start..-1]
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
data/lib/assert/assert_runner.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
require
|
1
|
+
require "assert/cli"
|
2
2
|
|
3
3
|
module Assert
|
4
|
-
|
5
4
|
class AssertRunner
|
6
5
|
USER_SETTINGS_FILE = ".assert/init.rb"
|
7
6
|
LOCAL_SETTINGS_FILE = ".assert.rb"
|
@@ -10,7 +9,7 @@ module Assert
|
|
10
9
|
|
11
10
|
def initialize(config, test_paths, test_options)
|
12
11
|
@config = config
|
13
|
-
Assert::CLI.bench(
|
12
|
+
Assert::CLI.bench("Applying settings") do
|
14
13
|
apply_user_settings
|
15
14
|
apply_local_settings
|
16
15
|
apply_env_settings
|
@@ -25,7 +24,7 @@ module Assert
|
|
25
24
|
def init(test_files, test_dir)
|
26
25
|
# load any test helper file
|
27
26
|
if test_dir && (h = File.join(test_dir, self.config.test_helper)) && File.exists?(h)
|
28
|
-
Assert::CLI.bench(
|
27
|
+
Assert::CLI.bench("Requiring test helper"){ require h }
|
29
28
|
end
|
30
29
|
|
31
30
|
if self.config.list
|
@@ -61,15 +60,15 @@ module Assert
|
|
61
60
|
end
|
62
61
|
|
63
62
|
def apply_user_settings
|
64
|
-
safe_require("#{ENV[
|
63
|
+
safe_require("#{ENV["HOME"]}/#{USER_SETTINGS_FILE}") if ENV["HOME"]
|
65
64
|
end
|
66
65
|
|
67
66
|
def apply_local_settings
|
68
|
-
safe_require(ENV[
|
67
|
+
safe_require(ENV["ASSERT_LOCALFILE"] || path_of(LOCAL_SETTINGS_FILE, Dir.pwd))
|
69
68
|
end
|
70
69
|
|
71
70
|
def apply_env_settings
|
72
|
-
self.config.runner_seed ENV[
|
71
|
+
self.config.runner_seed ENV["ASSERT_RUNNER_SEED"].to_i if ENV["ASSERT_RUNNER_SEED"]
|
73
72
|
end
|
74
73
|
|
75
74
|
def apply_option_settings(options)
|
@@ -111,13 +110,11 @@ module Assert
|
|
111
110
|
|
112
111
|
def path_of(segment, a_path)
|
113
112
|
# this method inspects a test path and finds the test dir path.
|
114
|
-
full_path = File.expand_path(a_path ||
|
113
|
+
full_path = File.expand_path(a_path || ".", Dir.pwd)
|
115
114
|
seg_pos = full_path.index(segment_regex(segment))
|
116
115
|
File.join(seg_pos && (seg_pos > 0) ? full_path[0..(seg_pos-1)] : full_path, segment)
|
117
116
|
end
|
118
117
|
|
119
118
|
def segment_regex(seg); /^#{seg}$|^#{seg}\/|\/#{seg}\/|\/#{seg}$/; end
|
120
|
-
|
121
119
|
end
|
122
|
-
|
123
120
|
end
|
data/lib/assert/assertions.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require "assert/utils"
|
2
2
|
|
3
3
|
module Assert
|
4
|
-
|
5
4
|
module Assertions
|
6
|
-
|
7
5
|
def assert_block(desc = nil)
|
8
6
|
assert(yield, desc){ "Expected block to return a true value." }
|
9
7
|
end
|
@@ -214,8 +212,8 @@ module Assert
|
|
214
212
|
c = __assert_config__
|
215
213
|
exp_show = Assert::U.show_for_diff(exp, c)
|
216
214
|
act_show = Assert::U.show_for_diff(act, c)
|
217
|
-
exp_id = "#<#{exp.class}:#{
|
218
|
-
act_id = "#<#{act.class}:#{
|
215
|
+
exp_id = "#<#{exp.class}:#{"0x0%x" % (exp.object_id << 1)}>"
|
216
|
+
act_id = "#<#{act.class}:#{"0x0%x" % (act.object_id << 1)}>"
|
219
217
|
|
220
218
|
if c.use_diff_proc.call(exp_show, act_show)
|
221
219
|
"Expected #{act_id} to be the same as #{exp_id}, diff:\n"\
|
@@ -232,8 +230,8 @@ module Assert
|
|
232
230
|
c = __assert_config__
|
233
231
|
exp_show = Assert::U.show_for_diff(exp, c)
|
234
232
|
act_show = Assert::U.show_for_diff(act, c)
|
235
|
-
exp_id = "#<#{exp.class}:#{
|
236
|
-
act_id = "#<#{act.class}:#{
|
233
|
+
exp_id = "#<#{exp.class}:#{"0x0%x" % (exp.object_id << 1)}>"
|
234
|
+
act_id = "#<#{act.class}:#{"0x0%x" % (act.object_id << 1)}>"
|
237
235
|
|
238
236
|
if c.use_diff_proc.call(exp_show, act_show)
|
239
237
|
"Expected #{act_id} to not be the same as #{exp_id}, diff:\n"\
|
@@ -328,7 +326,5 @@ module Assert
|
|
328
326
|
super("exception not expected, but raised:")
|
329
327
|
end
|
330
328
|
end
|
331
|
-
|
332
329
|
end
|
333
|
-
|
334
330
|
end
|