expectations 0.2.0 → 0.2.1

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.
@@ -1,12 +1,11 @@
1
- class Expectations::NegativeStateBasedRecorder < Expectations::StateBasedRecorder
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
@@ -8,11 +8,27 @@ class Object
8
8
  end
9
9
 
10
10
  def to
11
- Expectations::PositiveStateBasedRecorder.new(self)
11
+ Expectations::StateBasedRecorder.new(self).extend Expectations::PositiveStateBasedRecorder
12
12
  end
13
13
 
14
14
  def not
15
- Expectations::NegativeStateBasedRecorder.new(self)
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
- class Expectations::PositiveStateBasedRecorder < Expectations::StateBasedRecorder
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 = "expected #{expected.subject} to #{expected.message}"
10
+ self.message = expected.message
11
11
  end
12
12
  rescue Exception => ex
13
13
  self.extend(Expectations::Results::Error)
@@ -15,10 +15,6 @@ class Expectations::StateBasedRecorder
15
15
  self
16
16
  end
17
17
 
18
- def message
19
- @message_parts.join(" ")
20
- end
21
-
22
18
  def method_stack
23
19
  @method_stack ||= []
24
20
  end
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.0"
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.0
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-02 00:00:00 -08:00
12
+ date: 2008-03-03 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency