pickle 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,12 @@
1
+ == 0.3.2
2
+
3
+ * 3 minor improvements
4
+ * Document how to use machinist named blueprints [Christopher Darroch]
5
+ * Email links now visit the url, rather than just the path, this allows for features that
6
+ make use of the domain to function correctly
7
+ * Deprecation warnings for Rails 3 removed [Brian Rose & Kevin Olsen]
8
+
9
+
1
10
  == 0.3.1
2
11
 
3
12
  * 1 major improvement
@@ -93,10 +93,7 @@ you've written, you can just do stuff like
93
93
  Then a user should exist with name: "Fred"
94
94
  And that user should be activated # this uses rspec predicate matchers
95
95
 
96
- ==== Machinst: require your blueprints and reset Shams
97
-
98
- (The latest version of pickle supports {multiple blueprints}[http://github.com/notahat/machinist/commit/d6492e6927a8aa1819926e48b22377171fd20496], for
99
- earlier versions of machinist use pickle <= 0.1.10)
96
+ ==== Machinist: require your blueprints and reset Shams
100
97
 
101
98
  In your <tt>features/support/env.rb</tt> add the following lines at the bottom
102
99
 
@@ -114,7 +111,7 @@ If that doesn't solve loading issues then require your factories.rb file directl
114
111
 
115
112
  === Using with an ORM other than ActiveRecord or DataMapper
116
113
 
117
- Pickle can be used with any Modeling library provided there is an adapter written for it.
114
+ Pickle can be used with any modelling library provided there is an adapter written for it.
118
115
 
119
116
  Adapters are very simple and exist a module or class with the name "PickleAdapter" available to the class. For example
120
117
 
@@ -187,6 +184,35 @@ You can refer to other models in the fields
187
184
  | Fred | false |
188
185
  | Ethel | true |
189
186
 
187
+ ===== Named machinist blueprints
188
+
189
+ "Given <b> a <i>named</i> model</b> exists with <b>fields</b>"
190
+
191
+ The latest version of pickle supports {named machinist blueprints}[http://github.com/notahat/machinist/commit/d6492e6927a8aa1819926e48b22377171fd20496].
192
+
193
+ If you had the following blueprints:
194
+
195
+ User.blueprint do
196
+ name
197
+ email
198
+ end
199
+
200
+ User.blueprint(:super_admin) do
201
+ role { "admin" }
202
+ end
203
+
204
+ User.blueprint(:activated) do
205
+ activated { true }
206
+ end
207
+
208
+ You could create a user with pickle by simply adding the name of the blueprint before the model:
209
+
210
+ Given a super admin user exists
211
+ And an activated user exists with name: "Fred"
212
+
213
+ This is much nicer than having to set up common configurations in your steps all the time, and far more readable to boot.
214
+
215
+
190
216
  ==== Then steps
191
217
 
192
218
  ===== Asserting existence of models
@@ -302,6 +328,8 @@ To run the features (rails 2.3 only ATM):
302
328
 
303
329
  The following people have made Pickle better:
304
330
 
331
+ * Brian Rose & Kevin Olsen
332
+ * {Christopher Darroch}[http://github.com/chrisdarroch]
305
333
  * {Szymon Nowak}[http://github.com/szimek]
306
334
  * {H.J. Blok}[http://github.com/hjblok]
307
335
  * {Daniel Neighman}[http://github.com/hassox]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
@@ -18,7 +18,13 @@ class ActiveRecord::Base
18
18
 
19
19
  # Gets a list of the available models for this adapter
20
20
  def self.model_classes
21
- ::ActiveRecord::Base.__send__(:subclasses).select do |klass|
21
+ begin
22
+ klasses = ::ActiveRecord::Base.__send__(:descendants) # Rails 3
23
+ rescue
24
+ klasses = ::ActiveRecord::Base.__send__(:subclasses) # Rails 2
25
+ end
26
+
27
+ klasses.select do |klass|
22
28
  !klass.abstract_class? && klass.table_exists? && !except_classes.include?(klass.name)
23
29
  end
24
30
  end
@@ -25,8 +25,7 @@ module Pickle
25
25
 
26
26
  def click_first_link_in_email(email)
27
27
  link = links_in_email(email).first
28
- request_uri = URI::parse(link).request_uri
29
- visit request_uri
28
+ visit link
30
29
  end
31
30
 
32
31
  protected
@@ -60,15 +59,14 @@ module Pickle
60
59
  # e.g. confirm in http://confirm
61
60
  def parse_email_for_explicit_link(email, regex)
62
61
  regex = /#{Regexp.escape(regex)}/ unless regex.is_a?(Regexp)
63
- url = links_in_email(email).detect { |link| link =~ regex }
64
- URI::parse(url).request_uri if url
62
+ links_in_email(email).detect { |link| link =~ regex }
65
63
  end
66
64
 
67
65
  # e.g. Click here in <a href="http://confirm">Click here</a>
68
66
  def parse_email_for_anchor_text_link(email, link_text)
69
- email.body =~ %r{<a[^>]*href=['"]?([^'"]*)['"]?[^>]*?>[^<]*?#{link_text}[^<]*?</a>}
70
- URI.split($~[1])[5..-1].compact!.join("?").gsub("&amp;", "&")
71
- # sub correct ampersand after rails switches it (http://dev.rubyonrails.org/ticket/4002)
67
+ if match_data = email.body.match(%r{<a[^>]*href=['"]?([^'"]*)['"]?[^>]*?>[^<]*?#{link_text}[^<]*?</a>})
68
+ match_data[1]
69
+ end
72
70
  end
73
71
 
74
72
  def links_in_email(email, protos=['http', 'https'])
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{pickle}
8
- s.version = "0.3.1"
8
+ s.version = "0.3.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ian White"]
12
- s.date = %q{2010-07-31}
12
+ s.date = %q{2010-08-05}
13
13
  s.description = %q{Easy model creation and reference in your cucumber features}
14
14
  s.email = %q{ian.w.white@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -7,11 +7,11 @@ require 'pickle/adapters/active_record'
7
7
 
8
8
  describe Pickle::Adapter do
9
9
  it ".factories should raise NotImplementedError" do
10
- lambda{ Pickle::Adapter.factories }.should raise_error(NotImplementedError)
10
+ lambda { Pickle::Adapter.factories }.should raise_error(NotImplementedError)
11
11
  end
12
12
 
13
13
  it "#create should raise NotImplementedError" do
14
- lambda{ Pickle::Adapter.new.create }.should raise_error(NotImplementedError)
14
+ lambda { Pickle::Adapter.new.create }.should raise_error(NotImplementedError)
15
15
  end
16
16
 
17
17
  describe ".model_classes" do
@@ -26,7 +26,7 @@ describe Pickle::Adapter do
26
26
  klass4 = Class.new(ActiveRecord::Base)
27
27
  klass5 = Class.new(ActiveRecord::Base)
28
28
  klass6 = Class.new(ActiveRecord::Base)
29
- [klass1, klass2,klass3,klass4, klass5, klass6].each{|k| k.stub!(:table_exists?).and_return(true)}
29
+ [klass1, klass2, klass3, klass4, klass5, klass6].each { |k| k.stub!(:table_exists?).and_return(true) }
30
30
 
31
31
  klass2.stub!(:name).and_return("CGI::Session::ActiveRecordStore::Session")
32
32
  klass3.stub!(:name).and_return("ActiveRecord::SessionStore::Session")
@@ -39,37 +39,60 @@ describe Pickle::Adapter do
39
39
 
40
40
  describe "adapters: " do
41
41
  before do
42
- @klass1 = returning(Class.new(ActiveRecord::Base)) {|k| k.stub!(:name).and_return('One')}
43
- @klass2 = returning(Class.new(ActiveRecord::Base)) {|k| k.stub!(:name).and_return('One::Two')}
44
- @klass3 = returning(Class.new(ActiveRecord::Base)) {|k| k.stub!(:name).and_return('Three')}
42
+ @klass1 = returning(Class.new(ActiveRecord::Base)) { |k| k.stub!(:name).and_return('One') }
43
+ @klass2 = returning(Class.new(ActiveRecord::Base)) { |k| k.stub!(:name).and_return('One::Two') }
44
+ @klass3 = returning(Class.new(ActiveRecord::Base)) { |k| k.stub!(:name).and_return('Three') }
45
45
  end
46
46
 
47
47
  describe 'ActiveRecord' do
48
- before do
49
- ActiveRecord::Base::PickleAdapter.stub!(:model_classes).and_return([@klass1, @klass2, @klass3])
50
- end
51
48
 
52
- it ".factories should create one for each active record class" do
53
- Pickle::Adapter::ActiveRecord.should_receive(:new).with(@klass1).once
54
- Pickle::Adapter::ActiveRecord.should_receive(:new).with(@klass2).once
55
- Pickle::Adapter::ActiveRecord.should_receive(:new).with(@klass3).once
56
- Pickle::Adapter::ActiveRecord.factories
49
+ #DEPRECATION WARNING: subclasses is deprecated and will be removed from Rails 3.0 (use descendants instead). (called from __send__ at /Users/pivotal/workspace/factorylabs/protosite/vendor/cache/ruby/1.8/gems/pickle-0.3.1/lib/pickle/adapters/active_record.rb:21)
50
+
51
+ describe ".model_classes" do
52
+ it "calls .descendants" do
53
+ ::ActiveRecord::Base.should_receive(:descendants).and_return([])
54
+ ::ActiveRecord::Base.should_not_receive(:subclasses).and_return([])
55
+
56
+ ActiveRecord::Base::PickleAdapter.model_classes
57
+ end
58
+
59
+ it "calls .subclasses when .descendants doesn't respond" do
60
+ ::ActiveRecord::Base.should_receive(:subclasses).and_return([])
61
+
62
+ ActiveRecord::Base::PickleAdapter.model_classes
63
+ end
64
+
57
65
  end
58
66
 
59
- describe ".new(Class)" do
67
+ describe 'with class stubs' do
60
68
  before do
61
- @factory = Pickle::Adapter::ActiveRecord.new(@klass2)
69
+ ActiveRecord::Base::PickleAdapter.stub!(:model_classes).and_return([@klass1, @klass2, @klass3])
62
70
  end
63
71
 
64
- it "should have underscored (s/_) name of Class as #name" do
65
- @factory.name.should == 'one_two'
72
+ it ".factories should create one for each active record class" do
73
+ Pickle::Adapter::ActiveRecord.should_receive(:new).with(@klass1).once
74
+ Pickle::Adapter::ActiveRecord.should_receive(:new).with(@klass2).once
75
+ Pickle::Adapter::ActiveRecord.should_receive(:new).with(@klass3).once
76
+ Pickle::Adapter::ActiveRecord.factories
66
77
  end
67
78
 
68
- it "#create(attrs) should call Class.create!(attrs)" do
69
- @klass2.should_receive(:create!).with({:key => "val"})
70
- @factory.create(:key => "val")
79
+ describe ".new(Class)" do
80
+ before do
81
+ @factory = Pickle::Adapter::ActiveRecord.new(@klass2)
82
+ end
83
+
84
+ it "should have underscored (s/_) name of Class as #name" do
85
+ @factory.name.should == 'one_two'
86
+ end
87
+
88
+ it "#create(attrs) should call Class.create!(attrs)" do
89
+ @klass2.should_receive(:create!).with({:key => "val"})
90
+ @factory.create(:key => "val")
91
+ end
71
92
  end
72
93
  end
94
+
95
+
73
96
  end
74
97
 
75
98
  describe 'FactoryGirl' do
@@ -143,17 +143,17 @@ describe Pickle::Email do
143
143
  end
144
144
 
145
145
  it "should find a link for http://example.com/page" do
146
- should_receive(:visit).with('/page')
146
+ should_receive(:visit).with('http://example.com/page')
147
147
  visit_in_email(@email1, 'http://example.com/page')
148
148
  end
149
149
 
150
150
  it "should find a link for \"example page\"" do
151
- should_receive(:visit).with('/page')
151
+ should_receive(:visit).with('http://example.com/page')
152
152
  visit_in_email(@email1, 'example page')
153
153
  end
154
154
 
155
155
  it "should follow the first link in an email" do
156
- should_receive(:visit).with('/page')
156
+ should_receive(:visit).with('http://example.com/page')
157
157
  click_first_link_in_email(@email1)
158
158
  end
159
159
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pickle
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 1
10
- version: 0.3.1
9
+ - 2
10
+ version: 0.3.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ian White
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-31 00:00:00 +01:00
18
+ date: 2010-08-05 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies: []
21
21