fried-test 0.5.1 → 1.0.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: 5d7a984e66ed0f83bab50c34eccd6aa17fb5d60a
4
- data.tar.gz: bbbae73358678dcad8727ea0fa788b8053bcce7d
3
+ metadata.gz: 2d46219ca40b00b37129cc0a978378f371d8b528
4
+ data.tar.gz: 67a15b62486e81d34d2501a89b298a7071913203
5
5
  SHA512:
6
- metadata.gz: 8f77e98a421e2290e39c6ec197c64170cb08c7c1ef2f6ab45d70ab4f2c313eaafc71ca65bd7ecf9643f851f4b6639094b51b94fbcff5db2fe846a028bc300089
7
- data.tar.gz: 5ee3b09130bd002e553c578134158905ea6d5d16169960ee96b6d709edf3fc0b6329ddc4a5b581bb8bdbb848537dd6ce54794e148a859b45176ced690ac1e617
6
+ metadata.gz: 07a87e887d707f93130fe9acafb1f48433171357a25d756dc4af368776525da03b25592dbe1c02579377ba89d48cfc81e1fdfeec113969cec81305c89091b2e8
7
+ data.tar.gz: 72180d22728be5d4cd41a61110b4965b137ecc93379ff5d03141d4d4ed9b12c7f77b7e1e95efb552214509eb3ee627b741a215d22fa3c987989ebf3c882e8b11
data/README.md CHANGED
@@ -5,6 +5,9 @@ opinionated wrapper around `minitest/autorun`. You can run `friest` and it
5
5
  will run the test suite automatically for any test found in the directory
6
6
  `test` with any file ending with `_test.rb`.
7
7
 
8
+ It automatically includes (and uses) the Progress Report (you can overwrite
9
+ it), and `minitest-focus` for when you need it.
10
+
8
11
  ## Philosophy
9
12
 
10
13
  This gem is mainly a **philosophy** on how your tests should be written.
@@ -31,4 +31,5 @@ Gem::Specification.new do |spec|
31
31
  spec.add_runtime_dependency "fried-core"
32
32
  spec.add_runtime_dependency "minitest"
33
33
  spec.add_runtime_dependency "minitest-reporters"
34
+ spec.add_runtime_dependency "minitest-focus"
34
35
  end
@@ -2,36 +2,46 @@ require "fried/core"
2
2
  require "fried/test/load_test_files"
3
3
  require "fried/test/load_tests_path"
4
4
  require "fried/test/autorun"
5
+ require "fried/test/get_options"
6
+ require "fried/test/load_plugins"
5
7
 
6
8
  module Fried::Test
7
9
  class CLI
8
10
  attr_accessor :load_tests_path
9
11
  attr_accessor :load_test_files
12
+ attr_accessor :load_plugins
10
13
  attr_accessor :autorun
14
+ attr_accessor :get_options
11
15
 
12
16
  def initialize
13
17
  @load_tests_path = LoadTestsPath.new
14
18
  @load_test_files = LoadTestFiles.new
19
+ @load_plugins = LoadPlugins.new
15
20
  @autorun = Autorun.new
21
+ @get_options = GetOptions.new
16
22
  end
17
23
 
18
24
  def self.build
19
25
  new.tap do |instance|
20
26
  instance.load_tests_path = LoadTestsPath.build
21
27
  instance.load_test_files = LoadTestFiles.build
28
+ instance.load_plugins = LoadPlugins.build
22
29
  instance.autorun = Autorun.build
30
+ instance.get_options = GetOptions.build
23
31
  end
24
32
  end
25
33
 
26
- def call
34
+ def call(argv = ARGV)
35
+ load_plugins.()
36
+ options = get_options.(argv)
27
37
  load_tests_path.()
28
- load_test_files.()
38
+ load_test_files.(options)
29
39
  autorun.()
30
40
  end
31
41
 
32
- def self.call
42
+ def self.call(argv = ARGV)
33
43
  instance = build
34
- instance.()
44
+ instance.(argv)
35
45
  end
36
46
  end
37
47
  end
@@ -0,0 +1,22 @@
1
+ require "fried/core"
2
+ require "fried/test/options"
3
+
4
+ module Fried::Test
5
+ class GetOptions
6
+ def self.build
7
+ new
8
+ end
9
+
10
+ def self.call
11
+ instance = build
12
+ instance.()
13
+ end
14
+
15
+ # @param argv [Array<String>]
16
+ # @return [Options]
17
+ def call(argv)
18
+ file = ARGV.last
19
+ Options.build(file: file)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,34 @@
1
+ require "fried/core"
2
+ require "fried/test/directory/current_working_directory"
3
+
4
+ module Fried::Test
5
+ class GetSingleTestFile
6
+ CurrentWorkingDirectory = Directory::CurrentWorkingDirectory
7
+
8
+ attr_accessor :current_working_directory
9
+
10
+ def initialize
11
+ self.current_working_directory = CurrentWorkingDirectory.new
12
+ end
13
+
14
+ def self.build
15
+ new.tap do |instance|
16
+ instance.current_working_directory = CurrentWorkingDirectory.build
17
+ end
18
+ end
19
+
20
+ def self.call(file)
21
+ instance = build
22
+ instance.(file)
23
+ end
24
+
25
+ # @param file [String]
26
+ # @return [Array<Pathname>]
27
+ def call(file)
28
+ directory = current_working_directory.()
29
+ test_file_path = directory.join(file.to_s)
30
+
31
+ [test_file_path]
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,23 @@
1
+ require "fried/core"
2
+
3
+ module Fried::Test
4
+ class LoadPlugins
5
+ def self.build
6
+ new
7
+ end
8
+
9
+ def self.call
10
+ instance = build
11
+ instance.()
12
+ end
13
+
14
+ # @return [void]
15
+ def call
16
+ require "minitest/spec"
17
+ require "minitest/focus"
18
+ require "minitest/reporters"
19
+ reporter = Minitest::Reporters::ProgressReporter.new
20
+ Minitest::Reporters.use!(reporter)
21
+ end
22
+ end
23
+ end
@@ -1,5 +1,7 @@
1
1
  require "fried/core"
2
2
  require "fried/test/get_test_files"
3
+ require "fried/test/get_single_test_file"
4
+ require "fried/test/options"
3
5
 
4
6
  module Fried::Test
5
7
  # Load test files using {require_relative}
@@ -7,33 +9,46 @@ module Fried::Test
7
9
  class Substitute
8
10
  include ::Fried::Test::Telemetry
9
11
 
10
- def call
11
- record :call
12
+ def call(options = Options::Default)
13
+ record :call, options
12
14
  nil
13
15
  end
14
16
  end
15
17
 
16
18
  attr_accessor :get_test_files
19
+ attr_accessor :get_single_test_file
17
20
 
18
21
  def initialize
19
22
  @get_test_files = GetTestFiles.new
23
+ @get_single_test_file = GetSingleTestFile.new
20
24
  end
21
25
 
22
26
  def self.build
23
27
  new.tap do |instance|
24
28
  instance.get_test_files = GetTestFiles.build
29
+ instance.get_single_test_file = GetSingleTestFile.build
25
30
  end
26
31
  end
27
32
 
33
+ def self.call(options = Options::Default)
34
+ instance = build
35
+ instance.(options)
36
+ end
37
+
28
38
  # @return [void]
29
- def call
30
- test_files = get_test_files.()
39
+ def call(options = Options::Default)
40
+ test_files = fetch_files(options)
31
41
  test_files.each { |file| require_relative file.to_s }
32
42
  end
33
43
 
34
- def self.call
35
- instance = build
36
- instance.()
44
+ private
45
+
46
+ def fetch_files(options)
47
+ if options.single_file?
48
+ get_single_test_file.(options.file)
49
+ else
50
+ get_test_files.()
51
+ end
37
52
  end
38
53
  end
39
54
  end
@@ -0,0 +1,19 @@
1
+ require "fried/core"
2
+
3
+ module Fried::Test
4
+ class Options
5
+ Default = new.freeze
6
+
7
+ attr_accessor :file
8
+
9
+ def self.build(file: nil)
10
+ new.tap do |instance|
11
+ instance.file = file
12
+ end
13
+ end
14
+
15
+ def single_file?
16
+ !file.nil?
17
+ end
18
+ end
19
+ end
@@ -1,5 +1,5 @@
1
1
  module Fried
2
2
  module Test
3
- VERSION = "0.5.1"
3
+ VERSION = "1.0.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fried-test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fire-Dragon-DoL
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-18 00:00:00.000000000 Z
11
+ date: 2018-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: minitest-focus
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  description: Minitest helpers and testing philosophy
98
112
  email:
99
113
  - francesco.belladonna@gmail.com
@@ -118,11 +132,15 @@ files:
118
132
  - lib/fried/test/cli.rb
119
133
  - lib/fried/test/directory/current_working_directory.rb
120
134
  - lib/fried/test/directory/get_files_by_pattern.rb
135
+ - lib/fried/test/get_options.rb
136
+ - lib/fried/test/get_single_test_file.rb
121
137
  - lib/fried/test/get_test_directory.rb
122
138
  - lib/fried/test/get_test_files.rb
139
+ - lib/fried/test/load_plugins.rb
123
140
  - lib/fried/test/load_test_files.rb
124
141
  - lib/fried/test/load_tests_path.rb
125
142
  - lib/fried/test/noop.rb
143
+ - lib/fried/test/options.rb
126
144
  - lib/fried/test/prepend_to_load_path.rb
127
145
  - lib/fried/test/rake.rb
128
146
  - lib/fried/test/telemetry.rb