pickle-has_many_support 0.3.1
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/.gitignore +5 -0
- data/History.txt +331 -0
- data/License.txt +20 -0
- data/README.rdoc +299 -0
- data/Rakefile +20 -0
- data/Rakefile.d/cucumber.rake +24 -0
- data/Rakefile.d/jeweller.rake +19 -0
- data/Rakefile.d/rcov.rake +18 -0
- data/Rakefile.d/rspec.rake +7 -0
- data/Rakefile.d/yard.rake +5 -0
- data/Todo.txt +3 -0
- data/VERSION +1 -0
- data/features/app/app.rb +122 -0
- data/features/app/blueprints.rb +11 -0
- data/features/app/factories.rb +23 -0
- data/features/app/views/notifier/email.erb +1 -0
- data/features/app/views/notifier/user_email.erb +6 -0
- data/features/email/email.feature +64 -0
- data/features/generator/generators.feature +59 -0
- data/features/path/models_page.feature +44 -0
- data/features/path/named_route_page.feature +10 -0
- data/features/pickle/create_from_active_record.feature +76 -0
- data/features/pickle/create_from_factory_girl.feature +59 -0
- data/features/pickle/create_from_machinist.feature +39 -0
- data/features/step_definitions/email_steps.rb +63 -0
- data/features/step_definitions/extra_email_steps.rb +7 -0
- data/features/step_definitions/fork_steps.rb +4 -0
- data/features/step_definitions/generator_steps.rb +46 -0
- data/features/step_definitions/path_steps.rb +14 -0
- data/features/step_definitions/pickle_steps.rb +100 -0
- data/features/support/email.rb +21 -0
- data/features/support/env.rb +52 -0
- data/features/support/paths.rb +47 -0
- data/features/support/pickle.rb +26 -0
- data/features/support/pickle_app.rb +4 -0
- data/init.rb +0 -0
- data/lib/pickle/adapter.rb +127 -0
- data/lib/pickle/adapters/active_record.rb +46 -0
- data/lib/pickle/adapters/data_mapper.rb +37 -0
- data/lib/pickle/config.rb +48 -0
- data/lib/pickle/email/parser.rb +18 -0
- data/lib/pickle/email/world.rb +13 -0
- data/lib/pickle/email.rb +79 -0
- data/lib/pickle/parser/matchers.rb +95 -0
- data/lib/pickle/parser.rb +71 -0
- data/lib/pickle/path/world.rb +5 -0
- data/lib/pickle/path.rb +45 -0
- data/lib/pickle/session/parser.rb +34 -0
- data/lib/pickle/session.rb +195 -0
- data/lib/pickle/version.rb +9 -0
- data/lib/pickle/world.rb +13 -0
- data/lib/pickle.rb +26 -0
- data/pickle.gemspec +117 -0
- data/rails_generators/pickle/pickle_generator.rb +33 -0
- data/rails_generators/pickle/templates/email.rb +21 -0
- data/rails_generators/pickle/templates/email_steps.rb +63 -0
- data/rails_generators/pickle/templates/paths.rb +47 -0
- data/rails_generators/pickle/templates/pickle.rb +28 -0
- data/rails_generators/pickle/templates/pickle_steps.rb +100 -0
- data/spec/pickle/adapter_spec.rb +163 -0
- data/spec/pickle/config_spec.rb +105 -0
- data/spec/pickle/email/parser_spec.rb +51 -0
- data/spec/pickle/email_spec.rb +160 -0
- data/spec/pickle/parser/matchers_spec.rb +74 -0
- data/spec/pickle/parser_spec.rb +165 -0
- data/spec/pickle/path_spec.rb +101 -0
- data/spec/pickle/session_spec.rb +451 -0
- data/spec/pickle_spec.rb +24 -0
- data/spec/spec_helper.rb +8 -0
- metadata +144 -0
@@ -0,0 +1,451 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
# TODO: remove this and push AR stuff into ORM adapter
|
4
|
+
module ActiveRecord
|
5
|
+
class Base
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
module DataMapper
|
10
|
+
class Model
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe Pickle::Session do
|
15
|
+
include Pickle::Session
|
16
|
+
|
17
|
+
let :user_class do
|
18
|
+
mock("User class", :name => 'User', :const_get => ActiveRecord::Base::PickleAdapter)
|
19
|
+
end
|
20
|
+
|
21
|
+
let :user do
|
22
|
+
mock("user", :class => user_class, :id => 1)
|
23
|
+
end
|
24
|
+
|
25
|
+
let :user_factory do
|
26
|
+
Pickle::Adapter::ActiveRecord.new(user_class)
|
27
|
+
end
|
28
|
+
|
29
|
+
before do
|
30
|
+
config.stub(:factories).and_return('user' => user_factory)
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "Pickle::Session proxy missing methods to parser", :shared => true do
|
34
|
+
it "should forward to pickle_parser it responds_to them" do
|
35
|
+
subject.pickle_parser.should_receive(:parse_model)
|
36
|
+
subject.parse_model
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should raise error if pickle_parser don't know about em" do
|
40
|
+
lambda { subject.parse_infinity }.should raise_error
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "including Pickle::Session" do
|
45
|
+
subject do
|
46
|
+
self
|
47
|
+
end
|
48
|
+
|
49
|
+
it_should_behave_like "Pickle::Session proxy missing methods to parser"
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "extending Pickle::Session" do
|
53
|
+
subject do
|
54
|
+
returning Object.new do |object|
|
55
|
+
object.extend Pickle::Session
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
it_should_behave_like "Pickle::Session proxy missing methods to parser"
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "after storing a single user", :shared => true do
|
63
|
+
it "created_models('user') should be array containing the original user" do
|
64
|
+
created_models('user').should == [user]
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "the original user should be retrievable with" do
|
68
|
+
it "created_model('the user')" do
|
69
|
+
created_model('the user').should == user
|
70
|
+
end
|
71
|
+
|
72
|
+
it "created_model('1st user')" do
|
73
|
+
created_model('1st user').should == user
|
74
|
+
end
|
75
|
+
|
76
|
+
it "created_model('last user')" do
|
77
|
+
created_model('last user').should == user
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "(found from db)" do
|
82
|
+
let :user_from_db do
|
83
|
+
user.dup.tap do |from_db|
|
84
|
+
from_db.stub!(:id).and_return(100)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
before do
|
89
|
+
Pickle::Adapter.stub!(:get_model).with(user_class, 100).and_return(user_from_db)
|
90
|
+
end
|
91
|
+
|
92
|
+
it "models('user') should be array containing user" do
|
93
|
+
models('user').should == [user_from_db]
|
94
|
+
end
|
95
|
+
|
96
|
+
describe "user should be retrievable with" do
|
97
|
+
it "model('the user')" do
|
98
|
+
model('the user').should == user_from_db
|
99
|
+
end
|
100
|
+
|
101
|
+
it "model('1st user')" do
|
102
|
+
model('1st user').should == user_from_db
|
103
|
+
end
|
104
|
+
|
105
|
+
it "model('last user')" do
|
106
|
+
model('last user').should == user_from_db
|
107
|
+
end
|
108
|
+
|
109
|
+
it "model!('last user')" do
|
110
|
+
model('last user').should == user_from_db
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe "#create_model" do
|
117
|
+
before do
|
118
|
+
user_factory.stub!(:create).and_return(user)
|
119
|
+
end
|
120
|
+
|
121
|
+
describe "('a user')" do
|
122
|
+
it "should call user_factory.create({})" do
|
123
|
+
user_factory.should_receive(:create).with({})
|
124
|
+
create_model('a user')
|
125
|
+
end
|
126
|
+
|
127
|
+
describe "after create," do
|
128
|
+
before { create_model('a user') }
|
129
|
+
|
130
|
+
it_should_behave_like "after storing a single user"
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
describe "('1 user', 'foo: \"bar\", baz: \"bing bong\"')" do
|
135
|
+
it "should call user_factory.create({'foo' => 'bar', 'baz' => 'bing bong'})" do
|
136
|
+
user_factory.should_receive(:create).with({'foo' => 'bar', 'baz' => 'bing bong'})
|
137
|
+
create_model('1 user', 'foo: "bar", baz: "bing bong"')
|
138
|
+
end
|
139
|
+
|
140
|
+
describe "after create," do
|
141
|
+
before { create_model('1 user', 'foo: "bar", baz: "bing bong"') }
|
142
|
+
|
143
|
+
it_should_behave_like "after storing a single user"
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
describe "('1 user', 'friends: []')" do
|
148
|
+
it "should call user_factory.create({'friends' => []})" do
|
149
|
+
user_factory.should_receive(:create).with({'friends' => []})
|
150
|
+
create_model('1 user', 'friends: []')
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
describe "('1 user', 'friends: [a user]')" do
|
155
|
+
it "should call user_factory.create({'friends' => []})" do
|
156
|
+
user_class.should_receive(:find).with(1).once
|
157
|
+
user_factory.should_receive(:create).with({'friends' => [create_model("user")]})
|
158
|
+
create_model('1 user', 'friends: [a user]')
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
describe "('1 user', 'friends: [a user, an user]')" do
|
163
|
+
it "should call user_factory.create({'friends' => []})" do
|
164
|
+
user_class.should_receive(:find).with(1).twice
|
165
|
+
user_factory.should_receive(:create).with({'friends' => [create_model("user"), create_model("user")]})
|
166
|
+
create_model('1 user', 'friends: [a user, an user]')
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
describe "('an user: \"fred\")" do
|
171
|
+
it "should call user_factory.create({})" do
|
172
|
+
user_factory.should_receive(:create).with({})
|
173
|
+
create_model('an user: "fred"')
|
174
|
+
end
|
175
|
+
|
176
|
+
describe "after create," do
|
177
|
+
before { create_model('an user: "fred"') }
|
178
|
+
|
179
|
+
it_should_behave_like "after storing a single user"
|
180
|
+
|
181
|
+
it "created_model('the user: \"fred\"') should retrieve the user" do
|
182
|
+
created_model('the user: "fred"').should == user
|
183
|
+
end
|
184
|
+
|
185
|
+
it "created_model?('the user: \"shirl\"') should be false" do
|
186
|
+
created_model?('the user: "shirl"').should == false
|
187
|
+
end
|
188
|
+
|
189
|
+
it "model?('the user: \"shirl\"') should be false" do
|
190
|
+
model?('the user: "shirl"').should == false
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
describe "with hash" do
|
196
|
+
it "should call user_factory.create({'foo' => 'bar'})" do
|
197
|
+
user_factory.should_receive(:create).with({'foo' => 'bar'})
|
198
|
+
create_model('a user', {'foo' => 'bar'}).should == user
|
199
|
+
end
|
200
|
+
|
201
|
+
describe "after create," do
|
202
|
+
before { create_model('a user', {'foo' => 'bar'}) }
|
203
|
+
|
204
|
+
it_should_behave_like "after storing a single user"
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
describe '#find_model' do
|
210
|
+
before do
|
211
|
+
Pickle::Adapter.stub!(:find_first_model).with(user_class, anything).and_return(user)
|
212
|
+
end
|
213
|
+
|
214
|
+
it "should call user_class.find :first, :conditions => {<fields>}" do
|
215
|
+
find_model('a user', 'hair: "pink"').should == user
|
216
|
+
end
|
217
|
+
|
218
|
+
describe "after find," do
|
219
|
+
before { find_model('a user', 'hair: "pink"') }
|
220
|
+
|
221
|
+
it_should_behave_like "after storing a single user"
|
222
|
+
end
|
223
|
+
|
224
|
+
describe "with hash" do
|
225
|
+
it "should call user_class.find('user', {'foo' => 'bar'})" do
|
226
|
+
find_model('a user', {'foo' => 'bar'})
|
227
|
+
end
|
228
|
+
|
229
|
+
describe "after find," do
|
230
|
+
before { find_model('a user', {'foo' => 'bar'}) }
|
231
|
+
|
232
|
+
it_should_behave_like "after storing a single user"
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
describe "create and find using plural_factory and table" do
|
238
|
+
context "when given a table without a matching pickle ref column" do
|
239
|
+
let :table do
|
240
|
+
mock(:hashes => [{'name' => 'Fred'}, {'name' => 'Betty'}])
|
241
|
+
end
|
242
|
+
|
243
|
+
it "#create_models_from_table(<plural factory>, <table>) should call create_model for each of the table hashes with plain factory name and return the models" do
|
244
|
+
should_receive(:create_model).with("user", 'name' => "Fred").once.ordered.and_return(:fred)
|
245
|
+
should_receive(:create_model).with("user", 'name' => "Betty").once.ordered.and_return(:betty)
|
246
|
+
create_models_from_table("users", table).should == [:fred, :betty]
|
247
|
+
end
|
248
|
+
|
249
|
+
it "#find_models_from_table(<plural factory>, <table>) should call find_model for each of the table hashes with plain factory name and return the models" do
|
250
|
+
should_receive(:find_model).with("user", 'name' => "Fred").once.ordered.and_return(:fred)
|
251
|
+
should_receive(:find_model).with("user", 'name' => "Betty").once.ordered.and_return(:betty)
|
252
|
+
find_models_from_table("users", table).should == [:fred, :betty]
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
context "when given a table with a matching pickle ref column" do
|
257
|
+
let :table do
|
258
|
+
mock(:hashes => [{'user' => "fred", 'name' => 'Fred'}, {'user' => "betty", 'name' => 'Betty'}])
|
259
|
+
end
|
260
|
+
|
261
|
+
it "#create_models_from_table(<plural factory>, <table>) should call create_model for each of the table hashes with labelled pickle ref" do
|
262
|
+
should_receive(:create_model).with("user \"fred\"", 'name' => "Fred").once.ordered.and_return(:fred)
|
263
|
+
should_receive(:create_model).with("user \"betty\"", 'name' => "Betty").once.ordered.and_return(:betty)
|
264
|
+
create_models_from_table("users", table).should == [:fred, :betty]
|
265
|
+
end
|
266
|
+
|
267
|
+
it "#find_models_from_table(<plural factory>, <table>) should call find_model for each of the table hashes with labelled pickle ref" do
|
268
|
+
should_receive(:find_model).with("user \"fred\"", 'name' => "Fred").once.ordered.and_return(:fred)
|
269
|
+
should_receive(:find_model).with("user \"betty\"", 'name' => "Betty").once.ordered.and_return(:betty)
|
270
|
+
find_models_from_table("users", table).should == [:fred, :betty]
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
describe "#find_model!" do
|
276
|
+
it "should call find_model" do
|
277
|
+
should_receive(:find_model).with('name', 'fields').and_return(user)
|
278
|
+
find_model!('name', 'fields')
|
279
|
+
end
|
280
|
+
|
281
|
+
it "should call raise error if find_model returns nil" do
|
282
|
+
should_receive(:find_model).with('name', 'fields').and_return(nil)
|
283
|
+
lambda { find_model!('name', 'fields') }.should raise_error(RuntimeError, "Can't find pickle model: 'name' in this scenario")
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
describe "#find_models" do
|
288
|
+
before do
|
289
|
+
Pickle::Adapter.stub!(:find_all_models).with(user_class, anything).and_return([user])
|
290
|
+
end
|
291
|
+
|
292
|
+
it "should call User.find :all, :conditions => {'hair' => 'pink'}" do
|
293
|
+
find_models('user', 'hair: "pink"')
|
294
|
+
end
|
295
|
+
|
296
|
+
describe "after find," do
|
297
|
+
before { find_models('user', 'hair: "pink"') }
|
298
|
+
|
299
|
+
it_should_behave_like "after storing a single user"
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
describe 'creating \'a super admin: "fred"\', then \'a user: "shirl"\', \'then 1 super_admin\' (super_admin is factory that returns users)' do
|
304
|
+
let(:fred) { mock("fred", :class => user_class, :id => 2) }
|
305
|
+
let(:shirl) { mock("shirl", :class => user_class, :id => 3) }
|
306
|
+
let(:noname) { mock("noname", :class => user_class, :is => 4) }
|
307
|
+
|
308
|
+
let(:super_admin_factory) do
|
309
|
+
Pickle::Adapter::FactoryGirl.new(mock(:build_class => user_class, :factory_name => :super_admin))
|
310
|
+
end
|
311
|
+
|
312
|
+
before do
|
313
|
+
config.stub(:factories).and_return(user_factory.name => user_factory, super_admin_factory.name => super_admin_factory)
|
314
|
+
user_factory.stub(:create).and_return(shirl)
|
315
|
+
super_admin_factory.stub(:create).and_return(fred, noname)
|
316
|
+
end
|
317
|
+
|
318
|
+
def do_create_users
|
319
|
+
create_model('a super admin: "fred"')
|
320
|
+
create_model('a user: "shirl"')
|
321
|
+
create_model('1 super_admin')
|
322
|
+
end
|
323
|
+
|
324
|
+
it "should call Factory.create with <'super_admin'>, <'user'>, <'super_admin'>" do
|
325
|
+
super_admin_factory.should_receive(:create).with({}).twice
|
326
|
+
user_factory.should_receive(:create).with({}).once
|
327
|
+
do_create_users
|
328
|
+
end
|
329
|
+
|
330
|
+
describe "after create," do
|
331
|
+
before do
|
332
|
+
do_create_users
|
333
|
+
end
|
334
|
+
|
335
|
+
it "created_models('user') should == [fred, shirl, noname]" do
|
336
|
+
created_models('user').should == [fred, shirl, noname]
|
337
|
+
end
|
338
|
+
|
339
|
+
it "created_models('super_admin') should == [fred, noname]" do
|
340
|
+
created_models('super_admin').should == [fred, noname]
|
341
|
+
end
|
342
|
+
|
343
|
+
describe "#created_model" do
|
344
|
+
it "'that user' should be noname (the last user created - as super_admins are users)" do
|
345
|
+
created_model('that user').should == noname
|
346
|
+
end
|
347
|
+
|
348
|
+
it "'the super admin' should be noname (the last super admin created)" do
|
349
|
+
created_model('that super admin').should == noname
|
350
|
+
end
|
351
|
+
|
352
|
+
it "'the 1st super admin' should be fred" do
|
353
|
+
created_model('the 1st super admin').should == fred
|
354
|
+
end
|
355
|
+
|
356
|
+
it "'the first user' should be fred" do
|
357
|
+
created_model('the first user').should == fred
|
358
|
+
end
|
359
|
+
|
360
|
+
it "'the 2nd user' should be shirl" do
|
361
|
+
created_model('the 2nd user').should == shirl
|
362
|
+
end
|
363
|
+
|
364
|
+
it "'the last user' should be noname" do
|
365
|
+
created_model('the last user').should == noname
|
366
|
+
end
|
367
|
+
|
368
|
+
it "'the user: \"fred\" should be fred" do
|
369
|
+
created_model('the user: "fred"').should == fred
|
370
|
+
end
|
371
|
+
|
372
|
+
it "'the user: \"shirl\" should be shirl" do
|
373
|
+
created_model('the user: "shirl"').should == shirl
|
374
|
+
end
|
375
|
+
end
|
376
|
+
end
|
377
|
+
end
|
378
|
+
|
379
|
+
describe "when 'the user: \"me\"' exists and there is a mapping from 'I', 'myself' => 'user: \"me\"" do
|
380
|
+
before do
|
381
|
+
self.pickle_parser = Pickle::Parser.new(:config => Pickle::Config.new {|c| c.map 'I', 'myself', :to => 'user: "me"'})
|
382
|
+
config.stub(:factories).and_return('user' => user_factory)
|
383
|
+
Pickle::Adapter.stub!(:get_model).with(user_class, anything).and_return(user)
|
384
|
+
user_factory.stub!(:create).and_return(user)
|
385
|
+
create_model('the user: "me"')
|
386
|
+
end
|
387
|
+
|
388
|
+
it 'model("I") should return the user' do
|
389
|
+
model('I').should == user
|
390
|
+
end
|
391
|
+
|
392
|
+
it 'model("myself") should return the user' do
|
393
|
+
model('myself').should == user
|
394
|
+
end
|
395
|
+
|
396
|
+
it "#parser.parse_fields 'author: user \"JIM\"' should raise Error, as model deos not refer" do
|
397
|
+
lambda { pickle_parser.parse_fields('author: user "JIM"') }.should raise_error
|
398
|
+
end
|
399
|
+
|
400
|
+
it "#parser.parse_fields 'author: the user' should return {\"author\" => <user>}" do
|
401
|
+
pickle_parser.parse_fields('author: the user').should == {"author" => user}
|
402
|
+
end
|
403
|
+
|
404
|
+
it "#parser.parse_fields 'author: myself' should return {\"author\" => <user>}" do
|
405
|
+
pickle_parser.parse_fields('author: myself').should == {"author" => user}
|
406
|
+
end
|
407
|
+
|
408
|
+
it "#parser.parse_fields 'author: the user, approver: I, rating: \"5\"' should return {'author' => <user>, 'approver' => <user>, 'rating' => '5'}" do
|
409
|
+
pickle_parser.parse_fields('author: the user, approver: I, rating: "5"').should == {'author' => user, 'approver' => user, 'rating' => '5'}
|
410
|
+
end
|
411
|
+
|
412
|
+
it "#parser.parse_fields 'author: user: \"me\", approver: \"\"' should return {'author' => <user>, 'approver' => \"\"}" do
|
413
|
+
pickle_parser.parse_fields('author: user: "me", approver: ""').should == {'author' => user, 'approver' => ""}
|
414
|
+
end
|
415
|
+
end
|
416
|
+
|
417
|
+
describe "convert_models_to_attributes(ar_class, :user => <a user>)" do
|
418
|
+
before do
|
419
|
+
user.stub(:is_a?).with(ActiveRecord::Base).and_return(true)
|
420
|
+
end
|
421
|
+
|
422
|
+
describe "(when ar_class has column 'user_id')" do
|
423
|
+
let :ar_class do
|
424
|
+
mock('ActiveRecord', :column_names => ['user_id'], :const_get => ActiveRecord::Base::PickleAdapter)
|
425
|
+
end
|
426
|
+
|
427
|
+
it "should return {'user_id' => <the user.id>}" do
|
428
|
+
convert_models_to_attributes(ar_class, :user => user).should == {'user_id' => user.id}
|
429
|
+
end
|
430
|
+
end
|
431
|
+
|
432
|
+
describe "(when ar_class has columns 'user_id', 'user_type')" do
|
433
|
+
let :ar_class do
|
434
|
+
mock('ActiveRecord', :column_names => ['user_id', 'user_type'], :const_get => ActiveRecord::Base::PickleAdapter)
|
435
|
+
end
|
436
|
+
|
437
|
+
it "should return {'user_id' => <the user.id>, 'user_type' => <the user.base_class>}" do
|
438
|
+
user.class.should_receive(:base_class).and_return(mock('User base class', :name => 'UserBase'))
|
439
|
+
convert_models_to_attributes(ar_class, :user => user).should == {'user_id' => user.id, 'user_type' => 'UserBase'}
|
440
|
+
end
|
441
|
+
end
|
442
|
+
end
|
443
|
+
|
444
|
+
it "#model!('unknown') should raise informative error message" do
|
445
|
+
lambda { model!('unknown') }.should raise_error("Can't find pickle model: 'unknown' in this scenario")
|
446
|
+
end
|
447
|
+
|
448
|
+
it "#created_model!('unknown') should raise informative error message" do
|
449
|
+
lambda { created_model!('unknown') }.should raise_error("Can't find pickle model: 'unknown' in this scenario")
|
450
|
+
end
|
451
|
+
end
|
data/spec/pickle_spec.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe Pickle do
|
4
|
+
it ".config should be same object on multiple calls" do
|
5
|
+
Pickle.config.should == Pickle.config
|
6
|
+
end
|
7
|
+
|
8
|
+
it ".configure should configure the .config object" do
|
9
|
+
Pickle.config.should_receive(:foo).with(:bar)
|
10
|
+
Pickle.configure do |c|
|
11
|
+
c.foo :bar
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it ".parser should create a parser with the default config" do
|
16
|
+
Pickle.instance_variable_set('@parser', nil)
|
17
|
+
Pickle::Parser.should_receive(:new).with(:config => Pickle.config)
|
18
|
+
Pickle.parser
|
19
|
+
end
|
20
|
+
|
21
|
+
it ".parser should be same object on multiple calls" do
|
22
|
+
Pickle.parser.should == Pickle.parser
|
23
|
+
end
|
24
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pickle-has_many_support
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 17
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 3
|
9
|
+
- 1
|
10
|
+
version: 0.3.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Ian White
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-07-21 00:00:00 -04:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: Easy model creation and reference in your cucumber features
|
23
|
+
email: ian.w.white@gmail.com
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files:
|
29
|
+
- README.rdoc
|
30
|
+
files:
|
31
|
+
- .gitignore
|
32
|
+
- History.txt
|
33
|
+
- License.txt
|
34
|
+
- README.rdoc
|
35
|
+
- Rakefile
|
36
|
+
- Rakefile.d/cucumber.rake
|
37
|
+
- Rakefile.d/jeweller.rake
|
38
|
+
- Rakefile.d/rcov.rake
|
39
|
+
- Rakefile.d/rspec.rake
|
40
|
+
- Rakefile.d/yard.rake
|
41
|
+
- Todo.txt
|
42
|
+
- VERSION
|
43
|
+
- features/app/app.rb
|
44
|
+
- features/app/blueprints.rb
|
45
|
+
- features/app/factories.rb
|
46
|
+
- features/app/views/notifier/email.erb
|
47
|
+
- features/app/views/notifier/user_email.erb
|
48
|
+
- features/email/email.feature
|
49
|
+
- features/generator/generators.feature
|
50
|
+
- features/path/models_page.feature
|
51
|
+
- features/path/named_route_page.feature
|
52
|
+
- features/pickle/create_from_active_record.feature
|
53
|
+
- features/pickle/create_from_factory_girl.feature
|
54
|
+
- features/pickle/create_from_machinist.feature
|
55
|
+
- features/step_definitions/email_steps.rb
|
56
|
+
- features/step_definitions/extra_email_steps.rb
|
57
|
+
- features/step_definitions/fork_steps.rb
|
58
|
+
- features/step_definitions/generator_steps.rb
|
59
|
+
- features/step_definitions/path_steps.rb
|
60
|
+
- features/step_definitions/pickle_steps.rb
|
61
|
+
- features/support/email.rb
|
62
|
+
- features/support/env.rb
|
63
|
+
- features/support/paths.rb
|
64
|
+
- features/support/pickle.rb
|
65
|
+
- features/support/pickle_app.rb
|
66
|
+
- init.rb
|
67
|
+
- lib/pickle.rb
|
68
|
+
- lib/pickle/adapter.rb
|
69
|
+
- lib/pickle/adapters/active_record.rb
|
70
|
+
- lib/pickle/adapters/data_mapper.rb
|
71
|
+
- lib/pickle/config.rb
|
72
|
+
- lib/pickle/email.rb
|
73
|
+
- lib/pickle/email/parser.rb
|
74
|
+
- lib/pickle/email/world.rb
|
75
|
+
- lib/pickle/parser.rb
|
76
|
+
- lib/pickle/parser/matchers.rb
|
77
|
+
- lib/pickle/path.rb
|
78
|
+
- lib/pickle/path/world.rb
|
79
|
+
- lib/pickle/session.rb
|
80
|
+
- lib/pickle/session/parser.rb
|
81
|
+
- lib/pickle/version.rb
|
82
|
+
- lib/pickle/world.rb
|
83
|
+
- pickle.gemspec
|
84
|
+
- rails_generators/pickle/pickle_generator.rb
|
85
|
+
- rails_generators/pickle/templates/email.rb
|
86
|
+
- rails_generators/pickle/templates/email_steps.rb
|
87
|
+
- rails_generators/pickle/templates/paths.rb
|
88
|
+
- rails_generators/pickle/templates/pickle.rb
|
89
|
+
- rails_generators/pickle/templates/pickle_steps.rb
|
90
|
+
- spec/pickle/adapter_spec.rb
|
91
|
+
- spec/pickle/config_spec.rb
|
92
|
+
- spec/pickle/email/parser_spec.rb
|
93
|
+
- spec/pickle/email_spec.rb
|
94
|
+
- spec/pickle/parser/matchers_spec.rb
|
95
|
+
- spec/pickle/parser_spec.rb
|
96
|
+
- spec/pickle/path_spec.rb
|
97
|
+
- spec/pickle/session_spec.rb
|
98
|
+
- spec/pickle_spec.rb
|
99
|
+
- spec/spec_helper.rb
|
100
|
+
has_rdoc: true
|
101
|
+
homepage: http://github.com/kb/pickle/tree
|
102
|
+
licenses: []
|
103
|
+
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options:
|
106
|
+
- --charset=UTF-8
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
none: false
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
hash: 3
|
115
|
+
segments:
|
116
|
+
- 0
|
117
|
+
version: "0"
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
none: false
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
hash: 3
|
124
|
+
segments:
|
125
|
+
- 0
|
126
|
+
version: "0"
|
127
|
+
requirements: []
|
128
|
+
|
129
|
+
rubyforge_project:
|
130
|
+
rubygems_version: 1.3.7
|
131
|
+
signing_key:
|
132
|
+
specification_version: 3
|
133
|
+
summary: Easy model creation and reference in your cucumber features
|
134
|
+
test_files:
|
135
|
+
- spec/pickle/adapter_spec.rb
|
136
|
+
- spec/pickle/config_spec.rb
|
137
|
+
- spec/pickle/email/parser_spec.rb
|
138
|
+
- spec/pickle/email_spec.rb
|
139
|
+
- spec/pickle/parser/matchers_spec.rb
|
140
|
+
- spec/pickle/parser_spec.rb
|
141
|
+
- spec/pickle/path_spec.rb
|
142
|
+
- spec/pickle/session_spec.rb
|
143
|
+
- spec/pickle_spec.rb
|
144
|
+
- spec/spec_helper.rb
|