socialcast_shoulda_ext 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +8 -0
- data/Gemfile +1 -11
- data/README.rdoc +1 -0
- data/lib/shoulda_ext/version.rb +1 -1
- data/socialcast_shoulda_ext.gemspec +24 -2
- data/test/test_assertions.rb +1 -2
- data/test/test_record_count_change_matcher.rb +1 -2
- data/test/test_respond_with_json.rb +8 -7
- data/test/test_trigger_callback_matcher.rb +1 -2
- metadata +137 -193
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -1,13 +1,3 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
|
-
gemspec
|
4
|
-
|
5
|
-
group :test do
|
6
|
-
gem 'rails', "~> 3.0.0"
|
7
|
-
gem 'shoulda', '>= 2.11.3'
|
8
|
-
gem 'json', ">= 0"
|
9
|
-
gem 'bundler', ">= 0"
|
10
|
-
gem 'mocha', ">= 0"
|
11
|
-
gem 'sqlite3-ruby', "~> 1.3.2"
|
12
|
-
gem 'ruby-debug', ">= 0"
|
13
|
-
end
|
3
|
+
gemspec
|
data/README.rdoc
CHANGED
data/lib/shoulda_ext/version.rb
CHANGED
@@ -12,8 +12,30 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.summary = %q{adds new shoulda matchers and assertions}
|
13
13
|
s.description = File.read('README.rdoc')
|
14
14
|
|
15
|
-
s.
|
16
|
-
|
15
|
+
s.add_dependency(%q<shoulda>, ["~> 2.11.3"])
|
16
|
+
|
17
|
+
%w[activerecord].each do |lib|
|
18
|
+
dep = case ENV[lib]
|
19
|
+
when 'stable', nil then nil
|
20
|
+
when /(\d+\.)+\d+/ then ["~> " + ENV[lib]]
|
21
|
+
else [">= 3.0"]
|
22
|
+
end
|
23
|
+
s.add_runtime_dependency(lib, dep)
|
24
|
+
end
|
25
|
+
|
26
|
+
%w[rails].each do |lib|
|
27
|
+
dep = case ENV[lib]
|
28
|
+
when 'stable', nil then nil
|
29
|
+
when /(\d+\.)+\d+/ then ["~> " + ENV[lib]]
|
30
|
+
else [">= 3.0"]
|
31
|
+
end
|
32
|
+
s.add_development_dependency(lib, dep)
|
33
|
+
end
|
34
|
+
s.add_development_dependency 'json', ">= 0"
|
35
|
+
s.add_development_dependency 'bundler', ">= 0"
|
36
|
+
s.add_development_dependency 'mocha', ">= 0"
|
37
|
+
s.add_development_dependency 'sqlite3', "~> 1.3.2"
|
38
|
+
|
17
39
|
|
18
40
|
s.files = `git ls-files`.split("\n")
|
19
41
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
data/test/test_assertions.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
|
-
|
2
|
-
require File.join(File.dirname(__FILE__), 'helper')
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/helper")
|
3
2
|
|
4
3
|
class TestRespondWithJson < ActionController::TestCase
|
4
|
+
setup do
|
5
|
+
@controller = BlogsController.new
|
6
|
+
@request = ActionController::TestRequest.new
|
7
|
+
@response = ActionController::TestResponse.new
|
8
|
+
end
|
9
|
+
|
5
10
|
context "blogs controller" do
|
6
|
-
|
7
|
-
@controller = BlogsController.new
|
8
|
-
@request = ActionController::TestRequest.new
|
9
|
-
@response = ActionController::TestResponse.new
|
10
|
-
end
|
11
|
+
subject { @controller }
|
11
12
|
|
12
13
|
context ":index.json and block test" do
|
13
14
|
setup do
|
metadata
CHANGED
@@ -1,194 +1,147 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: socialcast_shoulda_ext
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 2
|
10
|
-
version: 0.1.2
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Geoffrey Hichborn
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
prerelease: false
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
12
|
+
date: 2012-04-24 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: shoulda
|
16
|
+
requirement: &2169286140 !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
18
|
+
requirements:
|
26
19
|
- - ~>
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 3
|
31
|
-
- 0
|
32
|
-
- 0
|
33
|
-
version: 3.0.0
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.11.3
|
34
22
|
type: :runtime
|
35
|
-
version_requirements: *id001
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: shoulda
|
38
23
|
prerelease: false
|
39
|
-
|
24
|
+
version_requirements: *2169286140
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: activerecord
|
27
|
+
requirement: &2169285020 !ruby/object:Gem::Requirement
|
40
28
|
none: false
|
41
|
-
requirements:
|
42
|
-
- -
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
|
45
|
-
segments:
|
46
|
-
- 2
|
47
|
-
- 11
|
48
|
-
- 1
|
49
|
-
version: 2.11.1
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
50
33
|
type: :runtime
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
ShouldaExt::Matchers::TriggerCallbackMatcher.attach_active_record_callback_hooks!
|
155
|
-
in your test suite in order to work properly.
|
156
|
-
|
157
|
-
Examples:
|
158
|
-
|
159
|
-
context "doing nothing to a record" do
|
160
|
-
subject { Blog.new :title => 'blog title' }
|
161
|
-
should_not trigger_callbacks
|
162
|
-
end
|
163
|
-
|
164
|
-
context "creating a record" do
|
165
|
-
subject { Blog.create! :title => 'blog title' }
|
166
|
-
should trigger_callbacks.for :create
|
167
|
-
should_not trigger_callbacks.for :update, :destroy
|
168
|
-
end
|
169
|
-
|
170
|
-
= Integrations
|
171
|
-
|
172
|
-
Currently only integrates with test/unit. RSpec support to come.
|
173
|
-
|
174
|
-
= Shoulda Extensions
|
175
|
-
|
176
|
-
== ContextWithMatcherBeforeHooks
|
177
|
-
|
178
|
-
Adds the ability to define a 'before' method on any method which will be run before each context's setup/subject block. Used by RecordCountChangeMatcher to record the number of records before the tested operation takes place.
|
179
|
-
|
180
|
-
email:
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2169285020
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rails
|
38
|
+
requirement: &2169283620 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *2169283620
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: json
|
49
|
+
requirement: &2169281840 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *2169281840
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: bundler
|
60
|
+
requirement: &2169278820 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *2169278820
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: mocha
|
71
|
+
requirement: &2169277840 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *2169277840
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: sqlite3
|
82
|
+
requirement: &2169276600 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ~>
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: 1.3.2
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *2169276600
|
91
|
+
description: ! "{<img src=\"https://secure.travis-ci.org/socialcast/socialcast-shoulda-ext.png?branch=master\"
|
92
|
+
alt=\"Build Status\" />}[http://travis-ci.org/socialcast/socialcast-shoulda-ext]\n\n=
|
93
|
+
Socialcast Shoulda Extensions\nAdds new matchers and functionality to the shoulda
|
94
|
+
test library\n\n= Installation\n\nIn your Gemfile:\n\n group :test do\n gem
|
95
|
+
'socialcast_shoulda_ext', :git => 'git@github.com:socialcast/socialcast-shoulda-ext.git',
|
96
|
+
:require => 'shoulda_ext'\n end\n \nIf you want to include the trigger_callbacks
|
97
|
+
matcher, also add the following to your test helper:\n\n ShouldaExt::Matchers::TriggerCallbackMatcher.attach_active_record_callback_hooks!\n\n=
|
98
|
+
Matchers\n\n== RecordCountChangeMatcher\nTest if the count for a model has changed,
|
99
|
+
and by how much. Requires the context_with_matcher_before_hooks patch, which is
|
100
|
+
included by default.\n\nProvides the following matcher methods:\n\n- create_record(klass_or_symbol)\n
|
101
|
+
\ Alias for change_record_count.for(klass_or_symbol).by(1)\n\n- create_records(klass_or_symbol,
|
102
|
+
amount)\n Alias for change_record_count.for(klass_or_symbol).by(amount)\n\n- destroy_record(klass_or_symbol)\n
|
103
|
+
\ Alias for change_record_count.for(klass_or_symbol).by(-1)\n\n- destroy_records(klass_or_symbol,
|
104
|
+
amount) \n Alias for change_record_count.for(klass_or_symbol).by(-amount)\n\n-
|
105
|
+
change_record_count\n Tests the difference in record count before and after the
|
106
|
+
current setup/subject block\n Can be used with the follow methods:\n - for(klass_or_symbol)\n
|
107
|
+
\ Provides the class which the test is being performed on. Can be a constant
|
108
|
+
or a symbol\n\n - by(amount)\n Provides an expected difference for the number
|
109
|
+
of records for the specified class.\n Excluding this number will allow the matcher
|
110
|
+
to check for any difference\n\nExamples:\n\n context \"creating a blog article\"
|
111
|
+
do\n\n context \"with good parameters\" do\n setup do\n post :create,
|
112
|
+
:blog => {:title => 'my blog post', :body => 'Ipsum lorem...'}\n end\n should
|
113
|
+
create_record :blog\n end\n\n context \"without a body\" do\n setup do\n
|
114
|
+
\ post :create, :blog => {:title => 'my blog post' }\n end\n should_not
|
115
|
+
create_record Blog\n end\n\n end\n \n== RespondWithJson\nCheck if the controller's
|
116
|
+
response is json\n \nExamples:\n\n context \":index.json\" do\n setup do\n
|
117
|
+
\ get :index, :format => 'json'\n end\n # Just check to see that the response
|
118
|
+
was json\n should respond_with_json \n\n # Evaluate the hash produced by
|
119
|
+
the json yourself\n should respond_with_json { |json| json.first['blog']['title']
|
120
|
+
== 'blog post 1'}\n \n # Provide an exact match\n should respond_with_json.exactly(['blog'
|
121
|
+
=> {'id' => 1, 'title' => 'blog post 1'}])\n\n # Provide an exact match with
|
122
|
+
a block\n should response_with_json.exactly{ |json| JSON.parse(Blog.all.to_json)}\n
|
123
|
+
\ end\n \n context \":index.html\" do\n setup do\n get :index\n end\n
|
124
|
+
\n # or the negation\n should_not respond_with_json\n end\n\n== TriggerCallbackMatcher\n\nTest
|
125
|
+
if create, update, destroy, or save callbacks were triggered.\n\nRequires running\nShouldaExt::Matchers::TriggerCallbackMatcher.attach_active_record_callback_hooks!\nin
|
126
|
+
your test suite in order to work properly.\n\nExamples:\n\n context \"doing nothing
|
127
|
+
to a record\" do\n subject { Blog.new :title => 'blog title' }\n should_not
|
128
|
+
trigger_callbacks\n end\n\n context \"creating a record\" do\n subject { Blog.create!
|
129
|
+
:title => 'blog title' }\n should trigger_callbacks.for :create\n should_not
|
130
|
+
trigger_callbacks.for :update, :destroy\n end\n\n= Integrations\n\nCurrently only
|
131
|
+
integrates with test/unit. RSpec support to come.\n\n= Shoulda Extensions\n\n==
|
132
|
+
ContextWithMatcherBeforeHooks\n\nAdds the ability to define a 'before' method on
|
133
|
+
any method which will be run before each context's setup/subject block. Used by
|
134
|
+
RecordCountChangeMatcher to record the number of records before the tested operation
|
135
|
+
takes place.\n"
|
136
|
+
email:
|
181
137
|
- geoff@socialcast.com
|
182
138
|
executables: []
|
183
|
-
|
184
139
|
extensions: []
|
185
|
-
|
186
140
|
extra_rdoc_files: []
|
187
|
-
|
188
|
-
files:
|
141
|
+
files:
|
189
142
|
- .gitignore
|
143
|
+
- .travis.yml
|
190
144
|
- Gemfile
|
191
|
-
- Gemfile.lock
|
192
145
|
- MIT-LICENSE
|
193
146
|
- README.rdoc
|
194
147
|
- Rakefile
|
@@ -266,38 +219,29 @@ files:
|
|
266
219
|
- test/test_trigger_callback_matcher.rb
|
267
220
|
homepage: http://github.com/socialcast/socialcast-shoulda-ext
|
268
221
|
licenses: []
|
269
|
-
|
270
222
|
post_install_message:
|
271
223
|
rdoc_options: []
|
272
|
-
|
273
|
-
require_paths:
|
224
|
+
require_paths:
|
274
225
|
- lib
|
275
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
226
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
276
227
|
none: false
|
277
|
-
requirements:
|
278
|
-
- -
|
279
|
-
- !ruby/object:Gem::Version
|
280
|
-
|
281
|
-
|
282
|
-
- 0
|
283
|
-
version: "0"
|
284
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
228
|
+
requirements:
|
229
|
+
- - ! '>='
|
230
|
+
- !ruby/object:Gem::Version
|
231
|
+
version: '0'
|
232
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
285
233
|
none: false
|
286
|
-
requirements:
|
287
|
-
- -
|
288
|
-
- !ruby/object:Gem::Version
|
289
|
-
|
290
|
-
segments:
|
291
|
-
- 0
|
292
|
-
version: "0"
|
234
|
+
requirements:
|
235
|
+
- - ! '>='
|
236
|
+
- !ruby/object:Gem::Version
|
237
|
+
version: '0'
|
293
238
|
requirements: []
|
294
|
-
|
295
239
|
rubyforge_project:
|
296
240
|
rubygems_version: 1.8.10
|
297
241
|
signing_key:
|
298
242
|
specification_version: 3
|
299
243
|
summary: adds new shoulda matchers and assertions
|
300
|
-
test_files:
|
244
|
+
test_files:
|
301
245
|
- test/helper.rb
|
302
246
|
- test/rails3_root/.gitignore
|
303
247
|
- test/rails3_root/Rakefile
|