pickle 0.5.1 → 0.6.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.
- checksums.yaml +5 -5
- data/.gitignore +3 -2
- data/.travis.yml +24 -4
- data/History.txt +55 -34
- data/README.md +15 -26
- data/Rakefile.d/cucumber.rake +13 -4
- data/Rakefile.d/repoclean.rake +3 -0
- data/features/app/app.rb +7 -7
- data/features/app/factories.rb +5 -5
- data/features/email/email.feature +1 -0
- data/features/step_definitions/email_steps.rb +1 -0
- data/features/step_definitions/extra_email_steps.rb +5 -5
- data/features/step_definitions/pickle_steps.rb +1 -0
- data/features/support/email.rb +1 -0
- data/features/support/env.rb +9 -3
- data/features/support/pickle.rb +2 -2
- data/gemfiles/Gemfile-rails.5.0.x +12 -0
- data/gemfiles/Gemfile-rails.5.1.x +10 -0
- data/gemfiles/Gemfile-rails.5.2.x +11 -0
- data/gemfiles/Gemfile-rails.5.2.x-cukes-4 +11 -0
- data/gemfiles/Gemfile-rails.5.2.x-cukes-5 +12 -0
- data/gemfiles/Gemfile-rails.6.0.x +10 -0
- data/gemfiles/Gemfile-rails.6.0.x-cukes-5 +11 -0
- data/gemfiles/Gemfile-rails.edge +9 -0
- data/lib/pickle.rb +0 -1
- data/lib/pickle/adapter.rb +9 -11
- data/lib/pickle/config.rb +1 -1
- data/lib/pickle/path.rb +1 -1
- data/lib/pickle/session.rb +15 -18
- data/lib/pickle/session/parser.rb +11 -9
- data/lib/pickle/version.rb +1 -1
- data/pickle.gemspec +9 -8
- data/rails_generators/pickle/templates/pickle.rb +2 -2
- data/spec/pickle/adapter_spec.rb +19 -19
- data/spec/pickle/config_spec.rb +9 -9
- data/spec/pickle/email_spec.rb +1 -1
- data/spec/pickle/path_spec.rb +37 -18
- data/spec/pickle/session_spec.rb +5 -5
- data/spec/spec_helper.rb +6 -1
- metadata +52 -56
- data/Gemfile +0 -3
- data/Gemfile.lock.development +0 -158
- 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
- data/init.rb +0 -0
data/features/app/factories.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# Factories
|
2
|
-
require '
|
2
|
+
require 'factory_bot'
|
3
3
|
|
4
|
-
|
4
|
+
FactoryBot.define do
|
5
5
|
sequence :fork_name do |n|
|
6
6
|
"fork %d04" % n
|
7
7
|
end
|
8
8
|
|
9
9
|
factory :fork do |f|
|
10
|
-
f.name {
|
10
|
+
f.name { FactoryBot.generate(:fork_name) }
|
11
11
|
end
|
12
12
|
|
13
13
|
factory :tine do |t|
|
@@ -16,10 +16,10 @@ FactoryGirl.define do
|
|
16
16
|
|
17
17
|
factory :rusty_tine, :class => Tine do |t|
|
18
18
|
t.association :fork
|
19
|
-
t.rusty true
|
19
|
+
t.rusty { true }
|
20
20
|
end
|
21
21
|
|
22
22
|
factory :fancy_fork, :class => Fork do |t|
|
23
|
-
t.name { "Fancy " +
|
23
|
+
t.name { "Fancy " + FactoryBot.generate(:fork_name) }
|
24
24
|
end
|
25
25
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
../../rails_generators/pickle/templates/email_steps.rb
|
@@ -1,12 +1,12 @@
|
|
1
1
|
Given(/^an email "(.*?)" with body: "(.*?)" is delivered to (.+?)$/) do |subject, body, to|
|
2
|
-
Notifier.email(to, subject, body).
|
2
|
+
Notifier.email(to, subject, body).deliver_now
|
3
3
|
end
|
4
4
|
|
5
5
|
Given(/^an email with a link "(.+?)" to (.+?) is delivered to (.+?)$/) do |text, page, to|
|
6
|
-
body = "some text <a href='http://example.com/#{path_to(page)}'>#{text}</a> more text"
|
7
|
-
Notifier.email(to, "example", body).
|
6
|
+
body = "some text <a href='http://example.com/#{path_to(page)}'>#{text}</a> more text"
|
7
|
+
Notifier.email(to, "example", body).deliver_now
|
8
8
|
end
|
9
9
|
|
10
10
|
Given(/^#{capture_model}'s email is delivered$/) do |model|
|
11
|
-
Notifier.user_email(model!(model)).
|
12
|
-
end
|
11
|
+
Notifier.user_email(model!(model)).deliver_now
|
12
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
../../rails_generators/pickle/templates/pickle_steps.rb
|
@@ -0,0 +1 @@
|
|
1
|
+
../../rails_generators/pickle/templates/email.rb
|
data/features/support/env.rb
CHANGED
@@ -1,14 +1,20 @@
|
|
1
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
|
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
4
|
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
5
5
|
# files.
|
6
6
|
|
7
7
|
ENV["RAILS_ENV"] ||= "test"
|
8
8
|
ENV["RAILS_ROOT"] ||= File.expand_path(File.dirname(__FILE__) + '/../../cucumber_test_app')
|
9
9
|
|
10
|
+
Bundler.setup
|
11
|
+
|
12
|
+
require 'simplecov'
|
13
|
+
require 'codecov'
|
14
|
+
SimpleCov.formatter = SimpleCov::Formatter::Codecov
|
15
|
+
|
10
16
|
require 'capybara'
|
11
17
|
require 'cucumber/rails'
|
12
18
|
Capybara.default_selector = :css
|
13
19
|
ActionController::Base.allow_rescue = false
|
14
|
-
DatabaseCleaner.strategy = :truncation
|
20
|
+
DatabaseCleaner.strategy = :truncation
|
data/features/support/pickle.rb
CHANGED
@@ -7,9 +7,9 @@
|
|
7
7
|
# require 'machinist/active_record' # or your chosen adaptor
|
8
8
|
# require File.dirname(__FILE__) + '/../../spec/blueprints' # or wherever your blueprints are
|
9
9
|
#
|
10
|
-
# For
|
10
|
+
# For FactoryBot add: features/support/factory_bot.rb
|
11
11
|
#
|
12
|
-
# require '
|
12
|
+
# require 'factory_bot'
|
13
13
|
# require File.dirname(__FILE__) + '/../../spec/factories' # or wherever your factories are
|
14
14
|
#
|
15
15
|
# For Fabrication, just include it in the adapter list when configuring pickle as explained below.
|
@@ -0,0 +1,12 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# Bundler 1.x default to insecure http:// for github: shortcut
|
4
|
+
git_source(:github){ |repo_name| "https://github.com/#{repo_name}.git" }
|
5
|
+
|
6
|
+
gemspec :path => ".."
|
7
|
+
|
8
|
+
gem "rails", "~> 5.0.2"
|
9
|
+
gem "cucumber", "~> 3.2.0"
|
10
|
+
gem "sqlite3", "~> 1.3.6"
|
11
|
+
|
12
|
+
gem 'fabrication', github: 'mathieujobin/fabrication', ref: '923cf6fcefd0566b1d6be7bd2f685b89388f4800'
|
@@ -0,0 +1,10 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# Bundler 1.x default to insecure http:// for github: shortcut
|
4
|
+
git_source(:github){ |repo_name| "https://github.com/#{repo_name}.git" }
|
5
|
+
|
6
|
+
gemspec :path => ".."
|
7
|
+
|
8
|
+
gem "rails", "~> 5.1.0"
|
9
|
+
gem "cucumber", "~> 3.2"
|
10
|
+
gem 'fabrication', github: 'mathieujobin/fabrication', ref: '923cf6fcefd0566b1d6be7bd2f685b89388f4800'
|
@@ -0,0 +1,11 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# Bundler 1.x default to insecure http:// for github: shortcut
|
4
|
+
git_source(:github){ |repo_name| "https://github.com/#{repo_name}.git" }
|
5
|
+
|
6
|
+
gemspec :path => ".."
|
7
|
+
|
8
|
+
gem "rails", "~> 5.2.0"
|
9
|
+
gem "cucumber", "~> 3.2.0"
|
10
|
+
|
11
|
+
gem 'fabrication', github: 'mathieujobin/fabrication', ref: '923cf6fcefd0566b1d6be7bd2f685b89388f4800'
|
@@ -0,0 +1,11 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# Bundler 1.x default to insecure http:// for github: shortcut
|
4
|
+
git_source(:github){ |repo_name| "https://github.com/#{repo_name}.git" }
|
5
|
+
|
6
|
+
gemspec :path => ".."
|
7
|
+
|
8
|
+
gem "rails", "~> 5.2.0"
|
9
|
+
gem "cucumber", "~> 4.0"
|
10
|
+
|
11
|
+
gem 'fabrication', github: 'mathieujobin/fabrication', ref: '923cf6fcefd0566b1d6be7bd2f685b89388f4800'
|
@@ -0,0 +1,12 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# Bundler 1.x default to insecure http:// for github: shortcut
|
4
|
+
git_source(:github){ |repo_name| "https://github.com/#{repo_name}.git" }
|
5
|
+
|
6
|
+
gemspec :path => ".."
|
7
|
+
|
8
|
+
gem "rails", "~> 5.2.0"
|
9
|
+
gem "cucumber", "~> 5.0"
|
10
|
+
gem "cucumber-rails", github: 'cucumber/cucumber-rails', branch: 'cucumber5'
|
11
|
+
|
12
|
+
gem 'fabrication', github: 'mathieujobin/fabrication', ref: '923cf6fcefd0566b1d6be7bd2f685b89388f4800'
|
@@ -0,0 +1,10 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# Bundler 1.x default to insecure http:// for github: shortcut
|
4
|
+
git_source(:github){ |repo_name| "https://github.com/#{repo_name}.git" }
|
5
|
+
|
6
|
+
gemspec :path => ".."
|
7
|
+
|
8
|
+
gem "activerecord", "~> 6.0.0"
|
9
|
+
gem "cucumber", "~> 4.1"
|
10
|
+
gem 'fabrication', github: 'mathieujobin/fabrication', ref: '923cf6fcefd0566b1d6be7bd2f685b89388f4800'
|
@@ -0,0 +1,11 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# Bundler 1.x default to insecure http:// for github: shortcut
|
4
|
+
git_source(:github){ |repo_name| "https://github.com/#{repo_name}.git" }
|
5
|
+
|
6
|
+
gemspec :path => ".."
|
7
|
+
|
8
|
+
gem "rails", "~> 6.0.0"
|
9
|
+
gem "cucumber", "~> 5.0"
|
10
|
+
gem "cucumber-rails", github: 'cucumber/cucumber-rails', branch: 'cucumber5'
|
11
|
+
gem 'fabrication', github: 'mathieujobin/fabrication', ref: '923cf6fcefd0566b1d6be7bd2f685b89388f4800'
|
@@ -0,0 +1,9 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# Bundler 1.x default to insecure http:// for github: shortcut
|
4
|
+
git_source(:github){ |repo_name| "https://github.com/#{repo_name}.git" }
|
5
|
+
|
6
|
+
gemspec :path => ".."
|
7
|
+
|
8
|
+
gem "rails", :github => "rails/rails"
|
9
|
+
gem 'fabrication', github: 'mathieujobin/fabrication', ref: '923cf6fcefd0566b1d6be7bd2f685b89388f4800'
|
data/lib/pickle.rb
CHANGED
data/lib/pickle/adapter.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'active_support/core_ext'
|
2
|
-
|
3
1
|
module Pickle
|
4
2
|
# Abstract Factory adapter class, if you have a factory type setup, you
|
5
3
|
# can easily create an adaptor to make it work with Pickle.
|
@@ -100,11 +98,11 @@ module Pickle
|
|
100
98
|
end
|
101
99
|
|
102
100
|
# factory-girl adapter
|
103
|
-
class
|
101
|
+
class FactoryBot < Adapter
|
104
102
|
def self.factories
|
105
|
-
if defined? ::
|
103
|
+
if defined? ::FactoryBot
|
106
104
|
factories = []
|
107
|
-
::
|
105
|
+
::FactoryBot.factories.each do |factory|
|
108
106
|
factory.names.each do |name|
|
109
107
|
factories << new(factory, name)
|
110
108
|
end
|
@@ -116,7 +114,7 @@ module Pickle
|
|
116
114
|
end
|
117
115
|
|
118
116
|
def initialize(factory, factory_name)
|
119
|
-
if defined? ::
|
117
|
+
if defined? ::FactoryBot
|
120
118
|
@klass, @name = factory.build_class, factory_name.to_s
|
121
119
|
else
|
122
120
|
@klass, @name = factory.build_class, factory.factory_name.to_s
|
@@ -124,16 +122,16 @@ module Pickle
|
|
124
122
|
end
|
125
123
|
|
126
124
|
def create(attrs = {})
|
127
|
-
if defined? ::
|
128
|
-
::
|
125
|
+
if defined? ::FactoryBot
|
126
|
+
::FactoryBot.create(@name, attrs)
|
129
127
|
else
|
130
128
|
Factory(@name, attrs)
|
131
129
|
end
|
132
130
|
end
|
133
131
|
|
134
132
|
def build(attrs = {})
|
135
|
-
if defined? ::
|
136
|
-
::
|
133
|
+
if defined? ::FactoryBot
|
134
|
+
::FactoryBot.build(@name, attrs)
|
137
135
|
else
|
138
136
|
Factory.build(@name, attrs)
|
139
137
|
end
|
@@ -153,7 +151,7 @@ module Pickle
|
|
153
151
|
|
154
152
|
def initialize(factory)
|
155
153
|
if defined? ::Fabrication
|
156
|
-
@klass, @name = factory[1].klass, factory[0].to_s
|
154
|
+
@klass, @name = factory[1].send(:klass), factory[0].to_s
|
157
155
|
end
|
158
156
|
end
|
159
157
|
|
data/lib/pickle/config.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/session.rb
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
module Pickle
|
2
2
|
module Session
|
3
|
+
module PickleParserMethods
|
4
|
+
def method_missing(method, *args, &block)
|
5
|
+
if pickle_parser.respond_to?(method)
|
6
|
+
pickle_parser.send(method, *args, &block)
|
7
|
+
else
|
8
|
+
super(method, *args, &block)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def respond_to?(method, include_private = false)
|
13
|
+
super(method, include_private) || pickle_parser.respond_to?(method, include_private)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
3
17
|
class ModelNotKnownError < RuntimeError
|
4
18
|
attr_reader :name
|
5
19
|
|
@@ -27,12 +41,7 @@ module Pickle
|
|
27
41
|
|
28
42
|
protected
|
29
43
|
def proxy_to_pickle_parser(world_class)
|
30
|
-
world_class.
|
31
|
-
unless methods.include?('method_missing_with_pickle_parser')
|
32
|
-
alias_method_chain :method_missing, :pickle_parser
|
33
|
-
alias_method_chain :respond_to?, :pickle_parser
|
34
|
-
end
|
35
|
-
end
|
44
|
+
world_class.send(:prepend, PickleParserMethods)
|
36
45
|
end
|
37
46
|
end
|
38
47
|
|
@@ -153,10 +162,6 @@ module Pickle
|
|
153
162
|
end
|
154
163
|
end
|
155
164
|
|
156
|
-
def respond_to_with_pickle_parser?(method, include_private = false)
|
157
|
-
respond_to_without_pickle_parser?(method, include_private) || pickle_parser.respond_to?(method, include_private)
|
158
|
-
end
|
159
|
-
|
160
165
|
protected
|
161
166
|
def create_or_build_model(method, count, pickle_ref, fields = nil)
|
162
167
|
factory, label = *parse_model(pickle_ref)
|
@@ -171,14 +176,6 @@ module Pickle
|
|
171
176
|
end
|
172
177
|
end
|
173
178
|
|
174
|
-
def method_missing_with_pickle_parser(method, *args, &block)
|
175
|
-
if pickle_parser.respond_to?(method)
|
176
|
-
pickle_parser.send(method, *args, &block)
|
177
|
-
else
|
178
|
-
method_missing_without_pickle_parser(method, *args, &block)
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
179
|
def pickle_parser=(parser)
|
183
180
|
parser.session = self
|
184
181
|
@pickle_parser = parser
|
@@ -2,8 +2,18 @@ module Pickle
|
|
2
2
|
module Session
|
3
3
|
# add ability to parse model names as fields, using a session
|
4
4
|
module Parser
|
5
|
+
module ParseFieldWithModel
|
6
|
+
def parse_field(field)
|
7
|
+
if session && field =~ /^(\w+): #{capture_model}$/
|
8
|
+
{$1 => session.model!($2)}
|
9
|
+
else
|
10
|
+
super(field)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
5
15
|
def self.included(parser_class)
|
6
|
-
parser_class.
|
16
|
+
parser_class.send(:prepend, ParseFieldWithModel)
|
7
17
|
end
|
8
18
|
|
9
19
|
attr_accessor :session
|
@@ -12,14 +22,6 @@ module Pickle
|
|
12
22
|
"(?:\\w+: (?:#{match_model}|#{match_value}))"
|
13
23
|
end
|
14
24
|
|
15
|
-
def parse_field_with_model(field)
|
16
|
-
if session && field =~ /^(\w+): #{capture_model}$/
|
17
|
-
{$1 => session.model!($2)}
|
18
|
-
else
|
19
|
-
parse_field_without_model(field)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
25
|
def parse_hash(hash)
|
24
26
|
hash.inject({}) do |parsed, (key, val)|
|
25
27
|
if session && val =~ /^#{capture_model}$/
|
data/lib/pickle/version.rb
CHANGED
data/pickle.gemspec
CHANGED
@@ -6,10 +6,10 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.version = Pickle::VERSION.dup
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.licenses = ["MIT"]
|
9
|
-
s.authors = ["Ian White", "James Le Cuirot"]
|
9
|
+
s.authors = ["Ian White", "James Le Cuirot", "Mathieu Jobin"]
|
10
10
|
s.description = "Easy model creation and reference in your cucumber features"
|
11
11
|
s.summary = "Easy model creation and reference in your cucumber features."
|
12
|
-
s.email = ["ian.w.white@gmail.com", "chewi@aura-online.co.uk"]
|
12
|
+
s.email = ["ian.w.white@gmail.com", "chewi@aura-online.co.uk", "mathieu.jobin@gmail.com"]
|
13
13
|
s.homepage = "https://github.com/ianwhite/pickle"
|
14
14
|
|
15
15
|
s.rubyforge_project = "pickle"
|
@@ -18,21 +18,22 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.files = `git ls-files`.split("\n")
|
19
19
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
20
|
s.require_paths = ["lib"]
|
21
|
-
|
22
|
-
s.add_dependency "cucumber", ">=0.
|
21
|
+
|
22
|
+
s.add_dependency "cucumber", ">=3.0", "< 6.0"
|
23
23
|
s.add_dependency "rake"
|
24
|
-
|
24
|
+
|
25
25
|
s.add_development_dependency "rack"
|
26
26
|
s.add_development_dependency "bundler"
|
27
27
|
s.add_development_dependency "git"
|
28
28
|
s.add_development_dependency "yard"
|
29
29
|
s.add_development_dependency "rspec-rails", "~>3.0"
|
30
|
-
s.add_development_dependency "rails", "
|
30
|
+
s.add_development_dependency "rails", ">= 4.2.0", "< 7.0"
|
31
31
|
s.add_development_dependency "cucumber-rails"
|
32
|
-
s.add_development_dependency "
|
32
|
+
s.add_development_dependency "factory_bot"
|
33
33
|
s.add_development_dependency "fabrication", '~> 2.0'
|
34
|
-
s.add_development_dependency "machinist", "~>2.0"
|
34
|
+
s.add_development_dependency "machinist" # , "~>2.0"
|
35
35
|
s.add_development_dependency "database_cleaner"
|
36
36
|
s.add_development_dependency "capybara"
|
37
37
|
s.add_development_dependency "sqlite3"
|
38
|
+
s.add_development_dependency "codecov"
|
38
39
|
end
|
@@ -7,9 +7,9 @@
|
|
7
7
|
# require 'machinist/active_record' # or your chosen adaptor
|
8
8
|
# require File.dirname(__FILE__) + '/../../spec/blueprints' # or wherever your blueprints are
|
9
9
|
#
|
10
|
-
# For
|
10
|
+
# For FactoryBot add: features/support/factory_bot.rb
|
11
11
|
#
|
12
|
-
# require '
|
12
|
+
# require 'factory_bot'
|
13
13
|
# require File.dirname(__FILE__) + '/../../spec/factories' # or wherever your factories are
|
14
14
|
#
|
15
15
|
# For Fabrication, just include it in the adapter list when configuring pickle as explained below.
|
data/spec/pickle/adapter_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
require 'active_record'
|
4
|
-
require '
|
4
|
+
require 'factory_bot'
|
5
5
|
require 'fabrication'
|
6
6
|
require 'machinist/active_record'
|
7
7
|
require 'pickle/adapters/active_record'
|
@@ -58,17 +58,17 @@ describe Pickle::Adapter do
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
describe '
|
61
|
+
describe 'FactoryBot' do
|
62
62
|
before do
|
63
|
-
allow(Pickle::Adapter::
|
64
|
-
|
65
|
-
if defined? ::
|
66
|
-
@orig_factories = ::
|
67
|
-
::
|
68
|
-
::
|
69
|
-
::
|
70
|
-
@factory1 = ::
|
71
|
-
@factory2 = ::
|
63
|
+
allow(Pickle::Adapter::FactoryBot).to receive(:model_classes).and_return([One, One::Two, Three])
|
64
|
+
|
65
|
+
if defined? ::FactoryBot
|
66
|
+
@orig_factories = ::FactoryBot.factories.dup
|
67
|
+
::FactoryBot.factories.clear
|
68
|
+
::FactoryBot::Syntax::Default::DSL.new.factory(:one, :class => One) {}
|
69
|
+
::FactoryBot::Syntax::Default::DSL.new.factory(:two, :class => One::Two) {}
|
70
|
+
@factory1 = ::FactoryBot.factories[:one]
|
71
|
+
@factory2 = ::FactoryBot.factories[:two]
|
72
72
|
else
|
73
73
|
@orig_factories, Factory.factories = Factory.factories, {}
|
74
74
|
Factory.define(:one, :class => One) {}
|
@@ -79,23 +79,23 @@ describe Pickle::Adapter do
|
|
79
79
|
end
|
80
80
|
|
81
81
|
after do
|
82
|
-
if defined? ::
|
83
|
-
::
|
84
|
-
@orig_factories.each {|f| ::
|
82
|
+
if defined? ::FactoryBot
|
83
|
+
::FactoryBot.factories.clear
|
84
|
+
@orig_factories.each {|f| ::FactoryBot.factories.add(f) }
|
85
85
|
else
|
86
86
|
Factory.factories = @orig_factories
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
90
|
it ".factories should create one for each factory" do
|
91
|
-
expect(Pickle::Adapter::
|
92
|
-
expect(Pickle::Adapter::
|
93
|
-
Pickle::Adapter::
|
91
|
+
expect(Pickle::Adapter::FactoryBot).to receive(:new).with(@factory1, @factory1.name).once
|
92
|
+
expect(Pickle::Adapter::FactoryBot).to receive(:new).with(@factory2, @factory2.name).once
|
93
|
+
Pickle::Adapter::FactoryBot.factories
|
94
94
|
end
|
95
95
|
|
96
96
|
describe ".new(factory, factory_name)" do
|
97
97
|
before do
|
98
|
-
@factory = Pickle::Adapter::
|
98
|
+
@factory = Pickle::Adapter::FactoryBot.new(@factory1, @factory1.name)
|
99
99
|
end
|
100
100
|
|
101
101
|
it "should have name of factory_name" do
|
@@ -106,7 +106,7 @@ describe Pickle::Adapter do
|
|
106
106
|
expect(@factory.klass).to eq(One)
|
107
107
|
end
|
108
108
|
|
109
|
-
unless defined? ::
|
109
|
+
unless defined? ::FactoryBot
|
110
110
|
it "#create(attrs) should call Factory(<:key>, attrs)" do
|
111
111
|
expect(Factory).to receive(:create).with("one", {:key => "val"})
|
112
112
|
@factory.create(:key => "val")
|