stupid_test 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +77 -0
- data/Rakefile +2 -0
- data/lib/stupid_test.rb +128 -0
- data/lib/stupid_test/version.rb +3 -0
- data/stupid_test.gemspec +23 -0
- metadata +80 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 69ff6d37a151a8693f0102330e7e80f1b0adc5ef
|
4
|
+
data.tar.gz: e72ca466eb9bd4a951945e47d3eab1b9f5afdc3d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0927a9c2aa759598f0d2ea5ffd41f7a824b408e9c3677cab2c89a6d1c6e3fea0d0212d4faa3bfb6288339376aea3a71d54c8cc37e784622ade32dcb9f125cd6d
|
7
|
+
data.tar.gz: f1d14bce98acb7117be333e088d510379e223f1dd05cb7bed174ccb0c0fe331b1c554da101128fdf54b03420291f43edc09fe53ad5ff493b29e09ab9b8884dff
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Rathesan Iyadurai
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# StupidTest
|
2
|
+
|
3
|
+
A stupid, experimental clone of Minitest.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'stupid_test'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install stupid_test
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
# in dog_test.rb
|
25
|
+
|
26
|
+
require 'stupid_test'
|
27
|
+
|
28
|
+
class Dog
|
29
|
+
def bark
|
30
|
+
"wuff"
|
31
|
+
end
|
32
|
+
|
33
|
+
def has_four_legs?
|
34
|
+
true
|
35
|
+
end
|
36
|
+
|
37
|
+
def cat?
|
38
|
+
true
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class DogTest < StupidTest::Test
|
43
|
+
def test_bark_returns_wuff
|
44
|
+
assert_equal "miau", Dog.new.bark
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_has_four_legs
|
48
|
+
assert Dog.new.has_four_legs?
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_dog_is_definitely_not_a_cat
|
52
|
+
refute Dog.new.cat?, "Dog was a cat"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
```
|
56
|
+
|
57
|
+
`$ ruby dog_test.rb` then outputs:
|
58
|
+
|
59
|
+
```
|
60
|
+
F∙F
|
61
|
+
|
62
|
+
2/3 Tests failed:
|
63
|
+
|
64
|
+
lib/dog_test.rb:18:in `test_bark_returns_wuff':
|
65
|
+
Expected: wuff
|
66
|
+
Got: miau
|
67
|
+
|
68
|
+
lib/dog_test.rb:26:in `test_dog_is_definitely_not_a_cat': Dog was a cat
|
69
|
+
```
|
70
|
+
|
71
|
+
## Contributing
|
72
|
+
|
73
|
+
1. Fork it ( https://github.com/[my-github-username]/stupid_test/fork )
|
74
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
75
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
76
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
77
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/lib/stupid_test.rb
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
# require "stupid_test/version"
|
2
|
+
|
3
|
+
# https://stackoverflow.com/questions/1489183/colorized-ruby-output
|
4
|
+
class String
|
5
|
+
def colorize(color_code)
|
6
|
+
"\e[#{color_code}m#{self}\e[0m"
|
7
|
+
end
|
8
|
+
def green
|
9
|
+
colorize 32
|
10
|
+
end
|
11
|
+
def pink
|
12
|
+
colorize 35
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module StupidTest
|
17
|
+
def self.run
|
18
|
+
Test.run
|
19
|
+
end
|
20
|
+
|
21
|
+
class Test
|
22
|
+
class << self
|
23
|
+
def tests
|
24
|
+
@tests ||= []
|
25
|
+
end
|
26
|
+
|
27
|
+
def inherited(klass)
|
28
|
+
tests << klass.new
|
29
|
+
end
|
30
|
+
|
31
|
+
def run
|
32
|
+
tests.each &:run
|
33
|
+
puts
|
34
|
+
errors = tests.flat_map(&:errors)
|
35
|
+
methods_count = tests.map(&:test_methods_count).inject &:+
|
36
|
+
if errors.any?
|
37
|
+
puts "\n#{errors.count}/#{methods_count} Tests failed:\n"\
|
38
|
+
"\n#{errors.join("\n\n")}".pink
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def errors
|
44
|
+
@errors ||= []
|
45
|
+
end
|
46
|
+
|
47
|
+
def run
|
48
|
+
test_methods.each { |m| send m }
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_methods
|
52
|
+
self.class.public_instance_methods(false)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_methods_count
|
56
|
+
test_methods.count
|
57
|
+
end
|
58
|
+
|
59
|
+
def assert_equal(expected, actual)
|
60
|
+
if expected == actual
|
61
|
+
print_success
|
62
|
+
else
|
63
|
+
report Error.new(
|
64
|
+
:expected => expected,
|
65
|
+
:actual => actual,
|
66
|
+
:location => caller[0]
|
67
|
+
)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def assert(value, message = nil)
|
72
|
+
if value
|
73
|
+
print_success
|
74
|
+
else
|
75
|
+
location = caller[0]
|
76
|
+
location = caller[1] if location.include? 'refute'
|
77
|
+
report Error.new(
|
78
|
+
:expected => value,
|
79
|
+
:actual => !value,
|
80
|
+
:location => location,
|
81
|
+
:message => message
|
82
|
+
)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def refute(value, message = nil)
|
87
|
+
assert !value, message
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
def report(e)
|
93
|
+
errors << e
|
94
|
+
print_failure
|
95
|
+
end
|
96
|
+
|
97
|
+
def print_success
|
98
|
+
print '∙'.green
|
99
|
+
end
|
100
|
+
|
101
|
+
def print_failure
|
102
|
+
print 'F'.pink
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
class Error
|
107
|
+
attr_accessor :expected, :actual, :location, :message
|
108
|
+
|
109
|
+
def initialize(args = {})
|
110
|
+
@expected = args[:expected]
|
111
|
+
@actual = args[:actual]
|
112
|
+
@location = args[:location]
|
113
|
+
@message = args[:message]
|
114
|
+
end
|
115
|
+
|
116
|
+
def to_s
|
117
|
+
"#{location}: " + message
|
118
|
+
end
|
119
|
+
|
120
|
+
def message
|
121
|
+
@message ||= "\n Expected: #{expected}\n Got: #{actual}"
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
at_exit do
|
127
|
+
StupidTest.run
|
128
|
+
end
|
data/stupid_test.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'stupid_test/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "stupid_test"
|
8
|
+
spec.version = StupidTest::VERSION
|
9
|
+
spec.authors = ["Rathesan Iyadurai"]
|
10
|
+
spec.email = ["rad.iyadurai@gmail.com"]
|
11
|
+
spec.summary = "Stupid, experimental clone of minitest"
|
12
|
+
spec.description = ""
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: stupid_test
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rathesan Iyadurai
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: ''
|
42
|
+
email:
|
43
|
+
- rad.iyadurai@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- lib/stupid_test.rb
|
54
|
+
- lib/stupid_test/version.rb
|
55
|
+
- stupid_test.gemspec
|
56
|
+
homepage: ''
|
57
|
+
licenses:
|
58
|
+
- MIT
|
59
|
+
metadata: {}
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 2.4.2
|
77
|
+
signing_key:
|
78
|
+
specification_version: 4
|
79
|
+
summary: Stupid, experimental clone of minitest
|
80
|
+
test_files: []
|