microspec 0.1.0.beta3
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 +7 -0
- data/.gitignore +15 -0
- data/.travis.yml +11 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +34 -0
- data/Rakefile +24 -0
- data/lib/microspec/context.rb +10 -0
- data/lib/microspec/expectation.rb +49 -0
- data/lib/microspec/flunked.rb +15 -0
- data/lib/microspec/predicates.rb +16 -0
- data/lib/microspec/raise.rb +33 -0
- data/lib/microspec/runner.rb +36 -0
- data/lib/microspec/scope.rb +100 -0
- data/lib/microspec/spec.rb +29 -0
- data/lib/microspec/version.rb +3 -0
- data/lib/microspec.rb +5 -0
- data/microspec.gemspec +24 -0
- data/spec/microspec/expectation.rb +133 -0
- data/spec/microspec/raise.rb +57 -0
- data/spec/microspec/scope.rb +93 -0
- metadata +109 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: eb62dd0a6caad6dd7e63ce8c2cf6976ad57285ad
|
4
|
+
data.tar.gz: 6f75dbc1f3de73a8900b590cdf2b0ab05031fffb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: aea5d0d34e2bfdfc6bc42c5c333e249bfb7cad1adef3496cb0ecae726568118630d52ace61dce9acec7a3530e166e6c8ed339c107251b8b501dd56d155b280be
|
7
|
+
data.tar.gz: 7435d5ec8341ea6b4ff62a995392378b2c4a51edbf4dbaaa73918ad42488d3b8c1c543b29c6e7349634e0c2e9dd7ea7e1e0b064a451afe83ae53eaf7402282db
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.0.0
|
4
|
+
- 2.1.5
|
5
|
+
- 2.2.0
|
6
|
+
env:
|
7
|
+
- CODECLIMATE_REPO_COVERAGE=true
|
8
|
+
addons:
|
9
|
+
code_climate:
|
10
|
+
repo_token:
|
11
|
+
secure: "a8O1A7NSj4RBWKDGH31PG0RY2aATpVc6neC+kCTsSbqip6LE0JrJHSWbvF4TDD5SrgJc+s55elwkVOLRVsCeBL45+T4lOdopUr5n6nEz9ChUX2AeaT1V/fw/tAVKi/5tdMpCh72+CMiTsJsHxaSF1McA74A57pOtyu0ea/QHCKQ="
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Erol Fornoles
|
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,34 @@
|
|
1
|
+
[](https://codeclimate.com/github/Erol/microspec)
|
2
|
+
[](https://codeclimate.com/github/Erol/microspec)
|
3
|
+
|
4
|
+
# Microspec
|
5
|
+
|
6
|
+
TODO: Write a gem description
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'microspec'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install microspec
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
TODO: Write usage instructions here
|
27
|
+
|
28
|
+
## Contributing
|
29
|
+
|
30
|
+
1. Fork it ( https://github.com/[my-github-username]/microspec/fork )
|
31
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
32
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
33
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
34
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
|
3
|
+
$VERBOSE = true
|
4
|
+
|
5
|
+
desc 'Run gem specs'
|
6
|
+
task :spec do
|
7
|
+
if ENV['CODECLIMATE_REPO_COVERAGE']
|
8
|
+
require "codeclimate-test-reporter"
|
9
|
+
|
10
|
+
CodeClimate::TestReporter.start
|
11
|
+
end
|
12
|
+
|
13
|
+
require 'microspec'
|
14
|
+
|
15
|
+
runner = Microspec::Runner.new
|
16
|
+
runner.includes << 'spec/**/*.rb'
|
17
|
+
runner.excludes << 'spec/examples/**/*.rb'
|
18
|
+
|
19
|
+
success = runner.perform
|
20
|
+
|
21
|
+
exit 1 unless success
|
22
|
+
end
|
23
|
+
|
24
|
+
task :default => :spec
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'microspec/predicates'
|
2
|
+
|
3
|
+
module Microspec
|
4
|
+
module Expectation
|
5
|
+
def self.type(boolean)
|
6
|
+
boolean ? 'assert' : 'refute'
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.evaluate(boolean, actual, method, expected, type: type(boolean), &block)
|
10
|
+
if boolean ^ actual.send(method, *expected)
|
11
|
+
raise Flunked.new "failed #{type}", actual: actual, method: method, expected: expected
|
12
|
+
end
|
13
|
+
|
14
|
+
rescue NoMethodError => exception
|
15
|
+
if predicate = Predicates[method]
|
16
|
+
if boolean ^ predicate.call(actual, *expected, &block)
|
17
|
+
raise Flunked.new "failed #{type}", actual: actual, method: method, expected: expected
|
18
|
+
end
|
19
|
+
else
|
20
|
+
raise exception
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
module Methods
|
25
|
+
def asserts(object)
|
26
|
+
Object.new true, object
|
27
|
+
end
|
28
|
+
|
29
|
+
def refutes(object)
|
30
|
+
Object.new false, object
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class Object
|
35
|
+
def initialize(boolean, actual)
|
36
|
+
@_boolean = boolean
|
37
|
+
@_actual = actual
|
38
|
+
end
|
39
|
+
|
40
|
+
def ==(expected)
|
41
|
+
method_missing :==, expected
|
42
|
+
end
|
43
|
+
|
44
|
+
def method_missing(method, *expected, &block)
|
45
|
+
Expectation.evaluate @_boolean, @_actual, method, expected
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Microspec
|
2
|
+
module Predicates
|
3
|
+
@_predicates = {}
|
4
|
+
|
5
|
+
def self.[](method)
|
6
|
+
@_predicates[method]
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.[]=(method, proc)
|
10
|
+
@_predicates[method] = proc
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
Predicates[:truthy?] = -> (actual) { actual }
|
15
|
+
Predicates[:falsey?] = -> (actual) { !actual }
|
16
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'microspec/flunked'
|
2
|
+
|
3
|
+
module Microspec
|
4
|
+
module Raise
|
5
|
+
module Helper
|
6
|
+
def self.exception(expected: nil, actual: nil, message: nil)
|
7
|
+
if actual.nil?
|
8
|
+
Flunked.new 'missing exception', expected: expected, actual: actual
|
9
|
+
elsif not actual.is_a? expected.class
|
10
|
+
Flunked.new 'unexpected exception', expected: expected, actual: actual
|
11
|
+
elsif message.is_a? String and not actual.message == message
|
12
|
+
Flunked.new 'unexpected exception message', expected: expected, actual: actual
|
13
|
+
elsif message.is_a? Regexp and not actual.message =~ message
|
14
|
+
Flunked.new 'unexpected exception message', expected: expected, actual: actual
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
module Method
|
20
|
+
def raises(expected = Exception, message = nil)
|
21
|
+
expected = expected.new message if expected.is_a? Class
|
22
|
+
|
23
|
+
yield
|
24
|
+
|
25
|
+
rescue Exception => actual
|
26
|
+
ensure
|
27
|
+
exception = Helper.exception expected: expected, actual: actual, message: message
|
28
|
+
|
29
|
+
raise exception if exception
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'microspec/scope'
|
2
|
+
|
3
|
+
module Microspec
|
4
|
+
class Runner
|
5
|
+
def requires
|
6
|
+
@_requires ||= []
|
7
|
+
end
|
8
|
+
|
9
|
+
def includes
|
10
|
+
@_includes ||= []
|
11
|
+
end
|
12
|
+
|
13
|
+
def excludes
|
14
|
+
@_excludes ||= []
|
15
|
+
end
|
16
|
+
|
17
|
+
def filenames
|
18
|
+
Dir[*includes] - Dir[*excludes] - requires
|
19
|
+
end
|
20
|
+
|
21
|
+
def perform
|
22
|
+
requires.each do |filename|
|
23
|
+
require File.join Dir.pwd, filename
|
24
|
+
end
|
25
|
+
|
26
|
+
filenames.each do |filename|
|
27
|
+
context = Class.new Microspec::Context
|
28
|
+
scope = Scope.new filename, context: context do
|
29
|
+
instance_eval File.read(filename), filename
|
30
|
+
end
|
31
|
+
|
32
|
+
scope.perform
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'microspec/spec'
|
2
|
+
|
3
|
+
module Microspec
|
4
|
+
class Scope
|
5
|
+
def description
|
6
|
+
@_description
|
7
|
+
end
|
8
|
+
|
9
|
+
def parent
|
10
|
+
@_parent
|
11
|
+
end
|
12
|
+
|
13
|
+
def context
|
14
|
+
@_context
|
15
|
+
end
|
16
|
+
|
17
|
+
def block
|
18
|
+
@_block
|
19
|
+
end
|
20
|
+
|
21
|
+
def definitions
|
22
|
+
@_definitions ||= {}
|
23
|
+
end
|
24
|
+
|
25
|
+
def define(definitions)
|
26
|
+
definitions.each do |key, value|
|
27
|
+
context.send :define_method, key do
|
28
|
+
__memoizations.fetch key do
|
29
|
+
__memoizations[key] = if value.is_a? Proc
|
30
|
+
instance_exec(&value)
|
31
|
+
else
|
32
|
+
value
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def setup(&block)
|
40
|
+
setups << block
|
41
|
+
end
|
42
|
+
|
43
|
+
def teardown(&block)
|
44
|
+
teardowns << block
|
45
|
+
end
|
46
|
+
|
47
|
+
def scope(description = nil, &block)
|
48
|
+
scope = Scope.new description, parent: self, context: Class.new(context), &block
|
49
|
+
scope.perform
|
50
|
+
end
|
51
|
+
|
52
|
+
def spec(description = nil, &block)
|
53
|
+
instance = context.new
|
54
|
+
|
55
|
+
start instance
|
56
|
+
|
57
|
+
spec = Spec.new description, instance: instance, &block
|
58
|
+
spec.perform
|
59
|
+
|
60
|
+
finish instance
|
61
|
+
end
|
62
|
+
|
63
|
+
def initialize(description = nil, parent: nil, context: nil, &block)
|
64
|
+
@_description = description
|
65
|
+
@_parent = parent
|
66
|
+
@_context = context
|
67
|
+
@_block = block
|
68
|
+
end
|
69
|
+
|
70
|
+
def perform
|
71
|
+
instance_eval(&block)
|
72
|
+
end
|
73
|
+
|
74
|
+
protected
|
75
|
+
|
76
|
+
def setups
|
77
|
+
@_setups ||= []
|
78
|
+
end
|
79
|
+
|
80
|
+
def teardowns
|
81
|
+
@_setups ||= []
|
82
|
+
end
|
83
|
+
|
84
|
+
def start(instance)
|
85
|
+
parent.start instance if parent
|
86
|
+
|
87
|
+
setups.each do |setup|
|
88
|
+
instance.instance_exec(&setup)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def finish(instance)
|
93
|
+
parent.finish instance if parent
|
94
|
+
|
95
|
+
teardowns.each do |teardown|
|
96
|
+
instance.instance_exec(&teardown)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'microspec/raise'
|
2
|
+
require 'microspec/expectation'
|
3
|
+
require 'microspec/context'
|
4
|
+
|
5
|
+
module Microspec
|
6
|
+
class Spec
|
7
|
+
def description
|
8
|
+
@_description
|
9
|
+
end
|
10
|
+
|
11
|
+
def instance
|
12
|
+
@_instance
|
13
|
+
end
|
14
|
+
|
15
|
+
def block
|
16
|
+
@_block
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize(description = nil, instance:, &block)
|
20
|
+
@_description = description
|
21
|
+
@_instance = instance
|
22
|
+
@_block = block
|
23
|
+
end
|
24
|
+
|
25
|
+
def perform
|
26
|
+
instance.instance_eval(&block)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/microspec.rb
ADDED
data/microspec.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'microspec/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'microspec'
|
8
|
+
spec.version = Microspec::VERSION
|
9
|
+
spec.authors = ['Erol Fornoles']
|
10
|
+
spec.email = ['erol.fornoles@gmail.com']
|
11
|
+
spec.summary = %q{Lean testing framework for Ruby}
|
12
|
+
spec.description = %q{Lean testing framework for Ruby}
|
13
|
+
spec.homepage = 'https://github.com/Erol/microspec'
|
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
|
+
spec.add_development_dependency 'codeclimate-test-reporter'
|
24
|
+
end
|
@@ -0,0 +1,133 @@
|
|
1
|
+
spec do
|
2
|
+
raises Microspec::Flunked, 'failed assert' do
|
3
|
+
asserts([1, 2, 3]).include? 4
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
spec do
|
8
|
+
raises Microspec::Flunked, 'failed assert' do
|
9
|
+
asserts(true).falsey?
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
spec do
|
14
|
+
raises Microspec::Flunked, 'failed assert' do
|
15
|
+
asserts(false).truthy?
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
spec do
|
20
|
+
raises Microspec::Flunked, 'failed assert' do
|
21
|
+
asserts(100) == 1000
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
spec do
|
26
|
+
raises Microspec::Flunked, 'failed assert' do
|
27
|
+
asserts(100) > 1000
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
spec do
|
32
|
+
raises Microspec::Flunked, 'failed assert' do
|
33
|
+
asserts(100) < 10
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
spec do
|
38
|
+
raises NoMethodError, /unknown/ do
|
39
|
+
asserts(100).unknown?
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
spec do
|
44
|
+
asserts([1, 2, 3]).include? 3
|
45
|
+
end
|
46
|
+
|
47
|
+
spec do
|
48
|
+
asserts(true).truthy?
|
49
|
+
end
|
50
|
+
|
51
|
+
spec do
|
52
|
+
asserts(false).falsey?
|
53
|
+
end
|
54
|
+
|
55
|
+
spec do
|
56
|
+
asserts(100) == 100
|
57
|
+
end
|
58
|
+
|
59
|
+
spec do
|
60
|
+
asserts(100) < 1000
|
61
|
+
end
|
62
|
+
|
63
|
+
spec do
|
64
|
+
asserts(100) > 10
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
spec do
|
70
|
+
raises Microspec::Flunked, 'failed refute' do
|
71
|
+
refutes([1, 2, 3]).include? 3
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
spec do
|
76
|
+
raises Microspec::Flunked, 'failed refute' do
|
77
|
+
refutes(true).truthy?
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
spec do
|
82
|
+
raises Microspec::Flunked, 'failed refute' do
|
83
|
+
refutes(false).falsey?
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
spec do
|
88
|
+
raises Microspec::Flunked, 'failed refute' do
|
89
|
+
refutes(100) == 100
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
spec do
|
94
|
+
raises Microspec::Flunked, 'failed refute' do
|
95
|
+
refutes(100) < 1000
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
spec do
|
100
|
+
raises Microspec::Flunked, 'failed refute' do
|
101
|
+
refutes(100) > 10
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
spec do
|
106
|
+
raises NoMethodError, /unknown/ do
|
107
|
+
refutes(100).unknown?
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
spec do
|
112
|
+
refutes([1, 2, 3]).include? 4
|
113
|
+
end
|
114
|
+
|
115
|
+
spec do
|
116
|
+
refutes(true).falsey?
|
117
|
+
end
|
118
|
+
|
119
|
+
spec do
|
120
|
+
refutes(false).truthy?
|
121
|
+
end
|
122
|
+
|
123
|
+
spec do
|
124
|
+
refutes(100) == 1000
|
125
|
+
end
|
126
|
+
|
127
|
+
spec do
|
128
|
+
refutes(100) > 1000
|
129
|
+
end
|
130
|
+
|
131
|
+
spec do
|
132
|
+
refutes(100) < 10
|
133
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
class SomeException < Exception; end
|
2
|
+
class SomeOtherException < Exception; end
|
3
|
+
|
4
|
+
spec do
|
5
|
+
raises Microspec::Flunked, 'missing exception' do
|
6
|
+
raises SomeException do
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
spec do
|
12
|
+
raises Microspec::Flunked, 'unexpected exception' do
|
13
|
+
raises SomeException do
|
14
|
+
raise SomeOtherException
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
spec do
|
20
|
+
raises Microspec::Flunked, 'unexpected exception message' do
|
21
|
+
raises SomeException, 'failed' do
|
22
|
+
raise SomeException, 'flunked'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
spec do
|
28
|
+
raises Microspec::Flunked, 'unexpected exception message' do
|
29
|
+
raises SomeException, /fail/ do
|
30
|
+
raise SomeException, 'flunked'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
spec do
|
36
|
+
raises SomeException do
|
37
|
+
raise SomeException
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
spec do
|
42
|
+
raises do
|
43
|
+
raise SomeException
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
spec do
|
48
|
+
raises SomeException, 'failed' do
|
49
|
+
raise SomeException, 'failed'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
spec do
|
54
|
+
raises SomeException, /fail/ do
|
55
|
+
raise SomeException, 'failed'
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
setup do
|
2
|
+
@variable = 1
|
3
|
+
end
|
4
|
+
|
5
|
+
spec do
|
6
|
+
refutes(self).instance_variable_defined? :@variable
|
7
|
+
end
|
8
|
+
|
9
|
+
@variable = 1
|
10
|
+
|
11
|
+
spec do
|
12
|
+
refutes(self).instance_variable_defined? :@variable
|
13
|
+
end
|
14
|
+
|
15
|
+
define hash: -> { {o: :o} }
|
16
|
+
|
17
|
+
scope do
|
18
|
+
setup do
|
19
|
+
hash.merge! O: :O
|
20
|
+
end
|
21
|
+
|
22
|
+
spec do
|
23
|
+
asserts(hash) == {o: :o, O: :O}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
scope do
|
28
|
+
define hash: -> { {O: :O} }
|
29
|
+
|
30
|
+
spec do
|
31
|
+
asserts(hash) == {O: :O}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
spec do
|
36
|
+
asserts(hash) == {o: :o}
|
37
|
+
end
|
38
|
+
|
39
|
+
spec do
|
40
|
+
hash.merge! O: :O
|
41
|
+
|
42
|
+
asserts(hash) == {o: :o, O: :O}
|
43
|
+
end
|
44
|
+
|
45
|
+
define derived: -> { hash.merge O: :O }
|
46
|
+
|
47
|
+
spec do
|
48
|
+
asserts(derived) == {o: :o, O: :O}
|
49
|
+
end
|
50
|
+
|
51
|
+
define value: 1
|
52
|
+
|
53
|
+
spec do
|
54
|
+
asserts(value) == 1
|
55
|
+
end
|
56
|
+
|
57
|
+
scope do
|
58
|
+
setup do
|
59
|
+
$a = :a
|
60
|
+
end
|
61
|
+
|
62
|
+
spec do
|
63
|
+
asserts($a) == :a
|
64
|
+
end
|
65
|
+
|
66
|
+
scope do
|
67
|
+
setup do
|
68
|
+
$b = :b
|
69
|
+
end
|
70
|
+
|
71
|
+
spec do
|
72
|
+
asserts($b) == :b
|
73
|
+
end
|
74
|
+
|
75
|
+
scope do
|
76
|
+
teardown do
|
77
|
+
$b = nil
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
spec do
|
82
|
+
asserts($b).nil?
|
83
|
+
end
|
84
|
+
|
85
|
+
teardown do
|
86
|
+
$a = nil
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
spec do
|
91
|
+
asserts($a).nil?
|
92
|
+
end
|
93
|
+
end
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: microspec
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0.beta3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Erol Fornoles
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-31 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
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: codeclimate-test-reporter
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Lean testing framework for Ruby
|
56
|
+
email:
|
57
|
+
- erol.fornoles@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".travis.yml"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- lib/microspec.rb
|
69
|
+
- lib/microspec/context.rb
|
70
|
+
- lib/microspec/expectation.rb
|
71
|
+
- lib/microspec/flunked.rb
|
72
|
+
- lib/microspec/predicates.rb
|
73
|
+
- lib/microspec/raise.rb
|
74
|
+
- lib/microspec/runner.rb
|
75
|
+
- lib/microspec/scope.rb
|
76
|
+
- lib/microspec/spec.rb
|
77
|
+
- lib/microspec/version.rb
|
78
|
+
- microspec.gemspec
|
79
|
+
- spec/microspec/expectation.rb
|
80
|
+
- spec/microspec/raise.rb
|
81
|
+
- spec/microspec/scope.rb
|
82
|
+
homepage: https://github.com/Erol/microspec
|
83
|
+
licenses:
|
84
|
+
- MIT
|
85
|
+
metadata: {}
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">"
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: 1.3.1
|
100
|
+
requirements: []
|
101
|
+
rubyforge_project:
|
102
|
+
rubygems_version: 2.4.5
|
103
|
+
signing_key:
|
104
|
+
specification_version: 4
|
105
|
+
summary: Lean testing framework for Ruby
|
106
|
+
test_files:
|
107
|
+
- spec/microspec/expectation.rb
|
108
|
+
- spec/microspec/raise.rb
|
109
|
+
- spec/microspec/scope.rb
|