pickle 0.5.2 → 0.5.3
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.
- checksums.yaml +4 -4
- data/History.txt +4 -0
- data/Rakefile.d/cucumber.rake +1 -1
- data/features/step_definitions/email_steps.rb +1 -0
- data/features/step_definitions/pickle_steps.rb +1 -0
- data/features/support/email.rb +1 -0
- data/lib/pickle/adapter.rb +1 -1
- data/lib/pickle/path.rb +1 -1
- data/lib/pickle/version.rb +1 -1
- data/spec/pickle/path_spec.rb +37 -18
- metadata +3 -3
- data/features/step_definitions/email_steps.rb +0 -65
- data/features/step_definitions/pickle_steps.rb +0 -105
- data/features/support/email.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b58eef50218f9337a561a6bb1037202cc200fc2a
|
4
|
+
data.tar.gz: 4ef8f88b81920ea1e5297a10dc1407d61f4cba71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dd3d6376c5c8d7372935fc15d451e69c975155461003679e7bdfc6e82bb31775d3fb112eb2d7c2f4eb415591aa50b10ba72028ce68f3f9e4077ef63bda1d9d5
|
7
|
+
data.tar.gz: cece36b98a29a5b44c3751f6a592cbf8a2cca0d48e25f97e8ca97d599a55f689a310b1b94288da2cf5d89a193a58860a75aefba7dc5d6f673bd6d0087a9f890b
|
data/History.txt
CHANGED
data/Rakefile.d/cucumber.rake
CHANGED
@@ -16,7 +16,7 @@ namespace :cucumber do
|
|
16
16
|
Bundler.with_clean_env do
|
17
17
|
gemfile = "cucumber_test_app/Gemfile"
|
18
18
|
rm_rf "cucumber_test_app"
|
19
|
-
sh "rails new cucumber_test_app --skip-javascript --skip-sprockets"
|
19
|
+
sh "bundle exec rails new cucumber_test_app --skip-javascript --skip-sprockets"
|
20
20
|
sh "echo 'gem \"cucumber-rails\", :require => false' >> #{gemfile}"
|
21
21
|
sh "echo 'gem \"rspec-rails\", \"~>3.0\"' >> #{gemfile}"
|
22
22
|
sh "echo 'gem \"capybara\"' >> #{gemfile}"
|
@@ -0,0 +1 @@
|
|
1
|
+
features/step_definitions/../../rails_generators/pickle/templates/email_steps.rb
|
@@ -0,0 +1 @@
|
|
1
|
+
features/step_definitions/../../rails_generators/pickle/templates/pickle_steps.rb
|
@@ -0,0 +1 @@
|
|
1
|
+
features/support/../../rails_generators/pickle/templates/email.rb
|
data/lib/pickle/adapter.rb
CHANGED
data/lib/pickle/path.rb
CHANGED
@@ -36,7 +36,7 @@ module Pickle
|
|
36
36
|
def pickle_path_for_resources_action_segment(resources, action, segment)
|
37
37
|
action.blank? or action = action.downcase.gsub(' ','_')
|
38
38
|
segment.blank? or segment = segment.downcase.gsub(' ','_')
|
39
|
-
resource_names = resources.map{|s| s.is_a?(Symbol) ? s.to_s : s.class.name.underscore}.join("_")
|
39
|
+
resource_names = resources.map{|s| s.is_a?(Symbol) ? s.to_s : s.class.name.underscore.gsub('/', '_')}.join("_")
|
40
40
|
models = resources.reject{|s| s.is_a?(Symbol)}
|
41
41
|
parts = [action, resource_names, segment].reject(&:blank?)
|
42
42
|
send("#{parts.join('_')}_path", *models) rescue nil
|
data/lib/pickle/version.rb
CHANGED
data/spec/pickle/path_spec.rb
CHANGED
@@ -4,7 +4,7 @@ require 'pickle/path'
|
|
4
4
|
|
5
5
|
describe Pickle::Path do
|
6
6
|
include Pickle::Path
|
7
|
-
|
7
|
+
|
8
8
|
describe "#path_to_pickle, when the model doesn't exist" do
|
9
9
|
before do
|
10
10
|
allow(self).to receive(:model).and_return(nil)
|
@@ -12,81 +12,81 @@ describe Pickle::Path do
|
|
12
12
|
it "('that user', :extra => 'new comment') should raise the error raised by model!" do
|
13
13
|
expect { path_to_pickle "that user", "new comment" }.to raise_error(RuntimeError, 'Could not figure out a path for ["that user", "new comment"] {}')
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
describe "#path_to_pickle" do
|
19
19
|
describe "when model returns a user" do
|
20
20
|
let :user_class do
|
21
21
|
double 'User', :name => 'User'
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
let :user do
|
25
25
|
double 'user', :class => user_class
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
before do
|
29
29
|
allow(self).to receive(:model).and_return(user)
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
it "('a user', 'the user: \"fred\"') should retrieve 'a user', and 'the user: \"fred\"' models" do
|
33
33
|
expect(self).to receive(:model).with('a user')
|
34
34
|
expect(self).to receive(:model).with('the user: "fred"')
|
35
35
|
allow(self).to receive(:user_user_path).and_return('the path')
|
36
36
|
expect(path_to_pickle('a user', 'the user: "fred"')).to eq('the path')
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
it "('a user', :action => 'foo') should return foo_user_path(<user>)" do
|
40
40
|
expect(self).to receive(:foo_user_path).with(user).and_return('the path')
|
41
41
|
expect(path_to_pickle('a user', :action => 'foo')).to eq('the path')
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
it "('a user', :action => 'foo') should raise informative error if foo_user_path not defined" do
|
45
45
|
expect(self).to receive(:foo_user_path).with(user).and_raise(NoMethodError)
|
46
46
|
expect { path_to_pickle('a user', :action => 'foo') }.to raise_error(Exception, /Could not figure out a path for/)
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
it "('a user', :segment => 'foo') should return user_foo_path(<user>)" do
|
50
50
|
expect(self).to receive(:user_foo_path).with(user).and_return('the path')
|
51
51
|
expect(path_to_pickle('a user', :segment => 'foo')).to eq('the path')
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
it "('a user', :segment => 'foo') should raise informative error if foo_user_path not defined" do
|
55
55
|
expect(self).to receive(:user_foo_path).with(user).and_raise(NoMethodError)
|
56
56
|
expect { path_to_pickle('a user', :segment => 'foo') }.to raise_error(Exception, /Could not figure out a path for/)
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
59
|
it "('a user', :action => 'new', :segment => 'comment') should return new_user_comment_path(<user>)" do
|
60
60
|
expect(self).to receive(:new_user_comment_path).with(user).and_return('the path')
|
61
61
|
expect(path_to_pickle('a user', :segment => 'comment', :action => 'new')).to eq('the path')
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
it "('a user', :action => 'new', :segment => 'comment') should raise informative error if new_user_comment_path not defined" do
|
65
65
|
expect(self).to receive(:new_user_comment_path).with(user).and_raise(NoMethodError)
|
66
66
|
expect { path_to_pickle('a user', :action => 'new', :segment => 'comment') }.to raise_error(Exception, /Could not figure out a path for/)
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
it "('a user', :extra => 'new comment') should return new_user_comment_path(<user>)" do
|
70
70
|
expect(self).to receive(:new_user_comment_path).with(user).and_return('the path')
|
71
71
|
expect(path_to_pickle('a user', :extra => 'new comment')).to eq('the path')
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
74
|
it "('a user', :extra => 'new comment') should raise informative error if new_user_comment_path not defined" do
|
75
75
|
expect(self).to receive(:new_user_comment_path).with(user).and_raise(NoMethodError)
|
76
76
|
expect { path_to_pickle('a user', :extra => 'new comment') }.to raise_error(Exception, /Could not figure out a path for/)
|
77
77
|
end
|
78
|
-
|
78
|
+
|
79
79
|
describe "when args is a list of pickle and non pickle models" do
|
80
80
|
before do
|
81
81
|
allow(self).to receive(:model).with("account").and_return(nil)
|
82
82
|
end
|
83
|
-
|
83
|
+
|
84
84
|
it "('account', 'the user') should return account_user_path(<user>)" do
|
85
85
|
expect(self).to receive(:account_user_path).with(user).and_return("the path")
|
86
86
|
expect(path_to_pickle('account', 'the user')).to eq('the path')
|
87
87
|
end
|
88
88
|
end
|
89
|
-
|
89
|
+
|
90
90
|
describe "(private API)" do
|
91
91
|
it "('a user', :extra => 'new ish comment') should try combinations of 'new', 'ish', 'comment'" do
|
92
92
|
expect(self).to receive(:pickle_path_for_resources_action_segment).with([user], '', 'new_ish_comment').once
|
@@ -97,5 +97,24 @@ describe Pickle::Path do
|
|
97
97
|
end
|
98
98
|
end
|
99
99
|
end
|
100
|
+
|
101
|
+
describe "when model returns namespaced user" do
|
102
|
+
let :user_class do
|
103
|
+
double 'User', :name => 'Admin::User'
|
104
|
+
end
|
105
|
+
|
106
|
+
let :user do
|
107
|
+
double 'user', :class => user_class
|
108
|
+
end
|
109
|
+
|
110
|
+
before do
|
111
|
+
allow(self).to receive(:model).and_return(user)
|
112
|
+
end
|
113
|
+
|
114
|
+
it "('a user', :action => 'foo') should return foo_admin_user_path(<user>)" do
|
115
|
+
expect(self).to receive(:foo_admin_user_path).with(user).and_return('the path')
|
116
|
+
expect(path_to_pickle('a user', :action => 'foo')).to eq('the path')
|
117
|
+
end
|
118
|
+
end
|
100
119
|
end
|
101
|
-
end
|
120
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pickle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian White
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-08-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cucumber
|
@@ -326,7 +326,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
326
326
|
version: 1.3.6
|
327
327
|
requirements: []
|
328
328
|
rubyforge_project: pickle
|
329
|
-
rubygems_version: 2.
|
329
|
+
rubygems_version: 2.6.11
|
330
330
|
signing_key:
|
331
331
|
specification_version: 4
|
332
332
|
summary: Easy model creation and reference in your cucumber features.
|
@@ -1,65 +0,0 @@
|
|
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
|
-
expect(emails.size).to eq(count.to_i)
|
19
|
-
end
|
20
|
-
|
21
|
-
When(/^(?:I|they) follow "([^"]*?)" in #{capture_email}$/) do |link, email_ref|
|
22
|
-
visit_in_email(email(email_ref), link)
|
23
|
-
end
|
24
|
-
|
25
|
-
When(/^(?:I|they) click the first link in #{capture_email}$/) do |email_ref|
|
26
|
-
click_first_link_in_email(email(email_ref))
|
27
|
-
end
|
28
|
-
|
29
|
-
Then(/^(\d)+ emails? should be delivered to (.*)$/) do |count, to|
|
30
|
-
actual = emails("to: \"#{email_for(to)}\"").size
|
31
|
-
expect(actual).to eq(count.to_i), "Expected #{count} emails but encountered #{actual} delivered to #{to}"
|
32
|
-
end
|
33
|
-
|
34
|
-
Then(/^(\d)+ emails? should be delivered with #{capture_fields}$/) do |count, fields|
|
35
|
-
actual = emails(fields).size
|
36
|
-
expect(actual).to eq(count.to_i), "Expected #{count} emails but encountered #{actual} to be delivered with #{fields}"
|
37
|
-
end
|
38
|
-
|
39
|
-
Then(/^#{capture_email} should be delivered to (.+)$/) do |email_ref, to|
|
40
|
-
expect(email(email_ref, "to: \"#{email_for(to)}\"")).not_to be_nil, "Failed to find #{email_ref} delivered to: #{to}"
|
41
|
-
end
|
42
|
-
|
43
|
-
Then(/^#{capture_email} should not be delivered to (.+)$/) do |email_ref, to|
|
44
|
-
expect(email(email_ref, "to: \"#{email_for(to)}\"")).to be_nil, "Unexpectedly found #{email_ref} delivered to: #{to}"
|
45
|
-
end
|
46
|
-
|
47
|
-
Then(/^#{capture_email} should have #{capture_fields}$/) do |email_ref, fields|
|
48
|
-
expect(email(email_ref, fields)).not_to be_nil, "Failed to find #{fields} in #{email_ref}"
|
49
|
-
end
|
50
|
-
|
51
|
-
Then(/^#{capture_email} should contain "(.*)"$/) do |email_ref, text|
|
52
|
-
expect(email(email_ref).body).to match(/#{text}/), "Failed to find \"#{text}\" in #{email_ref}"
|
53
|
-
end
|
54
|
-
|
55
|
-
Then(/^#{capture_email} should not contain "(.*)"$/) do |email_ref, text|
|
56
|
-
expect(email(email_ref).body).not_to match(/#{text}/), "Unexpectedly found \"#{text}\" in #{email_ref}"
|
57
|
-
end
|
58
|
-
|
59
|
-
Then(/^#{capture_email} should link to (.+)$/) do |email_ref, page|
|
60
|
-
expect(email(email_ref).body).to match(/#{path_to(page)}/), "Failed to find link to #{page} in #{email_ref}"
|
61
|
-
end
|
62
|
-
|
63
|
-
Then(/^show me the emails?$/) do
|
64
|
-
save_and_open_emails
|
65
|
-
end
|
@@ -1,105 +0,0 @@
|
|
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
|
-
create_models(count, 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
|
-
create_models_from_table(plural_factory, table)
|
16
|
-
end
|
17
|
-
|
18
|
-
# find a model
|
19
|
-
Then(/^#{capture_model} should exist(?: with #{capture_fields})?$/) do |name, fields|
|
20
|
-
find_model!(name, fields)
|
21
|
-
end
|
22
|
-
|
23
|
-
# not find a model
|
24
|
-
Then(/^#{capture_model} should not exist(?: with #{capture_fields})?$/) do |name, fields|
|
25
|
-
expect(find_model(name, fields)).to be_nil
|
26
|
-
end
|
27
|
-
|
28
|
-
# find models with a table
|
29
|
-
Then(/^the following #{capture_plural_factory} should exist:?$/) do |plural_factory, table|
|
30
|
-
expect(find_models_from_table(plural_factory, table)).not_to be_any(&:nil?)
|
31
|
-
end
|
32
|
-
|
33
|
-
# not find models with a table
|
34
|
-
Then(/^the following #{capture_plural_factory} should not exists?:?$/) do |plural_factory, table|
|
35
|
-
find_models_from_table(plural_factory, table).should be_all(&:nil?)
|
36
|
-
end
|
37
|
-
|
38
|
-
# find exactly n models
|
39
|
-
Then(/^(\d+) #{capture_plural_factory} should exist(?: with #{capture_fields})?$/) do |count, plural_factory, fields|
|
40
|
-
expect(find_models(plural_factory.singularize, fields).size).to eq(count.to_i)
|
41
|
-
end
|
42
|
-
|
43
|
-
# assert equality of models
|
44
|
-
Then(/^#{capture_model} should be #{capture_model}$/) do |a, b|
|
45
|
-
expect(model!(a)).to eq(model!(b))
|
46
|
-
end
|
47
|
-
|
48
|
-
# assert model is in another model's has_many assoc
|
49
|
-
Then(/^#{capture_model} should be (?:in|one of|amongst) #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
|
50
|
-
expect(model!(owner).send(association)).to include(model!(target))
|
51
|
-
end
|
52
|
-
|
53
|
-
# assert model is not in another model's has_many assoc
|
54
|
-
Then(/^#{capture_model} should not be (?:in|one of|amongst) #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
|
55
|
-
expect(model!(owner).send(association)).not_to include(model!(target))
|
56
|
-
end
|
57
|
-
|
58
|
-
# assert model is another model's has_one/belongs_to assoc
|
59
|
-
Then(/^#{capture_model} should be #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
|
60
|
-
expect(model!(owner).send(association)).to eq(model!(target))
|
61
|
-
end
|
62
|
-
|
63
|
-
# assert model is not another model's has_one/belongs_to assoc
|
64
|
-
Then(/^#{capture_model} should not be #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
|
65
|
-
expect(model!(owner).send(association)).not_to eq(model!(target))
|
66
|
-
end
|
67
|
-
|
68
|
-
# assert model.predicate?
|
69
|
-
Then(/^#{capture_model} should (?:be|have) (?:an? )?#{capture_predicate}$/) do |name, predicate|
|
70
|
-
if model!(name).respond_to?("has_#{predicate.gsub(' ', '_')}")
|
71
|
-
expect(model!(name)).to send("have_#{predicate.gsub(' ', '_')}")
|
72
|
-
else
|
73
|
-
expect(model!(name)).to send("be_#{predicate.gsub(' ', '_')}")
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
# assert not model.predicate?
|
78
|
-
Then(/^#{capture_model} should not (?:be|have) (?:an? )?#{capture_predicate}$/) do |name, predicate|
|
79
|
-
if model!(name).respond_to?("has_#{predicate.gsub(' ', '_')}")
|
80
|
-
expect(model!(name)).not_to send("have_#{predicate.gsub(' ', '_')}")
|
81
|
-
else
|
82
|
-
expect(model!(name)).not_to send("be_#{predicate.gsub(' ', '_')}")
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
# expect(model.attribute).to eq(value)
|
87
|
-
# expect(model.attribute).not_to eq(value)
|
88
|
-
Then(/^#{capture_model}'s (\w+) (should(?: not)?) be #{capture_value}$/) do |name, attribute, expectation, expected|
|
89
|
-
actual_value = model(name).send(attribute)
|
90
|
-
expectation = expectation.gsub("should", "to").gsub(" ", "_")
|
91
|
-
|
92
|
-
case expected
|
93
|
-
when 'nil', 'true', 'false'
|
94
|
-
expect(actual_value).send(expectation, eq(eval(expected)))
|
95
|
-
when /^[+-]?[0-9_]+(\.\d+)?$/
|
96
|
-
expect(actual_value).send(expectation, eq(expected.to_f))
|
97
|
-
else
|
98
|
-
expect(actual_value.to_s).send(expectation, eq(eval(expected)))
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
# assert size of association
|
103
|
-
Then /^#{capture_model} should have (\d+) (\w+)$/ do |name, size, association|
|
104
|
-
expect(model!(name).send(association).size).to eq(size.to_i)
|
105
|
-
end
|
data/features/support/email.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
module EmailHelpers
|
2
|
-
# Maps a name to an email address. Used by email_steps
|
3
|
-
|
4
|
-
def email_for(to)
|
5
|
-
case to
|
6
|
-
|
7
|
-
# add your own name => email address mappings here
|
8
|
-
|
9
|
-
when /^#{capture_model}$/
|
10
|
-
model($1).email
|
11
|
-
|
12
|
-
when /^"(.*)"$/
|
13
|
-
$1
|
14
|
-
|
15
|
-
else
|
16
|
-
to
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
World(EmailHelpers)
|