minitest-hyper 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 811a9cc416d40c66ecd0fedc9a529fce0a82a708
4
- data.tar.gz: e2c0cde2163ba305e467e5f0639b74fd08c12263
3
+ metadata.gz: 09cc6208190579cf460ad97d83d1b92e49e39b37
4
+ data.tar.gz: 3994b587bfa8e682875e01640c2494a5991dff66
5
5
  SHA512:
6
- metadata.gz: 0cb8b60f1190b02abfabec01868a96cb93952d52370726b346543458a1b32ba4e587049802622768d34598ebfeb76cd10dbc4e9a5f840f6480643cffe9505d02
7
- data.tar.gz: 619549060baacfd77b99a98d7e911ff22a0d3b3c9881793b46cd0c9ca46ccadccea4ce541b9af32b97cf2ecce261f4fb987f3bb413ef6fa97f39ceb4fa9343e0
6
+ metadata.gz: 6206ea2d5a523163e8dff56bc527ca858982cda7b0db4fc4fa9278b234475d66ef91a26b5f60085ae8ee736988ca21fda349e45eb7926e38aacf74b622115ac2
7
+ data.tar.gz: eb4b4e28f794acd770e1ac55622c65d37dde6c70f936e7f6c07d1c5e421b0417cd838a0e1176b6260daa5a7542741f1b763c2ac58e9b7257ed3df73538f72a8f
data/README.md CHANGED
@@ -4,6 +4,8 @@ Generates attractive, self-contained HTML reports for your Minitest runs.
4
4
 
5
5
  This gem was created as a demonstration of how to build a Minitest extension for [The Minitest Cookbook](http://chriskottom.com/minitestcookbook/).
6
6
 
7
+ ![Sample Report](./assets/sample_report.png)
8
+
7
9
  ## Installation
8
10
 
9
11
  Add this line to your application's Gemfile:
@@ -43,6 +45,8 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
43
45
 
44
46
  Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/minitest-hyper. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
45
47
 
48
+ [The issue tracker for this project](https://github.com/[USERNAME]/minitest-hyper/issues) is the master list of enhancements and defects in need of repair. If you're looking to contribute, start there.
49
+
46
50
  ## License
47
51
 
48
52
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -4,7 +4,12 @@ require "rake/testtask"
4
4
  Rake::TestTask.new(:test) do |t|
5
5
  t.libs << "test"
6
6
  t.libs << "lib"
7
- t.test_files = FileList['test/**/*_test.rb']
7
+ t.test_files = FileList['test/minitest/**/*_test.rb']
8
8
  end
9
-
10
9
  task :default => :test
10
+
11
+ Rake::TestTask.new("test:integration") do |t|
12
+ t.libs << "test"
13
+ t.libs << "lib"
14
+ t.test_files = FileList['test/integration/**/*_test.rb']
15
+ end
Binary file
@@ -10,30 +10,38 @@ module Minitest
10
10
  @reporter = reporter
11
11
  end
12
12
 
13
- def url
14
- "file://#{ REPORT_FILE.gsub(/\\/, "/") }"
15
- end
16
-
17
13
  def write
18
14
  ensure_output_dir
19
15
  move_existing_file
20
16
  write_file
21
17
  end
22
18
 
19
+ def url
20
+ "file://#{ filename.gsub(/\\/, "/") }"
21
+ end
22
+
23
+ def dirname
24
+ Minitest::Hyper.report_dirname
25
+ end
26
+
27
+ def filename
28
+ Minitest::Hyper.report_filename
29
+ end
30
+
23
31
  private
24
32
 
25
33
  def ensure_output_dir
26
- unless Dir.exist?(REPORTS_DIR)
27
- FileUtils.mkdir_p REPORTS_DIR
34
+ unless Dir.exist?(dirname)
35
+ FileUtils.mkdir_p dirname
28
36
  end
29
37
  end
30
38
 
31
39
  def move_existing_file
32
- if File.exist?(REPORT_FILE)
33
- ctime = File.ctime(REPORT_FILE)
40
+ if File.exist?(filename)
41
+ ctime = File.ctime(filename)
34
42
  time_str = ctime.strftime("%Y%m%d%H%M%S")
35
- new_name = REPORT_FILE.sub(/\.html$/, "_#{ time_str }.html")
36
- FileUtils.mv(REPORT_FILE, new_name)
43
+ new_name = filename.sub(/\.html$/, "_#{ time_str }.html")
44
+ FileUtils.mv(filename, new_name)
37
45
  end
38
46
  end
39
47
 
@@ -46,7 +54,7 @@ module Minitest
46
54
  test_info = reporter.to_h
47
55
 
48
56
  erb = ERB.new(template_string)
49
- File.open(REPORT_FILE, "wb") do |file|
57
+ File.open(filename, "wb") do |file|
50
58
  file.write erb.result(binding)
51
59
  end
52
60
  end
@@ -19,10 +19,6 @@ module Minitest
19
19
  super
20
20
  @report = Report.new(self)
21
21
  @report.write
22
- end
23
-
24
- def passed?
25
- super
26
22
  io.puts "Wrote HTML test report to #{ @report.url }"
27
23
  end
28
24
 
@@ -23,19 +23,15 @@ module Minitest
23
23
 
24
24
  module Hyper
25
25
  GEM_DIR = File.join(File.dirname(__FILE__), "../..")
26
- WORKING_DIR = Dir.pwd
27
-
28
- REPORTS_DIR = File.join(WORKING_DIR, "test/reports/hyper")
29
- REPORT_FILE = File.join(REPORTS_DIR, "index.html")
30
26
 
31
27
  TEMPLATE_DIR = File.join(GEM_DIR, "lib/templates")
32
28
  CSS_TEMPLATE = File.join(TEMPLATE_DIR, "hyper.css")
33
29
  HTML_TEMPLATE = File.join(TEMPLATE_DIR, "index.html.erb")
34
-
35
- VERSION = "0.1.0"
30
+
31
+ VERSION = "0.2.0"
36
32
 
37
33
  @@enabled = false
38
-
34
+
39
35
  def self.enabled?
40
36
  @@enabled
41
37
  end
@@ -44,8 +40,22 @@ module Minitest
44
40
  @@enabled = true
45
41
  end
46
42
 
47
- def config(options)
48
- @options = options
43
+ def self.report_dirname
44
+ project_root = if defined?(Rails) && defined?(Rails.root)
45
+ Rails.root
46
+ else
47
+ Dir.pwd
48
+ end
49
+
50
+ if Dir.exist?(File.join(project_root, "spec"))
51
+ File.join(project_root, "spec/reports/hyper")
52
+ else
53
+ File.join(project_root, "test/reports/hyper")
54
+ end
55
+ end
56
+
57
+ def self.report_filename
58
+ File.join(report_dirname, "index.html")
49
59
  end
50
60
  end
51
61
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-hyper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Kottom
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-12-16 00:00:00.000000000 Z
11
+ date: 2015-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,7 @@ files:
66
66
  - LICENSE.txt
67
67
  - README.md
68
68
  - Rakefile
69
+ - assets/sample_report.png
69
70
  - bin/console
70
71
  - bin/setup
71
72
  - lib/minitest/hyper.rb