oktobertest 0.1.0 → 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
  SHA1:
3
- metadata.gz: 26c78afdc12b287e7fb1b42bc9df02edf9db80bc
4
- data.tar.gz: 395c8827be0f81e2575b57238fbb15e7c716dd5d
3
+ metadata.gz: b0f9607852623f5f9a4908be8ca040ca863957f5
4
+ data.tar.gz: 30f8a2a7b63f07bc9517456982f0aff1d21305e9
5
5
  SHA512:
6
- metadata.gz: 364372c78233456737c8b70ab2fd83ee3eb09d938c3b4ec4750848f811f2eaafc88be0240ecfd5abc54af6750d665035cb5d8a370f60f0ad0e0b11faa5465d85
7
- data.tar.gz: 0decf196630dcf487feb0b3957b5abcae7246c87204cfd9106406d9963b65e3a29365934e529a7f52de233239047b6a7cb195d5b1070fa4f4e773d2f04d4dea8
6
+ metadata.gz: ba1563ea9756c73a16ff2d72b9dec43dc380dd3d676a434f6b9c59be6d5d07809635605283206e4902a2e33da96d424e8b2c7cd116f80e6556c930412e282417
7
+ data.tar.gz: 3982d6c8217fb4617ed1ec52df46eee4aac4668cd8a567b136cfaa8fbd9ab817987f82fab4de2673eb4e0600157078838b226bf9b225f6765fbb60890cf83dbc
data/README.md CHANGED
@@ -115,10 +115,11 @@ Using `ruby`:
115
115
  $ ruby -r oktobertest test/*_test.rb
116
116
  ```
117
117
 
118
- When using `ruby` directly, you can specify two options: `--scope` and `--test`.
118
+ When using `ruby` directly, you can specify the scope (`SCOPE`) or the test
119
+ (`TEST`) to run:
119
120
 
120
121
  ```bash
121
- $ ruby -r oktobertest test/*_test.rb --test 'test this'
122
+ $ TEST='test this' ruby -r oktobertest test/*_test.rb
122
123
  ```
123
124
 
124
125
  ### Testing Rack applications
data/lib/oktobertest.rb CHANGED
@@ -1,7 +1,5 @@
1
- require 'clap'
2
-
3
1
  module Oktobertest
4
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
5
3
 
6
4
  TestFailed = Class.new StandardError
7
5
  TestSkipped = Class.new StandardError
@@ -9,17 +7,8 @@ module Oktobertest
9
7
  def self.display_errors
10
8
  puts
11
9
  errors.each do |error|
12
- case error
13
- when TestFailed
14
- file, line, _ = error.backtrace[2].split ':'
15
- print "\nerror: #{error.message}"
16
- when TestSkipped
17
- file, line, _ = error.backtrace[1].split ':'
18
- print "\nskip"
19
- else
20
- file, line, _ = error.backtrace[0].split ':'
21
- print "\nerror: #{error.message}"
22
- end
10
+ file, line, _ = error.backtrace.detect { |l| !l.match __FILE__ }.split ':'
11
+ print error.kind_of?(TestSkipped) ? "\nskip" : "\nerror: #{error.message}"
23
12
  print "\nfile: #{file}\nline: #{line}\n"
24
13
  end
25
14
  end
@@ -28,10 +17,6 @@ module Oktobertest
28
17
  @errors ||= []
29
18
  end
30
19
 
31
- def self.options
32
- @options ||= {}
33
- end
34
-
35
20
  module Assertions
36
21
  def assert(value, message = nil)
37
22
  message ||= "condition is not true: #{value.inspect}"
@@ -68,7 +53,7 @@ module Oktobertest
68
53
  end
69
54
 
70
55
  def run?
71
- !Oktobertest.options[:run_scope] || Oktobertest.options[:run_scope] == @name
56
+ !ENV['SCOPE'] || ENV['SCOPE'] == @name
72
57
  end
73
58
 
74
59
  protected
@@ -121,7 +106,7 @@ module Oktobertest
121
106
  end
122
107
 
123
108
  def run?
124
- !Oktobertest.options[:run_test] || Oktobertest.options[:run_test] == @name
109
+ !ENV['TEST'] || ENV['TEST'] == @name
125
110
  end
126
111
  end
127
112
  end
@@ -135,8 +120,4 @@ module Kernel
135
120
  end
136
121
  end
137
122
 
138
- Clap.run ARGV,
139
- '--scope' => ->(name) { Oktobertest.options[:run_scope] = name },
140
- '--test' => ->(name) { Oktobertest.options[:run_test] = name }
141
-
142
123
  at_exit { Oktobertest.display_errors }
data/oktobertest.gemspec CHANGED
@@ -21,6 +21,4 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency 'bundler', '~> 1.5'
22
22
  spec.add_development_dependency 'codeclimate-test-reporter'
23
23
  spec.add_development_dependency 'rake'
24
-
25
- spec.add_runtime_dependency 'clap', '~> 1.0.0'
26
24
  end
@@ -3,7 +3,7 @@ require 'helper'
3
3
  scope do
4
4
  test 'successful run' do
5
5
  expected = ".\n"
6
- output = %x(ruby test/fixtures/successful_test.rb)
6
+ output = %x(ruby -I lib:test test/fixtures/successful_test.rb)
7
7
  assert expected == output
8
8
  end
9
9
 
@@ -15,7 +15,7 @@ error: RuntimeError
15
15
  file: test/fixtures/error_test.rb
16
16
  line: 4
17
17
  EOS
18
- output = %x(ruby test/fixtures/error_test.rb)
18
+ output = %x(ruby -I lib:test test/fixtures/error_test.rb)
19
19
  assert expected == output
20
20
  end
21
21
 
@@ -27,7 +27,7 @@ error: condition is not true: false
27
27
  file: test/fixtures/failing_test.rb
28
28
  line: 4
29
29
  EOS
30
- output = %x(ruby test/fixtures/failing_test.rb)
30
+ output = %x(ruby -I lib:test test/fixtures/failing_test.rb)
31
31
  assert expected == output
32
32
  end
33
33
 
@@ -39,19 +39,19 @@ skip
39
39
  file: test/fixtures/skipped_test.rb
40
40
  line: 4
41
41
  EOS
42
- output = %x(ruby test/fixtures/skipped_test.rb)
42
+ output = %x(ruby -I lib:test test/fixtures/skipped_test.rb)
43
43
  assert expected == output
44
44
  end
45
45
 
46
46
  test 'run only one scope' do
47
47
  expected = "..\n"
48
- output = %x(ruby test/fixtures/run_scope_test.rb --scope 'run this')
48
+ output = %x(SCOPE='run this' ruby -I lib:test test/fixtures/run_scope_test.rb)
49
49
  assert expected == output
50
50
  end
51
51
 
52
52
  test 'run only one test' do
53
53
  expected = ".\n"
54
- output = %x(ruby test/fixtures/run_test_test.rb --test 'run this')
54
+ output = %x(TEST='run this' ruby -I lib:test test/fixtures/run_test_test.rb)
55
55
  assert expected == output
56
56
  end
57
57
  end
data/test/scope_test.rb CHANGED
@@ -26,6 +26,10 @@ scope do
26
26
  def foo
27
27
  'foo'
28
28
  end
29
+
30
+ test 'responds to foo' do
31
+ assert respond_to? :foo
32
+ end
29
33
  end
30
34
 
31
35
  scope do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oktobertest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patricio Mac Adden
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-05 00:00:00.000000000 Z
11
+ date: 2014-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: clap
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: 1.0.0
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: 1.0.0
69
55
  description: Small test library
70
56
  email:
71
57
  - patriciomacadden@gmail.com