custom_rspec_matchers 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- custom_rspec_matchers (0.0.1)
4
+ custom_rspec_matchers (0.0.2)
5
5
  actionpack (~> 3.0)
6
6
  activemodel (~> 3.0)
7
7
  rake
@@ -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
- it { should have_around_create_callback(:around_create_callback) }
11
- it { should have_before_create_callback(:before_create_callback) }
10
+ it { should have_around_create_callback(:around_create_callback) }
11
+ it { should have_before_create_callback(:before_create_callback) }
12
12
 
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) }
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
- 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) }
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.2'
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
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - kenny ortmann