kbaum-pickle 0.2.1.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 +3 -0
- data/History.txt +239 -0
- data/License.txt +20 -0
- data/README.rdoc +246 -0
- data/Rakefile +110 -0
- data/Todo.txt +4 -0
- data/VERSION +1 -0
- data/features/app/app.rb +121 -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 +39 -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 +49 -0
- data/features/pickle/create_from_factory_girl.feature +55 -0
- data/features/pickle/create_from_machinist.feature +38 -0
- data/features/step_definitions/email_steps.rb +55 -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 +73 -0
- data/features/support/email.rb +21 -0
- data/features/support/env.rb +55 -0
- data/features/support/paths.rb +46 -0
- data/features/support/pickle.rb +26 -0
- data/features/support/pickle_app.rb +4 -0
- data/garlic.rb +38 -0
- data/init.rb +0 -0
- data/lib/pickle/adapter.rb +88 -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 +36 -0
- data/lib/pickle/parser/matchers.rb +87 -0
- data/lib/pickle/parser.rb +65 -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 +157 -0
- data/lib/pickle/version.rb +6 -0
- data/lib/pickle/world.rb +9 -0
- data/lib/pickle.rb +26 -0
- data/pickle.gemspec +110 -0
- data/rails_generators/pickle/pickle_generator.rb +40 -0
- data/rails_generators/pickle/templates/email.rb +21 -0
- data/rails_generators/pickle/templates/email_steps.rb +55 -0
- data/rails_generators/pickle/templates/paths.rb +20 -0
- data/rails_generators/pickle/templates/pickle.rb +28 -0
- data/rails_generators/pickle/templates/pickle_steps.rb +73 -0
- data/spec/lib/pickle_adapter_spec.rb +164 -0
- data/spec/lib/pickle_config_spec.rb +97 -0
- data/spec/lib/pickle_email_parser_spec.rb +49 -0
- data/spec/lib/pickle_email_spec.rb +131 -0
- data/spec/lib/pickle_parser_matchers_spec.rb +70 -0
- data/spec/lib/pickle_parser_spec.rb +154 -0
- data/spec/lib/pickle_path_spec.rb +92 -0
- data/spec/lib/pickle_session_spec.rb +384 -0
- data/spec/lib/pickle_spec.rb +24 -0
- data/spec/spec_helper.rb +38 -0
- metadata +126 -0
@@ -0,0 +1,92 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '../spec_helper'))
|
2
|
+
|
3
|
+
describe Pickle::Path do
|
4
|
+
include Pickle::Path
|
5
|
+
|
6
|
+
describe "#path_to_pickle, when the model doesn't exist" do
|
7
|
+
before do
|
8
|
+
stub!(:model).and_return(nil)
|
9
|
+
end
|
10
|
+
it "('that user', :extra => 'new comment') should raise the error raised by model!" do
|
11
|
+
lambda { path_to_pickle "that user", "new comment" }.should raise_error(RuntimeError, 'Could not figure out a path for ["that user", "new comment"] {}')
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#path_to_pickle" do
|
17
|
+
describe "when model returns a user" do
|
18
|
+
before do
|
19
|
+
stub!(:model).and_return(@user = mock_model(User))
|
20
|
+
end
|
21
|
+
|
22
|
+
it "('a user', 'the user: \"fred\"') should retrieve 'a user', and 'the user: \"fred\"' models" do
|
23
|
+
should_receive(:model).with('a user')
|
24
|
+
should_receive(:model).with('the user: "fred"')
|
25
|
+
stub!(:user_user_path).and_return('the path')
|
26
|
+
path_to_pickle('a user', 'the user: "fred"').should == 'the path'
|
27
|
+
end
|
28
|
+
|
29
|
+
it "('a user', :action => 'foo') should return foo_user_path(<user>)" do
|
30
|
+
should_receive(:foo_user_path).with(@user).and_return('the path')
|
31
|
+
path_to_pickle('a user', :action => 'foo').should == 'the path'
|
32
|
+
end
|
33
|
+
|
34
|
+
it "('a user', :action => 'foo') should raise informative error if foo_user_path not defined" do
|
35
|
+
should_receive(:foo_user_path).with(@user).and_raise(NoMethodError)
|
36
|
+
lambda { path_to_pickle('a user', :action => 'foo') }.should raise_error(Exception, /Could not figure out a path for/)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "('a user', :segment => 'foo') should return user_foo_path(<user>)" do
|
40
|
+
should_receive(:user_foo_path).with(@user).and_return('the path')
|
41
|
+
path_to_pickle('a user', :segment => 'foo').should == 'the path'
|
42
|
+
end
|
43
|
+
|
44
|
+
it "('a user', :segment => 'foo') should raise informative error if foo_user_path not defined" do
|
45
|
+
should_receive(:user_foo_path).with(@user).and_raise(NoMethodError)
|
46
|
+
lambda { path_to_pickle('a user', :segment => 'foo') }.should raise_error(Exception, /Could not figure out a path for/)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "('a user', :action => 'new', :segment => 'comment') should return new_user_comment_path(<user>)" do
|
50
|
+
should_receive(:new_user_comment_path).with(@user).and_return('the path')
|
51
|
+
path_to_pickle('a user', :segment => 'comment', :action => 'new').should == 'the path'
|
52
|
+
end
|
53
|
+
|
54
|
+
it "('a user', :action => 'new', :segment => 'comment') should raise informative error if new_user_comment_path not defined" do
|
55
|
+
should_receive(:new_user_comment_path).with(@user).and_raise(NoMethodError)
|
56
|
+
lambda { path_to_pickle('a user', :action => 'new', :segment => 'comment') }.should raise_error(Exception, /Could not figure out a path for/)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "('a user', :extra => 'new comment') should return new_user_comment_path(<user>)" do
|
60
|
+
should_receive(:new_user_comment_path).with(@user).and_return('the path')
|
61
|
+
path_to_pickle('a user', :extra => 'new comment').should == 'the path'
|
62
|
+
end
|
63
|
+
|
64
|
+
it "('a user', :extra => 'new comment') should raise informative error if new_user_comment_path not defined" do
|
65
|
+
should_receive(:new_user_comment_path).with(@user).and_raise(NoMethodError)
|
66
|
+
lambda { path_to_pickle('a user', :extra => 'new comment') }.should raise_error(Exception, /Could not figure out a path for/)
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "(private API)" do
|
70
|
+
it "('a user', :extra => 'new ish comment') should try combinations of 'new', 'ish', 'comment'" do
|
71
|
+
should_receive(:pickle_path_for_resources_action_segment).with([@user], '', 'new_ish_comment').once
|
72
|
+
should_receive(:pickle_path_for_resources_action_segment).with([@user], 'new', 'ish_comment').once
|
73
|
+
should_receive(:pickle_path_for_resources_action_segment).with([@user], 'new_ish', 'comment').once
|
74
|
+
should_receive(:pickle_path_for_resources_action_segment).with([@user], 'new_ish_comment', '').once
|
75
|
+
lambda { path_to_pickle('a user', :extra => 'new ish comment') }.should raise_error(Exception, /Could not figure out a path for/)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "when args is a list of pickle and non pickle models" do
|
81
|
+
before do
|
82
|
+
stub!(:model).with("account").and_return(nil)
|
83
|
+
stub!(:model).with("the user").and_return(@user = mock_model(User))
|
84
|
+
end
|
85
|
+
|
86
|
+
it "('account', 'the user') should return account_user_path(<user>)" do
|
87
|
+
should_receive(:account_user_path).with(@user).and_return("the path")
|
88
|
+
path_to_pickle('account', 'the user').should == 'the path'
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,384 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '../spec_helper'))
|
2
|
+
|
3
|
+
describe Pickle::Session do
|
4
|
+
include Pickle::Session
|
5
|
+
|
6
|
+
describe "Pickle::Session proxy missing methods to parser", :shared => true do
|
7
|
+
it "should forward to pickle_parser it responds_to them" do
|
8
|
+
@it.pickle_parser.should_receive(:parse_model)
|
9
|
+
@it.parse_model
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should raise error if pickle_parser don't know about em" do
|
13
|
+
lambda { @it.parse_infinity }.should raise_error
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "including Pickle::Session" do
|
18
|
+
before do
|
19
|
+
@it = self
|
20
|
+
end
|
21
|
+
|
22
|
+
it_should_behave_like "Pickle::Session proxy missing methods to parser"
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "extending Pickle::Session" do
|
26
|
+
before do
|
27
|
+
@it = Object.new
|
28
|
+
@it.extend Pickle::Session
|
29
|
+
end
|
30
|
+
|
31
|
+
it_should_behave_like "Pickle::Session proxy missing methods to parser"
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "after storing a single user", :shared => true do
|
35
|
+
it "created_models('user') should be array containing the original user" do
|
36
|
+
created_models('user').should == [@user]
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "the original user should be retrievable with" do
|
40
|
+
it "created_model('the user')" do
|
41
|
+
created_model('the user').should == @user
|
42
|
+
end
|
43
|
+
|
44
|
+
it "created_model('1st user')" do
|
45
|
+
created_model('1st user').should == @user
|
46
|
+
end
|
47
|
+
|
48
|
+
it "created_model('last user')" do
|
49
|
+
created_model('last user').should == @user
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "(found from db)" do
|
54
|
+
before do
|
55
|
+
@user.stub!(:id).and_return(100)
|
56
|
+
@user.class.should_receive(:find).with(100).and_return(@user_from_db = @user.dup)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "models('user') should be array containing user" do
|
60
|
+
models('user').should == [@user_from_db]
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "user should be retrievable with" do
|
64
|
+
it "model('the user')" do
|
65
|
+
model('the user').should == @user_from_db
|
66
|
+
end
|
67
|
+
|
68
|
+
it "model('1st user')" do
|
69
|
+
model('1st user').should == @user_from_db
|
70
|
+
end
|
71
|
+
|
72
|
+
it "model('last user')" do
|
73
|
+
model('last user').should == @user_from_db
|
74
|
+
end
|
75
|
+
|
76
|
+
it "model!('last user')" do
|
77
|
+
model('last user').should == @user_from_db
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "#create_model" do
|
84
|
+
before do
|
85
|
+
@user = mock_model(User)
|
86
|
+
Factory.stub!(:create).and_return(@user)
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "('a user')" do
|
90
|
+
def do_create_model
|
91
|
+
create_model('a user')
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should call Factory.create('user', {})" do
|
95
|
+
Factory.should_receive(:create).with('user', {}).and_return(@user)
|
96
|
+
do_create_model
|
97
|
+
end
|
98
|
+
|
99
|
+
describe "after create," do
|
100
|
+
before { do_create_model }
|
101
|
+
|
102
|
+
it_should_behave_like "after storing a single user"
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe "('1 user', 'foo: \"bar\", baz: \"bing bong\"')" do
|
107
|
+
def do_create_model
|
108
|
+
create_model('1 user', 'foo: "bar", baz: "bing bong"')
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should call Factory.create('user', {'foo' => 'bar', 'baz' => 'bing bong'})" do
|
112
|
+
Factory.should_receive(:create).with('user', {'foo' => 'bar', 'baz' => 'bing bong'}).and_return(@user)
|
113
|
+
do_create_model
|
114
|
+
end
|
115
|
+
|
116
|
+
describe "after create," do
|
117
|
+
before { do_create_model }
|
118
|
+
|
119
|
+
it_should_behave_like "after storing a single user"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe "('an user: \"fred\")" do
|
124
|
+
def do_create_model
|
125
|
+
create_model('an user: "fred"')
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should call Factory.create('user', {})" do
|
129
|
+
Factory.should_receive(:create).with('user', {}).and_return(@user)
|
130
|
+
do_create_model
|
131
|
+
end
|
132
|
+
|
133
|
+
describe "after create," do
|
134
|
+
before { do_create_model }
|
135
|
+
|
136
|
+
it_should_behave_like "after storing a single user"
|
137
|
+
|
138
|
+
it "created_model('the user: \"fred\"') should retrieve the user" do
|
139
|
+
created_model('the user: "fred"').should == @user
|
140
|
+
end
|
141
|
+
|
142
|
+
it "created_model?('the user: \"shirl\"') should be false" do
|
143
|
+
created_model?('the user: "shirl"').should == false
|
144
|
+
end
|
145
|
+
|
146
|
+
it "model?('the user: \"shirl\"') should be false" do
|
147
|
+
model?('the user: "shirl"').should == false
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
describe "with hash" do
|
153
|
+
def do_create_model
|
154
|
+
create_model('a user', {'foo' => 'bar'})
|
155
|
+
end
|
156
|
+
|
157
|
+
it "should call Factory.create('user', {'foo' => 'bar'})" do
|
158
|
+
Factory.should_receive(:create).with('user', {'foo' => 'bar'}).and_return(@user)
|
159
|
+
do_create_model
|
160
|
+
end
|
161
|
+
|
162
|
+
describe "after create," do
|
163
|
+
before { do_create_model }
|
164
|
+
|
165
|
+
it_should_behave_like "after storing a single user"
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
end
|
170
|
+
|
171
|
+
describe '#find_model' do
|
172
|
+
before do
|
173
|
+
@user = mock_model(User)
|
174
|
+
User.stub!(:find).and_return(@user)
|
175
|
+
end
|
176
|
+
|
177
|
+
def do_find_model
|
178
|
+
find_model('a user', 'hair: "pink"')
|
179
|
+
end
|
180
|
+
|
181
|
+
it "should call User.find :first, :conditions => {'hair' => 'pink'}" do
|
182
|
+
User.should_receive(:find).with(:first, :conditions => {'hair' => 'pink'}).and_return(@user)
|
183
|
+
do_find_model
|
184
|
+
end
|
185
|
+
|
186
|
+
describe "after find," do
|
187
|
+
before { do_find_model }
|
188
|
+
|
189
|
+
it_should_behave_like "after storing a single user"
|
190
|
+
end
|
191
|
+
|
192
|
+
describe "with hash" do
|
193
|
+
def do_create_model
|
194
|
+
find_model('a user', {'foo' => 'bar'})
|
195
|
+
end
|
196
|
+
|
197
|
+
it "should call User.find('user', {'foo' => 'bar'})" do
|
198
|
+
User.should_receive(:find).with(:first, :conditions => {'foo' => 'bar'}).and_return(@user)
|
199
|
+
do_create_model
|
200
|
+
end
|
201
|
+
|
202
|
+
describe "after find," do
|
203
|
+
before { do_find_model }
|
204
|
+
|
205
|
+
it_should_behave_like "after storing a single user"
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
describe "#find_model!" do
|
211
|
+
it "should call find_model" do
|
212
|
+
should_receive(:find_model).with('name', 'fields').and_return(mock('User'))
|
213
|
+
find_model!('name', 'fields')
|
214
|
+
end
|
215
|
+
|
216
|
+
it "should call raise error if find_model returns nil" do
|
217
|
+
should_receive(:find_model).with('name', 'fields').and_return(nil)
|
218
|
+
lambda { find_model!('name', 'fields') }.should raise_error
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
describe "#find_models" do
|
223
|
+
before do
|
224
|
+
@user = mock_model(User)
|
225
|
+
User.stub!(:find).and_return([@user])
|
226
|
+
end
|
227
|
+
|
228
|
+
def do_find_models
|
229
|
+
find_models('user', 'hair: "pink"')
|
230
|
+
end
|
231
|
+
|
232
|
+
it "should call User.find :all, :conditions => {'hair' => 'pink'}" do
|
233
|
+
User.should_receive(:find).with(:all, :conditions => {'hair' => 'pink'}).and_return([@user])
|
234
|
+
do_find_models
|
235
|
+
end
|
236
|
+
|
237
|
+
describe "after find," do
|
238
|
+
before { do_find_models }
|
239
|
+
|
240
|
+
it_should_behave_like "after storing a single user"
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
describe 'creating \'a super admin: "fred"\', then \'a user: "shirl"\', \'then 1 super_admin\'' do
|
245
|
+
before do
|
246
|
+
@user = @fred = mock_model(User)
|
247
|
+
@shirl = mock_model(User)
|
248
|
+
@noname = mock_model(User)
|
249
|
+
Factory.stub!(:create).and_return(@fred, @shirl, @noname)
|
250
|
+
end
|
251
|
+
|
252
|
+
def do_create_users
|
253
|
+
create_model('a super admin: "fred"')
|
254
|
+
create_model('a user: "shirl"')
|
255
|
+
create_model('1 super_admin')
|
256
|
+
end
|
257
|
+
|
258
|
+
it "should call Factory.create with <'super_admin'>, <'user'>, <'super_admin'>" do
|
259
|
+
Factory.should_receive(:create).with('super_admin', {}).twice
|
260
|
+
Factory.should_receive(:create).with('user', {}).once
|
261
|
+
do_create_users
|
262
|
+
end
|
263
|
+
|
264
|
+
describe "after create," do
|
265
|
+
before do
|
266
|
+
do_create_users
|
267
|
+
end
|
268
|
+
|
269
|
+
it "created_models('user') should == [@fred, @shirl, @noname]" do
|
270
|
+
created_models('user').should == [@fred, @shirl, @noname]
|
271
|
+
end
|
272
|
+
|
273
|
+
it "created_models('super_admin') should == [@fred, @noname]" do
|
274
|
+
created_models('super_admin').should == [@fred, @noname]
|
275
|
+
end
|
276
|
+
|
277
|
+
describe "#created_model" do
|
278
|
+
it "'that user' should be @noname (the last user created - as super_admins are users)" do
|
279
|
+
created_model('that user').should == @noname
|
280
|
+
end
|
281
|
+
|
282
|
+
it "'the super admin' should be @noname (the last super admin created)" do
|
283
|
+
created_model('that super admin').should == @noname
|
284
|
+
end
|
285
|
+
|
286
|
+
it "'the 1st super admin' should be @fred" do
|
287
|
+
created_model('the 1st super admin').should == @fred
|
288
|
+
end
|
289
|
+
|
290
|
+
it "'the first user' should be @fred" do
|
291
|
+
created_model('the first user').should == @fred
|
292
|
+
end
|
293
|
+
|
294
|
+
it "'the 2nd user' should be @shirl" do
|
295
|
+
created_model('the 2nd user').should == @shirl
|
296
|
+
end
|
297
|
+
|
298
|
+
it "'the last user' should be @noname" do
|
299
|
+
created_model('the last user').should == @noname
|
300
|
+
end
|
301
|
+
|
302
|
+
it "'the user: \"fred\" should be @fred" do
|
303
|
+
created_model('the user: "fred"').should == @fred
|
304
|
+
end
|
305
|
+
|
306
|
+
it "'the user: \"shirl\" should be @shirl" do
|
307
|
+
created_model('the user: "shirl"').should == @shirl
|
308
|
+
end
|
309
|
+
end
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
describe "when 'the user: \"me\"' exists and there is a mapping from 'I', 'myself' => 'user: \"me\"" do
|
314
|
+
before do
|
315
|
+
@user = mock_model(User)
|
316
|
+
User.stub!(:find).and_return(@user)
|
317
|
+
Factory.stub!(:create).and_return(@user)
|
318
|
+
self.pickle_parser = Pickle::Parser.new(:config => Pickle::Config.new {|c| c.map 'I', 'myself', :to => 'user: "me"'})
|
319
|
+
create_model('the user: "me"')
|
320
|
+
end
|
321
|
+
|
322
|
+
it 'model("I") should return the user' do
|
323
|
+
model('I').should == @user
|
324
|
+
end
|
325
|
+
|
326
|
+
it 'model("myself") should return the user' do
|
327
|
+
model('myself').should == @user
|
328
|
+
end
|
329
|
+
|
330
|
+
it "#parser.parse_fields 'author: user \"JIM\"' should raise Error, as model deos not refer" do
|
331
|
+
lambda { pickle_parser.parse_fields('author: user "JIM"') }.should raise_error
|
332
|
+
end
|
333
|
+
|
334
|
+
it "#parser.parse_fields 'author: the user' should return {\"author\" => <user>}" do
|
335
|
+
pickle_parser.parse_fields('author: the user').should == {"author" => @user}
|
336
|
+
end
|
337
|
+
|
338
|
+
it "#parser.parse_fields 'author: myself' should return {\"author\" => <user>}" do
|
339
|
+
pickle_parser.parse_fields('author: myself').should == {"author" => @user}
|
340
|
+
end
|
341
|
+
|
342
|
+
it "#parser.parse_fields 'author: the user, approver: I, rating: \"5\"' should return {'author' => <user>, 'approver' => <user>, 'rating' => '5'}" do
|
343
|
+
pickle_parser.parse_fields('author: the user, approver: I, rating: "5"').should == {'author' => @user, 'approver' => @user, 'rating' => '5'}
|
344
|
+
end
|
345
|
+
|
346
|
+
it "#parser.parse_fields 'author: user: \"me\", approver: \"\"' should return {'author' => <user>, 'approver' => \"\"}" do
|
347
|
+
pickle_parser.parse_fields('author: user: "me", approver: ""').should == {'author' => @user, 'approver' => ""}
|
348
|
+
end
|
349
|
+
end
|
350
|
+
|
351
|
+
describe "convert_models_to_attributes(ar_class, :user => <a user>)" do
|
352
|
+
before do
|
353
|
+
@user = mock_model(User)
|
354
|
+
end
|
355
|
+
|
356
|
+
describe "(when ar_class has column 'user_id')" do
|
357
|
+
before do
|
358
|
+
@ar_class = mock('ActiveRecord', :column_names => ['user_id'])
|
359
|
+
end
|
360
|
+
|
361
|
+
it "should return {'user_id' => <the user.id>}" do
|
362
|
+
convert_models_to_attributes(@ar_class, :user => @user).should == {'user_id' => @user.id}
|
363
|
+
end
|
364
|
+
end
|
365
|
+
|
366
|
+
describe "(when ar_class has columns 'user_id', 'user_type')" do
|
367
|
+
before do
|
368
|
+
@ar_class = mock('ActiveRecord', :column_names => ['user_id', 'user_type'])
|
369
|
+
end
|
370
|
+
|
371
|
+
it "should return {'user_id' => <the user.id>, 'user_type' => <the user.type>}" do
|
372
|
+
convert_models_to_attributes(@ar_class, :user => @user).should == {'user_id' => @user.id, 'user_type' => @user.class.name}
|
373
|
+
end
|
374
|
+
end
|
375
|
+
end
|
376
|
+
|
377
|
+
it "#model!('unknown') should raise informative error message" do
|
378
|
+
lambda { model!('unknown') }.should raise_error("Can't find pickle model: 'unknown' in this scenario")
|
379
|
+
end
|
380
|
+
|
381
|
+
it "#created_model!('unknown') should raise informative error message" do
|
382
|
+
lambda { created_model!('unknown') }.should raise_error("Can't find pickle model: 'unknown' in this scenario")
|
383
|
+
end
|
384
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.expand_path(File.join(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
@@ -0,0 +1,38 @@
|
|
1
|
+
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
|
2
|
+
# from the project root directory.
|
3
|
+
ENV["RAILS_ENV"] ||= "test"
|
4
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "../../../../config/environment"))
|
5
|
+
require 'spec/rails'
|
6
|
+
|
7
|
+
# APP SETUP
|
8
|
+
|
9
|
+
# Models
|
10
|
+
class User < ActiveRecord::Base
|
11
|
+
end
|
12
|
+
|
13
|
+
class FastCar < ActiveRecord::Base
|
14
|
+
end
|
15
|
+
|
16
|
+
class Event < ActiveRecord::Base
|
17
|
+
class Create < Event
|
18
|
+
end
|
19
|
+
|
20
|
+
class Update < Event
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Factories
|
25
|
+
require 'factory_girl'
|
26
|
+
|
27
|
+
Factory.define :user do |u|
|
28
|
+
end
|
29
|
+
|
30
|
+
Factory.define :super_admin, :class => User do |u|
|
31
|
+
end
|
32
|
+
|
33
|
+
Factory.define :fast_car do |c|
|
34
|
+
end
|
35
|
+
|
36
|
+
# Machinist
|
37
|
+
require 'machinist/active_record'
|
38
|
+
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kbaum-pickle
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ian White
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-12-01 00:00:00 -05:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Easy model creation and reference in your cucumber features
|
17
|
+
email: ian.w.white@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README.rdoc
|
24
|
+
files:
|
25
|
+
- .gitignore
|
26
|
+
- History.txt
|
27
|
+
- License.txt
|
28
|
+
- README.rdoc
|
29
|
+
- Rakefile
|
30
|
+
- Todo.txt
|
31
|
+
- VERSION
|
32
|
+
- features/app/app.rb
|
33
|
+
- features/app/blueprints.rb
|
34
|
+
- features/app/factories.rb
|
35
|
+
- features/app/views/notifier/email.erb
|
36
|
+
- features/app/views/notifier/user_email.erb
|
37
|
+
- features/email/email.feature
|
38
|
+
- features/generator/generators.feature
|
39
|
+
- features/path/models_page.feature
|
40
|
+
- features/path/named_route_page.feature
|
41
|
+
- features/pickle/create_from_active_record.feature
|
42
|
+
- features/pickle/create_from_factory_girl.feature
|
43
|
+
- features/pickle/create_from_machinist.feature
|
44
|
+
- features/step_definitions/email_steps.rb
|
45
|
+
- features/step_definitions/extra_email_steps.rb
|
46
|
+
- features/step_definitions/fork_steps.rb
|
47
|
+
- features/step_definitions/generator_steps.rb
|
48
|
+
- features/step_definitions/path_steps.rb
|
49
|
+
- features/step_definitions/pickle_steps.rb
|
50
|
+
- features/support/email.rb
|
51
|
+
- features/support/env.rb
|
52
|
+
- features/support/paths.rb
|
53
|
+
- features/support/pickle.rb
|
54
|
+
- features/support/pickle_app.rb
|
55
|
+
- garlic.rb
|
56
|
+
- init.rb
|
57
|
+
- lib/pickle.rb
|
58
|
+
- lib/pickle/adapter.rb
|
59
|
+
- lib/pickle/config.rb
|
60
|
+
- lib/pickle/email.rb
|
61
|
+
- lib/pickle/email/parser.rb
|
62
|
+
- lib/pickle/email/world.rb
|
63
|
+
- lib/pickle/parser.rb
|
64
|
+
- lib/pickle/parser/matchers.rb
|
65
|
+
- lib/pickle/path.rb
|
66
|
+
- lib/pickle/path/world.rb
|
67
|
+
- lib/pickle/session.rb
|
68
|
+
- lib/pickle/session/parser.rb
|
69
|
+
- lib/pickle/version.rb
|
70
|
+
- lib/pickle/world.rb
|
71
|
+
- pickle.gemspec
|
72
|
+
- rails_generators/pickle/pickle_generator.rb
|
73
|
+
- rails_generators/pickle/templates/email.rb
|
74
|
+
- rails_generators/pickle/templates/email_steps.rb
|
75
|
+
- rails_generators/pickle/templates/paths.rb
|
76
|
+
- rails_generators/pickle/templates/pickle.rb
|
77
|
+
- rails_generators/pickle/templates/pickle_steps.rb
|
78
|
+
- spec/lib/pickle_adapter_spec.rb
|
79
|
+
- spec/lib/pickle_config_spec.rb
|
80
|
+
- spec/lib/pickle_email_parser_spec.rb
|
81
|
+
- spec/lib/pickle_email_spec.rb
|
82
|
+
- spec/lib/pickle_parser_matchers_spec.rb
|
83
|
+
- spec/lib/pickle_parser_spec.rb
|
84
|
+
- spec/lib/pickle_path_spec.rb
|
85
|
+
- spec/lib/pickle_session_spec.rb
|
86
|
+
- spec/lib/pickle_spec.rb
|
87
|
+
- spec/spec_helper.rb
|
88
|
+
has_rdoc: true
|
89
|
+
homepage: http://github.com/ianwhite/pickle/tree
|
90
|
+
licenses: []
|
91
|
+
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options:
|
94
|
+
- --charset=UTF-8
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: "0"
|
102
|
+
version:
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: "0"
|
108
|
+
version:
|
109
|
+
requirements: []
|
110
|
+
|
111
|
+
rubyforge_project:
|
112
|
+
rubygems_version: 1.3.5
|
113
|
+
signing_key:
|
114
|
+
specification_version: 3
|
115
|
+
summary: Easy model creation and reference in your cucumber features
|
116
|
+
test_files:
|
117
|
+
- spec/lib/pickle_adapter_spec.rb
|
118
|
+
- spec/lib/pickle_config_spec.rb
|
119
|
+
- spec/lib/pickle_email_parser_spec.rb
|
120
|
+
- spec/lib/pickle_email_spec.rb
|
121
|
+
- spec/lib/pickle_parser_matchers_spec.rb
|
122
|
+
- spec/lib/pickle_parser_spec.rb
|
123
|
+
- spec/lib/pickle_path_spec.rb
|
124
|
+
- spec/lib/pickle_session_spec.rb
|
125
|
+
- spec/lib/pickle_spec.rb
|
126
|
+
- spec/spec_helper.rb
|