ruby_tdd 0.1.6 → 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
  SHA256:
3
- metadata.gz: 60899d965739d3448fa6026744b976def9f61f1da12b7d7f2eea3d1e2d243a8a
4
- data.tar.gz: 5d6aaccf0e1b943a9af993ef7613302f6035bbc8f88ff5b07eac4fec08be3e4d
3
+ metadata.gz: 36d5fb41863c890e387737e0d977afc44893a50d1917a174ebc604991c689f2f
4
+ data.tar.gz: 4e301b225ee2c0c917bff2378fa37b5037a16351b5191ac6a6a9bd92397935fb
5
5
  SHA512:
6
- metadata.gz: 888c209b956e45710294ee322183a98cc2ff2d9b70514eafc14c31ba4b115c3ee29b6b925717cb0f4f68e886500adc057f7416c0c27bd7282e6126616aa3473b
7
- data.tar.gz: b28d768c2042b87f41e9405f0c011a02cd24019f3976fa906022be2661b0cc3d7b320e62347d8de511e5c3873a383271e5ed8af54b7d0c182fa95d903c14dc20
6
+ metadata.gz: 0463e7f464260d9bb884b86d20936717425fe80ce2febfccb610636386bb4e8dfdefd8d0d2a5a86dda080f93f7afca2b3814ca3c6986239528d8758e60a137f0
7
+ data.tar.gz: 5c31ed157453b4011f68a2b6ed61f2ad80e4f7de32fd3cb5c4b0c31714b7255e53b38dd3ff1f85eab17aabc9ac11e5e26498f70c2d53ddd4e55e7eedbb2aa812
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby_tdd (0.1.6)
4
+ ruby_tdd (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -0,0 +1,3 @@
1
+ require_relative '../ruby_tdd'
2
+
3
+ TestWatch.new(Dir.pwd + '/lib', Dir.pwd + '/tests/')
@@ -1,3 +1,3 @@
1
1
  module RubyTdd
2
- VERSION = "0.1.6"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/test_watch.rb CHANGED
@@ -1,10 +1,13 @@
1
+ require 'rbconfig'
1
2
  require 'listen'
2
3
 
3
- class TestWatch
4
- def initialize(relative_path, test_block)
5
- @relative_path = relative_path
6
- @test_block = test_block
4
+ THIS_FILE = File.expand_path(__FILE__)
5
+ RUBY = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
7
6
 
7
+ class TestWatch
8
+ def initialize(listen_to_relative_path, test_relative_path)
9
+ @listen_to_relative_path = listen_to_relative_path
10
+ @test_relative_path = test_relative_path
8
11
  start
9
12
  end
10
13
 
@@ -17,18 +20,52 @@ class TestWatch
17
20
  end
18
21
 
19
22
  def listener
20
- Listen.to(absolute_path) do
23
+ Listen.to(absolute_relative_path) do
21
24
  run
22
25
  end
23
26
  end
24
27
 
25
- def absolute_path
26
- File.expand_path(@relative_path)
28
+ def absolute_relative_path
29
+ File.expand_path(@listen_to_relative_path)
30
+ end
31
+
32
+ def absolute_test_path
33
+ File.expand_path(@test_relative_path)
27
34
  end
28
35
 
29
36
  def run
30
37
  system "clear" or system "cls"
31
- puts Time.new.inspect
32
- @test_block.call
38
+ puts test_runner_header + current_time
39
+ puts
40
+ put_lines from_test_output
41
+ end
42
+
43
+ def test_paths
44
+ Dir["#{absolute_test_path}/**/*.test.rb"]
45
+ end
46
+
47
+ def current_time
48
+ Time.new.inspect
49
+ end
50
+
51
+ def from_test_output
52
+ test_paths
53
+ .map { |path| "#{test_header_for path}:\n#{`#{RUBY} #{path}`}\n" }
54
+ .join ""
55
+ end
56
+
57
+ def test_header_for(path)
58
+ path.split('/').last.split('.').first.capitalize
59
+ end
60
+
61
+ def test_runner_header
62
+ "Running tests: "
63
+ end
64
+
65
+ def put_lines(text_with_lines)
66
+ lines = text_with_lines.split("\n")
67
+ lines.each do |line|
68
+ puts "#{line}"
69
+ end
33
70
  end
34
71
  end
@@ -0,0 +1,9 @@
1
+ require './lib/ruby_tdd'
2
+
3
+ test_case('smoke test', Proc.new {
4
+ 1 == 1
5
+ })
6
+
7
+ test_case('raises error', Proc.new {
8
+ raise 'ERROR!'
9
+ })
@@ -0,0 +1,5 @@
1
+ require './lib/ruby_tdd'
2
+
3
+ test_case('second test', Proc.new {
4
+ 2 == 2
5
+ })
data/tests/test.rb CHANGED
@@ -1,10 +1 @@
1
- require './lib/ruby_tdd'
2
-
3
- TestWatch.new('./lib', Proc.new {
4
- test_case('smoke test', Proc.new {
5
- 1 == 1
6
- })
7
- test_case('raises error', Proc.new {
8
- raise 'ERROR!'
9
- })
10
- })
1
+ require './lib/ruby_tdd/run'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_tdd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - August Alexandersson
@@ -54,10 +54,13 @@ files:
54
54
  - bin/console
55
55
  - bin/setup
56
56
  - lib/ruby_tdd.rb
57
+ - lib/ruby_tdd/run.rb
57
58
  - lib/ruby_tdd/version.rb
58
59
  - lib/stub.rb
59
60
  - lib/test_watch.rb
60
61
  - ruby_tdd.gemspec
62
+ - tests/first.test.rb
63
+ - tests/second.test.rb
61
64
  - tests/test.rb
62
65
  homepage: https://github.com/Augustalex/ruby_tdd
63
66
  licenses: