minitest-utils 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -0
- data/Rakefile +4 -4
- data/lib/minitest/utils/extension.rb +18 -0
- data/lib/minitest/utils/reporter.rb +10 -3
- data/lib/minitest/utils/version.rb +1 -1
- data/lib/minitest/utils.rb +1 -0
- 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: 700f67bcfb5d5fe53a2a75b7bf3ec8843ccc82f9
|
4
|
+
data.tar.gz: 9d5ad7d010ddc713d2ee5e420e93ccd3a9afec0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: caf2e42d4875292a0bb788cefce0f9ea3d3cbe76925250401c1e84e7b236bf572158e6b1b5d03c87ad7e53e55ff53b16173be74823295bc562899312fe9cebea
|
7
|
+
data.tar.gz: 0b1ea576e5cabae344f583f8a623164a299f1b6024c6889f37bccad16705e68c62563ea08628fce6ed610a678d328f0b8d6e5bbf47096d0e7541f1ec8bbbb58f
|
data/README.md
CHANGED
@@ -25,6 +25,20 @@ Or install it yourself as:
|
|
25
25
|
|
26
26
|
$ gem install minitest-utils
|
27
27
|
|
28
|
+
## Defining tests
|
29
|
+
|
30
|
+
This gem adds the `Minitest::Test.test` method, so you can easy define your methods like the following:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
class SampleTest < Minitest::Test
|
34
|
+
test 'useless test' do
|
35
|
+
assert true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
```
|
39
|
+
|
40
|
+
This is equivalent to defining a method named `test_useless_test`. You can also skip the block, which will define a [flunk](https://github.com/seattlerb/minitest/blob/77120c5b2511c4665610cda06c8058c801b28e7f/lib/minitest/assertions.rb#L477-L480) call.
|
41
|
+
|
28
42
|
## Screenshots
|
29
43
|
|
30
44
|
![](https://raw.githubusercontent.com/fnando/minitest-utils/master/screenshots/light-failing.png)
|
data/Rakefile
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
2
|
require 'rake/testtask'
|
3
3
|
|
4
|
-
Rake::TestTask.new(:
|
5
|
-
t.libs << '
|
6
|
-
t.test_files = FileList['
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
5
|
+
t.libs << 'test'
|
6
|
+
t.test_files = FileList['test/**/*_test.rb']
|
7
7
|
t.verbose = true
|
8
8
|
end
|
9
9
|
|
10
|
-
task :default => :
|
10
|
+
task :default => :test
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Minitest
|
2
|
+
class Test
|
3
|
+
def self.test(name, &block)
|
4
|
+
test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
|
5
|
+
defined = method_defined? test_name
|
6
|
+
|
7
|
+
raise "#{test_name} is already defined in #{self}" if defined
|
8
|
+
|
9
|
+
if block_given?
|
10
|
+
define_method(test_name, &block)
|
11
|
+
else
|
12
|
+
define_method(test_name) do
|
13
|
+
flunk "No implementation provided for #{name}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -79,7 +79,7 @@ module Minitest
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def display_replay_command(result)
|
82
|
-
location =
|
82
|
+
location = find_test_file(result)
|
83
83
|
command = %[rake TEST=#{location} TESTOPTS="--name=#{result.name}"]
|
84
84
|
str = "\n"
|
85
85
|
str << color(command, :red)
|
@@ -87,6 +87,12 @@ module Minitest
|
|
87
87
|
io.print str
|
88
88
|
end
|
89
89
|
|
90
|
+
def find_test_file(result)
|
91
|
+
filter_backtrace(result.failure.backtrace)
|
92
|
+
.find {|line| line.match(%r(^(test|spec)/.*?_(test|spec).rb)) }
|
93
|
+
.gsub(/:\d+.*?$/, '')
|
94
|
+
end
|
95
|
+
|
90
96
|
def backtrace(backtrace)
|
91
97
|
backtrace = filter_backtrace(backtrace).map {|line| location(line) }
|
92
98
|
return if backtrace.empty?
|
@@ -94,10 +100,11 @@ module Minitest
|
|
94
100
|
end
|
95
101
|
|
96
102
|
def location(location)
|
103
|
+
location = File.expand_path(location[/^([^:]+)/, 1])
|
104
|
+
|
97
105
|
return location unless location.start_with?(Dir.pwd)
|
98
106
|
|
99
|
-
location
|
100
|
-
"./#{location}"
|
107
|
+
location.gsub(%r[^#{Regexp.escape(Dir.pwd)}/], '')
|
101
108
|
end
|
102
109
|
|
103
110
|
def filter_backtrace(backtrace)
|
data/lib/minitest/utils.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nando Vieira
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -81,6 +81,7 @@ files:
|
|
81
81
|
- bin/rake
|
82
82
|
- bin/setup
|
83
83
|
- lib/minitest/utils.rb
|
84
|
+
- lib/minitest/utils/extension.rb
|
84
85
|
- lib/minitest/utils/rails.rb
|
85
86
|
- lib/minitest/utils/rails/capybara.rb
|
86
87
|
- lib/minitest/utils/rails/factory_girl.rb
|