attestify 0.1.0.pre.1 → 0.1.0.pre.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7b89b143f940ebbeb5be5c9f14d4d76e2211ec52
4
- data.tar.gz: 897b052d0d6b336246c716a561099b6996b96e3e
3
+ metadata.gz: 876c694bdaec5a2ae1048fc2a54b2d38b4251969
4
+ data.tar.gz: efc2a21cff2441ba14938aeac038f0d8912efbf5
5
5
  SHA512:
6
- metadata.gz: 0a2cf3fa488d7ad4f2ede463bd7380daf27807e94729aa66bef74a8b5756ead081e6ddc528581f66e54bb5973b442469befe3f104218e75822af799664742262
7
- data.tar.gz: 7de390a92c1f0cc8bda31846f4104344b55ce4be600a43301a95295c6ddb49e94814f5536ce447505d2dca1725137af16ef069f74160fac57a58c7e1fab2a0a5
6
+ metadata.gz: 5db0a47826a1872993a5be2780251302d3ec3fb2cf0cae3b9d861cd8c87f9c608f5b93da28bbdfe9b2c9984e413b6d92780dc081dfdb20ae9eefa49cf61b6451
7
+ data.tar.gz: 50427b717de140bca88a281a4cbdfa894c7de4ce9ab562c2008686e10cc52f5ff2a4de5235022cd03c4fd295f09770a5d8904933ef103565379f19e4913c4e10
@@ -2,6 +2,7 @@
2
2
  module Attestify
3
3
  autoload :AssertionResults, "attestify/assertion_results"
4
4
  autoload :Assertions, "attestify/assertions"
5
+ autoload :Autorun, "attestify/autorun"
5
6
  autoload :CLI, "attestify/cli"
6
7
  autoload :ColorReporter, "attestify/color_reporter"
7
8
  autoload :Mock, "attestify/mock"
@@ -9,6 +10,7 @@ module Attestify
9
10
  autoload :Reporter, "attestify/reporter"
10
11
  autoload :SkippedError, "attestify/skipped_error"
11
12
  autoload :Test, "attestify/test"
13
+ autoload :TestExecutor, "attestify/test_executor"
12
14
  autoload :TestList, "attestify/test_list"
13
15
  autoload :TestRunner, "attestify/test_runner"
14
16
  autoload :Timer, "attestify/timer"
@@ -17,4 +19,8 @@ module Attestify
17
19
  def self.root
18
20
  @root ||= File.realpath(File.expand_path("../..", __FILE__)).freeze
19
21
  end
22
+
23
+ def self.autorun
24
+ @autorun ||= Attestify::Autorun.new.tap(&:enable)
25
+ end
20
26
  end
@@ -0,0 +1,80 @@
1
+ require "attestify"
2
+ require "optparse"
3
+
4
+ module Attestify
5
+ # Supports autorun mode, where all tests defined will get run.
6
+ class Autorun
7
+ include Attestify::TestExecutor
8
+
9
+ def initialize(args = ARGV)
10
+ @args = args
11
+ end
12
+
13
+ def test_list
14
+ @test_list ||= Attestify::Autorun::TestList.new(dir: options[:directory])
15
+ end
16
+
17
+ def reporter
18
+ @reporter ||=
19
+ if options[:color]
20
+ Attestify::ColorReporter.new
21
+ else
22
+ Attestify::Reporter.new
23
+ end
24
+ end
25
+
26
+ def enable
27
+ parse_options
28
+ require_helper
29
+ at_exit { start }
30
+ end
31
+
32
+ private
33
+
34
+ def parse_options
35
+ option_parser.parse!(@args)
36
+ end
37
+
38
+ def require_helper
39
+ return unless test_list.test_helper_file
40
+ require File.realpath(test_list.test_helper_file)
41
+ end
42
+
43
+ def options
44
+ @options ||= {
45
+ color: true
46
+ }
47
+ end
48
+
49
+ def option_parser # rubocop:disable Metrics/MethodLength
50
+ @option_parser ||= OptionParser.new do |opts|
51
+ opts.on("-d", "--directory [DIR]", "Run the tests as if from the provided DIR") do |dir|
52
+ options[:directory] = dir
53
+ end
54
+
55
+ opts.on("-c", "--color", "Run with color") do
56
+ options[:color] = true
57
+ end
58
+
59
+ opts.on("-C", "--no-color", "Run without color") do
60
+ options[:color] = false
61
+ end
62
+ end
63
+ end
64
+
65
+ def after_exec
66
+ exit(exit_code)
67
+ end
68
+
69
+ # A TestList to support auto-running a test.
70
+ class TestList < Attestify::TestList
71
+ def test_files
72
+ []
73
+ end
74
+
75
+ def run?(_test_class, _method)
76
+ true
77
+ end
78
+ end
79
+ end
80
+ end
@@ -4,9 +4,10 @@ require "optparse"
4
4
  module Attestify
5
5
  # Command Line Interface for running Attestify tests.
6
6
  class CLI
7
+ include Attestify::TestExecutor
8
+
7
9
  def initialize(args = ARGV)
8
10
  @args = args
9
- @exit_code = true
10
11
  end
11
12
 
12
13
  def self.start
@@ -26,6 +27,8 @@ module Attestify
26
27
  end
27
28
  end
28
29
 
30
+ private
31
+
29
32
  def options
30
33
  @options ||= {
31
34
  color: true
@@ -56,29 +59,20 @@ module Attestify
56
59
  end
57
60
  end
58
61
 
62
+ def report?
63
+ !@ignore_reporting
64
+ end
65
+
59
66
  def ignore_reporting
60
67
  @ignore_reporting = true
61
68
  end
62
69
 
63
- def parse_arguments
70
+ def before_run
64
71
  option_parser.parse!(@args)
65
72
  end
66
73
 
67
- def start
68
- timer = Attestify::Timer.time { run }
69
- rescue => e
70
- @exit_code = 2
71
- STDERR.puts("Error running tests: #{e}\n #{e.backtrace.join("\n ")}")
72
- ensure
73
- reporter.timer = timer
74
- reporter.report unless @ignore_reporting
75
- exit(@exit_code)
76
- end
77
-
78
- def run
79
- parse_arguments
80
- Attestify::TestRunner.new(test_list, reporter).run
81
- @exit_code = 1 unless reporter.passed?
74
+ def after_exec
75
+ exit(exit_code)
82
76
  end
83
77
  end
84
78
  end
@@ -75,7 +75,11 @@ module Attestify
75
75
  end
76
76
 
77
77
  def puts_failure_header(failure, number)
78
- puts "#{number}) #{failure.name}"
78
+ puts "#{number}) #{failure.name}: #{failure_assertion_totals(failure)}"
79
+ end
80
+
81
+ def failure_assertion_totals(failure)
82
+ "#{failure.failed_assertions_total} out of #{failure.assertions_total} assertions failed"
79
83
  end
80
84
 
81
85
  def puts_failure_details(failure, number)
@@ -95,7 +99,7 @@ module Attestify
95
99
  puts "Finished in #{elapsed_time}, #{tests_per_second}, #{assertions_per_second}"
96
100
  puts "#{total_tests}, #{total_failures}, #{total_errors}, #{total_skips}, " \
97
101
  "#{total_assertions}, #{total_failed_assertions}"
98
- puts_failure_reruns
102
+ puts_failure_reruns unless @failures.empty?
99
103
  end
100
104
 
101
105
  def elapsed_time
@@ -47,6 +47,14 @@ module Attestify
47
47
  "#{self.class.name}##{@_test_method}"
48
48
  end
49
49
 
50
+ def assertions_total
51
+ assertions.total
52
+ end
53
+
54
+ def failed_assertions_total
55
+ assertions.failed
56
+ end
57
+
50
58
  def passed?
51
59
  assertions.passed?
52
60
  end
@@ -0,0 +1,49 @@
1
+ require "attestify"
2
+
3
+ module Attestify
4
+ # A TestExecutor is responsible for running and outputing the test
5
+ # reports. This module expects reporter and test_list to be implemented. The
6
+ # reporter method must return an Attestify::Reporter, while test_list must
7
+ # return an Attestify::TestList.
8
+ module TestExecutor
9
+ def start
10
+ before_exec
11
+ @exit_code = true
12
+ timer = Attestify::Timer.time { run }
13
+ rescue => e
14
+ @exit_code = 2
15
+ STDERR.puts("Error running tests: #{e}\n #{e.backtrace.join("\n ")}")
16
+ ensure
17
+ reporter.timer = timer
18
+ reporter.report unless @ignore_reporting
19
+ after_exec
20
+ end
21
+
22
+ private
23
+
24
+ def run
25
+ before_run
26
+ Attestify::TestRunner.new(test_list, reporter).run
27
+ @exit_code = 1 unless reporter.passed?
28
+ after_run
29
+ end
30
+
31
+ attr_reader :exit_code
32
+
33
+ def before_run
34
+ end
35
+
36
+ def after_run
37
+ end
38
+
39
+ def before_exec
40
+ end
41
+
42
+ def after_exec
43
+ end
44
+
45
+ def report?
46
+ true
47
+ end
48
+ end
49
+ end
@@ -1,3 +1,3 @@
1
1
  module Attestify
2
- VERSION = "0.1.0.pre.1".freeze
2
+ VERSION = "0.1.0.pre.2".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attestify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.1
4
+ version: 0.1.0.pre.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Virata-Stone
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-13 00:00:00.000000000 Z
11
+ date: 2016-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -77,6 +77,7 @@ files:
77
77
  - lib/attestify/assertion_results.rb
78
78
  - lib/attestify/assertions.rb
79
79
  - lib/attestify/assertions/output_assertion.rb
80
+ - lib/attestify/autorun.rb
80
81
  - lib/attestify/cli.rb
81
82
  - lib/attestify/color_reporter.rb
82
83
  - lib/attestify/mock.rb
@@ -84,6 +85,7 @@ files:
84
85
  - lib/attestify/reporter.rb
85
86
  - lib/attestify/skipped_error.rb
86
87
  - lib/attestify/test.rb
88
+ - lib/attestify/test_executor.rb
87
89
  - lib/attestify/test_list.rb
88
90
  - lib/attestify/test_runner.rb
89
91
  - lib/attestify/timer.rb
@@ -108,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
110
  version: 1.3.1
109
111
  requirements: []
110
112
  rubyforge_project:
111
- rubygems_version: 2.5.1
113
+ rubygems_version: 2.4.8
112
114
  signing_key:
113
115
  specification_version: 4
114
116
  summary: A new way to test your code