expectations 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/expectations/negative_state_based_recorder.rb +5 -6
- data/lib/expectations/object.rb +18 -2
- data/lib/expectations/positive_state_based_recorder.rb +9 -1
- data/lib/expectations/recorded_state_based_expectation.rb +1 -1
- data/lib/expectations/state_based_recorder.rb +0 -4
- data/rakefile.rb +1 -1
- metadata +2 -2
@@ -1,12 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
def to
|
4
|
-
@message_parts << "to"
|
5
|
-
self
|
6
|
-
end
|
1
|
+
module Expectations::NegativeStateBasedRecorder
|
7
2
|
|
8
3
|
def verify
|
9
4
|
not method_stack.inject(subject) { |result, element| result.send element.first, *element.last }
|
10
5
|
end
|
11
6
|
|
7
|
+
def message
|
8
|
+
"expected #{subject} not to #{@message_parts.join(" ")}"
|
9
|
+
end
|
10
|
+
|
12
11
|
end
|
data/lib/expectations/object.rb
CHANGED
@@ -8,11 +8,27 @@ class Object
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def to
|
11
|
-
Expectations::
|
11
|
+
Expectations::StateBasedRecorder.new(self).extend Expectations::PositiveStateBasedRecorder
|
12
12
|
end
|
13
13
|
|
14
14
|
def not
|
15
|
-
|
15
|
+
Not.new(self)
|
16
|
+
end
|
17
|
+
|
18
|
+
def __negate__
|
19
|
+
!self
|
20
|
+
end
|
21
|
+
|
22
|
+
class Not
|
23
|
+
private(*instance_methods.select { |m| m !~ /(^__|^\W|^binding$)/ })
|
24
|
+
|
25
|
+
def initialize(subject)
|
26
|
+
@subject = subject
|
27
|
+
end
|
28
|
+
|
29
|
+
def method_missing(sym, *args, &blk)
|
30
|
+
@subject.send(sym,*args,&blk).__negate__
|
31
|
+
end
|
16
32
|
end
|
17
33
|
|
18
34
|
def expectations_equal_to(other)
|
@@ -1,7 +1,15 @@
|
|
1
|
-
|
1
|
+
module Expectations::PositiveStateBasedRecorder
|
2
2
|
|
3
3
|
def verify
|
4
4
|
method_stack.inject(subject) { |result, element| result.send element.first, *element.last }
|
5
5
|
end
|
6
|
+
|
7
|
+
def __negate__
|
8
|
+
extend Expectations::NegativeStateBasedRecorder
|
9
|
+
end
|
10
|
+
|
11
|
+
def message
|
12
|
+
"expected #{subject} to #{@message_parts.join(" ")}"
|
13
|
+
end
|
6
14
|
|
7
15
|
end
|
@@ -7,7 +7,7 @@ module Expectations::RecordedStateBasedExpectation
|
|
7
7
|
self.extend(Expectations::Results::Fulfilled)
|
8
8
|
else
|
9
9
|
self.extend(Expectations::Results::StateBasedFailure)
|
10
|
-
self.message =
|
10
|
+
self.message = expected.message
|
11
11
|
end
|
12
12
|
rescue Exception => ex
|
13
13
|
self.extend(Expectations::Results::Error)
|
data/rakefile.rb
CHANGED
@@ -46,7 +46,7 @@ specification = Gem::Specification.new do |s|
|
|
46
46
|
expect NoMethodError do
|
47
47
|
Object.invalid_method_call
|
48
48
|
end."
|
49
|
-
s.version = "0.2.
|
49
|
+
s.version = "0.2.1"
|
50
50
|
s.author = 'Jay Fields'
|
51
51
|
s.description = "A lightweight unit testing framework. Tests (expectations) will be written as follows
|
52
52
|
expect 2 do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: expectations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jay Fields
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-03-
|
12
|
+
date: 2008-03-03 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|