public
Description: A collection of RSpec matchers to be used with the Ruby on Rails project
Clone URL: git://github.com/joshknowles/rspec-on-rails-matchers.git
Search Repo:
Added should observe.  Patch by Luke Melia.


git-svn-id: https://rspec-on-rails-matchers.googlecode.com/svn/trunk@23 
11e6f158-dd3c-0410-a69b-4d739fb74d9d
joshknowles (author)
Sun Mar 02 21:14:47 -0800 2008
commit  33f44e4d7242d05fa9f1a25556e0f4d11b713feb
tree    43bfa839f7b968a0a7235f11e1510dc7c6ee9314
parent  1b2d79a6d9b34c2815430a6d9193c88a1383fe02
...
4
5
6
 
7
8
...
4
5
6
7
8
9
0
@@ -4,6 +4,7 @@
0
 Trunk
0
 -----
0
 
0
+* 2008/03/02 - Added should observe (Luke Melia)
0
 * 2008/03/02 - Patched validates_length_of to use within to be consistent with Rails (Matt Pelletier)
0
 * 2007/01/03 - Initial Public Release
0
...
51
52
53
 
 
 
 
 
54
55
56
...
173
174
175
176
 
 
 
177
178
...
51
52
53
54
55
56
57
58
59
60
61
...
178
179
180
 
181
182
183
184
185
0
@@ -51,6 +51,11 @@
0
     object.should validate_length_of(:attribute, :is => 5)
0
     TM snippet: [msvl + tab]
0
 
0
+ * Observers:
0
+ Verify that the observer is observing a class. (doesn't verify that the observation works)
0
+
0
+ object.should observe(:model)
0
+ example: GroupObserver.should observe(Group)
0
 
0
   * Views:
0
     Verifies that the views contains some tags.
0
@@ -173,7 +178,9 @@
0
 Contributors
0
 -------------
0
 
0
- * ckknight (improved should validate_length_of)
0
+ * ckknight
0
+ * Matt Pelletier
0
+ * Luke Melia
0
 
0
 Copyright (c) 2008 The Plugin Development Team, released under the MIT license
...
 
1
2
3
 
...
1
2
3
4
5
0
@@ -1,4 +1,6 @@
0
+require 'spec/rails/matchers/observers'
0
 require 'spec/rails/matchers/associations'
0
 require 'spec/rails/matchers/validations'
0
 require 'spec/rails/matchers/views'
0
+require 'spec/rails/matchers/observers'
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
0
@@ -1 +1,35 @@
0
+module Spec
0
+ module Rails
0
+ module Matchers
0
+
0
+ class Observe
0
+ def initialize(expected_model_class)
0
+ @expected_model_class = expected_model_class
0
+ end
0
+
0
+ def matches?(observer)
0
+ @observer = observer
0
+ if @observer.is_a?(ActiveRecord::Observer)
0
+ @observer = @observer.class
0
+ end
0
+ @observed_classes = observer.observed_classes.flatten
0
+ @observed_classes.include?(@expected_model_class)
0
+ end
0
+
0
+ def failure_message
0
+ return "expected #{@observer.name} to observe #{@expected_model_class.name}, but it was not included in [#{@observed_classes.map(&:name).join(', ')}]"
0
+ end
0
+
0
+ def description
0
+ "observer to be observing #{@expected_model_class.name}"
0
+ end
0
+ end
0
+
0
+ def observe(expected_model_class)
0
+ Observe.new(expected_model_class)
0
+ end
0
+
0
+ end
0
+ end
0
+end

Comments

    No one has commented yet.