lightest 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cade7d0a5512630a8c003575360460c2dcdee56a
4
+ data.tar.gz: ecfcd4b40f1c1b72368ebbda7bd351604702b7f8
5
+ SHA512:
6
+ metadata.gz: 5295013730350d4eb3088ec71102c9e4fb5bdd3f072dae2da43b941c5fbe0c749eb33caa11836567e7f97a6f1b4b52ca2db68f36bf58fc9fec8d365f46889635
7
+ data.tar.gz: 30f0582960227c982c9c351cd08233d0991cceedcf85a2992547acc2270986f0f6d7c31f0f7383d9635f3493b53373ea95828e7fe9abca55cd0d4f0fdc6dcd6c
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ before_install: gem install bundler -v 1.13.7
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in lightest.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Thomas Cullen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,38 @@
1
+ # Lightest
2
+
3
+ A stupidly simple testing framework.
4
+
5
+ This was an experimental project inspired by Ryan Davis' incredible talk on [Writing a test framework from scratch](https://www.youtube.com/watch?v=VPr5pmlAq20).
6
+
7
+ ## Install
8
+
9
+ ```
10
+ gem 'lightest'
11
+ ```
12
+
13
+ or
14
+
15
+ ```
16
+ gem install lightest
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ Tests should be defined in methods prefixed with `_test` in classes that inherit from `Lightest::Test` in files that are prefixed with `_test.rb`
22
+
23
+ ```ruby
24
+ // basic_test.rb
25
+ class BasicTest << Lightest::Test
26
+ def simple_test
27
+ a = 1 + 1
28
+ assert a == 2, "a should be 2"
29
+ end
30
+ end
31
+ ```
32
+
33
+ You can then run the tests by simply using the `lightest` command
34
+
35
+ ## License
36
+
37
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
38
+
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :test
11
+
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "testinggem"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+
4
+ require "lightest"
5
+ Dir["#{Dir.getwd}/**/*_test.rb"].each { |f| load(f) }
6
+ Lightest.run_tests
7
+
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,22 @@
1
+ require_relative "./lightest/test"
2
+ require_relative "./lightest/reporter"
3
+
4
+ module Lightest
5
+ TESTS = []
6
+
7
+ def self.run_tests
8
+ test_files.each { |f| load(f) }
9
+ reporter = Reporter.new
10
+ TESTS.each do |test_class|
11
+ test_class.run(reporter)
12
+ end
13
+ reporter.summary
14
+ end
15
+
16
+ private
17
+
18
+ def self.test_files
19
+ Dir["#{Dir.pwd}/**/*_test.rb"]
20
+ end
21
+ end
22
+
@@ -0,0 +1,39 @@
1
+ module Lightest
2
+ class Reporter
3
+ attr_accessor :failures
4
+ attr_accessor :pass_count
5
+ attr_accessor :fail_count
6
+
7
+ def initialize
8
+ self.failures = []
9
+ self.pass_count = 0
10
+ self.fail_count = 0
11
+ end
12
+
13
+ def << result
14
+ unless result.failure? then
15
+ self.pass_count += 1
16
+ print_status
17
+ else
18
+ failures << result
19
+ self.fail_count += 1
20
+ print_status
21
+ end
22
+ end
23
+
24
+ def print_status
25
+ passed = "\033[32m #{pass_count} Passed"
26
+ failed = fail_count > 0 ? ", \033[031m #{fail_count} Failed" : ""
27
+ print "#{passed}#{failed} \r"
28
+ end
29
+
30
+ def summary
31
+ puts
32
+ failures.each do |result|
33
+ puts
34
+ puts "Fail: #{result.class}##{result.name}: #{result.failure.message}"
35
+ puts result.failure.backtrace.first
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,39 @@
1
+ module Lightest
2
+ class Test
3
+ attr_accessor :name
4
+ attr_accessor :failure
5
+ alias failure? :failure
6
+
7
+ def initialize(name)
8
+ self.name = name
9
+ self.failure = false
10
+ end
11
+
12
+ def self.inherited(test)
13
+ Lightest::TESTS << test
14
+ end
15
+
16
+ def self.run(reporter)
17
+ test_names.shuffle.each do |name|
18
+ result = self.new(name).run
19
+ reporter << result
20
+ end
21
+ end
22
+
23
+ def self.test_names
24
+ public_instance_methods.grep(/_test$/)
25
+ end
26
+
27
+ def run
28
+ send(name)
29
+ rescue => e
30
+ self.failure = e
31
+ ensure
32
+ return self
33
+ end
34
+
35
+ def assert(expression, message = "Test Failed")
36
+ raise RuntimeError, message, caller unless expression
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,3 @@
1
+ module Lightest
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'lightest/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "lightest"
8
+ spec.version = Lightest::VERSION
9
+ spec.authors = ["Thomas Cullen"]
10
+ spec.email = ["thomascullen92@gmail.com"]
11
+
12
+ spec.summary = "A super lightweight testing framework"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
16
+ f.match(%r{^(test|spec|features)/})
17
+ end
18
+
19
+ spec.executables = ["lightest"]
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.13"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ end
25
+
@@ -0,0 +1,6 @@
1
+ class LightestTest < Lightest::Test
2
+ def test_files_test
3
+ files = Lightest.test_files.select { |f| f =~ /lightest_test/ }
4
+ assert files.length > 0, "Should be able to find lightest_test.rb"
5
+ end
6
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lightest
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Thomas Cullen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-01-21 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.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
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
+ - thomascullen92@gmail.com
44
+ executables:
45
+ - lightest
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - ".travis.yml"
51
+ - Gemfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - bin/console
56
+ - bin/lightest
57
+ - bin/setup
58
+ - lib/lightest.rb
59
+ - lib/lightest/reporter.rb
60
+ - lib/lightest/test.rb
61
+ - lib/lightest/version.rb
62
+ - lightest.gemspec
63
+ - tests/lightest_test.rb
64
+ homepage:
65
+ licenses:
66
+ - MIT
67
+ metadata: {}
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubyforge_project:
84
+ rubygems_version: 2.6.8
85
+ signing_key:
86
+ specification_version: 4
87
+ summary: A super lightweight testing framework
88
+ test_files: []