shoulda-callback-matchers 1.1.1 → 1.1.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 1c1f3a238962147de08a5dfe77046fc8d4055901
4
- data.tar.gz: 58858d72aadfd5821ec598c795fed09364f9fc89
5
- SHA512:
6
- metadata.gz: 18ee32dd29e5cffc3937e6bde593a0e30304d13d33c37a4bd90c89056c7553d86d987d0020d5b47651d1d313bdbdf86b6ece185633bcce93ae4ff53a39d9a2d4
7
- data.tar.gz: d972b21525d285b2af3d366ae74623f56973ce07a68f338f2c4eb8201456d2fd4be2c3fe6c92e541d457f6942e6552ee389517a42053417325999a33859cf294
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3f00ef72e66bbe84af996f2f435cb49add03642f
4
+ data.tar.gz: 5bda94451994d17de1f96eba49790dfe5faef9c4
5
+ SHA512:
6
+ metadata.gz: 34be6faad876bb3488742d1d6f05524440beb6808862e8b67f860859ed428fd52bbb6c67f1db7e5d4b2fe608a5fd10255406d6e11bb1f92ed2ea40ea9b87741b
7
+ data.tar.gz: 296cfb37d4c2b111c36de75efe7211476a18ccc4e6107e20bd5c4bd54bdab62d0d0111d66e7c0f2b3ea657944bf70c23d73a5b2b4d7d94d11ca0b1f00dd0ef62
@@ -1,19 +1,28 @@
1
1
  rvm:
2
2
  - 1.9.3
3
3
  - 2.0.0
4
- - 2.1.2
4
+ - 2.1.5
5
+ - 2.2.0
5
6
  - rbx-2
6
7
  - jruby-19mode
8
+ - jruby-20mode
7
9
  - jruby-head
8
10
 
9
11
  script: "bundle exec rspec"
10
12
 
11
13
  gemfile:
14
+ - gemfiles/rails_4.2.gemfile
12
15
  - gemfiles/rails_4.1.gemfile
13
16
  - gemfiles/rails_4.0.gemfile
14
17
  - gemfiles/rails_3.2.gemfile
15
18
  - gemfiles/rails_3.1.gemfile
16
19
 
20
+
17
21
  matrix:
18
- allow_failures:
19
- - rvm: jruby-head
22
+ exclude:
23
+ - rvm: 2.2.0
24
+ gemfile: gemfiles/rails_4.0.gemfile
25
+ - rvm: 2.2.0
26
+ gemfile: gemfiles/rails_3.2.gemfile
27
+ - rvm: 2.2.0
28
+ gemfile: gemfiles/rails_3.1.gemfile
data/Appraisals CHANGED
@@ -1,3 +1,9 @@
1
+ appraise 'rails 4.2' do
2
+ gem 'rails', '~> 4.2.0'
3
+ gem 'jquery-rails'
4
+ gem 'sass-rails', '~> 4.0'
5
+ end
6
+
1
7
  appraise 'rails 4.1' do
2
8
  gem 'rails', '~> 4.1.0'
3
9
  gem 'jquery-rails'
data/Gemfile CHANGED
@@ -3,12 +3,14 @@ source 'http://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  # For test Rails application
6
- gem 'sqlite3', :platform => :ruby
6
+ gem 'sqlite3', platform: :ruby
7
7
 
8
8
  # Can't wrap in platform :jruby do...end block because appraisal doesn't support
9
9
  # it
10
- gem 'activerecord-jdbc-adapter', :platform => :jruby
11
- gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
12
- gem 'jdbc-sqlite3', :platform => :jruby
13
- gem 'jruby-openssl', :platform => :jruby
14
- gem 'therubyrhino', :platform => :jruby
10
+ gem 'activerecord-jdbc-adapter', platform: :jruby
11
+ gem 'activerecord-jdbcsqlite3-adapter', platform: :jruby
12
+ gem 'jdbc-sqlite3', platform: :jruby
13
+ gem 'jruby-openssl', platform: :jruby
14
+ gem 'therubyrhino', platform: :jruby
15
+
16
+ gem 'psych', platform: :rbx
data/README.md CHANGED
@@ -8,60 +8,64 @@ Matchers to test before, after and around hooks(currently supports method and ob
8
8
 
9
9
  Method Callbacks:
10
10
 
11
- describe Post do
12
- it { should callback(:count_comments).before(:save) }
13
- it { should callback(:post_to_twitter).after(:create) }
14
- it { should callback(:evaluate_if_should_validate).before(:validation) }
15
- it { should callback(:add_some_convenience_accessors).after(:find) }
16
-
17
- # with conditions
18
-
19
- it { should callback(:assign_something).before(:create).if(:this_is_true) }
20
- it { should callback(:destroy_something_else).before(:destroy).unless(:this_is_true) }
21
- end
22
-
23
- describe User do
24
- it { should_not callback(:make_email_validation_ready!).before(:validation).on(:update) }
25
- it { should callback(:make_email_validation_ready!).before(:validation).on(:create) }
26
- it { should callback(:update_user_count).before(:destroy) }
27
- end
11
+ ````ruby
12
+ describe Post do
13
+ it { is_expected.to callback(:count_comments).before(:save) }
14
+ it { is_expected.to callback(:post_to_twitter).after(:create) }
15
+ it { is_expected.to callback(:evaluate_if_is_should_validate).before(:validation) }
16
+ it { is_expected.to callback(:add_some_convenience_accessors).after(:find) }
17
+
18
+ # with conditions
19
+
20
+ it { is_expected.to callback(:assign_something).before(:create).if(:this_is_true) }
21
+ it { is_expected.to callback(:destroy_something_else).before(:destroy).unless(:this_is_true) }
22
+ end
23
+
24
+ describe User do
25
+ it { is_expected.not_to callback(:make_email_validation_ready!).before(:validation).on(:update) }
26
+ it { is_expected.to callback(:make_email_validation_ready!).before(:validation).on(:create) }
27
+ it { is_expected.to callback(:update_user_count).before(:destroy) }
28
+ end
29
+ ````
28
30
 
29
31
  Object Callbacks:
30
32
 
31
- class CallbackClass
32
- def before_save
33
- ...
34
- end
35
-
36
- def after_create
37
- ...
38
- end
39
-
40
- def before_validation
41
- ...
42
- end
43
-
44
- def after_find
45
- ...
46
- end
47
- end
48
-
49
- describe Post do
50
- it { should callback(CallbackClass).before(:save) }
51
- it { should callback(CallbackClass).after(:create) }
52
- it { should callback(CallbackClass).before(:validation) }
53
- it { should callback(CallbackClass).after(:find) }
54
-
55
- # with conditions
56
- it { should callback(CallbackClass).before(:create).if(:this_is_true) }
57
- it { should callback(CallbackClass).after(:find).unless(:is_this_true?) }
58
- end
59
-
60
- describe User do
61
- it { should_not callback(CallbackClass).before(:validation).on(:update) }
62
- it { should callback(CallbackClass).before(:validation).on(:create) }
63
- it { should callback(CallbackClass).before(:destroy) }
64
- end
33
+ ````ruby
34
+ class CallbackClass
35
+ def before_save
36
+ ...
37
+ end
38
+
39
+ def after_create
40
+ ...
41
+ end
42
+
43
+ def before_validation
44
+ ...
45
+ end
46
+
47
+ def after_find
48
+ ...
49
+ end
50
+ end
51
+
52
+ describe Post do
53
+ it { is_expected.to callback(CallbackClass).before(:save) }
54
+ it { is_expected.to callback(CallbackClass).after(:create) }
55
+ it { is_expected.to callback(CallbackClass).before(:validation) }
56
+ it { is_expected.to callback(CallbackClass).after(:find) }
57
+
58
+ # with conditions
59
+ it { is_expected.to callback(CallbackClass).before(:create).if(:this_is_true) }
60
+ it { is_expected.to callback(CallbackClass).after(:find).unless(:is_this_true?) }
61
+ end
62
+
63
+ describe User do
64
+ it { is_expected.not_to callback(CallbackClass).before(:validation).on(:update) }
65
+ it { is_expected.to callback(CallbackClass).before(:validation).on(:create) }
66
+ it { is_expected.to callback(CallbackClass).before(:destroy) }
67
+ end
68
+ ````
65
69
 
66
70
  This will test:
67
71
  - the method call
@@ -71,17 +75,21 @@ Either on the model itself or on the callback object. Be aware that obviously th
71
75
 
72
76
  In Rails 3 or 4 and Bundler, add the following to your Gemfile:
73
77
 
74
- group :test do
75
- gem "shoulda-callback-matchers", "~> 1.0"
76
- end
78
+ ````ruby
79
+ group :test do
80
+ gem 'shoulda-callback-matchers', '~> 1.1.1'
81
+ end
82
+ ````
77
83
 
78
84
  This gem uses semantic versioning, so you won't have incompability issues with patches.
79
85
 
80
86
  rspec-rails needs to be in the development group so that Rails generators work.
81
87
 
82
- group :development, :test do
83
- gem "rspec-rails"
84
- end
88
+ ````ruby
89
+ group :development, :test do
90
+ gem "rspec-rails"
91
+ end
92
+ ````
85
93
 
86
94
  Shoulda will automatically include matchers into the appropriate example groups.
87
95
 
@@ -92,6 +100,9 @@ Shoulda is maintained and funded by [thoughtbot](http://thoughtbot.com/community
92
100
 
93
101
  ## Contributors & Contributions
94
102
  - @pvertenten (callback objects)
103
+ - @johnnyshields (bugfixes)
104
+ - @esbarango (README updates)
105
+ - @yuku-t (Rails 4.2 Support)
95
106
 
96
107
  Let's make this gem useful, send me a PR if you've discovered an issue you'd like to fix!
97
108
 
@@ -8,6 +8,7 @@ gem "activerecord-jdbcsqlite3-adapter", :platform=>:jruby
8
8
  gem "jdbc-sqlite3", :platform=>:jruby
9
9
  gem "jruby-openssl", :platform=>:jruby
10
10
  gem "therubyrhino", :platform=>:jruby
11
+ gem "psych", :platform=>:rbx
11
12
  gem "rails", "~> 3.1.0"
12
13
  gem "jquery-rails"
13
14
  gem "sass-rails"
@@ -8,6 +8,7 @@ gem "activerecord-jdbcsqlite3-adapter", :platform=>:jruby
8
8
  gem "jdbc-sqlite3", :platform=>:jruby
9
9
  gem "jruby-openssl", :platform=>:jruby
10
10
  gem "therubyrhino", :platform=>:jruby
11
+ gem "psych", :platform=>:rbx
11
12
  gem "rails", "~> 3.2.0"
12
13
  gem "jquery-rails"
13
14
  gem "sass-rails"
@@ -8,6 +8,7 @@ gem "activerecord-jdbcsqlite3-adapter", :platform=>:jruby
8
8
  gem "jdbc-sqlite3", :platform=>:jruby
9
9
  gem "jruby-openssl", :platform=>:jruby
10
10
  gem "therubyrhino", :platform=>:jruby
11
+ gem "psych", :platform=>:rbx
11
12
  gem "rails", "~> 4.0.0"
12
13
  gem "jquery-rails"
13
14
  gem "sass-rails"
@@ -8,6 +8,7 @@ gem "activerecord-jdbcsqlite3-adapter", :platform=>:jruby
8
8
  gem "jdbc-sqlite3", :platform=>:jruby
9
9
  gem "jruby-openssl", :platform=>:jruby
10
10
  gem "therubyrhino", :platform=>:jruby
11
+ gem "psych", :platform=>:rbx
11
12
  gem "rails", "~> 4.1.0"
12
13
  gem "jquery-rails"
13
14
  gem "sass-rails", "~> 4.0"
@@ -0,0 +1,16 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "sqlite3", :platform=>:ruby
6
+ gem "activerecord-jdbc-adapter", :platform=>:jruby
7
+ gem "activerecord-jdbcsqlite3-adapter", :platform=>:jruby
8
+ gem "jdbc-sqlite3", :platform=>:jruby
9
+ gem "jruby-openssl", :platform=>:jruby
10
+ gem "therubyrhino", :platform=>:jruby
11
+ gem "psych", :platform=>:rbx
12
+ gem "rails", "~> 4.2.0"
13
+ gem "jquery-rails"
14
+ gem "sass-rails", "~> 4.0"
15
+
16
+ gemspec :path=>"../"
@@ -153,7 +153,7 @@ module Shoulda # :nodoc:
153
153
  end
154
154
 
155
155
  def matches_conditions? callback
156
- if rails_4_1?
156
+ if rails_version >= '4.1'
157
157
  !@condition || callback.instance_variable_get(:"@#{@condition_type}").include?(@condition)
158
158
  else
159
159
  !@condition || callback.options[@condition_type].include?(@condition)
@@ -161,7 +161,7 @@ module Shoulda # :nodoc:
161
161
  end
162
162
 
163
163
  def matches_optional_lifecycle? callback
164
- if rails_4_1?
164
+ if rails_version >= '4.1'
165
165
  if_conditions = callback.instance_variable_get(:@if)
166
166
  !@optional_lifecycle || if_conditions.include?(lifecycle_context_string) || active_model_proc_matches_optional_lifecycle?(if_conditions)
167
167
  else
@@ -178,7 +178,7 @@ module Shoulda # :nodoc:
178
178
  end
179
179
 
180
180
  def lifecycle_context_string
181
- if rails_4?
181
+ if rails_version >= '4.0'
182
182
  rails_4_lifecycle_context_string
183
183
  else
184
184
  rails_3_lifecycle_context_string
@@ -216,7 +216,7 @@ module Shoulda # :nodoc:
216
216
  end
217
217
 
218
218
  def callback_object subject, callback
219
- if (rails_3? || rails_4_0?) && !callback.filter.is_a?(Symbol)
219
+ if (rails_version >= '3.0' && rails_version < '4.1') && !callback.filter.is_a?(Symbol)
220
220
  subject.send("#{callback.filter}_object")
221
221
  else
222
222
  callback.filter
@@ -5,7 +5,7 @@ include Shoulda::Callback::Matchers::RailsVersionHelper
5
5
  # in environments where test/unit is not required, this is necessary
6
6
  unless defined?(Test::Unit::TestCase)
7
7
  begin
8
- require rails_4_1? ? 'minitest' : 'test/unit/testcase'
8
+ require rails_version == '4.1' ? 'minitest' : 'test/unit/testcase'
9
9
  rescue LoadError
10
10
  # silent
11
11
  end
@@ -3,42 +3,44 @@ module Shoulda
3
3
  module Callback
4
4
  module Matchers
5
5
  module RailsVersionHelper
6
- def rails_4_1?
7
- rails_4? && minor_version_equals?(1)
8
- end
9
-
10
- def rails_4_0?
11
- rails_4? && minor_version_equals?(0)
12
- end
13
-
14
- def rails_4?
15
- major_version_equals? 4
16
- end
17
-
18
- def rails_3?
19
- major_version_equals? 3
20
- end
21
-
22
- private
23
-
24
- def major_version_equals? number
25
- if active_record?
26
- ::ActiveRecord::VERSION::MAJOR == number
27
- else
28
- ::ActiveModel::VERSION::MAJOR == number
6
+ class RailsVersion
7
+ %w(< <= > >= ==).each do |operand|
8
+ define_method operand do |version_string|
9
+ version_int = convert_str_to_int(version_string)
10
+ rails_version_int.send(operand, version_int)
11
+ end
29
12
  end
30
- end
31
-
32
- def minor_version_equals? number
33
- if active_record?
34
- ::ActiveRecord::VERSION::MINOR == number
35
- else
36
- ::ActiveModel::VERSION::MINOR == number
13
+
14
+ private
15
+
16
+ def rails_version_int
17
+ calculate_version_int(rails_major_version, rails_minor_version)
18
+ end
19
+
20
+ def convert_str_to_int(version_string)
21
+ major, minor = version_string.split('.').map(&:to_i)
22
+ calculate_version_int(major, minor)
23
+ end
24
+
25
+ def calculate_version_int(major, minor)
26
+ major * 100 + minor
27
+ end
28
+
29
+ def rails_major_version
30
+ version_module::MAJOR
31
+ end
32
+
33
+ def rails_minor_version
34
+ version_module::MINOR
35
+ end
36
+
37
+ def version_module
38
+ (defined?(::ActiveRecord) ? ::ActiveRecord : ::ActiveModel)::VERSION
37
39
  end
38
40
  end
39
-
40
- def active_record?
41
- defined?(::ActiveRecord)
41
+
42
+ def rails_version
43
+ @rails_version ||= RailsVersion.new
42
44
  end
43
45
  end
44
46
  end
@@ -1,7 +1,7 @@
1
1
  module Shoulda
2
2
  module Callback
3
3
  module Matchers
4
- VERSION = '1.1.1'.freeze
4
+ VERSION = '1.1.2'.freeze
5
5
  end
6
6
  end
7
7
  end
@@ -25,8 +25,8 @@ Gem::Specification.new do |s|
25
25
  s.add_development_dependency('bundler', '>= 1.1')
26
26
  s.add_development_dependency('rails', '>= 3')
27
27
  s.add_development_dependency('rake', '~> 10')
28
- s.add_development_dependency('rspec-rails', '~> 2')
29
-
28
+ s.add_development_dependency('rspec-rails', '~> 3')
29
+
30
30
  if RUBY_ENGINE == 'rbx'
31
31
  s.add_development_dependency "rubysl", "~> 2"
32
32
  s.add_development_dependency "rubysl-test-unit", '~> 2'
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Shoulda::Callback::Matchers::ActiveModel do
4
-
4
+
5
5
  context "invalid use" do
6
6
  before do
7
7
  @callback_object_class = define_model :callback do
@@ -20,30 +20,30 @@ describe Shoulda::Callback::Matchers::ActiveModel do
20
20
  define_method(:shake!){}
21
21
  define_method(:dance!){}
22
22
  end.new
23
-
23
+
24
24
  end
25
25
  it "should return a meaningful error when used without a defined lifecycle" do
26
- lambda { callback(:dance!).matches? :foo }.should raise_error Shoulda::Callback::Matchers::ActiveModel::UsageError,
26
+ expect { callback(:dance!).matches? :foo }.to raise_error Shoulda::Callback::Matchers::ActiveModel::UsageError,
27
27
  "callback dance! can not be tested against an undefined lifecycle, use .before, .after or .around"
28
28
  end
29
29
  it "should return a meaningful error when used with an optional lifecycle without the original lifecycle being validation" do
30
- lambda { callback(:dance!).after(:create).on(:save) }.should raise_error Shoulda::Callback::Matchers::ActiveModel::UsageError,
30
+ expect { callback(:dance!).after(:create).on(:save) }.to raise_error Shoulda::Callback::Matchers::ActiveModel::UsageError,
31
31
  "The .on option is only valid for validation, commit, and rollback and cannot be used with create, use with .before(:validation) or .after(:validation)"
32
32
  end
33
33
  it "should return a meaningful error when used without a defined lifecycle" do
34
- lambda { callback(@callback_object_class).matches? :foo }.should raise_error Shoulda::Callback::Matchers::ActiveModel::UsageError,
34
+ expect { callback(@callback_object_class).matches? :foo }.to raise_error Shoulda::Callback::Matchers::ActiveModel::UsageError,
35
35
  "callback Callback can not be tested against an undefined lifecycle, use .before, .after or .around"
36
36
  end
37
37
  it "should return a meaningful error when used with an optional lifecycle without the original lifecycle being validation" do
38
- lambda { callback(@callback_object_class).after(:create).on(:save) }.should raise_error Shoulda::Callback::Matchers::ActiveModel::UsageError,
38
+ expect { callback(@callback_object_class).after(:create).on(:save) }.to raise_error Shoulda::Callback::Matchers::ActiveModel::UsageError,
39
39
  "The .on option is only valid for validation, commit, and rollback and cannot be used with create, use with .before(:validation) or .after(:validation)"
40
40
  end
41
41
  it "should return a meaningful error when used with rollback or commit and before" do
42
- lambda { callback(@callback_object_class).before(:commit).on(:destroy) }.should raise_error Shoulda::Callback::Matchers::ActiveModel::UsageError,
42
+ expect { callback(@callback_object_class).before(:commit).on(:destroy) }.to raise_error Shoulda::Callback::Matchers::ActiveModel::UsageError,
43
43
  "Can not callback before or around commit, use after."
44
44
  end
45
45
  end
46
-
46
+
47
47
  [:save, :create, :update, :destroy].each do |lifecycle|
48
48
  context "on #{lifecycle}" do
49
49
  before do
@@ -52,16 +52,16 @@ describe Shoulda::Callback::Matchers::ActiveModel do
52
52
  define_method("after_#{lifecycle}"){}
53
53
  define_method("around_#{lifecycle}"){}
54
54
  end
55
-
55
+
56
56
  callback_object = @callback_object_class.new
57
-
57
+
58
58
  @other_callback_object_class = define_model(:other_callback) do
59
59
  define_method("after_#{lifecycle}"){}
60
60
  define_method("around_#{lifecycle}"){}
61
61
  end
62
62
 
63
63
  other_callback_object = @other_callback_object_class.new
64
-
64
+
65
65
  @callback_object_not_found_class = define_model(:callback_not_found) do
66
66
  define_method("before_#{lifecycle}"){}
67
67
  define_method("after_#{lifecycle}"){}
@@ -74,12 +74,12 @@ describe Shoulda::Callback::Matchers::ActiveModel do
74
74
  send(:"after_#{lifecycle}", :shake!, :unless => :evaluates_to_true!)
75
75
  send(:"around_#{lifecycle}", :giggle!)
76
76
  send(:"before_#{lifecycle}", :wiggle!)
77
-
77
+
78
78
  send(:"before_#{lifecycle}", callback_object, :if => :evaluates_to_false!)
79
79
  send(:"after_#{lifecycle}", callback_object, :unless => :evaluates_to_true!)
80
80
  send(:"around_#{lifecycle}", callback_object)
81
81
  send(:"before_#{lifecycle}", other_callback_object)
82
-
82
+
83
83
  define_method(:shake!){}
84
84
  define_method(:dance!){}
85
85
  define_method(:giggle!){}
@@ -87,92 +87,92 @@ describe Shoulda::Callback::Matchers::ActiveModel do
87
87
  end
88
88
  context "as a simple callback test" do
89
89
  it "should find the callback before the fact" do
90
- @model.should callback(:dance!).before(lifecycle)
90
+ expect(@model).to callback(:dance!).before(lifecycle)
91
91
  end
92
92
  it "should find the callback after the fact" do
93
- @model.should callback(:shake!).after(lifecycle)
93
+ expect(@model).to callback(:shake!).after(lifecycle)
94
94
  end
95
95
  it "should find the callback around the fact" do
96
- @model.should callback(:giggle!).around(lifecycle)
96
+ expect(@model).to callback(:giggle!).around(lifecycle)
97
97
  end
98
98
  it "should not find callbacks that are not there" do
99
- @model.should_not callback(:scream!).around(lifecycle)
99
+ expect(@model).not_to callback(:scream!).around(lifecycle)
100
100
  end
101
101
  it "should not find callback_objects around the fact" do
102
- @model.should_not callback(:shake!).around(lifecycle)
102
+ expect(@model).not_to callback(:shake!).around(lifecycle)
103
103
  end
104
104
  it "should have a meaningful description" do
105
105
  matcher = callback(:dance!).before(lifecycle)
106
- matcher.description.should == "callback dance! before #{lifecycle}"
106
+ expect(matcher.description).to eq("callback dance! before #{lifecycle}")
107
107
  end
108
108
  it "should find the callback_object before the fact" do
109
- @model.should callback(@callback_object_class).before(lifecycle)
109
+ expect(@model).to callback(@callback_object_class).before(lifecycle)
110
110
  end
111
111
  it "should find the callback_object after the fact" do
112
- @model.should callback(@callback_object_class).after(lifecycle)
112
+ expect(@model).to callback(@callback_object_class).after(lifecycle)
113
113
  end
114
114
  it "should find the callback_object around the fact" do
115
- @model.should callback(@callback_object_class).around(lifecycle)
115
+ expect(@model).to callback(@callback_object_class).around(lifecycle)
116
116
  end
117
117
  it "should not find callbacks that are not there" do
118
- @model.should_not callback(@callback_object_not_found_class).around(lifecycle)
118
+ expect(@model).not_to callback(@callback_object_not_found_class).around(lifecycle)
119
119
  end
120
120
  it "should not find callback_objects around the fact" do
121
- @model.should_not callback(@callback_object_not_found_class).around(lifecycle)
121
+ expect(@model).not_to callback(@callback_object_not_found_class).around(lifecycle)
122
122
  end
123
123
  it "should have a meaningful description" do
124
124
  matcher = callback(@callback_object_class).before(lifecycle)
125
- matcher.description.should == "callback Callback before #{lifecycle}"
125
+ expect(matcher.description).to eq("callback Callback before #{lifecycle}")
126
126
  end
127
127
  it "should have a meaningful error if it fails with an inexistent method on a model" do
128
128
  matcher = callback(:wiggle!).before(lifecycle)
129
- matcher.matches?(@model).should be_false
130
- matcher.failure_message.should == "callback wiggle! is listed as a callback before #{lifecycle}, but the model does not respond to wiggle! (using respond_to?(:wiggle!, true)"
129
+ expect(matcher.matches?(@model)).to eq(false)
130
+ expect(matcher.failure_message).to eq("callback wiggle! is listed as a callback before #{lifecycle}, but the model does not respond to wiggle! (using respond_to?(:wiggle!, true)")
131
131
  end
132
132
  it "should have a meaningful error if it fails with an inexistent method on a callback class" do
133
133
  matcher = callback(@other_callback_object_class).before(lifecycle)
134
- matcher.matches?(@model).should be_false
135
- matcher.failure_message.should == "callback OtherCallback is listed as a callback before #{lifecycle}, but the given object does not respond to before_#{lifecycle} (using respond_to?(:before_#{lifecycle}, true)"
134
+ expect(matcher.matches?(@model)).to eq(false)
135
+ expect(matcher.failure_message).to eq("callback OtherCallback is listed as a callback before #{lifecycle}, but the given object does not respond to before_#{lifecycle} (using respond_to?(:before_#{lifecycle}, true)")
136
136
  end
137
137
  end
138
138
  context "with conditions" do
139
139
  it "should match the if condition" do
140
- @model.should callback(:dance!).before(lifecycle).if(:evaluates_to_false!)
140
+ expect(@model).to callback(:dance!).before(lifecycle).if(:evaluates_to_false!)
141
141
  end
142
142
  it "should match the unless condition" do
143
- @model.should callback(:shake!).after(lifecycle).unless(:evaluates_to_true!)
143
+ expect(@model).to callback(:shake!).after(lifecycle).unless(:evaluates_to_true!)
144
144
  end
145
145
  it "should not find callbacks not matching the conditions" do
146
- @model.should_not callback(:giggle!).around(lifecycle).unless(:evaluates_to_false!)
146
+ expect(@model).not_to callback(:giggle!).around(lifecycle).unless(:evaluates_to_false!)
147
147
  end
148
148
  it "should not find callbacks that are not there entirely" do
149
- @model.should_not callback(:scream!).before(lifecycle).unless(:evaluates_to_false!)
149
+ expect(@model).not_to callback(:scream!).before(lifecycle).unless(:evaluates_to_false!)
150
150
  end
151
151
  it "should have a meaningful description" do
152
152
  matcher = callback(:dance!).after(lifecycle).unless(:evaluates_to_false!)
153
- matcher.description.should == "callback dance! after #{lifecycle} unless evaluates_to_false! evaluates to false"
153
+ expect(matcher.description).to eq("callback dance! after #{lifecycle} unless evaluates_to_false! evaluates to false")
154
154
  end
155
155
 
156
156
  it "should match the if condition" do
157
- @model.should callback(@callback_object_class).before(lifecycle).if(:evaluates_to_false!)
157
+ expect(@model).to callback(@callback_object_class).before(lifecycle).if(:evaluates_to_false!)
158
158
  end
159
159
  it "should match the unless condition" do
160
- @model.should callback(@callback_object_class).after(lifecycle).unless(:evaluates_to_true!)
160
+ expect(@model).to callback(@callback_object_class).after(lifecycle).unless(:evaluates_to_true!)
161
161
  end
162
162
  it "should not find callbacks not matching the conditions" do
163
- @model.should_not callback(@callback_object_class).around(lifecycle).unless(:evaluates_to_false!)
163
+ expect(@model).not_to callback(@callback_object_class).around(lifecycle).unless(:evaluates_to_false!)
164
164
  end
165
165
  it "should not find callbacks that are not there entirely" do
166
- @model.should_not callback(@callback_object_not_found_class).before(lifecycle).unless(:evaluates_to_false!)
166
+ expect(@model).not_to callback(@callback_object_not_found_class).before(lifecycle).unless(:evaluates_to_false!)
167
167
  end
168
168
  it "should have a meaningful description" do
169
169
  matcher = callback(@callback_object_class).after(lifecycle).unless(:evaluates_to_false!)
170
- matcher.description.should == "callback Callback after #{lifecycle} unless evaluates_to_false! evaluates to false"
170
+ expect(matcher.description).to eq("callback Callback after #{lifecycle} unless evaluates_to_false! evaluates to false")
171
171
  end
172
172
  end
173
173
  end
174
174
  end
175
-
175
+
176
176
  context "on validation" do
177
177
  before do
178
178
  @callback_object_class = define_model(:callback) do
@@ -211,153 +211,153 @@ describe Shoulda::Callback::Matchers::ActiveModel do
211
211
  define_method(:pucker!){}
212
212
  end.new
213
213
  end
214
-
214
+
215
215
  context "as a simple callback test" do
216
216
  it "should find the callback before the fact" do
217
- @model.should callback(:dance!).before(:validation)
217
+ expect(@model).to callback(:dance!).before(:validation)
218
218
  end
219
219
  it "should find the callback after the fact" do
220
- @model.should callback(:shake!).after(:validation)
220
+ expect(@model).to callback(:shake!).after(:validation)
221
221
  end
222
222
  it "should not find a callback around the fact" do
223
- @model.should_not callback(:giggle!).around(:validation)
223
+ expect(@model).not_to callback(:giggle!).around(:validation)
224
224
  end
225
225
  it "should not find callbacks that are not there" do
226
- @model.should_not callback(:scream!).around(:validation)
226
+ expect(@model).not_to callback(:scream!).around(:validation)
227
227
  end
228
228
  it "should have a meaningful description" do
229
229
  matcher = callback(:dance!).before(:validation)
230
- matcher.description.should == "callback dance! before validation"
230
+ expect(matcher.description).to eq("callback dance! before validation")
231
231
  end
232
232
 
233
233
  it "should find the callback before the fact" do
234
- @model.should callback(@callback_object_class).before(:validation)
234
+ expect(@model).to callback(@callback_object_class).before(:validation)
235
235
  end
236
236
  it "should find the callback after the fact" do
237
- @model.should callback(@callback_object_class).after(:validation)
237
+ expect(@model).to callback(@callback_object_class).after(:validation)
238
238
  end
239
239
  it "should not find a callback around the fact" do
240
- @model.should_not callback(@callback_object_class).around(:validation)
240
+ expect(@model).not_to callback(@callback_object_class).around(:validation)
241
241
  end
242
242
  it "should not find callbacks that are not there" do
243
- @model.should_not callback(@callback_object_not_found_class).around(:validation)
243
+ expect(@model).not_to callback(@callback_object_not_found_class).around(:validation)
244
244
  end
245
245
  it "should have a meaningful description" do
246
246
  matcher = callback(@callback_object_class).before(:validation)
247
- matcher.description.should == "callback Callback before validation"
247
+ expect(matcher.description).to eq("callback Callback before validation")
248
248
  end
249
249
  end
250
-
250
+
251
251
  context "with additinal lifecycles defined" do
252
252
  it "should find the callback before the fact on create" do
253
- @model.should callback(:dress!).before(:validation).on(:create)
253
+ expect(@model).to callback(:dress!).before(:validation).on(:create)
254
254
  end
255
255
  it "should find the callback after the fact on update" do
256
- @model.should callback(:shriek!).after(:validation).on(:update)
256
+ expect(@model).to callback(:shriek!).after(:validation).on(:update)
257
257
  end
258
258
  it "should find the callback after the fact on save" do
259
- @model.should callback(:pucker!).after(:validation).on(:save)
259
+ expect(@model).to callback(:pucker!).after(:validation).on(:save)
260
260
  end
261
261
  it "should not find a callback for pucker! after the fact on update" do
262
- @model.should_not callback(:pucker!).after(:validation).on(:update)
262
+ expect(@model).not_to callback(:pucker!).after(:validation).on(:update)
263
263
  end
264
264
  it "should have a meaningful description" do
265
265
  matcher = callback(:dance!).after(:validation).on(:update)
266
- matcher.description.should == "callback dance! after validation on update"
266
+ expect(matcher.description).to eq("callback dance! after validation on update")
267
267
  end
268
268
 
269
269
  it "should find the callback before the fact on create" do
270
- @model.should callback(@callback_object_class).before(:validation).on(:create)
270
+ expect(@model).to callback(@callback_object_class).before(:validation).on(:create)
271
271
  end
272
272
  it "should find the callback after the fact on update" do
273
- @model.should callback(@callback_object_class).after(:validation).on(:update)
273
+ expect(@model).to callback(@callback_object_class).after(:validation).on(:update)
274
274
  end
275
275
  it "should find the callback after the fact on save" do
276
- @model.should callback(@callback_object_class2).after(:validation).on(:save)
276
+ expect(@model).to callback(@callback_object_class2).after(:validation).on(:save)
277
277
  end
278
278
  it "should not find a callback for Callback after the fact on update" do
279
- @model.should_not callback(@callback_object_class2).after(:validation).on(:update)
279
+ expect(@model).not_to callback(@callback_object_class2).after(:validation).on(:update)
280
280
  end
281
281
  it "should have a meaningful description" do
282
282
  matcher = callback(@callback_object_class).after(:validation).on(:update)
283
- matcher.description.should == "callback Callback after validation on update"
283
+ expect(matcher.description).to eq("callback Callback after validation on update")
284
284
  end
285
285
  end
286
-
286
+
287
287
  context "with conditions" do
288
288
  it "should match the if condition" do
289
- @model.should callback(:dance!).before(:validation).if(:evaluates_to_false!)
289
+ expect(@model).to callback(:dance!).before(:validation).if(:evaluates_to_false!)
290
290
  end
291
291
  it "should match the unless condition" do
292
- @model.should callback(:shake!).after(:validation).unless(:evaluates_to_true!)
292
+ expect(@model).to callback(:shake!).after(:validation).unless(:evaluates_to_true!)
293
293
  end
294
294
  it "should not find callbacks not matching the conditions" do
295
- @model.should_not callback(:giggle!).around(:validation).unless(:evaluates_to_false!)
295
+ expect(@model).not_to callback(:giggle!).around(:validation).unless(:evaluates_to_false!)
296
296
  end
297
297
  it "should not find callbacks that are not there entirely" do
298
- @model.should_not callback(:scream!).before(:validation).unless(:evaluates_to_false!)
298
+ expect(@model).not_to callback(:scream!).before(:validation).unless(:evaluates_to_false!)
299
299
  end
300
300
  it "should have a meaningful description" do
301
301
  matcher = callback(:dance!).after(:validation).unless(:evaluates_to_false!)
302
- matcher.description.should == "callback dance! after validation unless evaluates_to_false! evaluates to false"
302
+ expect(matcher.description).to eq("callback dance! after validation unless evaluates_to_false! evaluates to false")
303
303
  end
304
304
 
305
305
  it "should match the if condition" do
306
- @model.should callback(@callback_object_class).before(:validation).if(:evaluates_to_false!)
306
+ expect(@model).to callback(@callback_object_class).before(:validation).if(:evaluates_to_false!)
307
307
  end
308
308
  it "should match the unless condition" do
309
- @model.should callback(@callback_object_class).after(:validation).unless(:evaluates_to_true!)
309
+ expect(@model).to callback(@callback_object_class).after(:validation).unless(:evaluates_to_true!)
310
310
  end
311
311
  it "should not find callbacks not matching the conditions" do
312
- @model.should_not callback(@callback_object_class).around(:validation).unless(:evaluates_to_false!)
312
+ expect(@model).not_to callback(@callback_object_class).around(:validation).unless(:evaluates_to_false!)
313
313
  end
314
314
  it "should not find callbacks that are not there entirely" do
315
- @model.should_not callback(@callback_object_not_found_class).before(:validation).unless(:evaluates_to_false!)
315
+ expect(@model).not_to callback(@callback_object_not_found_class).before(:validation).unless(:evaluates_to_false!)
316
316
  end
317
317
  it "should have a meaningful description" do
318
318
  matcher = callback(@callback_object_class).after(:validation).unless(:evaluates_to_false!)
319
- matcher.description.should == "callback Callback after validation unless evaluates_to_false! evaluates to false"
319
+ expect(matcher.description).to eq("callback Callback after validation unless evaluates_to_false! evaluates to false")
320
320
  end
321
321
  end
322
-
322
+
323
323
  context "with conditions and additional lifecycles" do
324
324
  it "should find the callback before the fact on create" do
325
- @model.should callback(:dress!).before(:validation).on(:create)
325
+ expect(@model).to callback(:dress!).before(:validation).on(:create)
326
326
  end
327
327
  it "should find the callback after the fact on update with the unless condition" do
328
- @model.should callback(:shriek!).after(:validation).on(:update).unless(:evaluates_to_true!)
328
+ expect(@model).to callback(:shriek!).after(:validation).on(:update).unless(:evaluates_to_true!)
329
329
  end
330
330
  it "should find the callback after the fact on save with the if condition" do
331
- @model.should callback(:pucker!).after(:validation).on(:save).if(:evaluates_to_false!)
331
+ expect(@model).to callback(:pucker!).after(:validation).on(:save).if(:evaluates_to_false!)
332
332
  end
333
333
  it "should not find a callback for pucker! after the fact on save with the wrong condition" do
334
- @model.should_not callback(:pucker!).after(:validation).on(:save).unless(:evaluates_to_false!)
334
+ expect(@model).not_to callback(:pucker!).after(:validation).on(:save).unless(:evaluates_to_false!)
335
335
  end
336
336
  it "should have a meaningful description" do
337
337
  matcher = callback(:dance!).after(:validation).on(:save).unless(:evaluates_to_false!)
338
- matcher.description.should == "callback dance! after validation on save unless evaluates_to_false! evaluates to false"
338
+ expect(matcher.description).to eq("callback dance! after validation on save unless evaluates_to_false! evaluates to false")
339
339
  end
340
340
 
341
341
  it "should find the callback before the fact on create" do
342
- @model.should callback(@callback_object_class).before(:validation).on(:create)
342
+ expect(@model).to callback(@callback_object_class).before(:validation).on(:create)
343
343
  end
344
344
  it "should find the callback after the fact on update with the unless condition" do
345
- @model.should callback(@callback_object_class).after(:validation).on(:update).unless(:evaluates_to_true!)
345
+ expect(@model).to callback(@callback_object_class).after(:validation).on(:update).unless(:evaluates_to_true!)
346
346
  end
347
347
  it "should find the callback after the fact on save with the if condition" do
348
- @model.should callback(@callback_object_class2).after(:validation).on(:save).if(:evaluates_to_false!)
348
+ expect(@model).to callback(@callback_object_class2).after(:validation).on(:save).if(:evaluates_to_false!)
349
349
  end
350
350
  it "should not find a callback for Callback after the fact on save with the wrong condition" do
351
- @model.should_not callback(@callback_object_class).after(:validation).on(:save).unless(:evaluates_to_false!)
351
+ expect(@model).not_to callback(@callback_object_class).after(:validation).on(:save).unless(:evaluates_to_false!)
352
352
  end
353
353
  it "should have a meaningful description" do
354
354
  matcher = callback(@callback_object_class).after(:validation).on(:save).unless(:evaluates_to_false!)
355
- matcher.description.should == "callback Callback after validation on save unless evaluates_to_false! evaluates to false"
355
+ expect(matcher.description).to eq("callback Callback after validation on save unless evaluates_to_false! evaluates to false")
356
356
  end
357
357
  end
358
358
  end
359
-
360
-
359
+
360
+
361
361
  [:rollback, :commit].each do |lifecycle|
362
362
  context "on #{lifecycle}" do
363
363
  before do
@@ -394,141 +394,141 @@ describe Shoulda::Callback::Matchers::ActiveModel do
394
394
  define_method(:pucker!){}
395
395
  end.new
396
396
  end
397
-
398
- context "as a simple callback test" do
397
+
398
+ context "as a simple callback test" do
399
399
  it "should find the callback after the fact" do
400
- @model.should callback(:shake!).after(lifecycle)
400
+ expect(@model).to callback(:shake!).after(lifecycle)
401
401
  end
402
402
  it "should not find callbacks that are not there" do
403
- @model.should_not callback(:scream!).after(lifecycle)
403
+ expect(@model).not_to callback(:scream!).after(lifecycle)
404
404
  end
405
405
  it "should have a meaningful description" do
406
406
  matcher = callback(:dance!).after(lifecycle)
407
- matcher.description.should == "callback dance! after #{lifecycle}"
407
+ expect(matcher.description).to eq("callback dance! after #{lifecycle}")
408
408
  end
409
409
 
410
410
  it "should find the callback after the fact" do
411
- @model.should callback(@callback_object_class).after(lifecycle)
411
+ expect(@model).to callback(@callback_object_class).after(lifecycle)
412
412
  end
413
413
  it "should not find callbacks that are not there" do
414
- @model.should_not callback(@callback_object_not_found_class).after(lifecycle)
414
+ expect(@model).not_to callback(@callback_object_not_found_class).after(lifecycle)
415
415
  end
416
416
  it "should have a meaningful description" do
417
417
  matcher = callback(@callback_object_class).after(lifecycle)
418
- matcher.description.should == "callback Callback after #{lifecycle}"
418
+ expect(matcher.description).to eq("callback Callback after #{lifecycle}")
419
419
  end
420
420
  end
421
-
421
+
422
422
  context "with additinal lifecycles defined" do
423
423
  it "should find the callback after the fact on create" do
424
- @model.should callback(:dress!).after(lifecycle).on(:create)
424
+ expect(@model).to callback(:dress!).after(lifecycle).on(:create)
425
425
  end
426
426
  it "should find the callback after the fact on update" do
427
- @model.should callback(:shriek!).after(lifecycle).on(:update)
427
+ expect(@model).to callback(:shriek!).after(lifecycle).on(:update)
428
428
  end
429
429
  it "should find the callback after the fact on save" do
430
- @model.should callback(:pucker!).after(lifecycle).on(:destroy)
430
+ expect(@model).to callback(:pucker!).after(lifecycle).on(:destroy)
431
431
  end
432
432
  it "should not find a callback for pucker! after the fact on update" do
433
- @model.should_not callback(:pucker!).after(lifecycle).on(:update)
433
+ expect(@model).not_to callback(:pucker!).after(lifecycle).on(:update)
434
434
  end
435
435
  it "should have a meaningful description" do
436
436
  matcher = callback(:dance!).after(lifecycle).on(:update)
437
- matcher.description.should == "callback dance! after #{lifecycle} on update"
437
+ expect(matcher.description).to eq("callback dance! after #{lifecycle} on update")
438
438
  end
439
439
 
440
440
  it "should find the callback before the fact on create" do
441
- @model.should callback(@callback_object_class).after(lifecycle).on(:create)
441
+ expect(@model).to callback(@callback_object_class).after(lifecycle).on(:create)
442
442
  end
443
443
  it "should find the callback after the fact on update" do
444
- @model.should callback(@callback_object_class).after(lifecycle).on(:update)
444
+ expect(@model).to callback(@callback_object_class).after(lifecycle).on(:update)
445
445
  end
446
446
  it "should find the callback after the fact on save" do
447
- @model.should callback(@callback_object_class2).after(lifecycle).on(:destroy)
447
+ expect(@model).to callback(@callback_object_class2).after(lifecycle).on(:destroy)
448
448
  end
449
449
  it "should not find a callback for Callback after the fact on update" do
450
- @model.should_not callback(@callback_object_class2).after(lifecycle).on(:update)
450
+ expect(@model).not_to callback(@callback_object_class2).after(lifecycle).on(:update)
451
451
  end
452
452
  it "should have a meaningful description" do
453
453
  matcher = callback(@callback_object_class).after(lifecycle).on(:update)
454
- matcher.description.should == "callback Callback after #{lifecycle} on update"
454
+ expect(matcher.description).to eq("callback Callback after #{lifecycle} on update")
455
455
  end
456
456
  end
457
-
457
+
458
458
  context "with conditions" do
459
459
  it "should match the if condition" do
460
- @model.should callback(:dance!).after(lifecycle).if(:evaluates_to_false!)
460
+ expect(@model).to callback(:dance!).after(lifecycle).if(:evaluates_to_false!)
461
461
  end
462
462
  it "should match the unless condition" do
463
- @model.should callback(:shake!).after(lifecycle).unless(:evaluates_to_true!)
463
+ expect(@model).to callback(:shake!).after(lifecycle).unless(:evaluates_to_true!)
464
464
  end
465
465
  it "should not find callbacks not matching the conditions" do
466
- @model.should_not callback(:giggle!).after(lifecycle).unless(:evaluates_to_false!)
466
+ expect(@model).not_to callback(:giggle!).after(lifecycle).unless(:evaluates_to_false!)
467
467
  end
468
468
  it "should not find callbacks that are not there entirely" do
469
- @model.should_not callback(:scream!).after(lifecycle).unless(:evaluates_to_false!)
469
+ expect(@model).not_to callback(:scream!).after(lifecycle).unless(:evaluates_to_false!)
470
470
  end
471
471
  it "should have a meaningful description" do
472
472
  matcher = callback(:dance!).after(lifecycle).unless(:evaluates_to_false!)
473
- matcher.description.should == "callback dance! after #{lifecycle} unless evaluates_to_false! evaluates to false"
473
+ expect(matcher.description).to eq("callback dance! after #{lifecycle} unless evaluates_to_false! evaluates to false")
474
474
  end
475
475
 
476
476
  it "should match the if condition" do
477
- @model.should callback(@callback_object_class).after(lifecycle).if(:evaluates_to_false!)
477
+ expect(@model).to callback(@callback_object_class).after(lifecycle).if(:evaluates_to_false!)
478
478
  end
479
479
  it "should match the unless condition" do
480
- @model.should callback(@callback_object_class).after(lifecycle).unless(:evaluates_to_true!)
480
+ expect(@model).to callback(@callback_object_class).after(lifecycle).unless(:evaluates_to_true!)
481
481
  end
482
482
  it "should not find callbacks not matching the conditions" do
483
- @model.should_not callback(@callback_object_class).after(lifecycle).unless(:evaluates_to_false!)
483
+ expect(@model).not_to callback(@callback_object_class).after(lifecycle).unless(:evaluates_to_false!)
484
484
  end
485
485
  it "should not find callbacks that are not there entirely" do
486
- @model.should_not callback(@callback_object_not_found_class).after(lifecycle).unless(:evaluates_to_false!)
486
+ expect(@model).not_to callback(@callback_object_not_found_class).after(lifecycle).unless(:evaluates_to_false!)
487
487
  end
488
488
  it "should have a meaningful description" do
489
489
  matcher = callback(@callback_object_class).after(lifecycle).unless(:evaluates_to_false!)
490
- matcher.description.should == "callback Callback after #{lifecycle} unless evaluates_to_false! evaluates to false"
490
+ expect(matcher.description).to eq("callback Callback after #{lifecycle} unless evaluates_to_false! evaluates to false")
491
491
  end
492
492
  end
493
-
493
+
494
494
  context "with conditions and additional lifecycles" do
495
495
  it "should find the callback before the fact on create" do
496
- @model.should callback(:dress!).after(lifecycle).on(:create)
496
+ expect(@model).to callback(:dress!).after(lifecycle).on(:create)
497
497
  end
498
498
  it "should find the callback after the fact on update with the unless condition" do
499
- @model.should callback(:shriek!).after(lifecycle).on(:update).unless(:evaluates_to_true!)
499
+ expect(@model).to callback(:shriek!).after(lifecycle).on(:update).unless(:evaluates_to_true!)
500
500
  end
501
501
  it "should find the callback after the fact on save with the if condition" do
502
- @model.should callback(:pucker!).after(lifecycle).on(:destroy).if(:evaluates_to_false!)
502
+ expect(@model).to callback(:pucker!).after(lifecycle).on(:destroy).if(:evaluates_to_false!)
503
503
  end
504
504
  it "should not find a callback for pucker! after the fact on save with the wrong condition" do
505
- @model.should_not callback(:pucker!).after(lifecycle).on(:destroy).unless(:evaluates_to_false!)
505
+ expect(@model).not_to callback(:pucker!).after(lifecycle).on(:destroy).unless(:evaluates_to_false!)
506
506
  end
507
507
  it "should have a meaningful description" do
508
508
  matcher = callback(:dance!).after(lifecycle).on(:save).unless(:evaluates_to_false!)
509
- matcher.description.should == "callback dance! after #{lifecycle} on save unless evaluates_to_false! evaluates to false"
509
+ expect(matcher.description).to eq("callback dance! after #{lifecycle} on save unless evaluates_to_false! evaluates to false")
510
510
  end
511
511
 
512
512
  it "should find the callback before the fact on create" do
513
- @model.should callback(@callback_object_class).after(lifecycle).on(:create)
513
+ expect(@model).to callback(@callback_object_class).after(lifecycle).on(:create)
514
514
  end
515
515
  it "should find the callback after the fact on update with the unless condition" do
516
- @model.should callback(@callback_object_class).after(lifecycle).on(:update).unless(:evaluates_to_true!)
516
+ expect(@model).to callback(@callback_object_class).after(lifecycle).on(:update).unless(:evaluates_to_true!)
517
517
  end
518
518
  it "should find the callback after the fact on save with the if condition" do
519
- @model.should callback(@callback_object_class2).after(lifecycle).on(:destroy).if(:evaluates_to_false!)
519
+ expect(@model).to callback(@callback_object_class2).after(lifecycle).on(:destroy).if(:evaluates_to_false!)
520
520
  end
521
521
  it "should not find a callback for Callback after the fact on save with the wrong condition" do
522
- @model.should_not callback(@callback_object_class).after(lifecycle).on(:destroy).unless(:evaluates_to_false!)
522
+ expect(@model).not_to callback(@callback_object_class).after(lifecycle).on(:destroy).unless(:evaluates_to_false!)
523
523
  end
524
524
  it "should have a meaningful description" do
525
525
  matcher = callback(@callback_object_class).after(lifecycle).on(:destroy).unless(:evaluates_to_false!)
526
- matcher.description.should == "callback Callback after #{lifecycle} on destroy unless evaluates_to_false! evaluates to false"
526
+ expect(matcher.description).to eq("callback Callback after #{lifecycle} on destroy unless evaluates_to_false! evaluates to false")
527
527
  end
528
528
  end
529
529
  end
530
530
  end
531
-
531
+
532
532
  [:initialize, :find, :touch].each do |lifecycle|
533
533
  context "on #{lifecycle}" do
534
534
  before do
@@ -555,89 +555,89 @@ describe Shoulda::Callback::Matchers::ActiveModel do
555
555
  send(:"after_#{lifecycle}", callback_object2, :unless => :evaluates_to_true!)
556
556
  define_method(:shake!){}
557
557
  define_method(:dance!){}
558
-
558
+
559
559
  define_method :evaluates_to_false! do
560
560
  false
561
561
  end
562
-
562
+
563
563
  define_method :evaluates_to_true! do
564
564
  true
565
565
  end
566
-
566
+
567
567
  end.new
568
568
  end
569
-
569
+
570
570
  context "as a simple callback test" do
571
571
  it "should not find a callback before the fact" do
572
- @model.should_not callback(:dance!).before(lifecycle)
572
+ expect(@model).not_to callback(:dance!).before(lifecycle)
573
573
  end
574
574
  it "should find the callback after the fact" do
575
- @model.should callback(:shake!).after(lifecycle)
575
+ expect(@model).to callback(:shake!).after(lifecycle)
576
576
  end
577
577
  it "should not find a callback around the fact" do
578
- @model.should_not callback(:giggle!).around(lifecycle)
578
+ expect(@model).not_to callback(:giggle!).around(lifecycle)
579
579
  end
580
580
  it "should not find callbacks that are not there" do
581
- @model.should_not callback(:scream!).around(lifecycle)
581
+ expect(@model).not_to callback(:scream!).around(lifecycle)
582
582
  end
583
583
  it "should have a meaningful description" do
584
584
  matcher = callback(:dance!).before(lifecycle)
585
- matcher.description.should == "callback dance! before #{lifecycle}"
585
+ expect(matcher.description).to eq("callback dance! before #{lifecycle}")
586
586
  end
587
587
 
588
588
  it "should not find a callback before the fact" do
589
- @model.should_not callback(@callback_object_class).before(lifecycle)
589
+ expect(@model).not_to callback(@callback_object_class).before(lifecycle)
590
590
  end
591
591
  it "should find the callback after the fact" do
592
- @model.should callback(@callback_object_class).after(lifecycle)
592
+ expect(@model).to callback(@callback_object_class).after(lifecycle)
593
593
  end
594
594
  it "should not find a callback around the fact" do
595
- @model.should_not callback(@callback_object_class).around(lifecycle)
595
+ expect(@model).not_to callback(@callback_object_class).around(lifecycle)
596
596
  end
597
597
  it "should not find callbacks that are not there" do
598
- @model.should_not callback(@callback_object_not_found_class).around(lifecycle)
598
+ expect(@model).not_to callback(@callback_object_not_found_class).around(lifecycle)
599
599
  end
600
600
  it "should have a meaningful description" do
601
601
  matcher = callback(@callback_object_class).before(lifecycle)
602
- matcher.description.should == "callback Callback before #{lifecycle}"
602
+ expect(matcher.description).to eq("callback Callback before #{lifecycle}")
603
603
  end
604
604
  end
605
-
605
+
606
606
  context "with conditions" do
607
607
  it "should match the if condition" do
608
- @model.should callback(:dance!).after(lifecycle).if(:evaluates_to_false!)
608
+ expect(@model).to callback(:dance!).after(lifecycle).if(:evaluates_to_false!)
609
609
  end
610
610
  it "should match the unless condition" do
611
- @model.should callback(:shake!).after(lifecycle).unless(:evaluates_to_true!)
611
+ expect(@model).to callback(:shake!).after(lifecycle).unless(:evaluates_to_true!)
612
612
  end
613
613
  it "should not find callbacks not matching the conditions" do
614
- @model.should_not callback(:giggle!).around(lifecycle).unless(:evaluates_to_false!)
614
+ expect(@model).not_to callback(:giggle!).around(lifecycle).unless(:evaluates_to_false!)
615
615
  end
616
616
  it "should not find callbacks that are not there entirely" do
617
- @model.should_not callback(:scream!).before(lifecycle).unless(:evaluates_to_false!)
617
+ expect(@model).not_to callback(:scream!).before(lifecycle).unless(:evaluates_to_false!)
618
618
  end
619
619
  it "should have a meaningful description" do
620
620
  matcher = callback(:dance!).after(lifecycle).unless(:evaluates_to_false!)
621
- matcher.description.should == "callback dance! after #{lifecycle} unless evaluates_to_false! evaluates to false"
621
+ expect(matcher.description).to eq("callback dance! after #{lifecycle} unless evaluates_to_false! evaluates to false")
622
622
  end
623
623
  it "should match the if condition" do
624
- @model.should callback(@callback_object_class).after(lifecycle).if(:evaluates_to_false!)
624
+ expect(@model).to callback(@callback_object_class).after(lifecycle).if(:evaluates_to_false!)
625
625
  end
626
626
  it "should match the unless condition" do
627
- @model.should callback(@callback_object_class2).after(lifecycle).unless(:evaluates_to_true!)
627
+ expect(@model).to callback(@callback_object_class2).after(lifecycle).unless(:evaluates_to_true!)
628
628
  end
629
629
  it "should not find callbacks not matching the conditions" do
630
- @model.should_not callback(@callback_object_class).around(lifecycle).unless(:evaluates_to_false!)
630
+ expect(@model).not_to callback(@callback_object_class).around(lifecycle).unless(:evaluates_to_false!)
631
631
  end
632
632
  it "should not find callbacks that are not there entirely" do
633
- @model.should_not callback(@callback_object_not_found_class).before(lifecycle).unless(:evaluates_to_false!)
633
+ expect(@model).not_to callback(@callback_object_not_found_class).before(lifecycle).unless(:evaluates_to_false!)
634
634
  end
635
635
  it "should have a meaningful description" do
636
636
  matcher = callback(@callback_object_class).after(lifecycle).unless(:evaluates_to_false!)
637
- matcher.description.should == "callback Callback after #{lifecycle} unless evaluates_to_false! evaluates to false"
637
+ expect(matcher.description).to eq("callback Callback after #{lifecycle} unless evaluates_to_false! evaluates to false")
638
638
  end
639
639
  end
640
-
640
+
641
641
  end
642
642
  end
643
643
  end