matest 1.4.1 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +29 -2
- data/Rakefile +1 -23
- data/lib/matest/example_block.rb +12 -8
- data/lib/matest/spec_printer.rb +25 -9
- data/lib/matest/spec_tasks.rb +16 -0
- data/lib/matest/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f02cbd7cc39eda882dd572d7cf95e7acdee9bed9
|
4
|
+
data.tar.gz: def3bb5852801094f9013b62ab1a9b16217710f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73bc398f1d198bad0ea52f09834569175820e0d305ebedc44d3a50ee04c5bbb1462296af64bb0323390d7f072917c131877cbba08fac87311f01c1e8fd3c24f8
|
7
|
+
data.tar.gz: e262572d3c83067f57b19f1d4e9857f00f1b2041a8c14fdfef48d299795a93501af85956d842f048dae602efe60d4cb47e654c38859f6875d0d2fb9c8a1ed441
|
data/README.md
CHANGED
@@ -148,7 +148,7 @@ end
|
|
148
148
|
|
149
149
|
## The output
|
150
150
|
|
151
|
-
In case the test fails, you'll get an extensive explanation about why.
|
151
|
+
In case the test fails or is not a natural assertion, you'll get an extensive explanation about why.
|
152
152
|
|
153
153
|
To show a trivial example:
|
154
154
|
|
@@ -226,14 +226,37 @@ You may be used to other keywords provenient from different testing frameworks.
|
|
226
226
|
- `test` (and `xtest`)
|
227
227
|
- `example` (and `xexample`)
|
228
228
|
|
229
|
+
## Configuration
|
230
|
+
|
231
|
+
You can add some configuration to the way the tests are run, by using the ```Matest.configure``` method.
|
232
|
+
|
233
|
+
To use it, you need to pass a block with the configuration instructions inside.
|
234
|
+
|
235
|
+
```ruby
|
236
|
+
Matest.configure do |config|
|
237
|
+
config.use_color
|
238
|
+
end
|
239
|
+
```
|
240
|
+
|
241
|
+
### Color
|
242
|
+
|
243
|
+
You can tell Matest to use colored output by calling the ```use_color``` method on the config object
|
244
|
+
|
245
|
+
```ruby
|
246
|
+
Matest.configure do |config|
|
247
|
+
config.use_color
|
248
|
+
end
|
249
|
+
```
|
250
|
+
|
229
251
|
## TODO ... or not TODO
|
230
|
-
- Colorize output
|
231
252
|
- Before and after callbacks
|
232
253
|
- matest-given-ish
|
233
254
|
- Allow seamless transition (separated gems)
|
234
255
|
* matest-assert (to move from TestUnit, Minitest::Unit, Cutest)
|
235
256
|
* matest-should (to move from RSpec
|
236
257
|
* matest-must (to move from Minitest::Spec)
|
258
|
+
- Run "<file>:<line>"
|
259
|
+
Should run the enclosing test or scope
|
237
260
|
|
238
261
|
## Installation
|
239
262
|
|
@@ -251,6 +274,10 @@ Or install it yourself as:
|
|
251
274
|
|
252
275
|
$ gem install matest
|
253
276
|
|
277
|
+
## Known Issues
|
278
|
+
|
279
|
+
- If the test contains a here doc and it fails, it raises a Sorcerer error
|
280
|
+
|
254
281
|
## Contributing
|
255
282
|
|
256
283
|
1. Fork it ( https://github.com/[my-github-username]/matest/fork )
|
data/Rakefile
CHANGED
@@ -1,27 +1,5 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
|
3
3
|
task default: :matest
|
4
|
+
require "matest/spec_tasks"
|
4
5
|
|
5
|
-
task :spec do
|
6
|
-
arg_files = (ENV["FILES"] && ENV["FILES"].split(/[\s,]+/)) || [ENV["SPEC"]]
|
7
|
-
if arg_files
|
8
|
-
arg_files.map! { |file_name|
|
9
|
-
Pathname(file_name).directory? ? file_name + "/**/*.rb" : file_name
|
10
|
-
}
|
11
|
-
end
|
12
|
-
|
13
|
-
all_files = Rake::FileList["./spec/matest_specs/**/*_spec.rb"]
|
14
|
-
files = arg_files || all_files
|
15
|
-
puts "\nRuning tests for: #{ files.join(" ") }\n\n"
|
16
|
-
|
17
|
-
system *["./bin/matest"].concat(files)
|
18
|
-
end
|
19
|
-
|
20
|
-
task :matest do
|
21
|
-
arg_files = ENV["FILES"] && ENV["FILES"].split(/[\s,]+/)
|
22
|
-
all_files = Rake::FileList["./spec/matest_specs/**/*_spec.rb"]
|
23
|
-
files = arg_files || all_files
|
24
|
-
puts "\nRuning tests for: #{ files.join(" ") }\n\n"
|
25
|
-
|
26
|
-
system *["./bin/matest"].concat(files)
|
27
|
-
end
|
data/lib/matest/example_block.rb
CHANGED
@@ -29,22 +29,26 @@ class ExampleBlock
|
|
29
29
|
private
|
30
30
|
|
31
31
|
def generate_code
|
32
|
-
file = File.open(block.source_location.first)
|
33
|
-
source = file.read
|
34
|
-
lines = source.each_line.to_a
|
35
|
-
|
36
32
|
lineno = block.source_location.last
|
37
33
|
|
38
34
|
current_line = lineno-1
|
39
35
|
valid_lines = [lines[current_line]]
|
40
36
|
|
41
|
-
valid_lines
|
42
|
-
|
43
37
|
until Ripper::SexpBuilder.new(valid_lines.join("\n")).parse
|
44
38
|
current_line += 1
|
45
39
|
valid_lines << lines[current_line]
|
46
40
|
end
|
47
|
-
|
48
|
-
|
41
|
+
|
42
|
+
valid_lines[1..-2].join
|
43
|
+
end
|
44
|
+
|
45
|
+
def lines
|
46
|
+
@lines ||= get_lines
|
47
|
+
end
|
48
|
+
|
49
|
+
def get_lines
|
50
|
+
file = File.open(block.source_location.first)
|
51
|
+
source = file.read
|
52
|
+
source.each_line.to_a
|
49
53
|
end
|
50
54
|
end
|
data/lib/matest/spec_printer.rb
CHANGED
@@ -9,7 +9,7 @@ module Matest
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def print_messages(runner)
|
12
|
-
puts
|
12
|
+
puts "\n\n### Messages ###"
|
13
13
|
|
14
14
|
statuses = []
|
15
15
|
runner.info[:success] = true
|
@@ -30,17 +30,17 @@ module Matest
|
|
30
30
|
if status.is_a?(Matest::SpecFailed)
|
31
31
|
runner.info[:success] = false
|
32
32
|
puts header("Assertion")
|
33
|
-
puts " #{status.example.example_block.assertion}"
|
33
|
+
puts expression(" #{status.example.example_block.assertion}")
|
34
34
|
if status.example.track_variables.any?
|
35
35
|
puts header("Variables")
|
36
36
|
status.example.track_variables.each do |var, val|
|
37
|
-
puts
|
37
|
+
puts key_value(var, val)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
if status.example.track_lets.any?
|
41
41
|
puts header("Lets")
|
42
42
|
status.example.track_lets.each do |var, val|
|
43
|
-
puts
|
43
|
+
puts key_value(var, val)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -53,9 +53,9 @@ module Matest
|
|
53
53
|
end
|
54
54
|
if status.is_a?(Matest::ExceptionRaised)
|
55
55
|
runner.info[:success] = false
|
56
|
-
puts
|
56
|
+
puts error("EXCEPTION >> #{status.result}")
|
57
57
|
status.result.backtrace.each do |l|
|
58
|
-
puts
|
58
|
+
puts error(" #{l}")
|
59
59
|
end
|
60
60
|
|
61
61
|
end
|
@@ -79,9 +79,9 @@ module Matest
|
|
79
79
|
result = Evaluator.new(just_before_assertion, just_before_assertion.before_assertion_block).eval_string(code)
|
80
80
|
if result.class != Matest::EvalErr
|
81
81
|
explanation = []
|
82
|
-
explanation <<
|
82
|
+
explanation << expression(" #{code}")
|
83
83
|
explanation << "\n"
|
84
|
-
explanation <<
|
84
|
+
explanation << value(" # => #{result}")
|
85
85
|
puts explanation.join
|
86
86
|
true
|
87
87
|
else
|
@@ -91,7 +91,7 @@ module Matest
|
|
91
91
|
#{result}
|
92
92
|
Make sure you are not calling any local vaiables on your code assertion.
|
93
93
|
CODE
|
94
|
-
puts
|
94
|
+
puts error(code)
|
95
95
|
false
|
96
96
|
end
|
97
97
|
end
|
@@ -102,6 +102,22 @@ module Matest
|
|
102
102
|
str + ":"
|
103
103
|
end
|
104
104
|
|
105
|
+
def expression(str)
|
106
|
+
yellow(str)
|
107
|
+
end
|
108
|
+
|
109
|
+
def value(str)
|
110
|
+
blue(str)
|
111
|
+
end
|
112
|
+
|
113
|
+
def key_value(key, value)
|
114
|
+
" #{yellow(key.to_s)} #{bright_black("=>")} #{blue(value.inspect)}"
|
115
|
+
end
|
116
|
+
|
117
|
+
def error(str)
|
118
|
+
red(str)
|
119
|
+
end
|
120
|
+
|
105
121
|
def colors
|
106
122
|
{
|
107
123
|
Matest::SpecPassed => :green,
|
@@ -0,0 +1,16 @@
|
|
1
|
+
task :spec do
|
2
|
+
arg_files = (ENV["FILES"] && ENV["FILES"].split(/[\s,]+/)) || [ENV["SPEC"]]
|
3
|
+
if arg_files
|
4
|
+
arg_files.map! { |file_name|
|
5
|
+
path = Pathname(file_name).expand_path
|
6
|
+
raise "Spec file not found: #{file_name.inspect}" unless path.exist?
|
7
|
+
path.directory? ? path.to_s + "/**/*.rb" : path.to_s
|
8
|
+
}
|
9
|
+
end
|
10
|
+
|
11
|
+
all_files = Rake::FileList["./spec/**/*_spec.rb"]
|
12
|
+
files = arg_files || all_files
|
13
|
+
puts "\nRuning tests for: #{ files.join(" ") }\n\n"
|
14
|
+
|
15
|
+
system *["matest"].concat(files)
|
16
|
+
end
|
data/lib/matest/version.rb
CHANGED
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: 1.
|
4
|
+
version: 1.5.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: 2015-01-
|
11
|
+
date: 2015-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -92,6 +92,7 @@ files:
|
|
92
92
|
- lib/matest/skip_me.rb
|
93
93
|
- lib/matest/spec_printer.rb
|
94
94
|
- lib/matest/spec_status.rb
|
95
|
+
- lib/matest/spec_tasks.rb
|
95
96
|
- lib/matest/top_level_methods.rb
|
96
97
|
- lib/matest/version.rb
|
97
98
|
- matest.gemspec
|