MacSpec 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +20 -0
- data/Rakefile +53 -0
- data/lib/mac_spec.rb +59 -0
- data/lib/mac_spec/matcher_system.rb +19 -0
- data/lib/mac_spec/matcher_system/built_in/change_expectations.rb +36 -0
- data/lib/mac_spec/matcher_system/built_in/enumerable_expectations.rb +43 -0
- data/lib/mac_spec/matcher_system/built_in/error_expectations.rb +68 -0
- data/lib/mac_spec/matcher_system/built_in/operator_expectations.rb +45 -0
- data/lib/mac_spec/matcher_system/built_in/truth_expectations.rb +148 -0
- data/lib/mac_spec/matcher_system/core/def_matcher.rb +14 -0
- data/lib/mac_spec/matcher_system/core/exceptions.rb +7 -0
- data/lib/mac_spec/matcher_system/core/expectation_builder.rb +11 -0
- data/lib/mac_spec/matcher_system/core/matcher_builder.rb +53 -0
- data/lib/mac_spec/matcher_system/core/modals.rb +36 -0
- data/lib/mac_spec/mocking_framework.rb +13 -0
- data/lib/mac_spec/mocking_framework/extensions/kernel_extension.rb +14 -0
- data/lib/mac_spec/mocking_framework/extensions/object_extension.rb +74 -0
- data/lib/mac_spec/mocking_framework/message_expectation.rb +127 -0
- data/lib/mac_spec/mocking_framework/mock.rb +20 -0
- data/lib/mac_spec/testing_framework.rb +13 -0
- data/lib/mac_spec/testing_framework/core/functions.rb +26 -0
- data/lib/mac_spec/testing_framework/core/kernel_extension.rb +27 -0
- data/lib/mac_spec/testing_framework/core/test_case_class_methods.rb +90 -0
- data/lib/mac_spec/version.rb +3 -0
- data/test/all.rb +6 -0
- data/test/mac_spec/matcher_system/built_in/change_expectations_test.rb +68 -0
- data/test/mac_spec/matcher_system/built_in/enumerable_expectations_test.rb +91 -0
- data/test/mac_spec/matcher_system/built_in/error_expectations_test.rb +144 -0
- data/test/mac_spec/matcher_system/built_in/operator_expectations_test.rb +136 -0
- data/test/mac_spec/matcher_system/built_in/truth_expectations_test.rb +373 -0
- data/test/mac_spec/matcher_system/core/def_matcher_test.rb +100 -0
- data/test/mac_spec/matcher_system/core/expectation_builder_test.rb +34 -0
- data/test/mac_spec/matcher_system/core/matcher_builder_test.rb +72 -0
- data/test/mac_spec/matcher_system/core/modals_test.rb +39 -0
- data/test/mac_spec/matcher_system/script.rb +29 -0
- data/test/mac_spec/matcher_system/test_helper.rb +2 -0
- data/test/mac_spec/mocking_framework/extensions/kernel_extension_test.rb +37 -0
- data/test/mac_spec/mocking_framework/extensions/object_extension_test.rb +9 -0
- data/test/mac_spec/mocking_framework/message_expectation_test.rb +9 -0
- data/test/mac_spec/mocking_framework/mock_test.rb +9 -0
- data/test/mac_spec/mocking_framework/regression/mocking_class_methods_test.rb +96 -0
- data/test/mac_spec/mocking_framework/regression/negative_expectation_test.rb +33 -0
- data/test/mac_spec/mocking_framework/regression/stub_test.rb +19 -0
- data/test/mac_spec/mocking_framework/test_helper.rb +1 -0
- data/test/mac_spec/test_helper.rb +1 -0
- data/test/mac_spec/testing_framework/performance/x_test_performance.rb +125 -0
- data/test/mac_spec/testing_framework/regression/before_test.rb +32 -0
- data/test/mac_spec/testing_framework/regression/deep_nested_example_groups_test.rb +20 -0
- data/test/mac_spec/testing_framework/regression/description_string_test.rb +13 -0
- data/test/mac_spec/testing_framework/regression/example_name_test.rb +11 -0
- data/test/mac_spec/testing_framework/regression/inherit_not_double_test.rb +39 -0
- data/test/mac_spec/testing_framework/regression/surrounding_module_scope_test.rb +31 -0
- data/test/mac_spec/testing_framework/regression/testing_functions_test.rb +66 -0
- data/test/mac_spec/testing_framework/test_helper.rb +1 -0
- data/test/test_helper.rb +1 -0
- metadata +150 -0
@@ -0,0 +1,90 @@
|
|
1
|
+
module MacSpec
|
2
|
+
module TestingFramework
|
3
|
+
# The methods defined in this module are available
|
4
|
+
# inside the TestCases.
|
5
|
+
module TestCaseClassMethods
|
6
|
+
attr_accessor :desc, :setup_chained, :teardown_chained
|
7
|
+
@desc ||= ""
|
8
|
+
def setup_chained # :nodoc:
|
9
|
+
@setup_chained || lambda {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def teardown_chained # :nodoc:
|
13
|
+
@teardown_chained || lambda {}
|
14
|
+
end
|
15
|
+
|
16
|
+
def testcases
|
17
|
+
@@testcases ||= []
|
18
|
+
@@testcases
|
19
|
+
end
|
20
|
+
|
21
|
+
def own_tests
|
22
|
+
@own_tests ||= []
|
23
|
+
end
|
24
|
+
|
25
|
+
def all_tests
|
26
|
+
@@_tests ||= []
|
27
|
+
end
|
28
|
+
|
29
|
+
def macspec_superclass
|
30
|
+
@macspec_superclass
|
31
|
+
end
|
32
|
+
|
33
|
+
def macspec_superclass=(sc)
|
34
|
+
@macspec_superclass = sc
|
35
|
+
end
|
36
|
+
|
37
|
+
# == Run before each Test.
|
38
|
+
# The code in the block attached to this method will be run before each
|
39
|
+
# test in all subsequent, eventually nested testcases.
|
40
|
+
def setup(&block)
|
41
|
+
passed_through_setup = self.setup_chained
|
42
|
+
self.setup_chained = lambda { instance_eval(&passed_through_setup);instance_eval(&block) }
|
43
|
+
define_method :setup, &self.setup_chained
|
44
|
+
end
|
45
|
+
alias before setup
|
46
|
+
|
47
|
+
# == Run after each Test.
|
48
|
+
# The code in the block attached to this method will be run after each
|
49
|
+
# test in all subsequent, eventually nested testcases.
|
50
|
+
def teardown(&block)
|
51
|
+
passed_through_teardown = self.teardown_chained
|
52
|
+
self.teardown_chained = lambda {instance_eval(&block);instance_eval(&passed_through_teardown) }
|
53
|
+
define_method :teardown, &self.teardown_chained
|
54
|
+
end
|
55
|
+
alias after teardown
|
56
|
+
|
57
|
+
# == Define a TestCase.
|
58
|
+
def describe desc, &block
|
59
|
+
cls = Class.new(macspec_superclass)
|
60
|
+
mods = self.ancestors.reject {|m| Module === m }
|
61
|
+
Object.const_set(self.name + desc.to_s.split(/\W+/).map { |s| s.capitalize }.join, cls)
|
62
|
+
cls.setup_chained = self.setup_chained
|
63
|
+
cls.teardown_chained = self.teardown_chained
|
64
|
+
cls.macspec_superclass = self.macspec_superclass
|
65
|
+
cls.desc = self.desc + " " + desc
|
66
|
+
cls.tests($1.constantize) if defined?(Rails) &&
|
67
|
+
self.name =~ /^(.*(Controller|Helper|Mailer))Test/ &&
|
68
|
+
self < ActiveSupport::TestCase
|
69
|
+
mods = self.ancestors.select {|m| m.class.to_s == "Module" }
|
70
|
+
orig_block = block
|
71
|
+
block = lambda {include *mods; instance_eval(&orig_block)}
|
72
|
+
cls.class_eval(&block)
|
73
|
+
self.testcases << cls
|
74
|
+
end
|
75
|
+
|
76
|
+
# == Define a test.
|
77
|
+
def it desc, &block
|
78
|
+
self.setup {}
|
79
|
+
desc = MacSpec::TestingFramework::Functions.make_constantizeable(desc)
|
80
|
+
if block_given?
|
81
|
+
test = "test_#{desc.gsub(/\W+/, '_').downcase}"
|
82
|
+
define_method(test, &lambda {$current_spec = self; instance_eval(&block)})
|
83
|
+
(@@_tests ||= []) << test.to_sym
|
84
|
+
(@own_tests ||= []) << test.to_sym
|
85
|
+
end
|
86
|
+
self.teardown {}
|
87
|
+
end
|
88
|
+
end # TestCaseClassMethods
|
89
|
+
end
|
90
|
+
end # MacSpec
|
data/test/all.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper.rb'
|
2
|
+
|
3
|
+
module MacSpec
|
4
|
+
module MatcherSystem
|
5
|
+
describe "change matcher" do
|
6
|
+
before do
|
7
|
+
@var = 1
|
8
|
+
end
|
9
|
+
|
10
|
+
it "passing" do
|
11
|
+
lambda {@var += 1}.should change {@var}
|
12
|
+
end
|
13
|
+
|
14
|
+
it "change fails" do
|
15
|
+
lambda do
|
16
|
+
lambda { }.should change {@var}
|
17
|
+
end.should raise_error
|
18
|
+
end
|
19
|
+
|
20
|
+
it "change by" do
|
21
|
+
lambda {@var += 1}.should change {@var}.by(1)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "change by fails" do
|
25
|
+
lambda do
|
26
|
+
lambda {@var += 2}.should change {@var}.by(1)
|
27
|
+
end.should raise_error
|
28
|
+
end
|
29
|
+
|
30
|
+
it "change by at least" do
|
31
|
+
lambda {@var += 1}.should change {@var}.by_at_least(1)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "change by at least fails" do
|
35
|
+
lambda do
|
36
|
+
lambda {@var += 0.9}.should change {@var}.by_at_least(1)
|
37
|
+
end.should raise_error
|
38
|
+
end
|
39
|
+
|
40
|
+
it "change by at most" do
|
41
|
+
lambda {@var += 1}.should change {@var}.by_at_most(1)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "change by at most fails" do
|
45
|
+
lambda do
|
46
|
+
lambda {@var += 1.1}.should change {@var}.by_at_most(1)
|
47
|
+
end.should raise_error
|
48
|
+
end
|
49
|
+
|
50
|
+
it "change from to" do
|
51
|
+
lambda {@var += 1}.should change {@var}.from(1).to(2)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "change from to fails" do
|
55
|
+
lambda do
|
56
|
+
lambda {@var += 1.1}.should change {@var}.from(1).to(2)
|
57
|
+
end.should raise_error
|
58
|
+
end
|
59
|
+
|
60
|
+
it "raises unsupported message sent" do
|
61
|
+
lambda do
|
62
|
+
lambda {@var += 1.1}.should change {@var}.unsupported_message
|
63
|
+
end.should raise_error Exceptions::UnsupportedMessageSentToMatcher
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper.rb'
|
2
|
+
|
3
|
+
describe "Enumerable Expectations" do
|
4
|
+
it "include" do
|
5
|
+
[1,2,3,4].should include(4)
|
6
|
+
end
|
7
|
+
|
8
|
+
it "include fail" do
|
9
|
+
lambda {
|
10
|
+
[1,2,3,4].should include(6)
|
11
|
+
}.should raise_error(MacSpec.assertion_failed_error)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "exclude" do
|
15
|
+
[1,2,3,4].should exclude(9)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "exclude fail" do
|
19
|
+
lambda {
|
20
|
+
[1,2,3,4].should exclude(4)
|
21
|
+
}.should raise_error(MacSpec.assertion_failed_error)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "multi include" do
|
25
|
+
[1,2,3,4].should include(1,2)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "multi include fail" do
|
29
|
+
lambda {
|
30
|
+
[1,2,3,4].should include(6,7,8)
|
31
|
+
}.should raise_error(MacSpec.assertion_failed_error)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "multi exclude" do
|
35
|
+
[1,2,3,4].should exclude(13,14)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "multi exclude fail" do
|
39
|
+
lambda {
|
40
|
+
[1,2,3,4].should exclude(2,3,4)
|
41
|
+
}.should raise_error(MacSpec.assertion_failed_error)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "negative include" do
|
45
|
+
[1,2,3,4].should_not include(9)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "negative include fail" do
|
49
|
+
lambda {
|
50
|
+
[1,2,3,4].should_not include(4)
|
51
|
+
}.should raise_error(MacSpec.assertion_failed_error)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "negative exclude" do
|
55
|
+
[1,2,3,4].should_not exclude(3)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "negative exclude fail" do
|
59
|
+
lambda {
|
60
|
+
[1,2,3,4].should_not exclude(6,7)
|
61
|
+
}.should raise_error(MacSpec.assertion_failed_error)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "include fail message" do
|
65
|
+
obj = include(1)
|
66
|
+
obj.matches?([4,5,6])
|
67
|
+
|
68
|
+
obj.failure_message.should be("Expected [4, 5, 6] to include [1].")
|
69
|
+
end
|
70
|
+
|
71
|
+
it "include negative fail message" do
|
72
|
+
obj = include(1)
|
73
|
+
obj.matches?([4,5,6])
|
74
|
+
|
75
|
+
obj.negative_failure_message.should be("Expected [4, 5, 6] to not include [1].")
|
76
|
+
end
|
77
|
+
|
78
|
+
it "exclude fail message" do
|
79
|
+
obj = exclude(4)
|
80
|
+
obj.matches?([4,5,6])
|
81
|
+
|
82
|
+
obj.failure_message.should be("Expected [4, 5, 6] to exclude [4].")
|
83
|
+
end
|
84
|
+
|
85
|
+
it "exclude negative fail message" do
|
86
|
+
obj = exclude(4)
|
87
|
+
obj.matches?([4,5,6])
|
88
|
+
|
89
|
+
obj.negative_failure_message.should be("Expected [4, 5, 6] to not exclude [4].")
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,144 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper.rb'
|
2
|
+
|
3
|
+
describe "Error Expectations" do
|
4
|
+
it "raises error" do
|
5
|
+
lambda { raise "FAIL" }.should raise_error
|
6
|
+
end
|
7
|
+
|
8
|
+
it "raises error fail" do
|
9
|
+
lambda {
|
10
|
+
lambda { "WIN" }.should raise_error
|
11
|
+
}.should raise_error(MacSpec.assertion_failed_error)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "negative raises error" do
|
15
|
+
lambda { "WIN" }.should_not raise_error
|
16
|
+
end
|
17
|
+
|
18
|
+
it "negative raises error fail" do
|
19
|
+
lambda {
|
20
|
+
lambda { raise "FAIL" }.should_not raise_error
|
21
|
+
}.should raise_error(MacSpec.assertion_failed_error)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "raises specific error" do
|
25
|
+
lambda { raise TypeError }.should raise_error(TypeError)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "raises specific error fail with no error" do
|
29
|
+
lambda {
|
30
|
+
lambda { "WIN" }.should raise_error(TypeError)
|
31
|
+
}.should raise_error(MacSpec.assertion_failed_error)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "raises specific error fail with different error" do
|
35
|
+
lambda {
|
36
|
+
lambda { raise StandardError }.should raise_error(TypeError)
|
37
|
+
}.should raise_error(MacSpec.assertion_failed_error)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "throws symbol" do
|
41
|
+
lambda {
|
42
|
+
throw :win
|
43
|
+
}.should throw_symbol(:win)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "throws symbol fails with different symbol" do
|
47
|
+
lambda {
|
48
|
+
lambda {
|
49
|
+
throw :fail
|
50
|
+
}.should throw_symbol(:win)
|
51
|
+
}.should raise_error(MacSpec.assertion_failed_error)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "negative throws symbol" do
|
55
|
+
lambda {
|
56
|
+
"not this time!"
|
57
|
+
}.should_not throw_symbol(:win)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "negative throws symbol fails with different symbol" do
|
61
|
+
|
62
|
+
lambda{
|
63
|
+
lambda {
|
64
|
+
throw :fail
|
65
|
+
}.should_not throw_symbol(:fail)
|
66
|
+
}.should raise_error(MacSpec.assertion_failed_error)
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
it "error fail message" do
|
71
|
+
obj = raise_error(TypeError)
|
72
|
+
obj.matches?(lambda { raise NameError })
|
73
|
+
|
74
|
+
obj.failure_message.should =~ /Expected #<(.*)> to raise TypeError, but NameError was raised instead./
|
75
|
+
end
|
76
|
+
|
77
|
+
it "error fail message when no error" do
|
78
|
+
obj = raise_error(TypeError)
|
79
|
+
obj.matches?(lambda { "moop" })
|
80
|
+
|
81
|
+
obj.failure_message.should =~ /Expected #<(.*)> to raise TypeError, but none was raised./
|
82
|
+
end
|
83
|
+
|
84
|
+
it "error negative fail message" do
|
85
|
+
obj = raise_error(TypeError)
|
86
|
+
obj.matches?(lambda { raise TypeError })
|
87
|
+
|
88
|
+
obj.negative_failure_message.should =~ /Expected #<(.*)> to not raise TypeError./
|
89
|
+
end
|
90
|
+
|
91
|
+
it "throw fail message" do
|
92
|
+
obj = throw_symbol(:fail)
|
93
|
+
obj.matches?(lambda { throw :lame })
|
94
|
+
|
95
|
+
obj.failure_message.should =~ /Expected #<(.*)> to throw :fail, but :lame was thrown instead./
|
96
|
+
end
|
97
|
+
|
98
|
+
it "throw fail message when no symbol" do
|
99
|
+
obj = throw_symbol(:fail)
|
100
|
+
obj.matches?(lambda { "moop" })
|
101
|
+
|
102
|
+
obj.failure_message.should =~ /Expected #<(.*)> to throw :fail, but no symbol was thrown./
|
103
|
+
end
|
104
|
+
|
105
|
+
it "throw negative fail message" do
|
106
|
+
obj = throw_symbol(:fail)
|
107
|
+
obj.matches?(lambda { throw :fail })
|
108
|
+
|
109
|
+
obj.negative_failure_message.should =~ /Expected #<(.*)> to not throw :fail./
|
110
|
+
end
|
111
|
+
|
112
|
+
it "string argument message" do
|
113
|
+
lambda {raise "message"}.should raise_error("message")
|
114
|
+
end
|
115
|
+
|
116
|
+
it "string argument message fails no error" do
|
117
|
+
lambda do
|
118
|
+
lambda { 1 }.should raise_error("message")
|
119
|
+
|
120
|
+
end.should raise_error
|
121
|
+
end
|
122
|
+
|
123
|
+
it "string argument message fails wrong message" do
|
124
|
+
lambda do
|
125
|
+
lambda { raise "other message" }.should raise_error("message")
|
126
|
+
end.should raise_error
|
127
|
+
end
|
128
|
+
|
129
|
+
it "regexp argument message" do
|
130
|
+
lambda {raise "message"}.should raise_error(/essa/)
|
131
|
+
end
|
132
|
+
|
133
|
+
it "regexp argument message fails no error" do
|
134
|
+
lambda do
|
135
|
+
lambda { 1 }.should raise_error(/essa/)
|
136
|
+
end.should raise_error
|
137
|
+
end
|
138
|
+
|
139
|
+
it "regexp argument message fails wrong message" do
|
140
|
+
lambda do
|
141
|
+
lambda { raise "other message" }.should raise_error(/abc/)
|
142
|
+
end.should raise_error(/matching/)
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper.rb'
|
2
|
+
|
3
|
+
describe "Operator Expectations" do
|
4
|
+
|
5
|
+
it "equals (==)" do
|
6
|
+
3.should == 3
|
7
|
+
end
|
8
|
+
|
9
|
+
it "equals fails" do
|
10
|
+
lambda {
|
11
|
+
3.should == 5
|
12
|
+
}.should raise_error(MacSpec.assertion_failed_error)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "negative equals" do
|
16
|
+
3.should_not == 4
|
17
|
+
end
|
18
|
+
|
19
|
+
it "negative equals fails" do
|
20
|
+
lambda {
|
21
|
+
3.should_not == 3
|
22
|
+
}.should raise_error(MacSpec.assertion_failed_error)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "less than (<)" do
|
26
|
+
3.should < 5
|
27
|
+
end
|
28
|
+
|
29
|
+
it "less than fails" do
|
30
|
+
lambda {
|
31
|
+
4.should < 3
|
32
|
+
}.should raise_error(MacSpec.assertion_failed_error)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "less than equals" do
|
36
|
+
3.should_not < 2
|
37
|
+
end
|
38
|
+
|
39
|
+
it "negative less than fails" do
|
40
|
+
lambda {
|
41
|
+
4.should_not < 5
|
42
|
+
}.should raise_error(MacSpec.assertion_failed_error)
|
43
|
+
end
|
44
|
+
|
45
|
+
# GREATER THAN (>)
|
46
|
+
it "greater than" do
|
47
|
+
3.should > 2
|
48
|
+
end
|
49
|
+
|
50
|
+
it "greater than fails" do
|
51
|
+
lambda {
|
52
|
+
4.should > 5
|
53
|
+
}.should raise_error(MacSpec.assertion_failed_error)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "greater than equals" do
|
57
|
+
3.should_not > 5
|
58
|
+
end
|
59
|
+
|
60
|
+
it "negative greater than fails" do
|
61
|
+
lambda {
|
62
|
+
4.should_not > 3
|
63
|
+
}.should raise_error(MacSpec.assertion_failed_error)
|
64
|
+
end
|
65
|
+
|
66
|
+
# LESS THAN EQUAL (<=)
|
67
|
+
it "less than equal" do
|
68
|
+
3.should <= 5
|
69
|
+
end
|
70
|
+
|
71
|
+
it "less than equal equal" do
|
72
|
+
3.should <= 3
|
73
|
+
end
|
74
|
+
|
75
|
+
it "less than equal fails" do
|
76
|
+
lambda {
|
77
|
+
4.should <= 3
|
78
|
+
}.should raise_error(MacSpec.assertion_failed_error)
|
79
|
+
end
|
80
|
+
|
81
|
+
it "negative less than equal" do
|
82
|
+
3.should_not <= 2
|
83
|
+
end
|
84
|
+
|
85
|
+
it "negative less than equal fails" do
|
86
|
+
lambda {
|
87
|
+
4.should_not <= 5
|
88
|
+
}.should raise_error(MacSpec.assertion_failed_error)
|
89
|
+
end
|
90
|
+
|
91
|
+
# GREATER THAN EQUALS (>=)
|
92
|
+
it "greater than equal" do
|
93
|
+
3.should >= 2
|
94
|
+
end
|
95
|
+
|
96
|
+
it "greater than equal equals" do
|
97
|
+
3.should >= 3
|
98
|
+
end
|
99
|
+
|
100
|
+
it "greater than equal fails" do
|
101
|
+
lambda {
|
102
|
+
4.should >= 5
|
103
|
+
}.should raise_error(MacSpec.assertion_failed_error)
|
104
|
+
end
|
105
|
+
|
106
|
+
it "negative greater than equal equals" do
|
107
|
+
3.should_not >= 5
|
108
|
+
end
|
109
|
+
|
110
|
+
it "negative greater than equal fails" do
|
111
|
+
lambda {
|
112
|
+
4.should_not >= 3
|
113
|
+
}.should raise_error(MacSpec.assertion_failed_error)
|
114
|
+
end
|
115
|
+
|
116
|
+
# MATCHES (=~)
|
117
|
+
it "matches" do
|
118
|
+
"hey world".should =~ /world/
|
119
|
+
end
|
120
|
+
|
121
|
+
it "matches fails" do
|
122
|
+
lambda {
|
123
|
+
"d00d ur 1337".should =~ /world/
|
124
|
+
}.should raise_error(MacSpec.assertion_failed_error)
|
125
|
+
end
|
126
|
+
|
127
|
+
it "negative matches" do
|
128
|
+
"1337@age".should_not =~ /434/
|
129
|
+
end
|
130
|
+
|
131
|
+
it "negative matches fails" do
|
132
|
+
lambda {
|
133
|
+
"it's a freak out!".should_not =~ /freak/
|
134
|
+
}.should raise_error(MacSpec.assertion_failed_error)
|
135
|
+
end
|
136
|
+
end
|