matest 0.2.0 → 1.0.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/Gemfile +2 -3
- data/Rakefile +9 -0
- data/bin/mt +4 -0
- data/lib/matest.rb +48 -69
- data/lib/matest/spec_status.rb +67 -0
- data/lib/matest/version.rb +1 -1
- data/spec/matest_specs/nested_scopes_spec.rb +1 -0
- data/spec/matest_specs/passing_spec.rb +42 -0
- data/spec/matest_specs/scoping_stuff_spec.rb +20 -2
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3dca823c49ba5da737893a493c8b2d6577fe39a
|
4
|
+
data.tar.gz: ee624abd646826218183f7eb841d0e9eb2430c2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b04d07f356a535fdf18a12073d8cab63d3179e4d70555e91b3576de10b4a2d87b22239a5d160cd88d1c21fb8db023a0a103e8ad8ed94afc0999a33c04d2604f8
|
7
|
+
data.tar.gz: 1f3c6259e4f602eb7d2b1325cbb1255ef023ead69558511eb28bf01a76869f36971cdae788e7218f1a91a72b76330f74f526d64ea3e974b8c38efa6c73ad68fd
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -1,2 +1,11 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
|
3
|
+
task default: :matest
|
4
|
+
task :matest do
|
5
|
+
arg_files = ENV["FILES"] && ENV["FILES"].split(/[\s,]+/)
|
6
|
+
all_files = Rake::FileList["./spec/matest_specs/**/*_spec.rb"]
|
7
|
+
files = arg_files || all_files
|
8
|
+
puts "\nRuning tests for: #{ files.join(" ") }\n\n"
|
9
|
+
|
10
|
+
system *["./bin/mt"].concat(files)
|
11
|
+
end
|
data/bin/mt
CHANGED
data/lib/matest.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require "matest/version"
|
2
|
-
|
2
|
+
require "matest/spec_status"
|
3
3
|
module Matest
|
4
4
|
class Runner
|
5
5
|
attr_reader :example_groups
|
@@ -33,7 +33,9 @@ module Matest
|
|
33
33
|
puts "\n\n### Messages ###"
|
34
34
|
|
35
35
|
statuses = []
|
36
|
+
info[:success] = true
|
36
37
|
info[:num_specs] = { total: 0 }
|
38
|
+
|
37
39
|
example_groups.each do |current_group|
|
38
40
|
current_group.statuses.each do |status|
|
39
41
|
info[:num_specs][:total] += 1
|
@@ -43,11 +45,16 @@ module Matest
|
|
43
45
|
|
44
46
|
if status.is_a?(Matest::SpecPassed)
|
45
47
|
else
|
48
|
+
if status.is_a?(Matest::SpecFailed)
|
49
|
+
info[:success] = false
|
50
|
+
end
|
46
51
|
puts "\n[#{status.name}] #{status.description}"
|
47
52
|
if status.is_a?(Matest::NotANaturalAssertion)
|
53
|
+
info[:success] = false
|
48
54
|
puts " # => #{status.result.inspect}"
|
49
55
|
end
|
50
56
|
if status.is_a?(Matest::ExceptionRaised)
|
57
|
+
info[:success] = false
|
51
58
|
puts "EXCEPTION >> #{status.result}"
|
52
59
|
status.result.backtrace.each do |l|
|
53
60
|
puts " #{l}"
|
@@ -61,98 +68,71 @@ module Matest
|
|
61
68
|
end
|
62
69
|
end
|
63
70
|
|
64
|
-
class
|
65
|
-
|
71
|
+
class SkipMe; end
|
72
|
+
|
73
|
+
class Example
|
74
|
+
attr_reader :example_block
|
66
75
|
attr_reader :description
|
67
|
-
attr_reader :result
|
68
76
|
|
69
|
-
def initialize(
|
70
|
-
@
|
71
|
-
@result = result
|
77
|
+
def initialize(example_block, description, lets)
|
78
|
+
@example_block = example_block
|
72
79
|
@description = description
|
80
|
+
lets.each do |let|
|
81
|
+
self.class.let(let.var_name, &let.block)
|
82
|
+
send(let.var_name) if let.and_call
|
83
|
+
end
|
73
84
|
end
|
74
85
|
|
75
|
-
def
|
76
|
-
|
77
|
-
end
|
78
|
-
|
79
|
-
end
|
80
|
-
|
81
|
-
class SpecPassed < SpecStatus
|
82
|
-
def to_s
|
83
|
-
"."
|
84
|
-
end
|
85
|
-
|
86
|
-
def name
|
87
|
-
"PASSING"
|
88
|
-
end
|
89
|
-
end
|
90
|
-
class SpecFailed < SpecStatus
|
91
|
-
def to_s
|
92
|
-
"F"
|
93
|
-
end
|
94
|
-
|
95
|
-
def name
|
96
|
-
"FAILING"
|
97
|
-
end
|
98
|
-
end
|
99
|
-
class SpecSkipped < SpecStatus
|
100
|
-
def to_s
|
101
|
-
"S"
|
86
|
+
def call
|
87
|
+
instance_eval(&example_block)
|
102
88
|
end
|
103
89
|
|
104
|
-
def
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
class NotANaturalAssertion < SpecStatus
|
109
|
-
def to_s
|
110
|
-
"N"
|
111
|
-
end
|
112
|
-
|
113
|
-
def name
|
114
|
-
"NOT A NATURAL ASSERTION"
|
90
|
+
def self.let(var_name, &block)
|
91
|
+
define_method(var_name) do
|
92
|
+
instance_variable_set(:"@#{var_name}", block.call)
|
93
|
+
end
|
115
94
|
end
|
116
95
|
end
|
117
96
|
|
118
|
-
class
|
119
|
-
attr_reader :
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
97
|
+
class Let
|
98
|
+
attr_reader :var_name
|
99
|
+
attr_reader :block
|
100
|
+
attr_reader :and_call
|
101
|
+
|
102
|
+
def initialize(var_name, block, and_call=false)
|
103
|
+
@var_name = var_name
|
104
|
+
@block = block
|
105
|
+
@and_call = and_call
|
126
106
|
end
|
127
107
|
end
|
128
|
-
|
129
|
-
class SkipMe; end
|
130
|
-
|
108
|
+
|
131
109
|
class ExampleGroup
|
132
110
|
attr_reader :scope_block
|
133
111
|
attr_reader :specs
|
112
|
+
attr_reader :lets
|
134
113
|
attr_reader :statuses
|
135
114
|
|
136
115
|
def initialize(scope_block)
|
137
116
|
@scope_block = scope_block
|
138
117
|
@specs = []
|
118
|
+
@lets = []
|
139
119
|
@statuses = []
|
140
120
|
end
|
141
121
|
|
122
|
+
def spec(description=nil, &block)
|
123
|
+
current_example = block_given? ? block : -> { Matest::SkipMe.new }
|
124
|
+
specs << Example.new(current_example, description, lets)
|
125
|
+
end
|
126
|
+
|
142
127
|
def execute!
|
143
128
|
instance_eval(&scope_block)
|
144
129
|
specs.shuffle.each do |spec, desc|
|
145
|
-
res = run_spec(spec
|
130
|
+
res = run_spec(spec)
|
146
131
|
print res
|
147
132
|
end
|
148
133
|
|
149
134
|
end
|
150
135
|
|
151
|
-
def spec(description=nil, &block)
|
152
|
-
current_example = block_given? ? block : -> { Matest::SkipMe.new }
|
153
|
-
specs << [current_example, description]
|
154
|
-
end
|
155
|
-
|
156
136
|
def xspec(description=nil, &block)
|
157
137
|
spec(description)
|
158
138
|
end
|
@@ -168,16 +148,15 @@ module Matest
|
|
168
148
|
end
|
169
149
|
end
|
170
150
|
|
171
|
-
def let(var_name, &block)
|
172
|
-
|
151
|
+
def let(var_name, and_call=false, &block)
|
152
|
+
lets << Let.new(var_name, block, and_call=false)
|
173
153
|
end
|
174
154
|
|
175
155
|
def let!(var_name, &block)
|
176
|
-
|
177
|
-
send(var_name)
|
156
|
+
lets << Let.new(var_name, block, and_call=true)
|
178
157
|
end
|
179
158
|
|
180
|
-
def run_spec(spec
|
159
|
+
def run_spec(spec)
|
181
160
|
status = begin
|
182
161
|
result = spec.call
|
183
162
|
status_class = case result
|
@@ -190,9 +169,9 @@ module Matest
|
|
190
169
|
else
|
191
170
|
Matest::NotANaturalAssertion
|
192
171
|
end
|
193
|
-
status_class.new(spec, result, description)
|
172
|
+
status_class.new(spec.example_block, result, spec.description)
|
194
173
|
rescue Exception => e
|
195
|
-
Matest::ExceptionRaised.new(spec, e, description)
|
174
|
+
Matest::ExceptionRaised.new(spec.example_block, e, spec.description)
|
196
175
|
end
|
197
176
|
@statuses << status
|
198
177
|
status
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Matest
|
2
|
+
class SpecStatus
|
3
|
+
attr_reader :block
|
4
|
+
attr_reader :description
|
5
|
+
attr_reader :result
|
6
|
+
|
7
|
+
def initialize(block, result, description=nil)
|
8
|
+
@block = block
|
9
|
+
@result = result
|
10
|
+
@description = description
|
11
|
+
end
|
12
|
+
|
13
|
+
def location
|
14
|
+
"%s:%d" % block.source_location
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class SpecPassed < SpecStatus
|
19
|
+
def to_s
|
20
|
+
"."
|
21
|
+
end
|
22
|
+
|
23
|
+
def name
|
24
|
+
"PASSING"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class SpecFailed < SpecStatus
|
29
|
+
def to_s
|
30
|
+
"F"
|
31
|
+
end
|
32
|
+
|
33
|
+
def name
|
34
|
+
"FAILING"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class SpecSkipped < SpecStatus
|
39
|
+
def to_s
|
40
|
+
"S"
|
41
|
+
end
|
42
|
+
|
43
|
+
def name
|
44
|
+
"SKIPPED"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
class NotANaturalAssertion < SpecStatus
|
48
|
+
def to_s
|
49
|
+
"N"
|
50
|
+
end
|
51
|
+
|
52
|
+
def name
|
53
|
+
"NOT A NATURAL ASSERTION"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class ExceptionRaised < SpecStatus
|
58
|
+
attr_reader :exception
|
59
|
+
def to_s
|
60
|
+
"E"
|
61
|
+
end
|
62
|
+
|
63
|
+
def name
|
64
|
+
"ERROR"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/lib/matest/version.rb
CHANGED
@@ -0,0 +1,42 @@
|
|
1
|
+
scope do
|
2
|
+
test do
|
3
|
+
true
|
4
|
+
end
|
5
|
+
|
6
|
+
xtest do
|
7
|
+
true
|
8
|
+
end
|
9
|
+
|
10
|
+
test do
|
11
|
+
true
|
12
|
+
end
|
13
|
+
|
14
|
+
xtest do
|
15
|
+
5
|
16
|
+
end
|
17
|
+
|
18
|
+
xtest do
|
19
|
+
true
|
20
|
+
end
|
21
|
+
|
22
|
+
test do
|
23
|
+
true
|
24
|
+
end
|
25
|
+
|
26
|
+
test do
|
27
|
+
true
|
28
|
+
end
|
29
|
+
|
30
|
+
test do
|
31
|
+
true
|
32
|
+
end
|
33
|
+
|
34
|
+
test do
|
35
|
+
true
|
36
|
+
end
|
37
|
+
|
38
|
+
test do
|
39
|
+
true
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
scope do
|
2
2
|
let(:m1) { :m1 }
|
3
3
|
let!(:m3) { :m3 }
|
4
|
-
|
4
|
+
|
5
5
|
let(:m4) { :m4 }
|
6
6
|
let!(:m5) { :m5 }
|
7
7
|
|
8
8
|
spec do
|
9
9
|
m1 == :m1
|
10
10
|
end
|
11
|
-
|
11
|
+
#
|
12
12
|
spec do
|
13
13
|
! defined?(m2)
|
14
14
|
end
|
@@ -24,6 +24,7 @@ scope do
|
|
24
24
|
spec do
|
25
25
|
!! defined?(@m5)
|
26
26
|
end
|
27
|
+
|
27
28
|
scope do
|
28
29
|
let(:m2) { :m2 }
|
29
30
|
spec do
|
@@ -35,3 +36,20 @@ scope do
|
|
35
36
|
end
|
36
37
|
end
|
37
38
|
end
|
39
|
+
|
40
|
+
scope do
|
41
|
+
@c = true
|
42
|
+
test do
|
43
|
+
@a = true
|
44
|
+
!defined?(@b)
|
45
|
+
end
|
46
|
+
|
47
|
+
test do
|
48
|
+
@b = true
|
49
|
+
!defined?(@a)
|
50
|
+
end
|
51
|
+
|
52
|
+
test do
|
53
|
+
!defined?(@c)
|
54
|
+
end
|
55
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: matest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Federico Iachetti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -53,10 +53,12 @@ files:
|
|
53
53
|
- Rakefile
|
54
54
|
- bin/mt
|
55
55
|
- lib/matest.rb
|
56
|
+
- lib/matest/spec_status.rb
|
56
57
|
- lib/matest/version.rb
|
57
58
|
- matest.gemspec
|
58
59
|
- spec/matest_spec.rb
|
59
60
|
- spec/matest_specs/nested_scopes_spec.rb
|
61
|
+
- spec/matest_specs/passing_spec.rb
|
60
62
|
- spec/matest_specs/scope_spec.rb
|
61
63
|
- spec/matest_specs/scoping_stuff_spec.rb
|
62
64
|
- spec/matest_specs/spec_helper.rb
|
@@ -81,13 +83,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
83
|
version: '0'
|
82
84
|
requirements: []
|
83
85
|
rubyforge_project:
|
84
|
-
rubygems_version: 2.4.
|
86
|
+
rubygems_version: 2.4.3
|
85
87
|
signing_key:
|
86
88
|
specification_version: 4
|
87
89
|
summary: Tests gasoleros (cheap tests).
|
88
90
|
test_files:
|
89
91
|
- spec/matest_spec.rb
|
90
92
|
- spec/matest_specs/nested_scopes_spec.rb
|
93
|
+
- spec/matest_specs/passing_spec.rb
|
91
94
|
- spec/matest_specs/scope_spec.rb
|
92
95
|
- spec/matest_specs/scoping_stuff_spec.rb
|
93
96
|
- spec/matest_specs/spec_helper.rb
|