minitest-shouldify 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/.autotest +23 -0
- data/.gemtest +0 -0
- data/CHANGELOG.rdoc +3 -0
- data/Manifest.txt +14 -0
- data/README.rdoc +117 -0
- data/Rakefile +25 -0
- data/lib/minitest/shouldify.rb +154 -0
- data/lib/minitest-shouldify.rb +7 -0
- data/minitest-shouldify.gemspec +39 -0
- data/test/test_helper.rb +53 -0
- data/test/test_must_not.rb +101 -0
- data/test/test_sanity.rb +8 -0
- data/test/test_shall.rb +101 -0
- data/test/test_shouldify.rb +101 -0
- data/test/test_wimpy.rb +101 -0
- metadata +119 -0
data/.autotest
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'autotest/restart'
|
4
|
+
|
5
|
+
# Autotest.add_hook :initialize do |at|
|
6
|
+
# at.extra_files << "../some/external/dependency.rb"
|
7
|
+
#
|
8
|
+
# at.libs << ":../some/external"
|
9
|
+
#
|
10
|
+
# at.add_exception 'vendor'
|
11
|
+
#
|
12
|
+
# at.add_mapping(/dependency.rb/) do |f, _|
|
13
|
+
# at.files_matching(/test_.*rb$/)
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# %w(TestA TestB).each do |klass|
|
17
|
+
# at.extra_class_map[klass] = "test/test_misc.rb"
|
18
|
+
# end
|
19
|
+
# end
|
20
|
+
|
21
|
+
# Autotest.add_hook :run_command do |at|
|
22
|
+
# system "rake build"
|
23
|
+
# end
|
data/.gemtest
ADDED
File without changes
|
data/CHANGELOG.rdoc
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
.autotest
|
2
|
+
CHANGELOG.rdoc
|
3
|
+
Manifest.txt
|
4
|
+
README.rdoc
|
5
|
+
Rakefile
|
6
|
+
lib/minitest-shouldify.rb
|
7
|
+
lib/minitest/shouldify.rb
|
8
|
+
minitest-shouldify.gemspec
|
9
|
+
test/test_helper.rb
|
10
|
+
test/test_must_not.rb
|
11
|
+
test/test_sanity.rb
|
12
|
+
test/test_shall.rb
|
13
|
+
test/test_shouldify.rb
|
14
|
+
test/test_wimpy.rb
|
data/README.rdoc
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
= minitest-shouldify
|
2
|
+
|
3
|
+
This is a bad idea.
|
4
|
+
|
5
|
+
== The Problem
|
6
|
+
|
7
|
+
So you want to use minitest, but you are familiar with Rspec and don't like change to
|
8
|
+
<tt>must</tt>/<tt>wont</tt> from <tt>should</tt>/<tt>should_not</tt>.
|
9
|
+
|
10
|
+
== The Solution
|
11
|
+
|
12
|
+
First, require minitest-shouldify in your <tt>test_helper.rb</tt> file:
|
13
|
+
|
14
|
+
require "minitest/shouldify"
|
15
|
+
|
16
|
+
Second, register your desired expectation names:
|
17
|
+
|
18
|
+
MiniTest::Shouldify.register! "should", "should_not"
|
19
|
+
|
20
|
+
Now you are ready to use the new names:
|
21
|
+
|
22
|
+
describe Foo, :bar do
|
23
|
+
it "is bar" do
|
24
|
+
Foo.new.bar.should_equal "bar"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "isn't baz" do
|
28
|
+
Foo.new.bar.should_not_equal "baz"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
Also, if you are using <tt>minitest-matchers</tt> and have defined a <tt>be_equal_to</tt>
|
33
|
+
matcher you could also use this syntax:
|
34
|
+
|
35
|
+
describe Foo, :bar do
|
36
|
+
subject { Foo.new.bar }
|
37
|
+
|
38
|
+
it { should be_equal_to("bar") }
|
39
|
+
it { should_not be_equal_to("baz") }
|
40
|
+
|
41
|
+
should { be_equal_to("bar") }
|
42
|
+
should_not { be_equal_to("baz") }
|
43
|
+
end
|
44
|
+
|
45
|
+
== Why "must"
|
46
|
+
|
47
|
+
Its a fair question, after all the method "should" is common in BDD-style specs.
|
48
|
+
Its also not uncommon for technical specifications to have guidelines similar to the following:
|
49
|
+
|
50
|
+
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
|
51
|
+
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
|
52
|
+
document are to be interpreted as described in [RFC2119].
|
53
|
+
|
54
|
+
So let's take a look at RFC2119[http://www.ietf.org/rfc/rfc2119.txt]:
|
55
|
+
|
56
|
+
1. MUST This word, or the terms "REQUIRED" or "SHALL", mean that the
|
57
|
+
definition is an absolute requirement of the specification.
|
58
|
+
|
59
|
+
2. MUST NOT This phrase, or the phrase "SHALL NOT", mean that the
|
60
|
+
definition is an absolute prohibition of the specification.
|
61
|
+
|
62
|
+
3. SHOULD This word, or the adjective "RECOMMENDED", mean that there
|
63
|
+
may exist valid reasons in particular circumstances to ignore a
|
64
|
+
particular item, but the full implications must be understood and
|
65
|
+
carefully weighed before choosing a different course.
|
66
|
+
|
67
|
+
4. SHOULD NOT This phrase, or the phrase "NOT RECOMMENDED" mean that
|
68
|
+
there may exist valid reasons in particular circumstances when the
|
69
|
+
particular behavior is acceptable or even useful, but the full
|
70
|
+
implications should be understood and the case carefully weighed
|
71
|
+
before implementing any behavior described with this label.
|
72
|
+
|
73
|
+
|
74
|
+
This clearly states that MUST is a requirement, and SHOULD is a recommendation.
|
75
|
+
However, your testing framework doesn't have the context to know under which
|
76
|
+
circumstances the tests are allowed to fail. So since you are asserting hard
|
77
|
+
requirements anyway, you might as well use the proper vocabulary.
|
78
|
+
|
79
|
+
== Wait. Then why "wont"?
|
80
|
+
|
81
|
+
Yes, minitest could have chosen to name the expectations <tt>must</tt> and <tt>must_not</tt>.
|
82
|
+
But, there are reasons to prefer <tt>wont</tt> over <tt>must_not</tt>.
|
83
|
+
One advantage is that <tt>must</tt> and <tt>wont</tt> are the same number of characters,
|
84
|
+
just as <tt>assert</tt> and <tt>refute</tt> are.
|
85
|
+
|
86
|
+
If you don't like it you can always change it:
|
87
|
+
|
88
|
+
MiniTest::Shouldify.register! "must", "must_not"
|
89
|
+
|
90
|
+
== Disclaimer
|
91
|
+
|
92
|
+
No really, its probably not a good idea to use this.
|
93
|
+
|
94
|
+
== License
|
95
|
+
|
96
|
+
(The MIT License)
|
97
|
+
|
98
|
+
Copyright (c) 2012 Mike Moore
|
99
|
+
|
100
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
101
|
+
a copy of this software and associated documentation files (the
|
102
|
+
'Software'), to deal in the Software without restriction, including
|
103
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
104
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
105
|
+
permit persons to whom the Software is furnished to do so, subject to
|
106
|
+
the following conditions:
|
107
|
+
|
108
|
+
The above copyright notice and this permission notice shall be
|
109
|
+
included in all copies or substantial portions of the Software.
|
110
|
+
|
111
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
112
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
113
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
114
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
115
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
116
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
117
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require "rubygems"
|
4
|
+
require "hoe"
|
5
|
+
|
6
|
+
Hoe.plugin :git
|
7
|
+
Hoe.plugin :gemspec
|
8
|
+
Hoe.plugin :travis
|
9
|
+
Hoe.plugins.delete :rubyforge
|
10
|
+
|
11
|
+
Hoe.spec 'minitest-shouldify' do
|
12
|
+
developer "Mike Moore", "mike@blowmage.com"
|
13
|
+
|
14
|
+
self.summary = "Its a bad idea"
|
15
|
+
self.description = "Adding all manner of shoulds to MiniTest"
|
16
|
+
self.urls = ["http://blowmage.com/minitest-rails-shoulda"]
|
17
|
+
|
18
|
+
self.history_file = "CHANGELOG.rdoc"
|
19
|
+
self.readme_file = "README.rdoc"
|
20
|
+
self.testlib = :minitest
|
21
|
+
|
22
|
+
dependency "minitest", "~> 3.5"
|
23
|
+
end
|
24
|
+
|
25
|
+
# vim: syntax=ruby
|
@@ -0,0 +1,154 @@
|
|
1
|
+
require "minitest/spec"
|
2
|
+
|
3
|
+
module MiniTest::Shouldify # :nodoc:
|
4
|
+
class << self
|
5
|
+
attr_accessor :run_setup # :nodoc:
|
6
|
+
attr_accessor :expectation_owners # :nodoc:
|
7
|
+
attr_accessor :expectation_names # :nodoc:
|
8
|
+
|
9
|
+
##
|
10
|
+
# Registers new expectations names.
|
11
|
+
#
|
12
|
+
# Example:
|
13
|
+
#
|
14
|
+
# MiniTest::Shouldify.register! "should", "should_not"
|
15
|
+
#
|
16
|
+
# describe Foo do
|
17
|
+
# it "is bar" do
|
18
|
+
# Foo.new.bar.should_be_equal_to "bar"
|
19
|
+
# end
|
20
|
+
# end
|
21
|
+
def register! new_must, new_wont # :nodoc:
|
22
|
+
self.expectation_names ||= []
|
23
|
+
self.expectation_names << [new_must, new_wont]
|
24
|
+
self.expectation_names.uniq!
|
25
|
+
# Run shouldify setup immediately
|
26
|
+
self.shouldify! true
|
27
|
+
end
|
28
|
+
|
29
|
+
##
|
30
|
+
# Main method for shouldifying expectations
|
31
|
+
# (and matchers)
|
32
|
+
def shouldify! force = nil # :nodoc:
|
33
|
+
# Don't run this more than needed
|
34
|
+
if force || self.run_setup
|
35
|
+
self.expectation_names ||= []
|
36
|
+
self.expectation_names.each do |new_must, new_wont|
|
37
|
+
shouldify_expectations new_must, new_wont
|
38
|
+
shouldify_matchers new_must, new_wont
|
39
|
+
|
40
|
+
self.run_setup = false
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
##
|
46
|
+
# Register a class that has expectation methods
|
47
|
+
# so we can alias the methods afterwards
|
48
|
+
def added_expectation! owner # :nodoc:
|
49
|
+
self.expectation_owners ||= []
|
50
|
+
self.expectation_owners << owner
|
51
|
+
self.expectation_owners.uniq!
|
52
|
+
# Flush the cache
|
53
|
+
self.run_setup = true
|
54
|
+
end
|
55
|
+
|
56
|
+
def shouldify_matchers new_must, new_wont # :nodoc:
|
57
|
+
# Only do this if Matchers exists
|
58
|
+
if MiniTest.const_defined?("Matchers")
|
59
|
+
unless MiniTest::Shouldify.const_defined?("Matcher_#{new_must}_#{new_wont}")
|
60
|
+
m = Module.new
|
61
|
+
m.module_eval "
|
62
|
+
def #{new_must}(*args, &block)
|
63
|
+
must(*args, &block)
|
64
|
+
end
|
65
|
+
def #{new_wont}(*args, &block)
|
66
|
+
wont(*args, &block)
|
67
|
+
end
|
68
|
+
"
|
69
|
+
MiniTest::Shouldify.const_set("Matcher_#{new_must}_#{new_wont}", m)
|
70
|
+
|
71
|
+
MiniTest::Spec.send :include, m
|
72
|
+
MiniTest::Spec.extend m
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def shouldify_expectations new_must, new_wont # :nodoc:
|
78
|
+
self.expectation_owners ||= []
|
79
|
+
self.expectation_owners.each do |klass|
|
80
|
+
shouldify_klass klass, new_must, new_wont
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def shouldify_klass klass, new_must, new_wont # :nodoc:
|
85
|
+
shouldify_klass_methods klass, /^must_/, "#{new_must}_"
|
86
|
+
shouldify_klass_methods klass, /^wont_/, "#{new_wont}_"
|
87
|
+
end
|
88
|
+
|
89
|
+
def shouldify_klass_methods klass, orig_regex, new_prefix # :nodoc:
|
90
|
+
klass.instance_eval do
|
91
|
+
public_instance_methods.grep(orig_regex).each do |method|
|
92
|
+
new_method = method.to_s.sub(orig_regex, new_prefix).to_sym
|
93
|
+
alias_method new_method, method
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
# Prime the existing expectation owner
|
100
|
+
# MiniTest adds all expectations to Object by default
|
101
|
+
MiniTest::Shouldify.added_expectation! Object
|
102
|
+
|
103
|
+
# Add hook to infect_an_assertion
|
104
|
+
class Module # :nodoc:
|
105
|
+
alias :infect_an_assertion_shouldified :infect_an_assertion
|
106
|
+
def infect_an_assertion meth, new_name, dont_flip = false # :nodoc:
|
107
|
+
# Call the original method
|
108
|
+
infect_an_assertion_shouldified meth, new_name, dont_flip
|
109
|
+
# Register the class that has the expectation
|
110
|
+
MiniTest::Shouldify.added_expectation! self
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
module MiniTest
|
115
|
+
module Shouldify
|
116
|
+
module Lifecycle # :nodoc:
|
117
|
+
# Hook into Minitest's Lifecycle to alias methods when tests are run.
|
118
|
+
def before_setup # :nodoc:
|
119
|
+
MiniTest::Shouldify.shouldify!
|
120
|
+
super
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
class Unit # :nodoc:
|
125
|
+
class TestCase # :nodoc:
|
126
|
+
# Register the Lifecycle
|
127
|
+
include MiniTest::Shouldify::Lifecycle
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
##
|
132
|
+
# Registers new expectations names.
|
133
|
+
#
|
134
|
+
# Example:
|
135
|
+
#
|
136
|
+
# MiniTest.shouldify! "should", "should_not"
|
137
|
+
#
|
138
|
+
# class Foo
|
139
|
+
# def bar; "bar"; end
|
140
|
+
# end
|
141
|
+
#
|
142
|
+
# describe Foo, :bar do
|
143
|
+
# it "is bar" do
|
144
|
+
# Foo.new.bar.should_equal "bar"
|
145
|
+
# end
|
146
|
+
#
|
147
|
+
# it "is not baz" do
|
148
|
+
# Foo.new.bar.should_not_equal "baz"
|
149
|
+
# end
|
150
|
+
# end
|
151
|
+
def self.shouldify! new_must, new_wont
|
152
|
+
MiniTest::Shouldify.register! new_must, new_wont
|
153
|
+
end
|
154
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "minitest-shouldify"
|
5
|
+
s.version = "1.0.20120925212120"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Mike Moore"]
|
9
|
+
s.date = "2012-09-26"
|
10
|
+
s.description = "Adding all manner of shoulds to MiniTest"
|
11
|
+
s.email = ["mike@blowmage.com"]
|
12
|
+
s.extra_rdoc_files = ["CHANGELOG.rdoc", "Manifest.txt", "README.rdoc"]
|
13
|
+
s.files = [".autotest", "CHANGELOG.rdoc", "Manifest.txt", "README.rdoc", "Rakefile", "lib/minitest-shouldify.rb", "lib/minitest/shouldify.rb", "minitest-shouldify.gemspec", "test/test_helper.rb", "test/test_must_not.rb", "test/test_sanity.rb", "test/test_shall.rb", "test/test_shouldify.rb", "test/test_wimpy.rb", ".gemtest"]
|
14
|
+
s.homepage = "http://blowmage.com/minitest-rails-shoulda"
|
15
|
+
s.rdoc_options = ["--main", "README.rdoc"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubyforge_project = "minitest-shouldify"
|
18
|
+
s.rubygems_version = "1.8.23"
|
19
|
+
s.summary = "Its a bad idea"
|
20
|
+
s.test_files = ["test/test_helper.rb", "test/test_must_not.rb", "test/test_sanity.rb", "test/test_shall.rb", "test/test_shouldify.rb", "test/test_wimpy.rb"]
|
21
|
+
|
22
|
+
if s.respond_to? :specification_version then
|
23
|
+
s.specification_version = 3
|
24
|
+
|
25
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
26
|
+
s.add_runtime_dependency(%q<minitest>, ["~> 3.5"])
|
27
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.10"])
|
28
|
+
s.add_development_dependency(%q<hoe>, ["~> 3.1"])
|
29
|
+
else
|
30
|
+
s.add_dependency(%q<minitest>, ["~> 3.5"])
|
31
|
+
s.add_dependency(%q<rdoc>, ["~> 3.10"])
|
32
|
+
s.add_dependency(%q<hoe>, ["~> 3.1"])
|
33
|
+
end
|
34
|
+
else
|
35
|
+
s.add_dependency(%q<minitest>, ["~> 3.5"])
|
36
|
+
s.add_dependency(%q<rdoc>, ["~> 3.10"])
|
37
|
+
s.add_dependency(%q<hoe>, ["~> 3.1"])
|
38
|
+
end
|
39
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "minitest/shouldify"
|
3
|
+
|
4
|
+
class Foo
|
5
|
+
def bar
|
6
|
+
"bar"
|
7
|
+
end
|
8
|
+
def baz
|
9
|
+
"baz"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
module MiniTest
|
15
|
+
module Shouldify
|
16
|
+
module Matchers
|
17
|
+
class BeEqualTo
|
18
|
+
def initialize expected
|
19
|
+
@expected = expected
|
20
|
+
end
|
21
|
+
|
22
|
+
def matches? actual
|
23
|
+
@actual = actual
|
24
|
+
@actual == @expected
|
25
|
+
end
|
26
|
+
|
27
|
+
def failure_message
|
28
|
+
"Expected #{@actual.inspect} " +
|
29
|
+
"to be the same as #{@expected.inspect}"
|
30
|
+
end
|
31
|
+
|
32
|
+
def negative_failure_message
|
33
|
+
"Expected #{@actual.inspect} " +
|
34
|
+
"to not be the same as #{@expected.inspect}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def be_equal_to(attr)
|
39
|
+
BeEqualTo.new(attr)
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.included(base)
|
43
|
+
instance_methods.each do |name|
|
44
|
+
base.register_matcher name, name
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class MiniTest::Unit::TestCase
|
52
|
+
include MiniTest::Shouldify::Matchers
|
53
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
MiniTest::Shouldify.register! "must", "must_not"
|
4
|
+
|
5
|
+
describe Foo do
|
6
|
+
|
7
|
+
before do
|
8
|
+
@foo = Foo.new
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "asserts" do
|
12
|
+
describe :bar do
|
13
|
+
it "is bar" do
|
14
|
+
assert_equal "bar", @foo.bar
|
15
|
+
end
|
16
|
+
it "isn't baz" do
|
17
|
+
refute_equal "baz", @foo.bar
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe :baz do
|
22
|
+
it "is baz" do
|
23
|
+
assert_equal "baz", @foo.baz
|
24
|
+
end
|
25
|
+
it "isn't baz" do
|
26
|
+
refute_equal "bar", @foo.baz
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "default matcher" do
|
32
|
+
describe :bar do
|
33
|
+
it "is bar" do
|
34
|
+
@foo.bar.must_equal "bar"
|
35
|
+
end
|
36
|
+
it "isn't baz" do
|
37
|
+
@foo.bar.wont_equal "baz"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe :baz do
|
42
|
+
it "is baz" do
|
43
|
+
@foo.baz.must_equal "baz"
|
44
|
+
end
|
45
|
+
it "isn't baz" do
|
46
|
+
@foo.baz.wont_equal "bar"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "new matcher" do
|
52
|
+
describe :bar do
|
53
|
+
it "is bar" do
|
54
|
+
@foo.bar.must_equal "bar"
|
55
|
+
end
|
56
|
+
it "isn't baz" do
|
57
|
+
@foo.bar.must_not_equal "baz"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe :baz do
|
62
|
+
it "is baz" do
|
63
|
+
@foo.baz.must_equal "baz"
|
64
|
+
end
|
65
|
+
it "isn't baz" do
|
66
|
+
@foo.baz.must_not_equal "bar"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "be_equal_to matcher" do
|
72
|
+
describe :bar do
|
73
|
+
it "is bar" do
|
74
|
+
@foo.bar.must_be_equal_to "bar"
|
75
|
+
end
|
76
|
+
it "isn't baz" do
|
77
|
+
@foo.bar.must_not_be_equal_to "baz"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe :baz do
|
82
|
+
it "is baz" do
|
83
|
+
@foo.baz.must_be_equal_to "baz"
|
84
|
+
end
|
85
|
+
it "isn't baz" do
|
86
|
+
@foo.baz.must_not_be_equal_to "bar"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "with subject" do
|
91
|
+
subject { @foo.bar }
|
92
|
+
|
93
|
+
it { must be_equal_to("bar") }
|
94
|
+
it { must_not be_equal_to("baz") }
|
95
|
+
|
96
|
+
must { be_equal_to("bar") }
|
97
|
+
must_not { be_equal_to("baz") }
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
data/test/test_sanity.rb
ADDED
data/test/test_shall.rb
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
MiniTest::Shouldify.register! "shall", "shant"
|
4
|
+
|
5
|
+
describe Foo do
|
6
|
+
|
7
|
+
before do
|
8
|
+
@foo = Foo.new
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "asserts" do
|
12
|
+
describe :bar do
|
13
|
+
it "is bar" do
|
14
|
+
assert_equal "bar", @foo.bar
|
15
|
+
end
|
16
|
+
it "isn't baz" do
|
17
|
+
refute_equal "baz", @foo.bar
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe :baz do
|
22
|
+
it "is baz" do
|
23
|
+
assert_equal "baz", @foo.baz
|
24
|
+
end
|
25
|
+
it "isn't baz" do
|
26
|
+
refute_equal "bar", @foo.baz
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "default matcher" do
|
32
|
+
describe :bar do
|
33
|
+
it "is bar" do
|
34
|
+
@foo.bar.must_equal "bar"
|
35
|
+
end
|
36
|
+
it "isn't baz" do
|
37
|
+
@foo.bar.wont_equal "baz"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe :baz do
|
42
|
+
it "is baz" do
|
43
|
+
@foo.baz.must_equal "baz"
|
44
|
+
end
|
45
|
+
it "isn't baz" do
|
46
|
+
@foo.baz.wont_equal "bar"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "new matcher" do
|
52
|
+
describe :bar do
|
53
|
+
it "is bar" do
|
54
|
+
@foo.bar.shall_equal "bar"
|
55
|
+
end
|
56
|
+
it "isn't baz" do
|
57
|
+
@foo.bar.shant_equal "baz"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe :baz do
|
62
|
+
it "is baz" do
|
63
|
+
@foo.baz.shall_equal "baz"
|
64
|
+
end
|
65
|
+
it "isn't baz" do
|
66
|
+
@foo.baz.shant_equal "bar"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "be_equal_to matcher" do
|
72
|
+
describe :bar do
|
73
|
+
it "is bar" do
|
74
|
+
@foo.bar.shall_be_equal_to "bar"
|
75
|
+
end
|
76
|
+
it "isn't baz" do
|
77
|
+
@foo.bar.shant_be_equal_to "baz"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe :baz do
|
82
|
+
it "is baz" do
|
83
|
+
@foo.baz.shall_be_equal_to "baz"
|
84
|
+
end
|
85
|
+
it "isn't baz" do
|
86
|
+
@foo.baz.shant_be_equal_to "bar"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "with subject" do
|
91
|
+
subject { @foo.bar }
|
92
|
+
|
93
|
+
it { shall be_equal_to("bar") }
|
94
|
+
it { shant be_equal_to("baz") }
|
95
|
+
|
96
|
+
shall { be_equal_to("bar") }
|
97
|
+
shant { be_equal_to("baz") }
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
MiniTest::Shouldify.register! "should", "should_not"
|
4
|
+
|
5
|
+
describe Foo do
|
6
|
+
|
7
|
+
before do
|
8
|
+
@foo = Foo.new
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "asserts" do
|
12
|
+
describe :bar do
|
13
|
+
it "is bar" do
|
14
|
+
assert_equal "bar", @foo.bar
|
15
|
+
end
|
16
|
+
it "isn't baz" do
|
17
|
+
refute_equal "baz", @foo.bar
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe :baz do
|
22
|
+
it "is baz" do
|
23
|
+
assert_equal "baz", @foo.baz
|
24
|
+
end
|
25
|
+
it "isn't baz" do
|
26
|
+
refute_equal "bar", @foo.baz
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "default matcher" do
|
32
|
+
describe :bar do
|
33
|
+
it "is bar" do
|
34
|
+
@foo.bar.must_equal "bar"
|
35
|
+
end
|
36
|
+
it "isn't baz" do
|
37
|
+
@foo.bar.wont_equal "baz"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe :baz do
|
42
|
+
it "is baz" do
|
43
|
+
@foo.baz.must_equal "baz"
|
44
|
+
end
|
45
|
+
it "isn't baz" do
|
46
|
+
@foo.baz.wont_equal "bar"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "new matcher" do
|
52
|
+
describe :bar do
|
53
|
+
it "is bar" do
|
54
|
+
@foo.bar.should_equal "bar"
|
55
|
+
end
|
56
|
+
it "isn't baz" do
|
57
|
+
@foo.bar.should_not_equal "baz"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe :baz do
|
62
|
+
it "is baz" do
|
63
|
+
@foo.baz.should_equal "baz"
|
64
|
+
end
|
65
|
+
it "isn't baz" do
|
66
|
+
@foo.baz.should_not_equal "bar"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "be_equal_to matcher" do
|
72
|
+
describe :bar do
|
73
|
+
it "is bar" do
|
74
|
+
@foo.bar.should_be_equal_to "bar"
|
75
|
+
end
|
76
|
+
it "isn't baz" do
|
77
|
+
@foo.bar.should_not_be_equal_to "baz"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe :baz do
|
82
|
+
it "is baz" do
|
83
|
+
@foo.baz.should_be_equal_to "baz"
|
84
|
+
end
|
85
|
+
it "isn't baz" do
|
86
|
+
@foo.baz.should_not_be_equal_to "bar"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "with subject" do
|
91
|
+
subject { @foo.bar }
|
92
|
+
|
93
|
+
it { should be_equal_to("bar") }
|
94
|
+
it { should_not be_equal_to("baz") }
|
95
|
+
|
96
|
+
should { be_equal_to("bar") }
|
97
|
+
should_not { be_equal_to("baz") }
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
data/test/test_wimpy.rb
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
MiniTest::Shouldify.register! "would_you_please", "rather_you_wouldnt"
|
4
|
+
|
5
|
+
describe Foo do
|
6
|
+
|
7
|
+
before do
|
8
|
+
@foo = Foo.new
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "asserts" do
|
12
|
+
describe :bar do
|
13
|
+
it "is bar" do
|
14
|
+
assert_equal "bar", @foo.bar
|
15
|
+
end
|
16
|
+
it "isn't baz" do
|
17
|
+
refute_equal "baz", @foo.bar
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe :baz do
|
22
|
+
it "is baz" do
|
23
|
+
assert_equal "baz", @foo.baz
|
24
|
+
end
|
25
|
+
it "isn't baz" do
|
26
|
+
refute_equal "bar", @foo.baz
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "default matcher" do
|
32
|
+
describe :bar do
|
33
|
+
it "is bar" do
|
34
|
+
@foo.bar.must_equal "bar"
|
35
|
+
end
|
36
|
+
it "isn't baz" do
|
37
|
+
@foo.bar.wont_equal "baz"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe :baz do
|
42
|
+
it "is baz" do
|
43
|
+
@foo.baz.must_equal "baz"
|
44
|
+
end
|
45
|
+
it "isn't baz" do
|
46
|
+
@foo.baz.wont_equal "bar"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "new matcher" do
|
52
|
+
describe :bar do
|
53
|
+
it "is bar" do
|
54
|
+
@foo.bar.would_you_please_equal "bar"
|
55
|
+
end
|
56
|
+
it "isn't baz" do
|
57
|
+
@foo.bar.rather_you_wouldnt_equal "baz"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe :baz do
|
62
|
+
it "is baz" do
|
63
|
+
@foo.baz.would_you_please_equal "baz"
|
64
|
+
end
|
65
|
+
it "isn't baz" do
|
66
|
+
@foo.baz.rather_you_wouldnt_equal "bar"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "be_equal_to matcher" do
|
72
|
+
describe :bar do
|
73
|
+
it "is bar" do
|
74
|
+
@foo.bar.would_you_please_be_equal_to "bar"
|
75
|
+
end
|
76
|
+
it "isn't baz" do
|
77
|
+
@foo.bar.rather_you_wouldnt_be_equal_to "baz"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe :baz do
|
82
|
+
it "is baz" do
|
83
|
+
@foo.baz.would_you_please_be_equal_to "baz"
|
84
|
+
end
|
85
|
+
it "isn't baz" do
|
86
|
+
@foo.baz.rather_you_wouldnt_be_equal_to "bar"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "with subject" do
|
91
|
+
subject { @foo.bar }
|
92
|
+
|
93
|
+
it { would_you_please be_equal_to("bar") }
|
94
|
+
it { rather_you_wouldnt be_equal_to("baz") }
|
95
|
+
|
96
|
+
would_you_please { be_equal_to("bar") }
|
97
|
+
rather_you_wouldnt { be_equal_to("baz") }
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: minitest-shouldify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '1.0'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Mike Moore
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-09-26 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: minitest
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.5'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.5'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rdoc
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '3.10'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '3.10'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: hoe
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.1'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.1'
|
62
|
+
description: Adding all manner of shoulds to MiniTest
|
63
|
+
email:
|
64
|
+
- mike@blowmage.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files:
|
68
|
+
- CHANGELOG.rdoc
|
69
|
+
- Manifest.txt
|
70
|
+
- README.rdoc
|
71
|
+
files:
|
72
|
+
- .autotest
|
73
|
+
- CHANGELOG.rdoc
|
74
|
+
- Manifest.txt
|
75
|
+
- README.rdoc
|
76
|
+
- Rakefile
|
77
|
+
- lib/minitest-shouldify.rb
|
78
|
+
- lib/minitest/shouldify.rb
|
79
|
+
- minitest-shouldify.gemspec
|
80
|
+
- test/test_helper.rb
|
81
|
+
- test/test_must_not.rb
|
82
|
+
- test/test_sanity.rb
|
83
|
+
- test/test_shall.rb
|
84
|
+
- test/test_shouldify.rb
|
85
|
+
- test/test_wimpy.rb
|
86
|
+
- .gemtest
|
87
|
+
homepage: http://blowmage.com/minitest-rails-shoulda
|
88
|
+
licenses: []
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options:
|
91
|
+
- --main
|
92
|
+
- README.rdoc
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ! '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
103
|
+
requirements:
|
104
|
+
- - ! '>='
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project: minitest-shouldify
|
109
|
+
rubygems_version: 1.8.23
|
110
|
+
signing_key:
|
111
|
+
specification_version: 3
|
112
|
+
summary: Its a bad idea
|
113
|
+
test_files:
|
114
|
+
- test/test_helper.rb
|
115
|
+
- test/test_must_not.rb
|
116
|
+
- test/test_sanity.rb
|
117
|
+
- test/test_shall.rb
|
118
|
+
- test/test_shouldify.rb
|
119
|
+
- test/test_wimpy.rb
|