shoulda-callback-matchers 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +11 -0
- data/.rvmrc +1 -0
- data/.travis.yml +18 -0
- data/Appraisals +15 -0
- data/CONTRIBUTING.md +0 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +148 -0
- data/MIT-LICENSE +22 -0
- data/NEWS.md +2 -0
- data/README.md +40 -0
- data/Rakefile +19 -0
- data/gemfiles/3.0.gemfile +13 -0
- data/gemfiles/3.0.gemfile.lock +133 -0
- data/gemfiles/3.1.gemfile +15 -0
- data/gemfiles/3.1.gemfile.lock +155 -0
- data/gemfiles/3.2.gemfile +15 -0
- data/gemfiles/3.2.gemfile.lock +153 -0
- data/lib/shoulda-callback-matchers.rb +1 -0
- data/lib/shoulda/callback/matchers.rb +7 -0
- data/lib/shoulda/callback/matchers/active_model.rb +107 -0
- data/lib/shoulda/callback/matchers/integrations/rspec.rb +13 -0
- data/lib/shoulda/callback/matchers/integrations/test_unit.rb +34 -0
- data/lib/shoulda/callback/matchers/version.rb +7 -0
- data/shoulda-callback-matchers.gemspec +28 -0
- data/spec/fixtures/users.yml +6 -0
- data/spec/shoulda/active_model/callback_matcher_spec.rb +229 -0
- data/spec/spec_helper.rb +27 -0
- data/spec/support/active_model_versions.rb +9 -0
- data/spec/support/class_builder.rb +42 -0
- data/spec/support/model_builder.rb +73 -0
- metadata +208 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use 1.9.3@shoulda-callback-matchers
|
data/.travis.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
rvm:
|
2
|
+
- 1.8.7
|
3
|
+
- 1.9.2
|
4
|
+
- 1.9.3
|
5
|
+
- ree
|
6
|
+
- rbx-18mode
|
7
|
+
- jruby
|
8
|
+
|
9
|
+
script: "bundle exec rake spec cucumber"
|
10
|
+
|
11
|
+
gemfile:
|
12
|
+
- gemfiles/3.0.gemfile
|
13
|
+
- gemfiles/3.1.gemfile
|
14
|
+
|
15
|
+
matrix:
|
16
|
+
allow_failures:
|
17
|
+
- rvm: rbx-18mode
|
18
|
+
- rvm: jruby
|
data/Appraisals
ADDED
data/CONTRIBUTING.md
ADDED
File without changes
|
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
# For test Rails application
|
6
|
+
gem 'sqlite3', :platform => :ruby
|
7
|
+
|
8
|
+
# Can't wrap in platform :jruby do...end block because appraisal doesn't support
|
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
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
shoulda-callback-matchers (0.1.0)
|
5
|
+
activesupport (>= 3.0.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actionmailer (3.2.3)
|
11
|
+
actionpack (= 3.2.3)
|
12
|
+
mail (~> 2.4.4)
|
13
|
+
actionpack (3.2.3)
|
14
|
+
activemodel (= 3.2.3)
|
15
|
+
activesupport (= 3.2.3)
|
16
|
+
builder (~> 3.0.0)
|
17
|
+
erubis (~> 2.7.0)
|
18
|
+
journey (~> 1.0.1)
|
19
|
+
rack (~> 1.4.0)
|
20
|
+
rack-cache (~> 1.2)
|
21
|
+
rack-test (~> 0.6.1)
|
22
|
+
sprockets (~> 2.1.2)
|
23
|
+
activemodel (3.2.3)
|
24
|
+
activesupport (= 3.2.3)
|
25
|
+
builder (~> 3.0.0)
|
26
|
+
activerecord (3.2.3)
|
27
|
+
activemodel (= 3.2.3)
|
28
|
+
activesupport (= 3.2.3)
|
29
|
+
arel (~> 3.0.2)
|
30
|
+
tzinfo (~> 0.3.29)
|
31
|
+
activeresource (3.2.3)
|
32
|
+
activemodel (= 3.2.3)
|
33
|
+
activesupport (= 3.2.3)
|
34
|
+
activesupport (3.2.3)
|
35
|
+
i18n (~> 0.6)
|
36
|
+
multi_json (~> 1.0)
|
37
|
+
appraisal (0.4.1)
|
38
|
+
bundler
|
39
|
+
rake
|
40
|
+
arel (3.0.2)
|
41
|
+
aruba (0.4.6)
|
42
|
+
bcat (>= 0.6.1)
|
43
|
+
childprocess (>= 0.2.0)
|
44
|
+
cucumber (>= 1.0.2)
|
45
|
+
rdiscount (>= 1.6.8)
|
46
|
+
rspec (>= 2.6.0)
|
47
|
+
bcat (0.6.2)
|
48
|
+
rack (~> 1.0)
|
49
|
+
bourne (1.1.2)
|
50
|
+
mocha (= 0.10.5)
|
51
|
+
builder (3.0.0)
|
52
|
+
childprocess (0.3.1)
|
53
|
+
ffi (~> 1.0.6)
|
54
|
+
cucumber (1.1.9)
|
55
|
+
builder (>= 2.1.2)
|
56
|
+
diff-lcs (>= 1.1.2)
|
57
|
+
gherkin (~> 2.9.0)
|
58
|
+
json (>= 1.4.6)
|
59
|
+
term-ansicolor (>= 1.0.6)
|
60
|
+
diff-lcs (1.1.3)
|
61
|
+
erubis (2.7.0)
|
62
|
+
ffi (1.0.11)
|
63
|
+
gherkin (2.9.3)
|
64
|
+
json (>= 1.4.6)
|
65
|
+
hike (1.2.1)
|
66
|
+
i18n (0.6.0)
|
67
|
+
journey (1.0.3)
|
68
|
+
json (1.6.6)
|
69
|
+
mail (2.4.4)
|
70
|
+
i18n (>= 0.4.0)
|
71
|
+
mime-types (~> 1.16)
|
72
|
+
treetop (~> 1.4.8)
|
73
|
+
metaclass (0.0.1)
|
74
|
+
mime-types (1.18)
|
75
|
+
mocha (0.10.5)
|
76
|
+
metaclass (~> 0.0.1)
|
77
|
+
multi_json (1.3.2)
|
78
|
+
polyglot (0.3.3)
|
79
|
+
rack (1.4.1)
|
80
|
+
rack-cache (1.2)
|
81
|
+
rack (>= 0.4)
|
82
|
+
rack-ssl (1.3.2)
|
83
|
+
rack
|
84
|
+
rack-test (0.6.1)
|
85
|
+
rack (>= 1.0)
|
86
|
+
rails (3.2.3)
|
87
|
+
actionmailer (= 3.2.3)
|
88
|
+
actionpack (= 3.2.3)
|
89
|
+
activerecord (= 3.2.3)
|
90
|
+
activeresource (= 3.2.3)
|
91
|
+
activesupport (= 3.2.3)
|
92
|
+
bundler (~> 1.0)
|
93
|
+
railties (= 3.2.3)
|
94
|
+
railties (3.2.3)
|
95
|
+
actionpack (= 3.2.3)
|
96
|
+
activesupport (= 3.2.3)
|
97
|
+
rack-ssl (~> 1.3.2)
|
98
|
+
rake (>= 0.8.7)
|
99
|
+
rdoc (~> 3.4)
|
100
|
+
thor (~> 0.14.6)
|
101
|
+
rake (0.9.2.2)
|
102
|
+
rdiscount (1.6.8)
|
103
|
+
rdoc (3.12)
|
104
|
+
json (~> 1.4)
|
105
|
+
rspec (2.8.0)
|
106
|
+
rspec-core (~> 2.8.0)
|
107
|
+
rspec-expectations (~> 2.8.0)
|
108
|
+
rspec-mocks (~> 2.8.0)
|
109
|
+
rspec-core (2.8.0)
|
110
|
+
rspec-expectations (2.8.0)
|
111
|
+
diff-lcs (~> 1.1.2)
|
112
|
+
rspec-mocks (2.8.0)
|
113
|
+
rspec-rails (2.8.1)
|
114
|
+
actionpack (>= 3.0)
|
115
|
+
activesupport (>= 3.0)
|
116
|
+
railties (>= 3.0)
|
117
|
+
rspec (~> 2.8.0)
|
118
|
+
sprockets (2.1.2)
|
119
|
+
hike (~> 1.2)
|
120
|
+
rack (~> 1.0)
|
121
|
+
tilt (~> 1.1, != 1.3.0)
|
122
|
+
sqlite3 (1.3.5)
|
123
|
+
term-ansicolor (1.0.7)
|
124
|
+
thor (0.14.6)
|
125
|
+
tilt (1.3.3)
|
126
|
+
treetop (1.4.10)
|
127
|
+
polyglot
|
128
|
+
polyglot (>= 0.3.1)
|
129
|
+
tzinfo (0.3.33)
|
130
|
+
|
131
|
+
PLATFORMS
|
132
|
+
ruby
|
133
|
+
|
134
|
+
DEPENDENCIES
|
135
|
+
activerecord-jdbc-adapter
|
136
|
+
activerecord-jdbcsqlite3-adapter
|
137
|
+
appraisal (~> 0.4.0)
|
138
|
+
aruba
|
139
|
+
bourne (~> 1.1.2)
|
140
|
+
bundler (>= 1.1.0)
|
141
|
+
jdbc-sqlite3
|
142
|
+
jruby-openssl
|
143
|
+
rails (~> 3.0)
|
144
|
+
rake (~> 0.9.2)
|
145
|
+
rspec-rails (~> 2.8.1)
|
146
|
+
shoulda-callback-matchers!
|
147
|
+
sqlite3
|
148
|
+
therubyrhino
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Beat Richartz
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
4
|
+
obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without
|
6
|
+
restriction, including without limitation the rights to use,
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the
|
9
|
+
Software is furnished to do so, subject to the following
|
10
|
+
conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/NEWS.md
ADDED
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
Matchers to test before, after and around hooks:
|
2
|
+
|
3
|
+
describe Post do
|
4
|
+
it { should callback(:count_comments).before(:save) }
|
5
|
+
it { should callback(:post_to_twitter).after(:create) }
|
6
|
+
it { should callback(:evaluate_if_should_validate).before(:validation) }
|
7
|
+
it { should callback(:add_some_convenience_accessors).after(:find) }
|
8
|
+
end
|
9
|
+
|
10
|
+
describe User do
|
11
|
+
it { should_not callback(:make_email_validation_ready!).before(:validation).on(:update) }
|
12
|
+
it { should callback(:make_email_validation_ready!).before(:validation).on(:create) }
|
13
|
+
it { should callback(:update_user_count).before(:destroy) }
|
14
|
+
end
|
15
|
+
|
16
|
+
Be aware that this tests for the method call and not the method itself. It makes testing via triggering the callback events (validation, save) unnecessary, but you should still test the called procedure seperately.
|
17
|
+
|
18
|
+
In Rails 3 and Bundler, add the following to your Gemfile:
|
19
|
+
|
20
|
+
group :test do
|
21
|
+
gem "shoulda-callback-matchers"
|
22
|
+
end
|
23
|
+
|
24
|
+
# rspec-rails needs to be in the development group so that Rails generators
|
25
|
+
# work.
|
26
|
+
group :development, :test do
|
27
|
+
gem "rspec-rails"
|
28
|
+
end
|
29
|
+
|
30
|
+
Shoulda will automatically include matchers into the appropriate example groups.
|
31
|
+
|
32
|
+
## Credits
|
33
|
+
|
34
|
+
Shoulda is maintained and funded by [thoughtbot](http://thoughtbot.com/community).
|
35
|
+
|
36
|
+
## License
|
37
|
+
|
38
|
+
Shoulda is Copyright © 2006-2012 thoughtbot, inc.
|
39
|
+
Callback Matchers is Copyright © 2012 Beat Richartz
|
40
|
+
It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
require 'cucumber/rake/task'
|
5
|
+
require 'appraisal'
|
6
|
+
|
7
|
+
RSpec::Core::RakeTask.new do |t|
|
8
|
+
t.pattern = "spec/**/*_spec.rb"
|
9
|
+
t.rspec_opts = '--color --format progress'
|
10
|
+
t.verbose = false
|
11
|
+
end
|
12
|
+
|
13
|
+
desc 'Test the plugin'
|
14
|
+
task :all => ["appraisal:cleanup", "appraisal:install"] do
|
15
|
+
exec('rake appraisal spec')
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'Default: run specs'
|
19
|
+
task :default => [:all]
|
@@ -0,0 +1,13 @@
|
|
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 "rails", "~>3.0.0"
|
12
|
+
|
13
|
+
gemspec :path=>"../"
|
@@ -0,0 +1,133 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /Users/beatrichartz/Projects/shoulda-callback-matchers
|
3
|
+
specs:
|
4
|
+
shoulda-callback-matchers (0.1.0)
|
5
|
+
activesupport (>= 3.0.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
abstract (1.0.0)
|
11
|
+
actionmailer (3.0.17)
|
12
|
+
actionpack (= 3.0.17)
|
13
|
+
mail (~> 2.2.19)
|
14
|
+
actionpack (3.0.17)
|
15
|
+
activemodel (= 3.0.17)
|
16
|
+
activesupport (= 3.0.17)
|
17
|
+
builder (~> 2.1.2)
|
18
|
+
erubis (~> 2.6.6)
|
19
|
+
i18n (~> 0.5.0)
|
20
|
+
rack (~> 1.2.5)
|
21
|
+
rack-mount (~> 0.6.14)
|
22
|
+
rack-test (~> 0.5.7)
|
23
|
+
tzinfo (~> 0.3.23)
|
24
|
+
activemodel (3.0.17)
|
25
|
+
activesupport (= 3.0.17)
|
26
|
+
builder (~> 2.1.2)
|
27
|
+
i18n (~> 0.5.0)
|
28
|
+
activerecord (3.0.17)
|
29
|
+
activemodel (= 3.0.17)
|
30
|
+
activesupport (= 3.0.17)
|
31
|
+
arel (~> 2.0.10)
|
32
|
+
tzinfo (~> 0.3.23)
|
33
|
+
activeresource (3.0.17)
|
34
|
+
activemodel (= 3.0.17)
|
35
|
+
activesupport (= 3.0.17)
|
36
|
+
activesupport (3.0.17)
|
37
|
+
appraisal (0.4.1)
|
38
|
+
bundler
|
39
|
+
rake
|
40
|
+
arel (2.0.10)
|
41
|
+
aruba (0.5.0)
|
42
|
+
childprocess (= 0.2.3)
|
43
|
+
cucumber (>= 1.1.1)
|
44
|
+
ffi (>= 1.0.11)
|
45
|
+
rspec-expectations (>= 2.7.0)
|
46
|
+
bourne (1.1.2)
|
47
|
+
mocha (= 0.10.5)
|
48
|
+
builder (2.1.2)
|
49
|
+
childprocess (0.2.3)
|
50
|
+
ffi (~> 1.0.6)
|
51
|
+
cucumber (1.2.1)
|
52
|
+
builder (>= 2.1.2)
|
53
|
+
diff-lcs (>= 1.1.3)
|
54
|
+
gherkin (~> 2.11.0)
|
55
|
+
json (>= 1.4.6)
|
56
|
+
diff-lcs (1.1.3)
|
57
|
+
erubis (2.6.6)
|
58
|
+
abstract (>= 1.0.0)
|
59
|
+
ffi (1.0.11)
|
60
|
+
gherkin (2.11.5)
|
61
|
+
json (>= 1.4.6)
|
62
|
+
i18n (0.5.0)
|
63
|
+
json (1.7.5)
|
64
|
+
mail (2.2.19)
|
65
|
+
activesupport (>= 2.3.6)
|
66
|
+
i18n (>= 0.4.0)
|
67
|
+
mime-types (~> 1.16)
|
68
|
+
treetop (~> 1.4.8)
|
69
|
+
metaclass (0.0.1)
|
70
|
+
mime-types (1.19)
|
71
|
+
mocha (0.10.5)
|
72
|
+
metaclass (~> 0.0.1)
|
73
|
+
polyglot (0.3.3)
|
74
|
+
rack (1.2.5)
|
75
|
+
rack-mount (0.6.14)
|
76
|
+
rack (>= 1.0.0)
|
77
|
+
rack-test (0.5.7)
|
78
|
+
rack (>= 1.0)
|
79
|
+
rails (3.0.17)
|
80
|
+
actionmailer (= 3.0.17)
|
81
|
+
actionpack (= 3.0.17)
|
82
|
+
activerecord (= 3.0.17)
|
83
|
+
activeresource (= 3.0.17)
|
84
|
+
activesupport (= 3.0.17)
|
85
|
+
bundler (~> 1.0)
|
86
|
+
railties (= 3.0.17)
|
87
|
+
railties (3.0.17)
|
88
|
+
actionpack (= 3.0.17)
|
89
|
+
activesupport (= 3.0.17)
|
90
|
+
rake (>= 0.8.7)
|
91
|
+
rdoc (~> 3.4)
|
92
|
+
thor (~> 0.14.4)
|
93
|
+
rake (0.9.4)
|
94
|
+
rdoc (3.12)
|
95
|
+
json (~> 1.4)
|
96
|
+
rspec (2.8.0)
|
97
|
+
rspec-core (~> 2.8.0)
|
98
|
+
rspec-expectations (~> 2.8.0)
|
99
|
+
rspec-mocks (~> 2.8.0)
|
100
|
+
rspec-core (2.8.0)
|
101
|
+
rspec-expectations (2.8.0)
|
102
|
+
diff-lcs (~> 1.1.2)
|
103
|
+
rspec-mocks (2.8.0)
|
104
|
+
rspec-rails (2.8.1)
|
105
|
+
actionpack (>= 3.0)
|
106
|
+
activesupport (>= 3.0)
|
107
|
+
railties (>= 3.0)
|
108
|
+
rspec (~> 2.8.0)
|
109
|
+
sqlite3 (1.3.6)
|
110
|
+
thor (0.14.6)
|
111
|
+
treetop (1.4.12)
|
112
|
+
polyglot
|
113
|
+
polyglot (>= 0.3.1)
|
114
|
+
tzinfo (0.3.35)
|
115
|
+
|
116
|
+
PLATFORMS
|
117
|
+
ruby
|
118
|
+
|
119
|
+
DEPENDENCIES
|
120
|
+
activerecord-jdbc-adapter
|
121
|
+
activerecord-jdbcsqlite3-adapter
|
122
|
+
appraisal (~> 0.4.0)
|
123
|
+
aruba
|
124
|
+
bourne (~> 1.1.2)
|
125
|
+
bundler (>= 1.1.0)
|
126
|
+
jdbc-sqlite3
|
127
|
+
jruby-openssl
|
128
|
+
rails (~> 3.0.0)
|
129
|
+
rake (~> 0.9.2)
|
130
|
+
rspec-rails (~> 2.8.1)
|
131
|
+
shoulda-callback-matchers!
|
132
|
+
sqlite3
|
133
|
+
therubyrhino
|