pickle-dupe 0.1.0
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.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +97 -0
- data/VERSION +1 -0
- data/features/app/active_resources.rb +8 -0
- data/features/app/dupe_definitions.rb +43 -0
- data/features/pickle/create_from_dupe.feature +49 -0
- data/features/step_definitions/path_steps.rb +14 -0
- data/features/step_definitions/pickle_steps.rb +73 -0
- data/features/step_definitions/recipe_steps.rb +4 -0
- data/features/support/email.rb +21 -0
- data/features/support/env.rb +56 -0
- data/features/support/paths.rb +46 -0
- data/features/support/pickle.rb +26 -0
- data/features/support/pickle_dupe_app.rb +7 -0
- data/lib/pickle_dupe/adapter.rb +29 -0
- data/lib/pickle_dupe/session.rb +17 -0
- data/lib/pickle_dupe.rb +3 -0
- data/spec/pickle_dupe_spec.rb +7 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +9 -0
- metadata +88 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 iawgens
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
= pickle-dupe
|
2
|
+
|
3
|
+
Pickle-dupe is an add-on to pickle that works with Dupe, an Active Resource mocking/factory.
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
13
|
+
* Send me a pull request. Bonus points for topic branches.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2010 iawgens. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "pickle-dupe"
|
8
|
+
gem.summary = %Q{Pickle that works with Dupe, an Active Resource mocking/factory}
|
9
|
+
gem.description = %Q{Dupe is Active Resource mocking/factory for use with cucumber. Pickle-dupe is a pickle add-on that works with Dupe}
|
10
|
+
gem.email = "gary.s.cheong@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/iawgens/pickle-dupe"
|
12
|
+
gem.authors = ["iawgens"]
|
13
|
+
gem.add_dependency "pickle",">=0.2.1"
|
14
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
+
end
|
16
|
+
Jeweler::GemcutterTasks.new
|
17
|
+
rescue LoadError
|
18
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'rake/testtask'
|
22
|
+
Rake::TestTask.new(:test) do |test|
|
23
|
+
test.libs << 'lib' << 'test'
|
24
|
+
test.pattern = 'test/**/test_*.rb'
|
25
|
+
test.verbose = true
|
26
|
+
end
|
27
|
+
|
28
|
+
begin
|
29
|
+
require 'rcov/rcovtask'
|
30
|
+
Rcov::RcovTask.new do |test|
|
31
|
+
test.libs << 'test'
|
32
|
+
test.pattern = 'test/**/test_*.rb'
|
33
|
+
test.verbose = true
|
34
|
+
end
|
35
|
+
rescue LoadError
|
36
|
+
task :rcov do
|
37
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
task :test => :check_dependencies
|
42
|
+
|
43
|
+
task :default => :test
|
44
|
+
|
45
|
+
require 'rake/rdoctask'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "pickle-dupe #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
54
|
+
|
55
|
+
## cucumber rake tasks
|
56
|
+
unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
|
57
|
+
|
58
|
+
# vendored_cucumber_bin = Dir["#{RAILS_ROOT}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
|
59
|
+
# $LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
|
60
|
+
vendored_cucumber_bin = nil
|
61
|
+
|
62
|
+
begin
|
63
|
+
require 'cucumber/rake/task'
|
64
|
+
|
65
|
+
namespace :cucumber do
|
66
|
+
Cucumber::Rake::Task.new(:ok, 'Run features that should pass') do |t|
|
67
|
+
t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
|
68
|
+
t.fork = true # You may get faster startup if you set this to false
|
69
|
+
t.profile = 'default'
|
70
|
+
end
|
71
|
+
|
72
|
+
Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t|
|
73
|
+
t.binary = vendored_cucumber_bin
|
74
|
+
t.fork = true # You may get faster startup if you set this to false
|
75
|
+
t.profile = 'wip'
|
76
|
+
end
|
77
|
+
|
78
|
+
desc 'Run all features'
|
79
|
+
task :all => [:ok, :wip]
|
80
|
+
end
|
81
|
+
desc 'Alias for cucumber:ok'
|
82
|
+
task :cucumber => 'cucumber:ok'
|
83
|
+
|
84
|
+
task :default => :cucumber
|
85
|
+
|
86
|
+
task :features => :cucumber do
|
87
|
+
STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
|
88
|
+
end
|
89
|
+
rescue LoadError
|
90
|
+
desc 'cucumber rake task not available (cucumber not installed)'
|
91
|
+
task :cucumber do
|
92
|
+
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# Dupe definitions
|
2
|
+
require 'dupe'
|
3
|
+
|
4
|
+
Dupe.debug = true
|
5
|
+
Dupe.sequence :recipe_title do |n|
|
6
|
+
"Recipe #{n} Title"
|
7
|
+
end
|
8
|
+
|
9
|
+
Dupe.define :recipe do |recipe|
|
10
|
+
recipe.title do
|
11
|
+
Dupe.next :recipe_title
|
12
|
+
end
|
13
|
+
|
14
|
+
# recipe.ingredients do |ingredients|
|
15
|
+
# ingredients.split(', ').map do |ingredient|
|
16
|
+
# Dupe.find(:ingredient) do |i|
|
17
|
+
# i.label == labelize(ingredient)
|
18
|
+
# end
|
19
|
+
# end
|
20
|
+
# end
|
21
|
+
|
22
|
+
recipe.after_create do |r|
|
23
|
+
r.label = labelize(r.title)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
# Not Applicable in Dupe
|
29
|
+
# Dupe.define :fancy_recipe, :class => Recipe do |t|
|
30
|
+
# t.name {"Fancy " + Dupe.next(:reipe_title)}
|
31
|
+
# end
|
32
|
+
|
33
|
+
Dupe.define :ingredient do |ingredient|
|
34
|
+
ingredient.uniquify :name
|
35
|
+
|
36
|
+
ingredient.after_create do |i|
|
37
|
+
i.label = labelize(i.name)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def labelize(name)
|
42
|
+
name.gsub(/\s/,'-').downcase
|
43
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
Feature: I can easily create models from dupe
|
2
|
+
As a pickle user
|
3
|
+
I want to be able to leverage my factories
|
4
|
+
So that I can create models quickly and easily in my features
|
5
|
+
|
6
|
+
Scenario: I create a recipe, and see if it looks right
|
7
|
+
Given a recipe exists
|
8
|
+
Then a recipe should exist
|
9
|
+
|
10
|
+
Scenario: I create a recipe with specific name, and see if it looks right
|
11
|
+
Given a recipe exists with name: "Chicken Recipe"
|
12
|
+
Then a recipe should exist with name: "Chicken Recipe"
|
13
|
+
|
14
|
+
Scenario: I create stub recipes, and see if it looks right
|
15
|
+
Given 3 recipes exist
|
16
|
+
Then 3 recipes should exist
|
17
|
+
|
18
|
+
Scenario: I create some recipes, and some ingredients
|
19
|
+
Given a recipe: "one" exists
|
20
|
+
And an ingredient exists with recipe: recipe "one"
|
21
|
+
And another ingredient exists with recipe: recipe "one"
|
22
|
+
And a recipe: "two" exists
|
23
|
+
And an ingredient exists with recipe: recipe "two"
|
24
|
+
|
25
|
+
# TODO: GC 02/05/2010 named factory definition is not yet supported by dupe
|
26
|
+
# And a fancy recipe exists
|
27
|
+
# And an ingredient exists with recipe: the fancy recipe
|
28
|
+
|
29
|
+
Then the first ingredient should be ingredient of the recipe: "one"
|
30
|
+
And the 2nd ingredient should be the ingredient of recipe "one"
|
31
|
+
And the last ingredient should be the recipe of recipe "two"
|
32
|
+
|
33
|
+
Then the first ingredient should be in recipe "one"'s ingredients
|
34
|
+
And the 2nd ingredient should be in recipe: "one"'s ingredients
|
35
|
+
And the last ingredient should be in recipe "two"'s ingredients
|
36
|
+
And recipe "two" should be the last ingredient's recipe
|
37
|
+
|
38
|
+
But the first ingredient should not be in the fancy recipe's ingredients
|
39
|
+
And the last ingredient should not be in recipe "one"'s ingredients
|
40
|
+
And the fancy recipe should not be the first ingredient's recipe
|
41
|
+
|
42
|
+
Scenario: Create an ingredient and a recipe refs in a table
|
43
|
+
Given 2 recipes exist
|
44
|
+
And the following ingredients exist:
|
45
|
+
| recipe |
|
46
|
+
| the 1st recipe |
|
47
|
+
| the 2nd recipe |
|
48
|
+
Then the 1st ingredient should be in the 1st recipe's ingredients
|
49
|
+
And the 2nd ingredient should be in the 2nd recipe's ingredients
|
@@ -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
|
@@ -0,0 +1,21 @@
|
|
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)
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
|
2
|
+
# It is recommended to regenerate this file in the future when you upgrade to a
|
3
|
+
# newer version of cucumber-rails. Consider adding your own code to a new file
|
4
|
+
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
5
|
+
# files.
|
6
|
+
|
7
|
+
ENV["RAILS_ENV"] ||= "cucumber"
|
8
|
+
|
9
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../../../config/environment')
|
10
|
+
|
11
|
+
require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
|
12
|
+
require 'cucumber/rails/rspec'
|
13
|
+
require 'cucumber/rails/world'
|
14
|
+
require 'cucumber/rails/active_record'
|
15
|
+
require 'cucumber/web/tableish'
|
16
|
+
|
17
|
+
require 'webrat'
|
18
|
+
require 'webrat/core/matchers'
|
19
|
+
#require 'cucumber/webrat/element_locator' # Deprecated in favor of #tableish - remove this line if you don't use #element_at or #table_at
|
20
|
+
|
21
|
+
Webrat.configure do |config|
|
22
|
+
config.mode = :rails
|
23
|
+
config.open_error_files = false # Set to true if you want error pages to pop up in the browser
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
# If you set this to false, any error raised from within your app will bubble
|
28
|
+
# up to your step definition and out to cucumber unless you catch it somewhere
|
29
|
+
# on the way. You can make Rails rescue errors and render error pages on a
|
30
|
+
# per-scenario basis by tagging a scenario or feature with the @allow-rescue tag.
|
31
|
+
#
|
32
|
+
# If you set this to true, Rails will rescue all errors and render error
|
33
|
+
# pages, more or less in the same way your application would behave in the
|
34
|
+
# default production environment. It's not recommended to do this for all
|
35
|
+
# of your scenarios, as this makes it hard to discover errors in your application.
|
36
|
+
ActionController::Base.allow_rescue = false
|
37
|
+
|
38
|
+
# If you set this to true, each scenario will run in a database transaction.
|
39
|
+
# You can still turn off transactions on a per-scenario basis, simply tagging
|
40
|
+
# a feature or scenario with the @no-txn tag. If you are using Capybara,
|
41
|
+
# tagging with @culerity or @javascript will also turn transactions off.
|
42
|
+
#
|
43
|
+
# If you set this to false, transactions will be off for all scenarios,
|
44
|
+
# regardless of whether you use @no-txn or not.
|
45
|
+
#
|
46
|
+
# Beware that turning transactions off will leave data in your database
|
47
|
+
# after each scenario, which can lead to hard-to-debug failures in
|
48
|
+
# subsequent scenarios. If you do this, we recommend you create a Before
|
49
|
+
# block that will explicitly put your database in a known state.
|
50
|
+
Cucumber::Rails::World.use_transactional_fixtures = true
|
51
|
+
|
52
|
+
# How to clean your database when transactions are turned off. See
|
53
|
+
# http://github.com/bmabey/database_cleaner for more info.
|
54
|
+
require 'database_cleaner'
|
55
|
+
DatabaseCleaner.strategy = :truncation
|
56
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module NavigationHelpers
|
2
|
+
# Maps a name to a path. Used by the
|
3
|
+
#
|
4
|
+
# When /^I go to (.+)$/ do |page_name|
|
5
|
+
#
|
6
|
+
# step definition in web_steps.rb
|
7
|
+
#
|
8
|
+
def path_to(page_name)
|
9
|
+
case page_name
|
10
|
+
|
11
|
+
when /the home\s?page/
|
12
|
+
'/'
|
13
|
+
|
14
|
+
# Add more mappings here.
|
15
|
+
# Here is an example that pulls values out of the Regexp:
|
16
|
+
#
|
17
|
+
# when /^(.*)'s profile page$/i
|
18
|
+
# user_profile_path(User.find_by_login($1))
|
19
|
+
|
20
|
+
# added by script/generate pickle path
|
21
|
+
|
22
|
+
when /^#{capture_model}(?:'s)? page$/ # eg. the forum's page
|
23
|
+
path_to_pickle $1
|
24
|
+
|
25
|
+
when /^#{capture_model}(?:'s)? #{capture_model}(?:'s)? page$/ # eg. the forum's post's page
|
26
|
+
path_to_pickle $1, $2
|
27
|
+
|
28
|
+
when /^#{capture_model}(?:'s)? #{capture_model}'s (.+?) page$/ # eg. the forum's post's comments page
|
29
|
+
path_to_pickle $1, $2, :extra => $3 # or the forum's post's edit page
|
30
|
+
|
31
|
+
when /^#{capture_model}(?:'s)? (.+?) page$/ # eg. the forum's posts page
|
32
|
+
path_to_pickle $1, :extra => $2 # or the forum's edit page
|
33
|
+
|
34
|
+
when /^the (.+?) page$/ # translate to named route
|
35
|
+
send "#{$1.downcase.gsub(' ','_')}_path"
|
36
|
+
|
37
|
+
# end added by pickle path
|
38
|
+
|
39
|
+
else
|
40
|
+
raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
|
41
|
+
"Now, go and add a mapping in #{__FILE__}"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
World(NavigationHelpers)
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# this file generated by script/generate pickle [paths] [email]
|
2
|
+
#
|
3
|
+
# Make sure that you are loading your factory of choice in your cucumber environment
|
4
|
+
#
|
5
|
+
# For machinist add: features/support/machinist.rb
|
6
|
+
#
|
7
|
+
# require 'machinist/active_record' # or your chosen adaptor
|
8
|
+
# require File.dirname(__FILE__) + '/../../spec/blueprints' # or wherever your blueprints are
|
9
|
+
# Before { Sham.reset } # to reset Sham's seed between scenarios so each run has same random sequences
|
10
|
+
#
|
11
|
+
# For FactoryGirl add: features/support/factory_girl.rb
|
12
|
+
#
|
13
|
+
# require 'factory_girl'
|
14
|
+
# require File.dirname(__FILE__) + '/../../spec/factories' # or wherever your factories are
|
15
|
+
#
|
16
|
+
# You may also need to add gem dependencies on your factory of choice in <tt>config/environments/cucumber.rb</tt>
|
17
|
+
|
18
|
+
require 'pickle/world'
|
19
|
+
# Example of configuring pickle:
|
20
|
+
#
|
21
|
+
# Pickle.configure do |config|
|
22
|
+
# config.adapters = [:machinist]
|
23
|
+
# config.map 'I', 'myself', 'me', 'my', :to => 'user: "me"'
|
24
|
+
# end
|
25
|
+
require 'pickle/path/world'
|
26
|
+
require 'pickle/email/world'
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Pickle
|
2
|
+
# Abstract Factory adapter class, if you have a factory type setup, you
|
3
|
+
# can easily create an adaptor to make it work with Pickle.
|
4
|
+
#
|
5
|
+
# The factory adaptor must have a #factories class method that returns
|
6
|
+
# its instances, and each instance must respond to:
|
7
|
+
#
|
8
|
+
# #name : identifies the factory by name (default is attr_reader)
|
9
|
+
# #klass : returns the associated model class for this factory (default is attr_reader)
|
10
|
+
# #create(attrs = {}) : returns a newly created object
|
11
|
+
class Adapter
|
12
|
+
|
13
|
+
# dupe adapter
|
14
|
+
class Dupe < Adapter
|
15
|
+
def self.factories
|
16
|
+
(::Dupe.models.values rescue []).map {|model| new(model)}
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize(model)
|
20
|
+
@klass, @name = model.name.to_s.classify.constantize, model.name.to_s
|
21
|
+
end
|
22
|
+
|
23
|
+
def create(attrs = {})
|
24
|
+
::Dupe.create(@name, attrs)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Pickle
|
2
|
+
module Session
|
3
|
+
# return a newly selected model when dupe is used
|
4
|
+
def model_with_dupe(name)
|
5
|
+
model = created_model(name)
|
6
|
+
|
7
|
+
if model.kind_of?(Dupe::Database::Record)
|
8
|
+
Dupe.find(model.__model__.name) {|dupe_model| dupe_model.id == model.id}
|
9
|
+
else
|
10
|
+
model_without_dupe(name)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
alias_method :model_without_dupe, :model
|
15
|
+
alias_method :model, :model_with_dupe
|
16
|
+
end
|
17
|
+
end
|
data/lib/pickle_dupe.rb
ADDED
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pickle-dupe
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- iawgens
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-02-08 00:00:00 -05:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: pickle
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.2.1
|
24
|
+
version:
|
25
|
+
description: Dupe is Active Resource mocking/factory for use with cucumber. Pickle-dupe is a pickle add-on that works with Dupe
|
26
|
+
email: gary.s.cheong@gmail.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- LICENSE
|
33
|
+
- README.rdoc
|
34
|
+
files:
|
35
|
+
- .document
|
36
|
+
- .gitignore
|
37
|
+
- LICENSE
|
38
|
+
- README.rdoc
|
39
|
+
- Rakefile
|
40
|
+
- VERSION
|
41
|
+
- features/app/active_resources.rb
|
42
|
+
- features/app/dupe_definitions.rb
|
43
|
+
- features/pickle/create_from_dupe.feature
|
44
|
+
- features/step_definitions/path_steps.rb
|
45
|
+
- features/step_definitions/pickle_steps.rb
|
46
|
+
- features/step_definitions/recipe_steps.rb
|
47
|
+
- features/support/email.rb
|
48
|
+
- features/support/env.rb
|
49
|
+
- features/support/paths.rb
|
50
|
+
- features/support/pickle.rb
|
51
|
+
- features/support/pickle_dupe_app.rb
|
52
|
+
- lib/pickle_dupe.rb
|
53
|
+
- lib/pickle_dupe/adapter.rb
|
54
|
+
- lib/pickle_dupe/session.rb
|
55
|
+
- spec/pickle_dupe_spec.rb
|
56
|
+
- spec/spec.opts
|
57
|
+
- spec/spec_helper.rb
|
58
|
+
has_rdoc: true
|
59
|
+
homepage: http://github.com/iawgens/pickle-dupe
|
60
|
+
licenses: []
|
61
|
+
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options:
|
64
|
+
- --charset=UTF-8
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: "0"
|
72
|
+
version:
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: "0"
|
78
|
+
version:
|
79
|
+
requirements: []
|
80
|
+
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 1.3.5
|
83
|
+
signing_key:
|
84
|
+
specification_version: 3
|
85
|
+
summary: Pickle that works with Dupe, an Active Resource mocking/factory
|
86
|
+
test_files:
|
87
|
+
- spec/pickle_dupe_spec.rb
|
88
|
+
- spec/spec_helper.rb
|