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.
Files changed (64) hide show
  1. data/.gitignore +3 -0
  2. data/History.txt +239 -0
  3. data/License.txt +20 -0
  4. data/README.rdoc +246 -0
  5. data/Rakefile +110 -0
  6. data/Todo.txt +4 -0
  7. data/VERSION +1 -0
  8. data/features/app/app.rb +121 -0
  9. data/features/app/blueprints.rb +11 -0
  10. data/features/app/factories.rb +23 -0
  11. data/features/app/views/notifier/email.erb +1 -0
  12. data/features/app/views/notifier/user_email.erb +6 -0
  13. data/features/email/email.feature +39 -0
  14. data/features/generator/generators.feature +59 -0
  15. data/features/path/models_page.feature +44 -0
  16. data/features/path/named_route_page.feature +10 -0
  17. data/features/pickle/create_from_active_record.feature +49 -0
  18. data/features/pickle/create_from_factory_girl.feature +55 -0
  19. data/features/pickle/create_from_machinist.feature +38 -0
  20. data/features/step_definitions/email_steps.rb +55 -0
  21. data/features/step_definitions/extra_email_steps.rb +7 -0
  22. data/features/step_definitions/fork_steps.rb +4 -0
  23. data/features/step_definitions/generator_steps.rb +46 -0
  24. data/features/step_definitions/path_steps.rb +14 -0
  25. data/features/step_definitions/pickle_steps.rb +73 -0
  26. data/features/support/email.rb +21 -0
  27. data/features/support/env.rb +55 -0
  28. data/features/support/paths.rb +46 -0
  29. data/features/support/pickle.rb +26 -0
  30. data/features/support/pickle_app.rb +4 -0
  31. data/garlic.rb +38 -0
  32. data/init.rb +0 -0
  33. data/lib/pickle/adapter.rb +88 -0
  34. data/lib/pickle/config.rb +48 -0
  35. data/lib/pickle/email/parser.rb +18 -0
  36. data/lib/pickle/email/world.rb +13 -0
  37. data/lib/pickle/email.rb +36 -0
  38. data/lib/pickle/parser/matchers.rb +87 -0
  39. data/lib/pickle/parser.rb +65 -0
  40. data/lib/pickle/path/world.rb +5 -0
  41. data/lib/pickle/path.rb +45 -0
  42. data/lib/pickle/session/parser.rb +34 -0
  43. data/lib/pickle/session.rb +157 -0
  44. data/lib/pickle/version.rb +6 -0
  45. data/lib/pickle/world.rb +9 -0
  46. data/lib/pickle.rb +26 -0
  47. data/pickle.gemspec +110 -0
  48. data/rails_generators/pickle/pickle_generator.rb +40 -0
  49. data/rails_generators/pickle/templates/email.rb +21 -0
  50. data/rails_generators/pickle/templates/email_steps.rb +55 -0
  51. data/rails_generators/pickle/templates/paths.rb +20 -0
  52. data/rails_generators/pickle/templates/pickle.rb +28 -0
  53. data/rails_generators/pickle/templates/pickle_steps.rb +73 -0
  54. data/spec/lib/pickle_adapter_spec.rb +164 -0
  55. data/spec/lib/pickle_config_spec.rb +97 -0
  56. data/spec/lib/pickle_email_parser_spec.rb +49 -0
  57. data/spec/lib/pickle_email_spec.rb +131 -0
  58. data/spec/lib/pickle_parser_matchers_spec.rb +70 -0
  59. data/spec/lib/pickle_parser_spec.rb +154 -0
  60. data/spec/lib/pickle_path_spec.rb +92 -0
  61. data/spec/lib/pickle_session_spec.rb +384 -0
  62. data/spec/lib/pickle_spec.rb +24 -0
  63. data/spec/spec_helper.rb +38 -0
  64. metadata +126 -0
@@ -0,0 +1,121 @@
1
+ # Routes
2
+ ActionController::Routing::Routes.draw do |map|
3
+ map.resources :spoons, :controller => 'default'
4
+ map.resources :forks, :controller => 'default' do |fork|
5
+ fork.resources :tines, :controller => 'default' do |tine|
6
+ tine.resources :comments, :controller => 'default'
7
+ end
8
+ end
9
+ map.resources :users, :controller => 'default'
10
+ end
11
+
12
+ # Migrations
13
+ ActiveRecord::Migration.suppress_messages do
14
+ ActiveRecord::Schema.define(:version => 0) do
15
+ create_table :forks, :force => true do |t|
16
+ t.string :name
17
+ end
18
+
19
+ create_table :spoons, :force => true do |t|
20
+ t.string :name
21
+ t.boolean :round, :default => true, :null => false
22
+ end
23
+
24
+ create_table :tines, :force => true do |t|
25
+ t.belongs_to :fork
26
+ t.boolean :rusty, :default => false, :null => false
27
+ end
28
+
29
+ create_table :users, :force => true do |t|
30
+ t.string :name, :status, :email
31
+ t.decimal :attitude_score, :precision => 4, :scale => 2
32
+ end
33
+ end
34
+ end
35
+
36
+
37
+ # Factories for these Fork & Spoon
38
+ class Fork < ActiveRecord::Base
39
+ validates_presence_of :name
40
+ has_many :tines
41
+
42
+ def completely_rusty?
43
+ tines.map(&:rusty?).uniq == [true]
44
+ end
45
+
46
+ def fancy?
47
+ name =~ /fancy/i
48
+ end
49
+ end
50
+
51
+ class Tine < ActiveRecord::Base
52
+ validates_presence_of :fork
53
+ belongs_to :fork
54
+ end
55
+
56
+ # Machinist blueprint for this
57
+ class Spoon < ActiveRecord::Base
58
+ validates_presence_of :name
59
+ end
60
+
61
+ # we don't want abstract classes getting in there
62
+ class AbstractUser < ActiveRecord::Base
63
+ self.abstract_class = true
64
+ end
65
+
66
+ # No factory or blueprint for this
67
+ class User < AbstractUser
68
+ validates_presence_of :name
69
+
70
+ def positive_person?
71
+ !no_attitude? && attitude_score > 0
72
+ end
73
+
74
+ def no_attitude?
75
+ attitude_score.nil?
76
+ end
77
+ end
78
+
79
+ # controllers
80
+ class DefaultController < ActionController::Base
81
+ def index
82
+ render :text => "index: I was invoked with #{request.path}"
83
+ end
84
+
85
+ def show
86
+ render :text => "show: I was invoked with #{request.path}"
87
+ end
88
+
89
+ def new
90
+ render :text => "new: I was invoked with #{request.path}"
91
+ end
92
+
93
+ def edit
94
+ render :text => "edit: I was invoked with #{request.path}"
95
+ end
96
+ end
97
+
98
+ # notifiers
99
+ class Notifier < ActionMailer::Base
100
+ include ActionController::UrlWriter
101
+
102
+ # BC 2.1
103
+ if respond_to?(:view_paths)
104
+ view_paths << "#{File.dirname(__FILE__)}/views"
105
+ else
106
+ self.template_root = "#{File.dirname(__FILE__)}/views"
107
+ end
108
+
109
+ def user_email(user)
110
+ @recipients = user.email
111
+ @subject = 'A user email'
112
+ @body[:user] = user
113
+ @body[:path] = user_path(user)
114
+ end
115
+
116
+ def email(to, subject, body)
117
+ @recipients = to
118
+ @subject = subject
119
+ @body[:body] = body
120
+ end
121
+ end
@@ -0,0 +1,11 @@
1
+ # Blueprints
2
+ require 'machinist/active_record'
3
+
4
+ Sham.spoon_name { |i| "Spoon #{i}" }
5
+
6
+ Spoon.blueprint do
7
+ name { Sham.spoon_name }
8
+ end
9
+
10
+ # reset shams between scenarios
11
+ Before { Sham.reset }
@@ -0,0 +1,23 @@
1
+ # Factories
2
+ require 'factory_girl'
3
+
4
+ Factory.sequence :fork_name do |n|
5
+ "fork %d04" % n
6
+ end
7
+
8
+ Factory.define :fork do |f|
9
+ f.name { Factory.next(:fork_name) }
10
+ end
11
+
12
+ Factory.define :tine do |t|
13
+ t.association :fork
14
+ end
15
+
16
+ Factory.define :rusty_tine, :class => Tine do |t|
17
+ t.association :fork
18
+ t.rusty true
19
+ end
20
+
21
+ Factory.define :fancy_fork, :class => Fork do |t|
22
+ t.name { "Fancy " + Factory.next(:fork_name) }
23
+ end
@@ -0,0 +1 @@
1
+ <%= @body %>
@@ -0,0 +1,6 @@
1
+ Dear <%= @user.name %>,
2
+
3
+ This is where you should go: <%= @path %>
4
+
5
+ Cheers,
6
+ The Pickle Team
@@ -0,0 +1,39 @@
1
+ Feature: I can test emails are sent
2
+ In order write features with emails as outcomes
3
+ As a feature writer
4
+ I want to easily see what emails have been delivered
5
+
6
+ Scenario: Deliver an email, and test it's properties
7
+ Given an email "Gday" with body: "Gday Mate" is delivered to fred@gmail.com
8
+ Then 1 email should be delivered
9
+ And the email should not be delivered to "frood@fmail.com"
10
+ And the email should have subject: "Gday", to: "fred@gmail.com"
11
+ And the email should contain "Mate"
12
+ And the email should not contain "Foo"
13
+
14
+ Scenario: Deliver some emails, restrict scope
15
+ Given an email "cool" with body: "body1" is delivered to fred@gmail.com
16
+ And an email "tasty" with body: "body2" is delivered to fred@gmail.com
17
+ And an email "cool" with body: "body3" is delivered to joe@gmail.com
18
+
19
+ Then 2 emails should be delivered to fred@gmail.com
20
+ And the 1st email should have subject: "cool"
21
+ And the 2nd email should have subject: "tasty"
22
+
23
+ And 2 emails should be delivered with subject: "cool"
24
+ And the 1st email should be delivered to fred@gmail.com
25
+ And the 2nd email should be delivered to joe@gmail.com
26
+
27
+ And 1 email should be delivered with subject: "cool", to: "fred@gmail.com"
28
+
29
+ Scenario: Deliver some emails, reset deliveries
30
+ Given an email "cool" with body: "body1" is delivered to fred@gmail.com
31
+ And all emails have been delivered
32
+ Then 0 emails should be delivered
33
+
34
+ Scenario: Deliver emails to user
35
+ Given a user exists with name: "Fred", email: "fred@gmail.com"
36
+ And the user's email is delivered
37
+ Then 1 email should be delivered to the user
38
+ And the email should contain "Dear Fred"
39
+ And the email should link to the user's page
@@ -0,0 +1,59 @@
1
+ @gen
2
+ Feature: allow pickle to generate steps
3
+ In order to get going with pickle
4
+ As a dev
5
+ I want to be able to generate steps
6
+
7
+ Scenario: script/generate pickle on fresh cuke install
8
+ Given cucumber has been freshly generated
9
+ When I run "script/generate pickle"
10
+ Then the file features/support/pickle.rb should exist
11
+ And the file features/support/pickle.rb should match /require 'pickle\/world'/
12
+ And the file features/step_definitions/pickle_steps.rb should be identical to the local step_definitions/pickle_steps.rb
13
+
14
+ Scenario: script/generate pickle path on fresh cuke install
15
+ Given cucumber has been freshly generated
16
+ When I run "script/generate pickle path"
17
+ Then the file features/support/pickle.rb should exist
18
+ And the file features/support/pickle.rb should match /require 'pickle\/world'/
19
+ And the file features/support/pickle.rb should match /require 'pickle\/path\/world'/
20
+ And the file features/step_definitions/pickle_steps.rb should be identical to the local step_definitions/pickle_steps.rb
21
+ And the file features/support/paths.rb should be identical to the local support/paths.rb
22
+
23
+ Scenario: script/generate pickle email on fresh cuke install
24
+ Given cucumber has been freshly generated
25
+ When I run "script/generate pickle email"
26
+ Then the file features/support/pickle.rb should exist
27
+ And the file features/support/pickle.rb should match /require 'pickle\/world'/
28
+ And the file features/support/pickle.rb should match /require 'pickle\/email\/world'/
29
+ And the file features/step_definitions/pickle_steps.rb should be identical to the local step_definitions/pickle_steps.rb
30
+ And the file features/step_definitions/email_steps.rb should be identical to the local step_definitions/email_steps.rb
31
+ And the file features/support/email.rb should be identical to the local support/email.rb
32
+
33
+ Scenario: script/generate pickle path email on fresh cuke install
34
+ Given cucumber has been freshly generated
35
+ When I run "script/generate pickle path email"
36
+ Then the file features/support/pickle.rb should exist
37
+ And the file features/support/pickle.rb should be identical to the local support/pickle.rb
38
+ And the file features/support/pickle.rb should match /require 'pickle\/world'/
39
+ And the file features/support/pickle.rb should match /require 'pickle\/path\/world'/
40
+ And the file features/support/pickle.rb should match /require 'pickle\/email\/world'/
41
+ And the file features/step_definitions/pickle_steps.rb should be identical to the local step_definitions/pickle_steps.rb
42
+ And the file features/support/paths.rb should be identical to the local support/paths.rb
43
+ And the file features/step_definitions/email_steps.rb should be identical to the local step_definitions/email_steps.rb
44
+ And the file features/support/email.rb should be identical to the local support/email.rb
45
+
46
+ Scenario: regenerating pickle
47
+ Given cucumber has been freshly generated
48
+ And pickle path email has been freshly generated
49
+ When I run "script/generate pickle path email"
50
+ Then the file features/support/pickle.rb should match /require 'pickle\/world'/
51
+ And the file features/support/pickle.rb should match /require 'pickle\/path\/world'/
52
+ And the file features/support/pickle.rb should match /require 'pickle\/email\/world'/
53
+ And the file features/step_definitions/pickle_steps.rb should be identical to the local step_definitions/pickle_steps.rb
54
+ And the file features/support/paths.rb should be identical to the local support/paths.rb
55
+ And the file features/step_definitions/email_steps.rb should be identical to the local step_definitions/email_steps.rb
56
+ But the file features/support/pickle.rb should not match /require 'pickle\/world'.*require 'pickle\/world'/
57
+ And the file features/support/pickle.rb should not match /require 'pickle\/path\/world'.*require 'pickle\/path\/world'/
58
+ And the file features/support/pickle.rb should not match /require 'pickle\/email\/world'.*require 'pickle\/email\/world'/
59
+ And the file features/support/email.rb should be identical to the local support/email.rb
@@ -0,0 +1,44 @@
1
+ Feature: I can visit a page for a model
2
+ In order to easily go to pages for models I've created
3
+ As a feature writer
4
+ I want to be able visit pages their model
5
+
6
+ Scenario: create a spoon, go its page
7
+ Given a spoon exists
8
+ When I go to the spoon's page
9
+ Then I should be at the spoon's page
10
+ And the spoon's page should match route /spoons/:id
11
+
12
+ Scenario: create a spoon, go to its edit page, check lots of different refs to it
13
+ Given a spoon: "fred" exists
14
+ When I go to spoon: "fred"'s edit page
15
+ Then I should be at the 1st spoon's edit page
16
+ And the 1st spoon's edit page should match route /spoons/:id/edit
17
+ And the spoon's edit page should match route /spoons/:id/edit
18
+ And the spoon: "fred"'s edit page should match route /spoons/:id/edit
19
+
20
+ Scenario: go to a fork's nested tines page
21
+ Given a fork exists
22
+ When I go to the fork's tines page
23
+ Then I should be at the fork's tines page
24
+ And the fork's tines page should match route /forks/:fork_id/tines
25
+
26
+ Scenario: go to a fork's new tine page
27
+ Given a fork exists
28
+ When I go to the fork's new tine page
29
+ Then I should be at the fork's new tine page
30
+ And the fork's new tine page should match route /forks/:fork_id/tines/new
31
+
32
+ Scenario: go to a tine in fork context page
33
+ Given a fork exists
34
+ And a tine exists with fork: the fork
35
+ When I go to the fork's tine's page
36
+ Then I should be at the fork's tine's page
37
+ And the fork's tine's page should match route /forks/:fork_id/tines/:id
38
+
39
+ Scenario: go to a tine's comments in fork context
40
+ Given a fork exists
41
+ And a tine exists with fork: the fork
42
+ When I go to the fork's tine's comments page
43
+ Then I should be at the fork's tine's comments page
44
+ And the fork's tine's comments page should match route /forks/:fork_id/tines/:tine_id/comments
@@ -0,0 +1,10 @@
1
+ Feature: I can visit a page by named route
2
+ In order to nav in my features
3
+ As a feature writer
4
+ I want to be able visit named routes
5
+
6
+ Scenario: visit the new spoons page
7
+ When I go to the new spoon page
8
+ Then I should be at the new spoon page
9
+ And the new spoon page should match route /spoons/new
10
+
@@ -0,0 +1,49 @@
1
+ Feature: I can easily create models from my blueprints
2
+
3
+ As a plain old AR user
4
+ I want to be able to create models with fields
5
+ So that I can create models quickly and easily in my features
6
+
7
+ Scenario: I create a user, and see if it looks right
8
+ Given a user exists with name: "Fred"
9
+ Then the user should not have a status
10
+
11
+ Scenario: I create a user, and see if it looks right
12
+ Given a user exists with name: "Fred", status: "crayzee"
13
+ Then a user should exist with name: "Fred"
14
+ And a user should exist with status: "crayzee"
15
+ But a user should not exist with name: "Wilma"
16
+
17
+ Scenario: I create a user via a mapping
18
+ Given I exist with status: "pwned", name: "fred"
19
+ Then I should have a status
20
+ And the user: "me" should have a status
21
+
22
+ Scenario: I create positive and negative users
23
+ Given a user exists with name: "Fred", attitude_score: +5.42
24
+ And another user exists with name: "Ethel", attitude_score: -1.46
25
+ Then 2 users should exist
26
+ And the 1st user should be a positive person
27
+ And the 2nd user should not be a positive person
28
+
29
+ Scenario: I create nil values
30
+ Given a user exists with name: "Fred", attitude_score: nil
31
+ Then 1 users should exist with attitude_score: nil
32
+ And that user should be the first user
33
+ And that user should have no attitude
34
+
35
+ Scenario: create and find using tables
36
+ Given the following users exist:
37
+ | name | status |
38
+ | Jim | married |
39
+ | Ethel | in a relationship with x |
40
+ Then the following users should exist:
41
+ | name |
42
+ | Jim |
43
+ | Ethel |
44
+ And the following users should exist:
45
+ | status |
46
+ | married |
47
+ | in a relationship with x |
48
+ And the 1st user should be the 3rd user
49
+ And the 2nd user should be the last user
@@ -0,0 +1,55 @@
1
+ Feature: I can easily create models from my factories
2
+
3
+ As a pickle user
4
+ I want to be able to leverage my factories
5
+ So that I can create models quickly and easily in my features
6
+
7
+ Scenario: I create a fork, and see if it looks right
8
+ Given a fork exists
9
+ Then the fork should not be completely rusty
10
+
11
+ Scenario: I create a fork, and see if it looks right
12
+ Given a fork exists with name: "Forky"
13
+ Then a fork should exist with name: "Forky"
14
+ And the fork should not be completely rusty
15
+
16
+ Scenario: I create some forks, and some tines
17
+ Given a fork: "one" exists
18
+ And a tine exists with fork: fork "one"
19
+ And another tine exists with fork: fork "one"
20
+
21
+ And a fancy fork exists
22
+ And a tine exists with fork: the fancy fork
23
+
24
+ Then the first tine should be tine of the fork: "one"
25
+ And the 2nd tine should be tine of fork: "one"
26
+ And the last tine should be tine of the fancy fork
27
+
28
+ Then the first tine should be in fork "one"'s tines
29
+ And the 2nd tine should be in fork: "one"'s tines
30
+ And the last tine should be in the fancy fork's tines
31
+ And the fancy fork should be the last tine's fork
32
+
33
+ But the first tine should not be in the fancy fork's tines
34
+ And the last tine should not be in fork "one"'s tines
35
+ And the fancy fork should not be the first tine's fork
36
+
37
+ Scenario: I create a fork with a tine, and find the tine by the fork
38
+ Given a fork exists
39
+ And a tine exists with fork: the fork
40
+
41
+ Then a tine should exist with fork: the fork
42
+
43
+ Scenario: create a tine with fork refs in a table
44
+ Given 2 forks exist
45
+ And the following tines exist:
46
+ | fork |
47
+ | the 1st fork |
48
+ | the 2nd fork |
49
+ Then the 1st tine should be in the 1st fork's tines
50
+ And the 2nd tine should be in the 2nd fork's tines
51
+
52
+ Scenario: I create fork via a mapping
53
+ Given killah fork exists
54
+ Then the fork should be fancy
55
+ And the fancy fork: "of cornwood" should be fancy
@@ -0,0 +1,38 @@
1
+ Feature: I can easily create models from my blueprints
2
+
3
+ As a machinist user
4
+ I want to be able to leverage my blueprints
5
+ So that I can create models quickly and easily in my features
6
+
7
+ Scenario: I create a spoon, and see if it looks right
8
+ Given a spoon exists
9
+ Then the spoon should be round
10
+
11
+ Scenario: I create a non round spoon, and see if it looks right
12
+ Given a spoon exists with round: false
13
+ Then the spoon should not be round
14
+
15
+ Scenario: I create a named spoon, and see if it has the name
16
+ Given a spoon exists with name: "Pete", round: false
17
+ Then a spoon should exist with name: "Pete"
18
+ And the spoon should not be round
19
+
20
+ Scenario: I create 7 spoons of various roundness
21
+ Given 2 spoons exist with round: false
22
+ And 2 spoons exist with round: true
23
+ And a spoon exists with round: false
24
+
25
+ Then the 1st spoon should not be round
26
+ And the 2nd spoon should not be round
27
+ And the 3rd spoon should be round
28
+ And the 4th spoon should be round
29
+ And the 5th spoon should not be round
30
+
31
+ And 3 spoons should exist with round: false
32
+ And the 1st spoon should not be round
33
+ And the 2nd spoon should not be round
34
+ And the last spoon should not be round
35
+
36
+ And 2 spoons should exist with round: true
37
+ And the first spoon should be round
38
+ And the last spoon should be round
@@ -0,0 +1,55 @@
1
+ # this file generated by script/generate pickle email
2
+ #
3
+ # add email mappings in features/support/email.rb
4
+
5
+ ActionMailer::Base.delivery_method = :test
6
+ ActionMailer::Base.perform_deliveries = true
7
+
8
+ Before do
9
+ ActionMailer::Base.deliveries.clear
10
+ end
11
+
12
+ # Clear the deliveries array, useful if your background sends email that you want to ignore
13
+ Given(/^all emails? (?:have|has) been delivered$/) do
14
+ ActionMailer::Base.deliveries.clear
15
+ end
16
+
17
+ Given(/^(\d)+ emails? should be delivered$/) do |count|
18
+ emails.size.should == count.to_i
19
+ end
20
+
21
+ Then(/^(\d)+ emails? should be delivered to (.*)$/) do |count, to|
22
+ emails("to: \"#{email_for(to)}\"").size.should == count.to_i
23
+ end
24
+
25
+ Then(/^(\d)+ emails? should be delivered with #{capture_fields}$/) do |count, fields|
26
+ emails(fields).size.should == count.to_i
27
+ end
28
+
29
+ Then(/^#{capture_email} should be delivered to (.+)$/) do |email_ref, to|
30
+ email(email_ref, "to: \"#{email_for(to)}\"").should_not be_nil
31
+ end
32
+
33
+ Then(/^#{capture_email} should not be delivered to (.+)$/) do |email_ref, to|
34
+ email(email_ref, "to: \"#{email_for(to)}\"").should be_nil
35
+ end
36
+
37
+ Then(/^#{capture_email} should have #{capture_fields}$/) do |email_ref, fields|
38
+ email(email_ref, fields).should_not be_nil
39
+ end
40
+
41
+ Then(/^#{capture_email} should contain "(.*)"$/) do |email_ref, text|
42
+ email(email_ref).body.should =~ /#{text}/
43
+ end
44
+
45
+ Then(/^#{capture_email} should not contain "(.*)"$/) do |email_ref, text|
46
+ email(email_ref).body.should_not =~ /#{text}/
47
+ end
48
+
49
+ Then(/^#{capture_email} should link to (.+)$/) do |email_ref, page|
50
+ email(email_ref).body.should =~ /#{path_to(page)}/
51
+ end
52
+
53
+ Then(/^show me the emails?$/) do
54
+ save_and_open_emails
55
+ end
@@ -0,0 +1,7 @@
1
+ Given(/^an email "(.*?)" with body: "(.*?)" is delivered to (.+?)$/) do |subject, body, to|
2
+ Notifier.deliver_email(to, subject, body)
3
+ end
4
+
5
+ Given(/^#{capture_model}'s email is delivered$/) do |model|
6
+ Notifier.deliver_user_email(model(model))
7
+ end
@@ -0,0 +1,4 @@
1
+ # example of making your own matcher with the pickle backend
2
+ Then(/^#{capture_model} should be tine of #{capture_model}$/) do |tine, fork|
3
+ model(fork).tines.should include(model(tine))
4
+ end
@@ -0,0 +1,46 @@
1
+ Before('@gen') do
2
+ `mv #{Rails.root}/features/ #{Rails.root}/features.orig/ > /dev/null 2>&1`
3
+ end
4
+
5
+ After('@gen') do
6
+ `rm -rf #{Rails.root}/features`
7
+ `mv #{Rails.root}/features.orig/ #{Rails.root}/features/ > /dev/null 2>&1`
8
+ end
9
+
10
+ Given(/^cucumber has been freshly generated$/) do
11
+ `cd #{Rails.root}; script/generate cucumber -f --webrat`
12
+ end
13
+
14
+ Given(/^pickle path email has been freshly generated$/) do
15
+ `cd #{Rails.root}; script/generate pickle path email`
16
+ end
17
+
18
+ Given(/^env\.rb already requires (.+)$/) do |file|
19
+ File.open("#{Rails.root}/features/support/env.rb", "a") do |env|
20
+ env << "require '#{file}'\n"
21
+ end
22
+ end
23
+
24
+ When(/^I run "(.*)"$/) do |command|
25
+ @output = `cd #{Rails.root}; #{command}`
26
+ end
27
+
28
+ Then(/^I should see "(.*)"$/) do |text|
29
+ @output.should include(text)
30
+ end
31
+
32
+ Then(/^the file (.+?) should exist$/) do |file|
33
+ File.exist?("#{Rails.root}/#{file}").should == true
34
+ end
35
+
36
+ Then(/^the file (.+?) should match \/(.*?)\/$/) do |file, regexp|
37
+ File.read("#{Rails.root}/#{file}").should match(/#{regexp}/m)
38
+ end
39
+
40
+ Then(/^the file (.+?) should not match \/(.*?)\/$/) do |file, regexp|
41
+ File.read("#{Rails.root}/#{file}").should_not match(/#{regexp}/m)
42
+ end
43
+
44
+ Then /^the file ([^ ]+) should be identical to the local (.+)$/ do |generated_file, source_file|
45
+ File.read("#{Rails.root}/#{generated_file}").should == File.read("#{File.dirname(__FILE__)}/../#{source_file}")
46
+ end
@@ -0,0 +1,14 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
2
+
3
+ Then(/^(.+?) should match route \/(.+?)$/) do |page, route|
4
+ regexp = route.gsub(/:(\w*?)id/,'\d+')
5
+ path_to(page).should =~ /#{regexp}/
6
+ end
7
+
8
+ When(/^I go to (.+)$/) do |page|
9
+ visit path_to(page)
10
+ end
11
+
12
+ Then(/^I should be at (.+)$/) do |page|
13
+ request.path.should =~ /#{path_to(page)}/
14
+ end
@@ -0,0 +1,73 @@
1
+ # this file generated by script/generate pickle
2
+
3
+ # create a model
4
+ Given(/^#{capture_model} exists?(?: with #{capture_fields})?$/) do |name, fields|
5
+ create_model(name, fields)
6
+ end
7
+
8
+ # create n models
9
+ Given(/^(\d+) #{capture_plural_factory} exist(?: with #{capture_fields})?$/) do |count, plural_factory, fields|
10
+ count.to_i.times { create_model(plural_factory.singularize, fields) }
11
+ end
12
+
13
+ # create models from a table
14
+ Given(/^the following #{capture_plural_factory} exists?:?$/) do |plural_factory, table|
15
+ name = plural_factory.singularize
16
+ table.hashes.each { |hash| create_model(name, hash) }
17
+ end
18
+
19
+ # find a model
20
+ Then(/^#{capture_model} should exist(?: with #{capture_fields})?$/) do |name, fields|
21
+ find_model!(name, fields)
22
+ end
23
+
24
+ # not find a model
25
+ Then(/^#{capture_model} should not exist(?: with #{capture_fields})?$/) do |name, fields|
26
+ find_model(name, fields).should be_nil
27
+ end
28
+
29
+ # find models with a table
30
+ Then(/^the following #{capture_plural_factory} should exists?:?$/) do |plural_factory, table|
31
+ name = plural_factory.singularize
32
+ table.hashes.each { |hash| find_model!(name, hash)}
33
+ end
34
+
35
+ # find exactly n models
36
+ Then(/^(\d+) #{capture_plural_factory} should exist(?: with #{capture_fields})?$/) do |count, plural_factory, fields|
37
+ find_models(plural_factory.singularize, fields).size.should == count.to_i
38
+ end
39
+
40
+ # assert equality of models
41
+ Then(/^#{capture_model} should be #{capture_model}$/) do |a, b|
42
+ model!(a).should == model!(b)
43
+ end
44
+
45
+ # assert model is in another model's has_many assoc
46
+ Then(/^#{capture_model} should be (?:in|one of|amongst) #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
47
+ model!(owner).send(association).should include(model!(target))
48
+ end
49
+
50
+ # assert model is not in another model's has_many assoc
51
+ Then(/^#{capture_model} should not be (?:in|one of|amongst) #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
52
+ model!(owner).send(association).should_not include(model!(target))
53
+ end
54
+
55
+ # assert model is another model's has_one/belongs_to assoc
56
+ Then(/^#{capture_model} should be #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
57
+ model!(owner).send(association).should == model!(target)
58
+ end
59
+
60
+ # assert model is not another model's has_one/belongs_to assoc
61
+ Then(/^#{capture_model} should not be #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
62
+ model!(owner).send(association).should_not == model!(target)
63
+ end
64
+
65
+ # assert model.predicate?
66
+ Then(/^#{capture_model} should (?:be|have) (?:an? )?#{capture_predicate}$/) do |name, predicate|
67
+ model!(name).should send("be_#{predicate.gsub(' ', '_')}")
68
+ end
69
+
70
+ # assert not model.predicate?
71
+ Then(/^#{capture_model} should not (?:be|have) (?:an? )?#{capture_predicate}$/) do |name, predicate|
72
+ model!(name).should_not send("be_#{predicate.gsub(' ', '_')}")
73
+ end