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 CHANGED
@@ -1,3 +1,10 @@
1
+ == 0.1.13 - 16 June 2009
2
+
3
+ * 2 minor enhancements
4
+ * model! and created_model! raise an error if pickle name can't be found
5
+ * path_to_pickle uses the above to give back a better error message
6
+
7
+
1
8
  == 0.1.12 - 7 Apr 2009
2
9
 
3
10
  * 2 minor enhancements
data/README.rdoc CHANGED
@@ -1,4 +1,4 @@
1
- = {ianwhite}[http://github.com/ianwhite] / {pickle}[http://github.com/ianwhite/pickle] >>{info}[http://ianwhite.github.com/pickle] >>{api}[http://ianwhite.github.com/pickle/doc]
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)
@@ -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)
@@ -2,7 +2,7 @@ module Pickle
2
2
  module Version
3
3
  Major = 0
4
4
  Minor = 1
5
- Tiny = 12
5
+ Tiny = 13
6
6
 
7
7
  String = [Major, Minor, Tiny].join('.')
8
8
  end
@@ -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
- before do
7
- stub!(:model).and_return(@user = mock_model(User))
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.12
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-04-07 00:00:00 -07:00
12
+ date: 2009-06-16 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15