ianwhite-pickle 0.1.12 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +7 -0
- data/README.rdoc +1 -1
- data/lib/pickle/path.rb +1 -1
- data/lib/pickle/session.rb +10 -0
- data/lib/pickle/version.rb +1 -1
- data/spec/lib/pickle_path_spec.rb +13 -4
- data/spec/lib/pickle_session_spec.rb +12 -0
- metadata +2 -2
data/History.txt
CHANGED
data/README.rdoc
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
=
|
1
|
+
= pickle
|
2
2
|
|
3
3
|
Pickle gives you cucumber steps that create your models easily from factory-girl or
|
4
4
|
machinist factories/blueprints. You can also just use ActiveRecord but it's not as cool.
|
data/lib/pickle/path.rb
CHANGED
@@ -13,7 +13,7 @@ module Pickle
|
|
13
13
|
# path_to_pickle 'the user', :extra => 'new comment' # => /users/3/comments/new
|
14
14
|
def path_to_pickle(*pickle_names)
|
15
15
|
options = pickle_names.extract_options!
|
16
|
-
models = pickle_names.map{|m| model(m)}
|
16
|
+
models = pickle_names.map{|m| model!(m)}
|
17
17
|
if options[:extra]
|
18
18
|
parts = options[:extra].underscore.gsub(' ','_').split("_")
|
19
19
|
find_pickle_path_using_action_segment_combinations(models, parts)
|
data/lib/pickle/session.rb
CHANGED
@@ -71,6 +71,16 @@ module Pickle
|
|
71
71
|
(model(name) rescue nil) ? true : false
|
72
72
|
end
|
73
73
|
|
74
|
+
# like model, but raise an error if it can't be found
|
75
|
+
def model!(name)
|
76
|
+
model(name) or raise "Can't find pickle model: '#{name}' in this scenario"
|
77
|
+
end
|
78
|
+
|
79
|
+
# like created_model, but raise an error if it can't be found
|
80
|
+
def created_model!(name)
|
81
|
+
created_model(name) or raise "Can't find pickle model: '#{name}' in this scenario"
|
82
|
+
end
|
83
|
+
|
74
84
|
# return all original models of specified type
|
75
85
|
def created_models(factory)
|
76
86
|
models_by_index(factory)
|
data/lib/pickle/version.rb
CHANGED
@@ -3,14 +3,23 @@ require File.expand_path(File.join(File.dirname(__FILE__), '../spec_helper'))
|
|
3
3
|
describe Pickle::Path do
|
4
4
|
include Pickle::Path
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
describe "#path_to_pickle, when the model doesn't exist" do
|
7
|
+
before do
|
8
|
+
stub!(:model!).and_raise("foo")
|
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("foo")
|
12
|
+
end
|
13
|
+
|
8
14
|
end
|
9
15
|
|
10
16
|
describe "#path_to_pickle" do
|
17
|
+
before do
|
18
|
+
stub!(:model!).and_return(@user = mock_model(User))
|
19
|
+
end
|
11
20
|
it "('a user', 'the user: \"fred\"') should retrieve 'a user', and 'the user: \"fred\"' models" do
|
12
|
-
should_receive(:model).with('a user')
|
13
|
-
should_receive(:model).with('the user: "fred"')
|
21
|
+
should_receive(:model!).with('a user')
|
22
|
+
should_receive(:model!).with('the user: "fred"')
|
14
23
|
stub!(:user_user_path).and_return('the path')
|
15
24
|
path_to_pickle 'a user', 'the user: "fred"'
|
16
25
|
end
|
@@ -72,6 +72,10 @@ describe Pickle::Session do
|
|
72
72
|
it "model('last user')" do
|
73
73
|
model('last user').should == @user_from_db
|
74
74
|
end
|
75
|
+
|
76
|
+
it "model!('last user')" do
|
77
|
+
model('last user').should == @user_from_db
|
78
|
+
end
|
75
79
|
end
|
76
80
|
end
|
77
81
|
end
|
@@ -322,4 +326,12 @@ describe Pickle::Session do
|
|
322
326
|
end
|
323
327
|
end
|
324
328
|
end
|
329
|
+
|
330
|
+
it "#model!('unknown') should raise informative error message" do
|
331
|
+
lambda { model!('unknown') }.should raise_error("Can't find pickle model: 'unknown' in this scenario")
|
332
|
+
end
|
333
|
+
|
334
|
+
it "#created_model!('unknown') should raise informative error message" do
|
335
|
+
lambda { created_model!('unknown') }.should raise_error("Can't find pickle model: 'unknown' in this scenario")
|
336
|
+
end
|
325
337
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ianwhite-pickle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian White
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-06-16 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|