ianwhite-pickle 0.1.9 → 0.1.10

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.10 - 13 Feb 2009
2
+
3
+ * 2 minor enhancements
4
+ * Made pickle paths generator compatible with latest cucumber
5
+ * Simplified and Rakefile, including auto push api docs to gh-pages on ci build
6
+
7
+
1
8
  == 0.1.9 - 29 Jan 2009
2
9
 
3
10
  * 1 minor enhancement
data/README.rdoc ADDED
@@ -0,0 +1,195 @@
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]
2
+
3
+ Pickle gives you cucumber steps that create your models easily from factory-girl or
4
+ machinist factories/blueprints. You can also just use ActiveRecord but it's not as cool.
5
+
6
+ References to the models are stored, not necessarily for the purpose of checking the db
7
+ (although you could use it for that), but for enabling easy reference to urls, and for
8
+ building complex givens which require a bunch of models collaborating
9
+
10
+ == Install
11
+
12
+ Install pickle either as a rails plugin, or a gem
13
+
14
+ # plugin
15
+ script/plugin install git://github.com/ianwhite/pickle.git
16
+
17
+ # or, plugin as submodule
18
+ git submodule add git://github.com/ianwhite/pickle.git vendor/plugins/pickle
19
+
20
+ # or, gem
21
+ sudo gem install ianwhite-pickle
22
+
23
+ == Get Started
24
+
25
+ (you'd better install cucumber)
26
+
27
+ script/generate pickle [paths] [email]
28
+
29
+ Now have a look at <tt>features/step_definitions/pickle_steps.rb</tt>
30
+
31
+ If you want path steps and email steps then just add 'paths' and/or 'email'. The code/steps will be
32
+ written to <tt>features/env/paths.rb</tt> and
33
+ <tt>features/step_definitions/email_steps.rb</tt> respectively.
34
+
35
+ === Using with plain ole Active Record
36
+
37
+ If you have an AR called 'Post', with required fields 'title', and 'body', then you can now write
38
+ steps like this
39
+
40
+ Given a post exists with title: "My Post", body: "My body"
41
+
42
+ === Using with factory-girl or machinist
43
+
44
+ But you're using Machinist or FactoryGirl right?! To leverage all of the factories/blueprints
45
+ you've written, you can just do stuff like
46
+
47
+ Given a user exists
48
+ And another user exists with role: "admin"
49
+
50
+ # later
51
+ Then a user should exist with name: "Fred"
52
+ And that user should be activated # this uses rspec predicate matchers
53
+
54
+ ==== Machinst: require your blueprints and reset Shams
55
+
56
+ In your <tt>features/support/env.rb</tt> add the following lines at the bottom
57
+
58
+ require "#{Rails.root}/spec/blueprints" # or wherever they live
59
+ Before { Sham.reset } # reset Shams in between scenarios
60
+
61
+ === Configuring Pickle
62
+
63
+ You can tell pickle to use another factory adapter (see Pickle::Adapter), or
64
+ create mappings from english expressions to pickle model names. You can also
65
+ override many of the options on the Pickle::Config object if you so choose
66
+
67
+ require 'pickle/world'
68
+
69
+ Pickle.configure do |config|
70
+ config.adapters = [:machinist, YourOwnAdapterClass]
71
+ config.map 'me', 'myself', 'my', 'I', :to => 'user: "me"'
72
+ end
73
+
74
+ == API
75
+
76
+ === Steps
77
+
78
+ When you run <tt>script/generate pickle</tt> you get the following steps
79
+
80
+ ==== Given steps
81
+
82
+ "Given <b>a model</b> exists", e.g.
83
+
84
+ Given a user exists
85
+ Given a user: "fred" exists
86
+ Given the user exists
87
+
88
+ "Given <b>a model</b> exists with <b>fields</b>", e.g.
89
+
90
+ Given a user exists with name: "Fred"
91
+ Given a user exists with name: "Fred", activated: false
92
+
93
+ You can refer to other models in the fields
94
+
95
+ Given a user exists
96
+ And a post exists with author: the user
97
+
98
+ Given a person: "fred" exists
99
+ And a person: "ethel" exists
100
+ And a fatherhood exists with parent: user "fred", child: user "ethel"
101
+
102
+ "Given <b>n</b> models exist", e.g.
103
+
104
+ Given 10 users exist
105
+
106
+ "Given <b>n</b> <b>models</b> exist with <b>fields</b>", examples:
107
+
108
+ Given 10 users exist with activated: false
109
+
110
+ ==== Then steps
111
+
112
+ ===== Asserting existence of models
113
+
114
+ "Then <b>a model</b> should exist", e.g.
115
+
116
+ Then a user should exist
117
+
118
+ "Then <b>a model</b> should exist with <b>fields</b>", e.g.
119
+
120
+ Then a user: "fred" should exist with name: "Fred" # we can label the found user for later use
121
+
122
+ You can use other models, booleans, numerics, and strings as fields
123
+
124
+ Then a person should exist with child: person "ethel"
125
+ Then a user should exist with activated: false
126
+ Then a user should exist with activated: true, email: "fred@gmail.com"
127
+
128
+ "Then <b>n</b> <b>models</b> should exist", e.g.
129
+
130
+ Then 10 events should exist
131
+
132
+ "Then <b>n</b> <b>models</b> should exist with <b>fields</b>", e.g.
133
+
134
+ Then 2 people should exist with father: person "fred"
135
+
136
+ ===== Asserting associations
137
+
138
+ One-to-one assocs: "Then <b>a model</b> should be <b>other model</b>'s <b>association</b>", e.g.
139
+
140
+ Then the person: "fred" should be person: "ethel"'s father
141
+
142
+ Many-to-one assocs: "Then <b>a model</b> should be [in|one of] <b>other model</b>'s <b>association</b>", e.g.
143
+
144
+ Then the person: "ethel" should be one of person: "fred"'s children
145
+ Then the comment should be in the post's comments
146
+
147
+ ===== Asserting predicate methods
148
+
149
+ "Then <b>a model</b> should [be|have] [a|an] <b>predicate</b>", e.g.
150
+
151
+ Then the user should have a status # => user.status?.should == true
152
+ Then the car: "batmobile" should be fast # => car.fast?.should == true
153
+
154
+ "Then <b>a model</b> should [be|have] [a|an] <b>predicate</b>", e.g.
155
+
156
+ Then person: "fred" should not be childless # => fred.childless?.should == false
157
+
158
+ === Regexps for use in your own steps
159
+
160
+ By default you get some regexps available in the main namespace for use
161
+ in creating your own steps: `capture_model`, `capture_fields`, and others (see lib/pickle.rb)
162
+
163
+ (You can use any of the regexps that Pickle uses by using the Pickle.parser namespace, see
164
+ Pickle::Parser::Matchers for the methods available)
165
+
166
+ *capture_model*
167
+
168
+ Given /^#{capture_model} exists$/ do |model_name|
169
+ model(model_name).should_not == nil
170
+ end
171
+
172
+ Then /^I should be at the (.*?) page$/ |page|
173
+ if page =~ /#{capture_model}'s/
174
+ url_for(model($1))
175
+ else
176
+ # ...
177
+ end
178
+ end
179
+
180
+ Then /^#{capture_model} should be one of #{capture_model}'s posts$/ do |post, forum|
181
+ model(forum).posts.should include(post)
182
+ end
183
+
184
+ *capture_fields*
185
+
186
+ This is useful for setting attributes, and knows about pickle model names so that you
187
+ can build up composite objects with ease
188
+
189
+ Given /^#{capture_model} exists with #{capture_fields}$/ do |model_name, fields|
190
+ create_model(model_name, fields)
191
+ end
192
+
193
+ # example of use
194
+ Given a user exists
195
+ And a post exists with author: the user # this step will assign the above user as :author on the post
@@ -2,7 +2,7 @@ module Pickle
2
2
  module Version
3
3
  Major = 0
4
4
  Minor = 1
5
- Tiny = 9
5
+ Tiny = 10
6
6
 
7
7
  String = [Major, Minor, Tiny].join('.')
8
8
  end
@@ -19,7 +19,7 @@ class PickleGenerator < Rails::Generator::Base
19
19
  env_assigns[:pickle_path] = true unless current_env.include?("require 'pickle/path/world'")
20
20
  current_paths = File.read('features/support/paths.rb')
21
21
  unless current_paths.include?('#{capture_model}')
22
- if current_paths =~ /^(.*)(\n\s+else\n\s+raise ".*"\n\s+end\nend\s*)$/m
22
+ if current_paths =~ /^(.*)(\n\s+else\n\s+raise "Can't find.*".*$)/m
23
23
  env_assigns[:current_paths_header] = $1
24
24
  env_assigns[:current_paths_footer] = $2
25
25
  m.template 'paths.rb', File.join('features/support', "paths.rb"), :assigns => env_assigns, :collision => :force
@@ -1,20 +1,20 @@
1
1
  <%= current_paths_header %>
2
- # added by script/generate pickle path
3
-
4
- when /^#{capture_model}(?:'s)? page$/ # eg. the forum's page
5
- path_to_pickle $1
6
-
7
- when /^#{capture_model}(?:'s)? #{capture_model}(?:'s)? page$/ # eg. the forum's post's page
8
- path_to_pickle $1, $2
2
+ # added by script/generate pickle path
3
+
4
+ when /^#{capture_model}(?:'s)? page$/ # eg. the forum's page
5
+ path_to_pickle $1
6
+
7
+ when /^#{capture_model}(?:'s)? #{capture_model}(?:'s)? page$/ # eg. the forum's post's page
8
+ path_to_pickle $1, $2
9
9
 
10
- when /^#{capture_model}(?:'s)? #{capture_model}'s (.+?) page$/ # eg. the forum's post's comments page
11
- path_to_pickle $1, $2, :extra => $3 # or the forum's post's edit page
10
+ when /^#{capture_model}(?:'s)? #{capture_model}'s (.+?) page$/ # eg. the forum's post's comments page
11
+ path_to_pickle $1, $2, :extra => $3 # or the forum's post's edit page
12
12
 
13
- when /^#{capture_model}(?:'s)? (.+?) page$/ # eg. the forum's posts page
14
- path_to_pickle $1, :extra => $2 # or the forum's edit page
13
+ when /^#{capture_model}(?:'s)? (.+?) page$/ # eg. the forum's posts page
14
+ path_to_pickle $1, :extra => $2 # or the forum's edit page
15
15
 
16
- when /^the (.+?) page$/ # translate to named route
17
- send "#{$1.downcase.gsub(' ','_')}_path"
16
+ when /^the (.+?) page$/ # translate to named route
17
+ send "#{$1.downcase.gsub(' ','_')}_path"
18
18
 
19
- # end added by pickle path
19
+ # end added by pickle path
20
20
  <%= current_paths_footer %>
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.9
4
+ version: 0.1.10
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-01-29 00:00:00 -08:00
12
+ date: 2009-02-13 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -42,7 +42,7 @@ files:
42
42
  - rails_generators/pickle/templates/paths.rb
43
43
  - rails_generators/pickle/templates/pickle_steps.rb
44
44
  - License.txt
45
- - README.textile
45
+ - README.rdoc
46
46
  - Todo.txt
47
47
  - History.txt
48
48
  - spec/lib/pickle_adapter_spec.rb