sfb_scripts 0.1.9 → 0.2.0

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: 1c4ffa5f6768611b201947a331bc2d19b6c4f33e
4
- data.tar.gz: 1e12c961a87746e5887e2b816dd3fc9471b1a677
3
+ metadata.gz: aa1bfa22f42bad325e3fae6d68a8cf56ae0ddadf
4
+ data.tar.gz: ef3751b60b61a8ccf310cb1f4bc6ccd08dd54361
5
5
  SHA512:
6
- metadata.gz: 06b67e433f81d759194d524ea86ae36fabbd883ed5479f3de148c392d42ed0e289ba2e922bc59dcef4e75feddf07c81ba07bf1829495619e2ed210fce8338a49
7
- data.tar.gz: 9317810f154b2ab142732c27c11e5855c38a00ae08175166961ff3718a52188300620d891e77ffa9b08f2054b70f308ff36cf2b6208d2ea9b55587060db27b4a
6
+ metadata.gz: 623055c0dbf1357e7ca7c91ea2d1632d6456c5e842e89cc7d7691dcb0e2d98ce1b20902b28ef8b30d5af6a8d81fcbaba21ffd8fac848bc3b9f669d099ae54154
7
+ data.tar.gz: 12c2377cf70bbfab5505e18847994f2538cc747a5ed6b6836e86b462877e13693da6e515f70b4a0aace25487ffeecf92f4522f15ce2733b935e1a52956bfd5df
@@ -84,7 +84,8 @@ class TestCollection
84
84
  private
85
85
 
86
86
  def find_test_name(grepped_line)
87
- return nil unless grepped_line
87
+ return nil unless grepped_line && grepped_line.match(/^\s*def\s+test_/)
88
+
88
89
  grepped_line.strip.gsub(/^\s*def /, '').strip
89
90
  end
90
91
 
@@ -92,7 +93,6 @@ class TestCollection
92
93
  file_path = test_data[:file]
93
94
  test_name = find_test_name(test_data[:line])
94
95
  return nil if ! file_path.match(/_test\.rb/)
95
- return nil if (test_name && ! test_name.match(/^test_/))
96
96
 
97
97
  TestCase.new(
98
98
  full_path: file_path,
@@ -21,11 +21,9 @@ class TestFileRunner
21
21
  inputs.each {|input| files << repo.find_files(input).map {|f| {:file => f} } }
22
22
  files.flatten!
23
23
  @tests = TestCollection.new(files)
24
- if @tests.present?
25
- test_runner.run_files(tests)
26
- else
27
- shell.notify "Could not find matching test file."
28
- end
24
+
25
+ return false unless @tests.present?
26
+ test_runner.run_files(tests)
29
27
  end
30
28
 
31
29
  def status
@@ -4,11 +4,16 @@ class TestMethodRunner
4
4
  new(env).run(regex)
5
5
  end
6
6
 
7
+ def self.run_file_with_match(regex, env)
8
+ new(env, pure_regex: true).run(regex)
9
+ end
10
+
7
11
  attr_reader :regex, :repo, :shell, :test_runner
8
- def initialize(env)
12
+ def initialize(env, pure_regex: false)
9
13
  @repo = env[:repo]
10
14
  @shell = env[:shell]
11
15
  @test_runner = env[:test_runner]
16
+ @pure_regex = pure_regex
12
17
  end
13
18
 
14
19
  def run(regex)
@@ -18,7 +23,11 @@ class TestMethodRunner
18
23
  shell.notify "Could not find matching test method."
19
24
  return false
20
25
  elsif tests.size == 1
21
- test_runner.run_method(tests.first)
26
+ if @pure_regex
27
+ test_runner.run_files(tests)
28
+ else
29
+ test_runner.run_method(tests.first)
30
+ end
22
31
  elsif tests.in_one_file?
23
32
  shell.notify "Multiple matches in same file. Running that file."
24
33
  test_runner.run_files(tests)
@@ -38,7 +47,7 @@ class TestMethodRunner
38
47
  end
39
48
 
40
49
  def find_tests_by_name
41
- test_def_regex = "^\s*def .*#{regex}.*"
50
+ test_def_regex = @pure_regex ? regex : "^\s*def .*#{regex}.*"
42
51
  begin
43
52
  return repo.grep(test_def_regex, file_pattern: '*_test.rb')
44
53
  rescue ShellRunner::CommandFailureError
@@ -32,7 +32,11 @@ class Tester
32
32
  if query_might_be_method?(inputs)
33
33
  TestMethodRunner.run(inputs.first, env)
34
34
  end
35
+
35
36
  TestFileRunner.find(inputs, env)
37
+
38
+ TestMethodRunner.run_file_with_match(inputs.first, env)
39
+
36
40
  env[:shell].warn "Giving up :("
37
41
  end
38
42
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sfb_scripts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Kinnecom