self_testing_framework 0.0.1

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.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.swp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in self_testing_framework.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Igor Kuznetsov
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,29 @@
1
+ # SelfTestingFramework
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'self_testing_framework'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install self_testing_framework
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,21 @@
1
+ module SelfTestingFramework
2
+ class Reporter
3
+
4
+ def report(test_result)
5
+ print test_result[:error] ? 'F' : '.'
6
+ end
7
+
8
+ def total_report(test_results)
9
+ r = test_results
10
+ puts "\n\n"
11
+ r.errors.each do |e|
12
+ puts "#{e[:class_name]}##{e[:test_name]}"
13
+ puts " ERROR: #{e[:error]}"
14
+ end
15
+ puts "\n"
16
+ puts "--------------------------------------------"
17
+ #puts "Total Results:"
18
+ puts "Tests: #{r.total_count}, Passed: #{r.passed_count}, Errors: #{r.errors_count}"
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,27 @@
1
+ module SelfTestingFramework
2
+ class Runner
3
+
4
+ def initialize(classes)
5
+ @classes = classes
6
+ end
7
+
8
+ def execute
9
+ reporter = Reporter.new
10
+ test_results = TestResult.new
11
+
12
+ @classes.each do |klass|
13
+ klass.new.methods.grep(/test_/).each do |test_method|
14
+ begin
15
+ klass.run test_method
16
+ test_results.passed(klass.name, test_method)
17
+ rescue SelfTestingFramework::AssertFalse => e
18
+ test_results.errored(klass.name, test_method, e.message)
19
+ end
20
+ reporter.report test_results.last_test
21
+ end
22
+ end
23
+ reporter.total_report test_results
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,25 @@
1
+ module SelfTestingFramework
2
+ class TestCase
3
+
4
+ class << self
5
+ def run(name)
6
+ iam = new
7
+ iam.before
8
+ iam.send(name)
9
+ iam.after
10
+ end
11
+ end
12
+
13
+ def before
14
+ end
15
+
16
+ def after
17
+ end
18
+
19
+ def assert(arg, fail_message = nil)
20
+ fail_message ||= "Assertion Fails"
21
+ raise AssertFalse.new(fail_message) unless arg
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,32 @@
1
+ module SelfTestingFramework
2
+ class TestResult
3
+
4
+ attr_reader :errors_count, :passed_count, :total_count, :tests, :errors
5
+
6
+ def initialize
7
+ @errors_count = 0
8
+ @passed_count = 0
9
+ @errors = []
10
+ @tests = []
11
+ @total_count = 0
12
+ end
13
+
14
+ def passed(klass_name, test_name)
15
+ @passed_count += 1
16
+ @tests << {:class_name => klass_name, :test_name => test_name}
17
+ @total_count += 1
18
+ end
19
+
20
+ def errored(klass_name, test_name, error)
21
+ @errors_count += 1
22
+ @tests << {:class_name => klass_name, :test_name => test_name, :error => error}
23
+ @errors << {:class_name => klass_name, :test_name => test_name, :error => error}
24
+ @total_count += 1
25
+ end
26
+
27
+ def last_test
28
+ @tests.last
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,3 @@
1
+ module SelfTestingFramework
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,18 @@
1
+ require "self_testing_framework/version"
2
+ require "active_support/core_ext/class/subclasses"
3
+
4
+ module SelfTestingFramework
5
+
6
+ class AssertFalse < RuntimeError; end
7
+
8
+ autoload "TestCase", "self_testing_framework/test_case"
9
+ autoload "Runner", "self_testing_framework/runner"
10
+ autoload "TestResult", "self_testing_framework/test_result"
11
+ autoload "Reporter", "self_testing_framework/reporter"
12
+
13
+ end
14
+
15
+ at_exit do
16
+ runner = SelfTestingFramework::Runner.new(SelfTestingFramework::TestCase.descendants)
17
+ runner.execute
18
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'self_testing_framework/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "self_testing_framework"
8
+ gem.version = SelfTestingFramework::VERSION
9
+ gem.authors = ["Igor Kuznetsov", "Mikhail Stolbov"]
10
+ gem.email = ["igkuznetsov@gmail.com", "mstolbov@gmail.com"]
11
+ gem.description = %q{This gem provides a self testing framework}
12
+ gem.summary = %q{This gem provides a self testing framework written for training. Useful for studing cases.}
13
+ gem.homepage = ""
14
+
15
+ gem.add_runtime_dependency "active_support"
16
+
17
+ gem.files = `git ls-files`.split($/)
18
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
19
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
20
+ gem.require_paths = ["lib"]
21
+ end
@@ -0,0 +1,13 @@
1
+ require "test_helper"
2
+
3
+ class SelfTestingFramework::TestCaseTest < SelfTestingFramework::TestCase
4
+
5
+ def test_assert_true
6
+ assert true
7
+ end
8
+
9
+ def test_assert_false
10
+ assert false
11
+ end
12
+
13
+ end
@@ -0,0 +1,2 @@
1
+ require "bundler/setup"
2
+ Bundler.require
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: self_testing_framework
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Igor Kuznetsov
9
+ - Mikhail Stolbov
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-12-01 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: active_support
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
31
+ description: This gem provides a self testing framework
32
+ email:
33
+ - igkuznetsov@gmail.com
34
+ - mstolbov@gmail.com
35
+ executables: []
36
+ extensions: []
37
+ extra_rdoc_files: []
38
+ files:
39
+ - .gitignore
40
+ - Gemfile
41
+ - LICENSE.txt
42
+ - README.md
43
+ - Rakefile
44
+ - lib/self_testing_framework.rb
45
+ - lib/self_testing_framework/reporter.rb
46
+ - lib/self_testing_framework/runner.rb
47
+ - lib/self_testing_framework/test_case.rb
48
+ - lib/self_testing_framework/test_result.rb
49
+ - lib/self_testing_framework/version.rb
50
+ - self_testing_framework.gemspec
51
+ - test/self_testing_framework/testcase_test.rb
52
+ - test/test_helper.rb
53
+ homepage: ''
54
+ licenses: []
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubyforge_project:
73
+ rubygems_version: 1.8.24
74
+ signing_key:
75
+ specification_version: 3
76
+ summary: This gem provides a self testing framework written for training. Useful for
77
+ studing cases.
78
+ test_files:
79
+ - test/self_testing_framework/testcase_test.rb
80
+ - test/test_helper.rb
81
+ has_rdoc: