pickle 0.5.2 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/build.yml +62 -0
  3. data/.gitignore +3 -2
  4. data/.travis.yml +24 -4
  5. data/History.txt +52 -35
  6. data/README.md +19 -27
  7. data/Rakefile.d/cucumber.rake +13 -4
  8. data/Rakefile.d/repoclean.rake +3 -0
  9. data/features/app/app.rb +7 -7
  10. data/features/app/factories.rb +5 -5
  11. data/features/email/email.feature +1 -0
  12. data/features/step_definitions/email_steps.rb +1 -0
  13. data/features/step_definitions/extra_email_steps.rb +5 -5
  14. data/features/step_definitions/pickle_steps.rb +1 -0
  15. data/features/support/email.rb +1 -0
  16. data/features/support/env.rb +9 -3
  17. data/features/support/pickle.rb +2 -2
  18. data/gemfiles/Gemfile-rails.4.2.x +13 -0
  19. data/gemfiles/Gemfile-rails.5.0.x +12 -0
  20. data/gemfiles/Gemfile-rails.5.1.x +10 -0
  21. data/gemfiles/Gemfile-rails.5.2.x +11 -0
  22. data/gemfiles/Gemfile-rails.5.2.x-cukes-4 +11 -0
  23. data/gemfiles/Gemfile-rails.5.2.x-cukes-5 +11 -0
  24. data/gemfiles/Gemfile-rails.6.0.x-cukes-3 +10 -0
  25. data/gemfiles/Gemfile-rails.6.0.x-cukes-4 +10 -0
  26. data/gemfiles/Gemfile-rails.6.0.x-cukes-5 +11 -0
  27. data/gemfiles/Gemfile-rails.6.0.x-cukes-6 +11 -0
  28. data/gemfiles/Gemfile-rails.6.1.x-cukes-3 +10 -0
  29. data/gemfiles/Gemfile-rails.6.1.x-cukes-4 +10 -0
  30. data/gemfiles/Gemfile-rails.6.1.x-cukes-5 +11 -0
  31. data/gemfiles/Gemfile-rails.6.1.x-cukes-6 +11 -0
  32. data/gemfiles/Gemfile-rails.edge +9 -0
  33. data/lib/pickle.rb +0 -1
  34. data/lib/pickle/adapter.rb +9 -11
  35. data/lib/pickle/config.rb +1 -1
  36. data/lib/pickle/path.rb +1 -1
  37. data/lib/pickle/version.rb +1 -1
  38. data/pickle.gemspec +10 -9
  39. data/rails_generators/pickle/templates/pickle.rb +2 -2
  40. data/spec/pickle/adapter_spec.rb +19 -19
  41. data/spec/pickle/config_spec.rb +9 -9
  42. data/spec/pickle/email_spec.rb +1 -1
  43. data/spec/pickle/path_spec.rb +37 -18
  44. data/spec/pickle/session_spec.rb +5 -5
  45. data/spec/spec_helper.rb +6 -1
  46. metadata +62 -56
  47. data/Gemfile +0 -3
  48. data/Gemfile.lock.development +0 -158
  49. data/features/step_definitions/email_steps.rb +0 -65
  50. data/features/step_definitions/pickle_steps.rb +0 -105
  51. data/features/support/email.rb +0 -21
  52. data/init.rb +0 -0
@@ -2,7 +2,7 @@ require 'cucumber/rake/task'
2
2
 
3
3
  desc "Run features"
4
4
  Cucumber::Rake::Task.new(:cucumber => [:cucumber_test_app]) do |t|
5
- t.cucumber_opts = ['--format', 'pretty', '--require', 'features']
5
+ t.cucumber_opts = %w[--format pretty --require features -t] + ["'not @wip'"]
6
6
  end
7
7
 
8
8
  desc "setup a rails app for running cucumber"
@@ -13,15 +13,24 @@ end
13
13
 
14
14
  namespace :cucumber do
15
15
  task :setup do
16
+ current_gemfile = ENV['BUNDLE_GEMFILE']
17
+ sh "BUNDLE_GEMFILE=#{current_gemfile} bundle show cucumber > /tmp/cukes_version"
18
+ sh "BUNDLE_GEMFILE=#{current_gemfile} bundle show sqlite3 > /tmp/sqlite_version"
19
+ cukes_version=File.read('/tmp/cukes_version').split('-').last.chomp
20
+ sqlite_version=File.read('/tmp/sqlite_version').split('-').last.chomp
21
+ puts "Versions: Cucumber #{cukes_version}, SQLite #{sqlite_version}."
16
22
  Bundler.with_clean_env do
17
23
  gemfile = "cucumber_test_app/Gemfile"
18
24
  rm_rf "cucumber_test_app"
19
- sh "rails new cucumber_test_app --skip-javascript --skip-sprockets"
25
+ sh "BUNDLE_GEMFILE=#{current_gemfile} bundle exec rails new cucumber_test_app --skip-spring --skip-javascript --skip-sprockets --skip-bootsnap"
26
+ sh "echo 'gem \"cucumber\", \"~> #{cukes_version}\", :require => false' >> #{gemfile}"
27
+ sh "sed -i 's/gem .sqlite3./gem \"sqlite3\", \"~> #{sqlite_version}\"/' #{gemfile}"
28
+ sh "cat #{gemfile} | grep sqli"
20
29
  sh "echo 'gem \"cucumber-rails\", :require => false' >> #{gemfile}"
21
30
  sh "echo 'gem \"rspec-rails\", \"~>3.0\"' >> #{gemfile}"
22
- sh "echo 'gem \"capybara\"' >> #{gemfile}"
31
+ sh "echo 'gem \"pickle\", path: \"#{__dir__}/..\"' >> #{gemfile}"
23
32
  sh "bundle install --gemfile=#{gemfile}"
24
- sh "ln -s ../../.. cucumber_test_app/vendor/plugins/pickle"
33
+ sh "(cd cucumber_test_app ; bundle exec rake db:migrate)"
25
34
  end
26
35
  end
27
36
  end
@@ -0,0 +1,3 @@
1
+ task :repoclean do
2
+ system "rm -fr pickle-email-* .bundle/ .yardoc/ cucumber_test_app/ doc/ tmp"
3
+ end
data/features/app/app.rb CHANGED
@@ -90,19 +90,19 @@ end
90
90
  # controllers
91
91
  class DefaultController < ActionController::Base
92
92
  def index
93
- render :text => "index: I was invoked with #{request.path}"
93
+ render :plain => "index: I was invoked with #{request.path}"
94
94
  end
95
-
95
+
96
96
  def show
97
- render :text => "show: I was invoked with #{request.path}"
97
+ render :plain => "show: I was invoked with #{request.path}"
98
98
  end
99
-
99
+
100
100
  def new
101
- render :text => "new: I was invoked with #{request.path}"
101
+ render :plain => "new: I was invoked with #{request.path}"
102
102
  end
103
-
103
+
104
104
  def edit
105
- render :text => "edit: I was invoked with #{request.path}"
105
+ render :plain => "edit: I was invoked with #{request.path}"
106
106
  end
107
107
  end
108
108
 
@@ -1,13 +1,13 @@
1
1
  # Factories
2
- require 'factory_girl'
2
+ require 'factory_bot'
3
3
 
4
- FactoryGirl.define do
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 { FactoryGirl.generate(:fork_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 " + FactoryGirl.generate(:fork_name) }
23
+ t.name { "Fancy " + FactoryBot.generate(:fork_name) }
24
24
  end
25
25
  end
@@ -1,3 +1,4 @@
1
+ @wip
1
2
  Feature: I can test emails are sent
2
3
  In order write features with emails as outcomes
3
4
  As a feature writer
@@ -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).deliver
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).deliver
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)).deliver
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
@@ -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
@@ -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 FactoryGirl add: features/support/factory_girl.rb
10
+ # For FactoryBot add: features/support/factory_bot.rb
11
11
  #
12
- # require 'factory_girl'
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,13 @@
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", "~> 4.2.9"
9
+ gem "cucumber", "~> 3.2.0"
10
+ gem "sqlite3", "~> 1.3.6"
11
+ gem "bundler", "~> 1.17"
12
+
13
+ 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.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,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", "~> 5.0"
10
+ gem "cucumber-rails"
11
+ 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", "~> 3.2"
10
+ 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"
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", "~> 6.0.0"
9
+ gem "cucumber", "~> 6.0"
10
+ gem "cucumber-rails"
11
+ 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.1.0"
9
+ gem "cucumber", "~> 3.2"
10
+ 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.1.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.1.0"
9
+ gem "cucumber", "~> 5.0"
10
+ gem "cucumber-rails"
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", "~> 6.1.0"
9
+ gem "cucumber", "~> 6.0"
10
+ gem "cucumber-rails"
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
@@ -1,4 +1,3 @@
1
- require 'active_support'
2
1
  require 'pickle/version'
3
2
  require 'pickle/adapter'
4
3
  require 'pickle/config'
@@ -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 FactoryGirl < Adapter
101
+ class FactoryBot < Adapter
104
102
  def self.factories
105
- if defined? ::FactoryGirl
103
+ if defined? ::FactoryBot
106
104
  factories = []
107
- ::FactoryGirl.factories.each do |factory|
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? ::FactoryGirl
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? ::FactoryGirl
128
- ::FactoryGirl.create(@name, attrs)
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? ::FactoryGirl
136
- ::FactoryGirl.build(@name, attrs)
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
@@ -11,7 +11,7 @@ module Pickle
11
11
  end
12
12
 
13
13
  def adapters
14
- @adapters ||= [:machinist, :factory_girl, :fabrication, :orm]
14
+ @adapters ||= [:machinist, :factory_bot, :fabrication, :orm]
15
15
  end
16
16
 
17
17
  def adapter_classes
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