assert 1.1.0 → 2.0.0.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.assert.rb +3 -0
- data/README.md +182 -108
- data/Rakefile +0 -3
- data/bin/assert +1 -1
- data/lib/assert.rb +75 -4
- data/lib/assert/assert_runner.rb +76 -0
- data/lib/assert/cli.rb +25 -46
- data/lib/assert/context.rb +3 -3
- data/lib/assert/result.rb +65 -55
- data/lib/assert/runner.rb +19 -38
- data/lib/assert/suite.rb +0 -7
- data/lib/assert/test.rb +4 -16
- data/lib/assert/version.rb +1 -1
- data/lib/assert/view.rb +23 -0
- data/lib/assert/view/base.rb +10 -19
- data/lib/assert/view/default_view.rb +16 -11
- data/lib/assert/view/helpers/ansi_styles.rb +1 -1
- data/lib/assert/view/helpers/common.rb +37 -16
- data/test/assert_test.rb +29 -14
- data/test/context/class_methods_test.rb +2 -2
- data/test/context_test.rb +28 -50
- data/test/helper.rb +4 -2
- data/test/runner_test.rb +5 -4
- data/test/suite_test.rb +1 -1
- data/test/test_test.rb +8 -15
- data/test/view/base_tests.rb +20 -37
- metadata +17 -39
- data/lib/assert/autorun.rb +0 -37
- data/lib/assert/options.rb +0 -43
- data/lib/assert/rake_tasks.rb +0 -75
- data/lib/assert/rake_tasks/irb.rb +0 -33
- data/lib/assert/rake_tasks/scope.rb +0 -100
- data/lib/assert/rake_tasks/test_task.rb +0 -66
- data/lib/assert/result_set.rb +0 -17
- data/lib/assert/setup.rb +0 -3
- data/lib/assert/setup/all.rb +0 -5
- data/lib/assert/setup/helpers.rb +0 -72
- data/lib/assert/setup/options.rb +0 -6
- data/lib/assert/setup/runner.rb +0 -13
- data/lib/assert/setup/suite.rb +0 -13
- data/lib/assert/setup/view.rb +0 -39
- data/lib/assert/view/helpers/capture_output.rb +0 -23
- data/test/default_view_test.rb +0 -16
- data/test/irb.rb +0 -5
- data/test/options_test.rb +0 -40
- data/test/rake_tasks/irb_test.rb +0 -45
- data/test/rake_tasks/scope_test.rb +0 -63
- data/test/rake_tasks/test_task_test.rb +0 -80
- data/test/result_set_test.rb +0 -72
data/test/suite_test.rb
CHANGED
@@ -22,7 +22,7 @@ class Assert::Suite
|
|
22
22
|
|
23
23
|
should have_accessors :tests, :test_methods
|
24
24
|
should have_accessors :start_time, :end_time
|
25
|
-
should have_instance_method :run_time
|
25
|
+
should have_instance_method :run_time
|
26
26
|
|
27
27
|
should "determine a klass' local public test methods" do
|
28
28
|
assert_equal(
|
data/test/test_test.rb
CHANGED
@@ -191,24 +191,22 @@ class Assert::Test
|
|
191
191
|
puts "std out from the test"
|
192
192
|
assert true
|
193
193
|
}
|
194
|
-
@
|
195
|
-
|
196
|
-
@test.run
|
194
|
+
@orig_show = Assert.config.show_output
|
195
|
+
Assert.config.show_output false
|
197
196
|
}
|
198
197
|
teardown {
|
199
|
-
|
198
|
+
Assert.config.show_output @orig_show
|
200
199
|
}
|
201
200
|
|
202
201
|
should "capture any io from the test" do
|
202
|
+
@test.run
|
203
203
|
assert_equal "std out from the test\n", @test.output
|
204
204
|
end
|
205
205
|
|
206
206
|
end
|
207
207
|
|
208
|
-
|
209
|
-
|
210
|
-
class FullOutputCaptureTest < BasicTest
|
211
|
-
desc "when collecting std out across setup, teardown, and meth calls"
|
208
|
+
class FullCaptureOutTest < CaptureOutTest
|
209
|
+
desc "across setup, teardown, and meth calls"
|
212
210
|
setup do
|
213
211
|
@test = Factory.test("fullstdouttest") {
|
214
212
|
puts "std out from the test"
|
@@ -220,16 +218,11 @@ class Assert::Test
|
|
220
218
|
puts "std out from a method an assert called"
|
221
219
|
true
|
222
220
|
end
|
223
|
-
|
224
|
-
@orig_capture = @test.class.options.capture_output
|
225
|
-
@test.class.options.capture_output(true)
|
226
|
-
@test.run
|
227
221
|
end
|
228
|
-
teardown {
|
229
|
-
@test.class.options.capture_output(@orig_capture)
|
230
|
-
}
|
231
222
|
|
232
223
|
should "collect it on itself in the output accessor" do
|
224
|
+
@test.run
|
225
|
+
|
233
226
|
assert_equal([
|
234
227
|
"std out from the setup",
|
235
228
|
"std out from the test",
|
data/test/view/base_tests.rb
CHANGED
@@ -9,29 +9,32 @@ module Assert::View
|
|
9
9
|
class BaseTests < Assert::Context
|
10
10
|
desc "the base view"
|
11
11
|
setup do
|
12
|
-
@view = Assert::View::Base.new(
|
12
|
+
@view = Assert::View::Base.new(StringIO.new("", "w+"), Assert::Suite.new)
|
13
13
|
end
|
14
14
|
subject{ @view }
|
15
15
|
|
16
|
-
# options
|
17
|
-
should have_instance_method :options
|
18
|
-
should have_class_method :options
|
19
|
-
|
20
16
|
# accessors, base methods
|
21
|
-
should
|
22
|
-
should
|
23
|
-
should
|
24
|
-
should have_instance_methods :before_test, :after_test, :on_result
|
17
|
+
should have_imeths :view, :suite, :fire
|
18
|
+
should have_imeths :before_load, :after_load, :on_start, :on_finish
|
19
|
+
should have_imeths :before_test, :after_test, :on_result
|
25
20
|
|
26
21
|
# common methods
|
27
|
-
should
|
28
|
-
should
|
29
|
-
should
|
30
|
-
should
|
31
|
-
should
|
32
|
-
should
|
33
|
-
should
|
34
|
-
should
|
22
|
+
should have_imeths :run_time, :runner_seed, :count, :tests?, :all_pass?
|
23
|
+
should have_imeths :suite_contexts, :ordered_suite_contexts
|
24
|
+
should have_imeths :suite_files, :ordered_suite_files
|
25
|
+
should have_imeths :result_details_for, :show_result_details?
|
26
|
+
should have_imeths :ocurring_result_types, :result_summary_msg
|
27
|
+
should have_imeths :all_pass_result_summary_msg, :results_summary_sentence
|
28
|
+
should have_imeths :test_count_statement, :result_count_statement
|
29
|
+
should have_imeths :to_sentence
|
30
|
+
|
31
|
+
should "default its result abbreviations" do
|
32
|
+
assert_equal '.', subject.pass_abbrev
|
33
|
+
assert_equal 'F', subject.fail_abbrev
|
34
|
+
assert_equal 'I', subject.ignore_abbrev
|
35
|
+
assert_equal 'S', subject.skip_abbrev
|
36
|
+
assert_equal 'E', subject.error_abbrev
|
37
|
+
end
|
35
38
|
|
36
39
|
end
|
37
40
|
|
@@ -42,24 +45,4 @@ module Assert::View
|
|
42
45
|
should have_instance_method :require_user_view
|
43
46
|
end
|
44
47
|
|
45
|
-
class BaseOptionsTestx < Assert::Context
|
46
|
-
desc "options for the base view"
|
47
|
-
subject do
|
48
|
-
Assert::View::Base.options
|
49
|
-
end
|
50
|
-
|
51
|
-
should "be an Options::Base object" do
|
52
|
-
assert_kind_of Assert::Options::Base, subject
|
53
|
-
end
|
54
|
-
|
55
|
-
should "default its result abbreviations" do
|
56
|
-
assert_equal '.', subject.default_pass_abbrev
|
57
|
-
assert_equal 'F', subject.default_fail_abbrev
|
58
|
-
assert_equal 'I', subject.default_ignore_abbrev
|
59
|
-
assert_equal 'S', subject.default_skip_abbrev
|
60
|
-
assert_equal 'E', subject.default_error_abbrev
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
64
|
-
|
65
48
|
end
|
metadata
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: assert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: -2762361102
|
5
|
+
prerelease: 6
|
6
6
|
segments:
|
7
|
-
-
|
8
|
-
- 1
|
7
|
+
- 2
|
9
8
|
- 0
|
10
|
-
|
9
|
+
- 0
|
10
|
+
- rc
|
11
|
+
- 1
|
12
|
+
version: 2.0.0.rc.1
|
11
13
|
platform: ruby
|
12
14
|
authors:
|
13
15
|
- Kelly Redding
|
@@ -16,7 +18,7 @@ autorequire:
|
|
16
18
|
bindir: bin
|
17
19
|
cert_chain: []
|
18
20
|
|
19
|
-
date: 2013-02-
|
21
|
+
date: 2013-02-16 00:00:00 Z
|
20
22
|
dependencies:
|
21
23
|
- !ruby/object:Gem::Dependency
|
22
24
|
name: ansi
|
@@ -44,6 +46,7 @@ extensions: []
|
|
44
46
|
extra_rdoc_files: []
|
45
47
|
|
46
48
|
files:
|
49
|
+
- .assert.rb
|
47
50
|
- .gitignore
|
48
51
|
- CHANGELOG.md
|
49
52
|
- Gemfile
|
@@ -53,34 +56,21 @@ files:
|
|
53
56
|
- assert.gemspec
|
54
57
|
- bin/assert
|
55
58
|
- lib/assert.rb
|
59
|
+
- lib/assert/assert_runner.rb
|
56
60
|
- lib/assert/assertions.rb
|
57
|
-
- lib/assert/autorun.rb
|
58
61
|
- lib/assert/cli.rb
|
59
62
|
- lib/assert/context.rb
|
60
63
|
- lib/assert/macro.rb
|
61
64
|
- lib/assert/macros/methods.rb
|
62
|
-
- lib/assert/options.rb
|
63
|
-
- lib/assert/rake_tasks.rb
|
64
|
-
- lib/assert/rake_tasks/irb.rb
|
65
|
-
- lib/assert/rake_tasks/scope.rb
|
66
|
-
- lib/assert/rake_tasks/test_task.rb
|
67
65
|
- lib/assert/result.rb
|
68
|
-
- lib/assert/result_set.rb
|
69
66
|
- lib/assert/runner.rb
|
70
|
-
- lib/assert/setup.rb
|
71
|
-
- lib/assert/setup/all.rb
|
72
|
-
- lib/assert/setup/helpers.rb
|
73
|
-
- lib/assert/setup/options.rb
|
74
|
-
- lib/assert/setup/runner.rb
|
75
|
-
- lib/assert/setup/suite.rb
|
76
|
-
- lib/assert/setup/view.rb
|
77
67
|
- lib/assert/suite.rb
|
78
68
|
- lib/assert/test.rb
|
79
69
|
- lib/assert/version.rb
|
70
|
+
- lib/assert/view.rb
|
80
71
|
- lib/assert/view/base.rb
|
81
72
|
- lib/assert/view/default_view.rb
|
82
73
|
- lib/assert/view/helpers/ansi_styles.rb
|
83
|
-
- lib/assert/view/helpers/capture_output.rb
|
84
74
|
- lib/assert/view/helpers/common.rb
|
85
75
|
- test/assert_test.rb
|
86
76
|
- test/assertions/assert_block_test.rb
|
@@ -110,7 +100,6 @@ files:
|
|
110
100
|
- test/assertions_test.rb
|
111
101
|
- test/context/class_methods_test.rb
|
112
102
|
- test/context_test.rb
|
113
|
-
- test/default_view_test.rb
|
114
103
|
- test/fixtures/inherited_stuff.rb
|
115
104
|
- test/fixtures/sample_context.rb
|
116
105
|
- test/fixtures/test_root/one_test.rb
|
@@ -120,13 +109,7 @@ files:
|
|
120
109
|
- test/fixtures/test_root/shallow_test.rb
|
121
110
|
- test/fixtures/test_root/two_test.rb
|
122
111
|
- test/helper.rb
|
123
|
-
- test/irb.rb
|
124
112
|
- test/macro_test.rb
|
125
|
-
- test/options_test.rb
|
126
|
-
- test/rake_tasks/irb_test.rb
|
127
|
-
- test/rake_tasks/scope_test.rb
|
128
|
-
- test/rake_tasks/test_task_test.rb
|
129
|
-
- test/result_set_test.rb
|
130
113
|
- test/result_test.rb
|
131
114
|
- test/runner_test.rb
|
132
115
|
- test/suite/context_info_test.rb
|
@@ -154,12 +137,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
154
137
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
138
|
none: false
|
156
139
|
requirements:
|
157
|
-
- - "
|
140
|
+
- - ">"
|
158
141
|
- !ruby/object:Gem::Version
|
159
|
-
hash:
|
142
|
+
hash: 25
|
160
143
|
segments:
|
161
|
-
-
|
162
|
-
|
144
|
+
- 1
|
145
|
+
- 3
|
146
|
+
- 1
|
147
|
+
version: 1.3.1
|
163
148
|
requirements: []
|
164
149
|
|
165
150
|
rubyforge_project:
|
@@ -196,7 +181,6 @@ test_files:
|
|
196
181
|
- test/assertions_test.rb
|
197
182
|
- test/context/class_methods_test.rb
|
198
183
|
- test/context_test.rb
|
199
|
-
- test/default_view_test.rb
|
200
184
|
- test/fixtures/inherited_stuff.rb
|
201
185
|
- test/fixtures/sample_context.rb
|
202
186
|
- test/fixtures/test_root/one_test.rb
|
@@ -206,13 +190,7 @@ test_files:
|
|
206
190
|
- test/fixtures/test_root/shallow_test.rb
|
207
191
|
- test/fixtures/test_root/two_test.rb
|
208
192
|
- test/helper.rb
|
209
|
-
- test/irb.rb
|
210
193
|
- test/macro_test.rb
|
211
|
-
- test/options_test.rb
|
212
|
-
- test/rake_tasks/irb_test.rb
|
213
|
-
- test/rake_tasks/scope_test.rb
|
214
|
-
- test/rake_tasks/test_task_test.rb
|
215
|
-
- test/result_set_test.rb
|
216
194
|
- test/result_test.rb
|
217
195
|
- test/runner_test.rb
|
218
196
|
- test/suite/context_info_test.rb
|
data/lib/assert/autorun.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'assert/setup/all'
|
2
|
-
|
3
|
-
module Assert
|
4
|
-
|
5
|
-
# a flag to know if at_exit hook has been installed already
|
6
|
-
@@at_exit_installed ||= false
|
7
|
-
|
8
|
-
# install at_exit hook (if needed) (runs at process exit)
|
9
|
-
# this ensures the test suite won't run until all test files are loaded
|
10
|
-
# (this is essentially a direct rip from Minitest)
|
11
|
-
|
12
|
-
def self.autorun
|
13
|
-
if !@@at_exit_installed
|
14
|
-
self.view.fire(:before_load)
|
15
|
-
|
16
|
-
at_exit do
|
17
|
-
# don't run if there was an exception
|
18
|
-
next if $!
|
19
|
-
|
20
|
-
# the order here is important. The at_exit handler must be
|
21
|
-
# installed before anyone else gets a chance to install their
|
22
|
-
# own, that way we can be assured that our exit will be last
|
23
|
-
# to run (at_exit stacks).
|
24
|
-
|
25
|
-
exit_code = nil
|
26
|
-
at_exit { exit(false) if exit_code && exit_code != 0 }
|
27
|
-
|
28
|
-
self.view.fire(:after_load)
|
29
|
-
self.runner.new(self.suite, self.view).run
|
30
|
-
end
|
31
|
-
|
32
|
-
@@at_exit_installed = true
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
|
data/lib/assert/options.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
module Assert
|
2
|
-
module Options
|
3
|
-
|
4
|
-
class Base
|
5
|
-
def method_missing(method, *args, &block)
|
6
|
-
if args.empty?
|
7
|
-
self.instance_variable_get("@#{method}")
|
8
|
-
else
|
9
|
-
value = args.size == 1 ? args.first : args
|
10
|
-
self.instance_variable_set("@#{method}", value)
|
11
|
-
if method.to_s =~ /^default_/
|
12
|
-
self.instance_variable_set("@#{$'}", value)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.included(receiver)
|
20
|
-
receiver.send(:class_variable_set, "@@options", Base.new)
|
21
|
-
receiver.send(:extend, ClassMethods)
|
22
|
-
receiver.send(:include, InstanceMethods)
|
23
|
-
end
|
24
|
-
|
25
|
-
module ClassMethods
|
26
|
-
def options(&block)
|
27
|
-
options = self.send(:class_variable_get, "@@options")
|
28
|
-
if block_given?
|
29
|
-
options.instance_eval(&block)
|
30
|
-
else
|
31
|
-
options
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
module InstanceMethods
|
37
|
-
def options
|
38
|
-
self.class.options
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
end
|
data/lib/assert/rake_tasks.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
require 'rake'
|
2
|
-
|
3
|
-
module Assert; end
|
4
|
-
module Assert::RakeTasks; end
|
5
|
-
|
6
|
-
require 'assert/rake_tasks/irb'
|
7
|
-
require 'assert/rake_tasks/scope'
|
8
|
-
require 'assert/rake_tasks/test_task'
|
9
|
-
|
10
|
-
module Assert::RakeTasks
|
11
|
-
|
12
|
-
# Setup the rake tasks for testing
|
13
|
-
# * add 'include Assert::RakeTasks' to your Rakefile
|
14
|
-
def self.included(receiver)
|
15
|
-
# auto-install rake tasks
|
16
|
-
self.install
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.install
|
20
|
-
warn "[DEPRECATED] `Assert::RakeTasts` has been deprecated. Support for running tests with Rake will be removed in v2.0. Use the assert CLI instead."
|
21
|
-
|
22
|
-
assert_test_root = ENV['ASSERT_TEST_ROOT'] || './test'
|
23
|
-
|
24
|
-
if File.exists?(assert_test_root)
|
25
|
-
self.irb_task(Assert::RakeTasks::Irb.new(assert_test_root))
|
26
|
-
self.to_tasks(Assert::RakeTasks::Scope.new(assert_test_root))
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def self.for(test_root_name)
|
31
|
-
warn "[DEPRECATED] `Assert::RakeTasts.for` has been deprecated. Use `Assert::RakeTasks.install` instead."
|
32
|
-
end
|
33
|
-
|
34
|
-
class << self
|
35
|
-
include Rake::DSL if defined? Rake::DSL
|
36
|
-
|
37
|
-
def irb_task(irb)
|
38
|
-
if irb.helper_exists?
|
39
|
-
desc irb.description
|
40
|
-
task irb.class.task_name do
|
41
|
-
sh irb.cmd
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def to_tasks(scope)
|
47
|
-
# if there is a test task for the scope
|
48
|
-
if (scope_tt = scope.to_test_task)
|
49
|
-
# create a rake task to run it
|
50
|
-
desc scope_tt.description
|
51
|
-
task scope_tt.name do
|
52
|
-
RakeFileUtils.verbose(scope_tt.show_loaded_files?) { ruby scope_tt.ruby_args }
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
# create a namespace for the scope
|
57
|
-
namespace scope.namespace do
|
58
|
-
# for each test task in the scope, create a rake task to run it
|
59
|
-
scope.test_tasks.each do |test_file_tt|
|
60
|
-
desc test_file_tt.description
|
61
|
-
task test_file_tt.name do
|
62
|
-
RakeFileUtils.verbose(test_file_tt.show_loaded_files?) { ruby test_file_tt.ruby_args }
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
# recusively generate rake tasks for each sub-scope in the scope
|
67
|
-
scope.scopes.each do |sub_scope|
|
68
|
-
self.to_tasks(sub_scope)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module Assert::RakeTasks
|
2
|
-
class Irb
|
3
|
-
|
4
|
-
def self.file_name
|
5
|
-
"irb.rb"
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.task_name
|
9
|
-
:irb
|
10
|
-
end
|
11
|
-
|
12
|
-
def initialize(test_root)
|
13
|
-
@test_root = test_root
|
14
|
-
end
|
15
|
-
|
16
|
-
def file_path
|
17
|
-
File.join(@test_root.to_s, self.class.file_name)
|
18
|
-
end
|
19
|
-
|
20
|
-
def helper_exists?
|
21
|
-
File.exists?(self.file_path)
|
22
|
-
end
|
23
|
-
|
24
|
-
def description
|
25
|
-
"Open irb preloaded with #{self.file_path}"
|
26
|
-
end
|
27
|
-
|
28
|
-
def cmd
|
29
|
-
"irb -rubygems -r #{self.file_path}"
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|