mini_shoulda 0.1.0
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/CHANGELOG +3 -0
- data/MIT-LICENSE +22 -0
- data/README.rdoc +54 -0
- data/lib/mini_shoulda.rb +11 -0
- data/lib/mini_shoulda/minitest_describe_patch.rb +21 -0
- data/lib/mini_shoulda/spec.rb +14 -0
- metadata +83 -0
data/CHANGELOG
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2010 Ken Collins, <ken@metaskills.net>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
4
|
+
obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without
|
6
|
+
restriction, including without limitation the rights to use,
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the
|
9
|
+
Software is furnished to do so, subject to the following
|
10
|
+
conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
|
2
|
+
= MiniShoulda
|
3
|
+
|
4
|
+
A minimal shoulda DSL built on top of MiniTest::Spec. MiniTest is the future, and we should all be
|
5
|
+
using it! No pun. The MiniShoulda gem is a simple set of alias built on top of MiniTest so that we can use
|
6
|
+
basic shoulda syntax. A simple example says it all.
|
7
|
+
|
8
|
+
class MyTestClass < MiniTest::Spec
|
9
|
+
|
10
|
+
setup do
|
11
|
+
@object = Object.new
|
12
|
+
end
|
13
|
+
|
14
|
+
teardown do
|
15
|
+
@object.freeze
|
16
|
+
end
|
17
|
+
|
18
|
+
should 'find object' do
|
19
|
+
assert @object
|
20
|
+
refute_instance_of Object, @object
|
21
|
+
end
|
22
|
+
|
23
|
+
should_eventually 'works too' do
|
24
|
+
refute true, 'will use skip and not run'
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'with another context' do
|
28
|
+
|
29
|
+
setup do
|
30
|
+
@object = [1,2,3]
|
31
|
+
end
|
32
|
+
|
33
|
+
should 'just work' do
|
34
|
+
assert_includes @object, 2
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
= What About ActiveRecord Macros
|
43
|
+
|
44
|
+
It is not my goal to implement all the ActiveRecord macros nor things like should_have_db_columns :)
|
45
|
+
|
46
|
+
|
47
|
+
= Any Hacks?
|
48
|
+
|
49
|
+
Not really. MiniShoulda is built on top of the existing MiniTest::Spec methods. Basically they are
|
50
|
+
just a series of aliases to those methods. Our only monkey patch is in MiniTest's Kernel#describe method
|
51
|
+
so you can maintain class scope in your own test cases. Please help me lobby the MiniTest team to get
|
52
|
+
that patch in.
|
53
|
+
|
54
|
+
* https://github.com/seattlerb/minitest/pull/9
|
data/lib/mini_shoulda.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# I currently have a patch submitted to minitest to allow parent classes to maintain their
|
2
|
+
# inhertance chain when describe blocks are used. Please help me get it into core!
|
3
|
+
# https://github.com/seattlerb/minitest/pull/9
|
4
|
+
|
5
|
+
module Kernel
|
6
|
+
|
7
|
+
def describe desc, &block
|
8
|
+
stack = MiniTest::Spec.describe_stack
|
9
|
+
name = [stack.last, desc].compact.join("::")
|
10
|
+
sclas = stack.last || (self.is_a?(Class) && self < MiniTest::Spec ? self : MiniTest::Spec)
|
11
|
+
cls = Class.new(sclas)
|
12
|
+
(class << cls; self; end).send(:define_method, :to_s) { name }
|
13
|
+
cls.nuke_test_methods!
|
14
|
+
stack.push cls
|
15
|
+
cls.class_eval(&block)
|
16
|
+
stack.pop
|
17
|
+
cls
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class MiniTest::Spec < MiniTest::Unit::TestCase
|
2
|
+
|
3
|
+
class << self
|
4
|
+
alias :setup :before
|
5
|
+
alias :teardown :after
|
6
|
+
alias :should :it
|
7
|
+
alias :context :describe
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.should_eventually(desc)
|
11
|
+
it("should eventually #{desc}") { skip("Should eventually #{desc}") }
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mini_shoulda
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Ken Collins
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-01-24 00:00:00 -05:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: minitest
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 2
|
30
|
+
- 0
|
31
|
+
- 2
|
32
|
+
version: 2.0.2
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
description: MiniShoulda - A minimal shoulda DSL built on top of MiniTest::Spec.
|
36
|
+
email: ken@metaskills.net
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files: []
|
42
|
+
|
43
|
+
files:
|
44
|
+
- CHANGELOG
|
45
|
+
- MIT-LICENSE
|
46
|
+
- README.rdoc
|
47
|
+
- lib/mini_shoulda/minitest_describe_patch.rb
|
48
|
+
- lib/mini_shoulda/spec.rb
|
49
|
+
- lib/mini_shoulda.rb
|
50
|
+
has_rdoc: true
|
51
|
+
homepage: http://github.com/metaskills/mini_shoulda
|
52
|
+
licenses: []
|
53
|
+
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options:
|
56
|
+
- --charset=UTF-8
|
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
|
+
segments:
|
65
|
+
- 0
|
66
|
+
version: "0"
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
75
|
+
requirements: []
|
76
|
+
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 1.3.7
|
79
|
+
signing_key:
|
80
|
+
specification_version: 3
|
81
|
+
summary: MiniShoulda - A minimal shoulda DSL built on top of MiniTest::Spec.
|
82
|
+
test_files: []
|
83
|
+
|