custom_rspec_matchers 0.0.2 → 0.0.3
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/Gemfile.lock
CHANGED
data/README.rdoc
CHANGED
@@ -7,16 +7,26 @@ This project contains a few custom rspec matchers that we have built to help us
|
|
7
7
|
describe Duck do
|
8
8
|
|
9
9
|
it { should have_after_create_callback(:after_create_callback) }
|
10
|
-
|
11
|
-
|
10
|
+
it { should have_around_create_callback(:around_create_callback) }
|
11
|
+
it { should have_before_create_callback(:before_create_callback) }
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
it { should have_after_save_callback(:after_save_callback) }
|
14
|
+
it { should have_around_save_callback(:around_save_callback) }
|
15
|
+
it { should have_before_save_callback(:before_save_callback) }
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
it { should have_after_update_callback(:after_update_callback) }
|
18
|
+
it { should have_around_update_callback(:around_update_callback) }
|
19
|
+
it { should have_before_update_callback(:before_update_callback) }
|
20
|
+
|
21
|
+
it { should have_after_validation_callback(:after_validation_callback) }
|
22
|
+
it { should have_before_validation_callback(:before_validation_callback) }
|
23
|
+
|
24
|
+
it { should have_after_validation_on_create_callback(:after_validation_on_create_callback) }
|
25
|
+
it { should have_before_validation_on_create_callback(:before_validation_on_create_callback) }
|
26
|
+
|
27
|
+
it { should have_after_validation_on_update_callback(:after_validation_on_update_callback) }
|
28
|
+
it { should have_before_validation_on_update_callback(:before_validation_on_update_callback) }
|
29
|
+
|
20
30
|
|
21
31
|
end
|
22
32
|
|
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "custom_rspec_matchers"
|
6
|
-
s.version = '0.0.
|
6
|
+
s.version = '0.0.3'
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.authors = ["kenny ortmann", "matt simpson", "amos king"]
|
9
9
|
s.email = ['kenny.ortmann@gmail.com', 'matt.simpson@asolutions.com', 'amos.king@asolutions.com']
|
@@ -21,6 +21,30 @@ module CustomRspecMatchers
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
+
def have_after_validation_callback(method)
|
25
|
+
CallbackMatcher.new(:after, :validation, method)
|
26
|
+
end
|
27
|
+
|
28
|
+
def have_before_validation_callback(method)
|
29
|
+
CallbackMatcher.new(:before, :validation, method)
|
30
|
+
end
|
31
|
+
|
32
|
+
def have_after_validation_on_create_callback(method)
|
33
|
+
CallbackMatcher.new(:after, :validation_on_create, method)
|
34
|
+
end
|
35
|
+
|
36
|
+
def have_before_validation_on_create_callback(method)
|
37
|
+
CallbackMatcher.new(:before, :validation_on_create, method)
|
38
|
+
end
|
39
|
+
|
40
|
+
def have_after_validation_on_update_callback(method)
|
41
|
+
CallbackMatcher.new(:after, :validation_on_update, method)
|
42
|
+
end
|
43
|
+
|
44
|
+
def have_before_validation_on_update_callback(method)
|
45
|
+
CallbackMatcher.new(:before, :validation_on_update, method)
|
46
|
+
end
|
47
|
+
|
24
48
|
def have_after_create_callback(method)
|
25
49
|
CallbackMatcher.new(:after, :create, method)
|
26
50
|
end
|
@@ -14,4 +14,13 @@ describe Duck do
|
|
14
14
|
it { should have_around_update_callback(:around_update_callback) }
|
15
15
|
it { should have_before_update_callback(:before_update_callback) }
|
16
16
|
|
17
|
+
it { should have_after_validation_callback(:after_validation_callback) }
|
18
|
+
it { should have_before_validation_callback(:before_validation_callback) }
|
19
|
+
|
20
|
+
it { should have_after_validation_on_create_callback(:after_validation_on_create_callback) }
|
21
|
+
it { should have_before_validation_on_create_callback(:before_validation_on_create_callback) }
|
22
|
+
|
23
|
+
it { should have_after_validation_on_update_callback(:after_validation_on_update_callback) }
|
24
|
+
it { should have_before_validation_on_update_callback(:before_validation_on_update_callback) }
|
25
|
+
|
17
26
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class Duck
|
2
2
|
extend ActiveModel::Callbacks
|
3
|
-
define_model_callbacks :create, :update, :save
|
3
|
+
define_model_callbacks :create, :update, :save, :validation, :validation_on_create, :validation_on_update
|
4
4
|
after_create :after_create_callback
|
5
5
|
around_create :around_create_callback
|
6
6
|
before_create :before_create_callback
|
@@ -13,4 +13,13 @@ class Duck
|
|
13
13
|
around_update :around_update_callback
|
14
14
|
before_update :before_update_callback
|
15
15
|
|
16
|
+
before_validation :before_validation_callback
|
17
|
+
after_validation :after_validation_callback
|
18
|
+
|
19
|
+
before_validation_on_create :before_validation_on_create_callback
|
20
|
+
after_validation_on_create :after_validation_on_create_callback
|
21
|
+
|
22
|
+
before_validation_on_update :before_validation_on_update_callback
|
23
|
+
after_validation_on_update :after_validation_on_update_callback
|
24
|
+
|
16
25
|
end
|