koine-test_runner 0.1.1 → 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
  SHA256:
3
- metadata.gz: 9ec65d3c6a1db49c56ceea5afb66ee6b8398f3a94849e2833c7d547eb44ae735
4
- data.tar.gz: d68aced56021535a0ba39c885903f4a2e5d498781e361540594cded8ff70093b
3
+ metadata.gz: 3afa12768cac1b4e38bc04ca4a126bfca0820a6ebf177afd7b3a1c5c4bb4aa43
4
+ data.tar.gz: 5e7d634096d91b84989f27eda80fd6478e49269ff16043555f106dd84ccde05a
5
5
  SHA512:
6
- metadata.gz: 2d923060a8fa002b2355e0bce237c714896bc5cdb3093b68adab680e12584e25f017097212864419f4770cb920d1998f3ac9b419ee42f9c694c762df3e6248ac
7
- data.tar.gz: fde040a024de8232e46eea1db6f27e29e1bc2c1ccb473ac4dc1d1faae9a6b1291b615bdafe2fe5173f771c432c4440fff3ee98e8d01f70c995dc1b0d5e61c368
6
+ metadata.gz: 160955b9b2280d0de4b90f26641a89c46537390c43bbab4eddc426fbced9180582bfe46c304b339eedee3c5e17075a5034481709b0b2762f413b816b349f372c
7
+ data.tar.gz: d77b6ccc215804d6f5a664fcbc69e0c5239fede453045da085c9110bf2bb8c60ab91b3a8c08fa8494867ad2c91747f5fa2578b7fc9a35c286cd2579e34c946bd
data/.rubocop.yml CHANGED
@@ -18,13 +18,16 @@ Metrics/MethodLength:
18
18
  Metrics/CyclomaticComplexity:
19
19
  Max: 7
20
20
 
21
+ Style/SpecialGlobalVars:
22
+ Enabled: false
23
+
21
24
  Style/GuardClause:
22
25
  Enabled: false
23
26
 
24
27
  Style/IfUnlessModifier:
25
28
  Enabled: false
26
29
 
27
- Style/PredicateName:
30
+ Naming/PredicateName:
28
31
  NamePrefix:
29
32
  - is_
30
33
  - has_
@@ -46,5 +49,5 @@ AllCops:
46
49
  Exclude:
47
50
  - Gemfile
48
51
 
49
- Style/ExtraSpacing:
52
+ Layout/ExtraSpacing:
50
53
  AllowForAlignment: true
data/.travis.yml CHANGED
@@ -12,3 +12,4 @@ before_install: gem install bundler -v 1.14.6
12
12
  script:
13
13
  - bundle exec rspec
14
14
  - ./tests/integration_tests.sh
15
+ - bundle exec rubocop
data/README.md CHANGED
@@ -43,27 +43,28 @@ bundle exec run_test some/file_spec.custom
43
43
  # .test_runner.yml
44
44
 
45
45
  adapters:
46
- minitest:
47
- adapter: Koine\TestRunner\Adapter\Ruby\Minitest
48
- file_pattern: "*_test.rb"
49
-
50
46
  rspec:
51
- adapter: Koine\TestRunner\Adapter\Ruby\RSpec
47
+ adapter: rspec
52
48
  file_pattern: "*_spec.rb"
53
49
 
54
50
  phpunit:
55
- adapter: Koine\TestRunner\Adapter\Php\PHPUnit
51
+ adapter: phpunit
56
52
  file_pattern: "*Test.php"
57
53
 
58
- codeception:
59
- adapter: Koine\TestRunner\Adapter\Php\Codeception
60
- file_pattern: "*Spec.php"
61
-
62
54
  jest:
63
- adapter: Koine\TestRunner\Adapter\Javascript\Jest
64
- file_pattern: "*_(test|spec).(js|jsx)"
65
-
55
+ adapter: custom
56
+ file_pattern: "client/.*.spec.js"
57
+ command: "./node_modules/.bin/jest"
58
+ commands:
59
+ all: "{command}"
60
+ file: "{command} {file}"
61
+ # oops, jest does not really filter by line
62
+ line: "{command} {file}"
63
+
64
+ # TODO
66
65
  My::CustoAdapter:
66
+ require:
67
+ - some/file
67
68
  adapter: MyCustomAdapter
68
69
  suffix: '_spec.custom'
69
70
  ```
@@ -1,4 +1,4 @@
1
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  require 'koine/test_runner'
@@ -35,5 +35,6 @@ Gem::Specification.new do |spec|
35
35
  spec.add_development_dependency 'object_comparator', '~> 0.1.3'
36
36
  spec.add_development_dependency 'rake', '~> 10.0'
37
37
  spec.add_development_dependency 'rspec', '~> 3.0'
38
+ spec.add_development_dependency 'rubocop', '~> 0.53.0'
38
39
  spec.add_development_dependency 'simplecov', '~> 0.14.1'
39
40
  end
@@ -4,9 +4,7 @@ module Koine
4
4
  class BaseAdapter
5
5
  # attr_writer :next_adapter
6
6
 
7
- def next_adapter=(adapter)
8
- @next_adapter = adapter
9
- end
7
+ attr_writer :next_adapter
10
8
 
11
9
  def next_adapter
12
10
  @next_adapter || raise("next_adapter is not set for #{self.class}")
@@ -1,7 +1,7 @@
1
1
  module Koine
2
2
  class TestRunner
3
3
  class Adapters
4
- class BaseRegexpAdapter < BaseAdapter
4
+ class BaseRegexp < BaseAdapter
5
5
  def initialize(file_pattern:)
6
6
  @file_pattern = file_pattern.is_a?(Regexp) ? file_pattern : Regexp.new(file_pattern)
7
7
  end
@@ -0,0 +1,41 @@
1
+ module Koine
2
+ class TestRunner
3
+ class Adapters
4
+ class Custom < BaseRegexp
5
+ def initialize(file_pattern:, command: nil, commands: {})
6
+ super(file_pattern: file_pattern)
7
+ @command = command
8
+ @commands = {}.tap do |hash|
9
+ commands.each do |key, value|
10
+ hash[key.to_sym] = value
11
+ end
12
+ end
13
+ end
14
+
15
+ private
16
+
17
+ def all_tests(config)
18
+ command(command_for(:all), config)
19
+ end
20
+
21
+ def single_file_command(config)
22
+ command(command_for(:file), config)
23
+ end
24
+
25
+ def file_line_command(config)
26
+ command(command_for(:line), config)
27
+ end
28
+
29
+ def command_for(type)
30
+ @commands.fetch(type).to_s
31
+ end
32
+
33
+ def command(template, config)
34
+ template.sub('{command}', @command)
35
+ .sub('{file}', config.file_path.to_s)
36
+ .sub('{line}', config.line.to_s)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -1,7 +1,7 @@
1
1
  module Koine
2
2
  class TestRunner
3
3
  class Adapters
4
- class LastCommandAdapter < BaseAdapter
4
+ class LastCommand < BaseAdapter
5
5
  def initialize(storage: Storage.new)
6
6
  @storage = storage
7
7
  end
@@ -1,7 +1,7 @@
1
1
  module Koine
2
2
  class TestRunner
3
3
  class Adapters
4
- class NullAdapter
4
+ class Null
5
5
  def test_command(_config)
6
6
  nil
7
7
  end
@@ -1,7 +1,7 @@
1
1
  module Koine
2
2
  class TestRunner
3
3
  class Adapters
4
- class Phpunit < BaseRegexpAdapter
4
+ class Phpunit < BaseRegexp
5
5
  DEFAULT_OPTIONS = [
6
6
  '--color'
7
7
  ].freeze
@@ -1,7 +1,7 @@
1
1
  module Koine
2
2
  class TestRunner
3
3
  class Adapters
4
- class Rspec < BaseRegexpAdapter
4
+ class Rspec < BaseRegexp
5
5
  def initialize(file_pattern: /.*_spec.rb$/)
6
6
  super(file_pattern: file_pattern)
7
7
  end
@@ -1,11 +1,11 @@
1
1
  module Koine
2
2
  class TestRunner
3
3
  class Adapters
4
- def initialize(adapters = [], fallback: LastCommandAdapter.new)
4
+ def initialize(adapters = [], fallback: LastCommand.new)
5
5
  adapters = adapters.dup
6
6
 
7
7
  adapters.unshift(fallback)
8
- adapters.push(Adapters::NullAdapter.new)
8
+ adapters.push(Adapters::Null.new)
9
9
 
10
10
  adapters.inject do |previous, adapter|
11
11
  previous.next_adapter = adapter
@@ -22,20 +22,25 @@ module Koine
22
22
  end
23
23
 
24
24
  def build_adapter(config)
25
- adapter = config.delete('adapter')
25
+ adapter_name = config.delete('adapter')
26
+ adapter_class = adapter_name
26
27
 
27
- if adapter.downcase == adapter.to_s
28
- adapter_class = "Koine::TestRunner::Adapters::#{adapter.capitalize}"
28
+ if adapter_class.downcase == adapter_class.to_s
29
+ adapter_class = "Koine::TestRunner::Adapters::#{classify(adapter_class)}"
29
30
  end
30
31
 
31
32
  unless Object.const_defined?(adapter_class)
32
- raise ArgumentError, "Cannot locate adapter #{adapter} => #{adapter_class}"
33
+ raise ArgumentError, "Cannot locate adapter #{adapter_name} => #{adapter_class}"
33
34
  end
34
35
 
35
36
  klass = Object.const_get(adapter_class)
36
37
  klass.new(symbolize_keys(config))
37
38
  end
38
39
 
40
+ def classify(klass)
41
+ klass.to_s.split('_').map(&:capitalize).join('')
42
+ end
43
+
39
44
  def symbolize_keys(hash)
40
45
  {}.tap do |new_hash|
41
46
  hash.each do |key, value|
@@ -27,7 +27,7 @@ module Koine
27
27
  def config_file
28
28
  return @options[:config_file] if @options[:config_file]
29
29
  return '.test_runner.yml' if File.exist?('.test_runner.yml')
30
- File.expand_path('../../../../config/default.yml', __FILE__)
30
+ File.expand_path('../../../config/default.yml', __dir__)
31
31
  end
32
32
 
33
33
  def run_options
@@ -11,8 +11,8 @@ module Koine
11
11
  length = @lines.length
12
12
  slice = length - line
13
13
  lines = @lines.reverse.slice(slice, length)
14
- lines.each do |line|
15
- match = regexp.match(line)
14
+ lines.each do |file_line|
15
+ match = regexp.match(file_line)
16
16
  return match if match
17
17
  end
18
18
 
@@ -1,3 +1,3 @@
1
1
  class TestRunner
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
@@ -4,15 +4,16 @@ require 'koine/test_runner/configuration'
4
4
  require 'koine/test_runner/builder'
5
5
  require 'koine/test_runner/adapters'
6
6
  require 'koine/test_runner/adapters/base_adapter'
7
- require 'koine/test_runner/adapters/null_adapter'
8
- require 'koine/test_runner/adapters/last_command_adapter'
7
+ require 'koine/test_runner/adapters/base_regexp'
8
+ require 'koine/test_runner/adapters/custom'
9
+ require 'koine/test_runner/adapters/null'
10
+ require 'koine/test_runner/adapters/last_command'
9
11
 
10
12
  module Koine
11
13
  class TestRunner
12
14
  autoload :FileMatcher, 'koine/test_runner/file_matcher'
13
15
 
14
16
  class Adapters
15
- autoload :BaseRegexpAdapter, 'koine/test_runner/adapters/base_regexp_adapter'
16
17
  autoload :Rspec, 'koine/test_runner/adapters/rspec'
17
18
  autoload :Phpunit, 'koine/test_runner/adapters/phpunit'
18
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: koine-test_runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcelo Jacobus
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-16 00:00:00.000000000 Z
11
+ date: 2018-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '3.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.53.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.53.0
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: simplecov
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -120,9 +134,10 @@ files:
120
134
  - lib/koine/test_runner.rb
121
135
  - lib/koine/test_runner/adapters.rb
122
136
  - lib/koine/test_runner/adapters/base_adapter.rb
123
- - lib/koine/test_runner/adapters/base_regexp_adapter.rb
124
- - lib/koine/test_runner/adapters/last_command_adapter.rb
125
- - lib/koine/test_runner/adapters/null_adapter.rb
137
+ - lib/koine/test_runner/adapters/base_regexp.rb
138
+ - lib/koine/test_runner/adapters/custom.rb
139
+ - lib/koine/test_runner/adapters/last_command.rb
140
+ - lib/koine/test_runner/adapters/null.rb
126
141
  - lib/koine/test_runner/adapters/phpunit.rb
127
142
  - lib/koine/test_runner/adapters/rspec.rb
128
143
  - lib/koine/test_runner/builder.rb