to_factory 2.1.0 → 3.0.0.pre.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/test.yml +35 -0
  3. data/.rubocop-disabled.yml +95 -0
  4. data/.rubocop-enabled.yml +1194 -0
  5. data/.rubocop.yml +938 -0
  6. data/CHANGELOG.md +11 -0
  7. data/Gemfile +6 -1
  8. data/README.md +2 -11
  9. data/Rakefile +17 -9
  10. data/lib/to_factory/collation.rb +9 -9
  11. data/lib/to_factory/file_sync.rb +10 -10
  12. data/lib/to_factory/file_writer.rb +1 -1
  13. data/lib/to_factory/finders/factory.rb +1 -1
  14. data/lib/to_factory/finders/model.rb +2 -4
  15. data/lib/to_factory/generation/attribute.rb +6 -10
  16. data/lib/to_factory/generation/factory.rb +3 -3
  17. data/lib/to_factory/klass_inference.rb +4 -6
  18. data/lib/to_factory/options_parser.rb +4 -4
  19. data/lib/to_factory/parsing/file.rb +85 -14
  20. data/lib/to_factory/representation.rb +9 -6
  21. data/lib/to_factory/version.rb +1 -1
  22. data/lib/to_factory.rb +7 -8
  23. data/spec/db/migrate/1_create_users.rb +4 -4
  24. data/spec/db/migrate/2_create_projects.rb +4 -4
  25. data/spec/db/migrate/3_create_not_namespaced.rb +4 -4
  26. data/spec/db/migrate/4_add_birthday_to_users.rb +3 -3
  27. data/spec/db/migrate/5_add_serialized_attributes_to_users.rb +3 -3
  28. data/spec/example_factories/admin.rb +6 -6
  29. data/spec/example_factories/admin_with_header.rb +7 -7
  30. data/spec/example_factories/inherited_project_with_header.rb +7 -0
  31. data/spec/example_factories/project_with_header.rb +4 -4
  32. data/spec/example_factories/user.rb +5 -5
  33. data/spec/example_factories/user_admin.rb +11 -11
  34. data/spec/example_factories/user_admin_root.rb +12 -13
  35. data/spec/example_factories/user_admin_super_admin.rb +6 -6
  36. data/spec/example_factories/user_admin_with_header.rb +12 -12
  37. data/spec/example_factories/user_with_header.rb +6 -6
  38. data/spec/integration/empty_factory_file_spec.rb +2 -2
  39. data/spec/integration/file_sync_spec.rb +16 -17
  40. data/spec/integration/file_writer_spec.rb +13 -9
  41. data/spec/integration/lint_spec.rb +4 -3
  42. data/spec/integration/multiple_to_factory_calls_spec.rb +37 -35
  43. data/spec/integration/non_active_record_classes_spec.rb +40 -0
  44. data/spec/integration/to_factory_method_spec.rb +21 -18
  45. data/spec/spec_helper.rb +8 -8
  46. data/spec/support/data_creation.rb +11 -13
  47. data/spec/support/match_sexp.rb +0 -1
  48. data/spec/support/non_active_record/inherited_project.rb +3 -0
  49. data/spec/support/non_active_record/project.rb +3 -0
  50. data/spec/support/non_active_record/some_other_service_inheriting_from_something_else.rb +4 -0
  51. data/spec/support/non_active_record/some_service.rb +2 -0
  52. data/spec/support/non_active_record/something_else.rb +2 -0
  53. data/spec/support/ruby_parser_exception_causing_string.rb +29 -29
  54. data/spec/unit/collation_spec.rb +9 -10
  55. data/spec/unit/file_writer_spec.rb +4 -8
  56. data/spec/unit/finders/factory_spec.rb +7 -9
  57. data/spec/unit/finders/model_spec.rb +6 -9
  58. data/spec/unit/generation/attribute_spec.rb +11 -12
  59. data/spec/unit/generation/factory_spec.rb +14 -16
  60. data/spec/unit/parsing/file_spec.rb +9 -9
  61. data/spec/unit/parsing/klass_inference_spec.rb +5 -7
  62. data/to_factory.gemspec +14 -10
  63. metadata +89 -31
  64. data/.travis.yml +0 -16
  65. data/lib/to_factory/parsing/syntax.rb +0 -83
data/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ # CHANGELOG
2
+
3
+ ## master
4
+
5
+ ## 3.0.0 (2022-12-31)
6
+
7
+ ### Support FactoryBot
8
+
9
+ * Add support for FactoryBot syntax
10
+ * drop FactoryGirl support
11
+ * drop any references to old or older FactoryGirl syntax
data/Gemfile CHANGED
@@ -1,5 +1,10 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem "codeclimate-test-reporter", :group => :test, :require => nil
3
+ group :test do
4
+ gem 'simplecov', require: false
5
+ gem 'rspec-github', require: false
6
+ gem 'byebug'
7
+ gem 'pry'
8
+ end
4
9
 
5
10
  gemspec
data/README.md CHANGED
@@ -17,7 +17,7 @@ If you find yourself retro-fitting tests this gem will save you some of the legw
17
17
  * adhoc generate from existing records
18
18
  * unintrusively update factory files in place
19
19
  * display factory definition for a record
20
- * parse and write `FactoryGirl` syntax or older `Factory.define` syntax
20
+ * parse and write `FactoryBot` syntax
21
21
 
22
22
  Tested against Ruby 1.8.7, 1.9.2, 1.9.3, 2.0.0, 2.1.x, 2.2.x
23
23
 
@@ -41,15 +41,6 @@ group :test, :development do
41
41
  end
42
42
  ```
43
43
 
44
- For Ruby < `2.x` and older `FactoryGirl` syntax etc
45
-
46
- ```ruby
47
- group :test, :development do
48
- gem "to_factory", "~> 0.2.1"
49
- end
50
- ```
51
-
52
-
53
44
 
54
45
  ```bash
55
46
  git add spec/factories
@@ -77,7 +68,7 @@ ToFactory(exclude: [User, Project])
77
68
  ToFactory User.last
78
69
 
79
70
  #writes to spec/factories/user.rb
80
- FactoryGirl.define
71
+ FactoryBot.define
81
72
  factory(:user) do |u|
82
73
  email "test@example.com"
83
74
  name "Mike"
data/Rakefile CHANGED
@@ -1,34 +1,42 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'byebug'
2
3
 
3
4
  namespace :spec do
4
5
  def setup_db
5
- require 'logger'
6
- require 'active_record'
7
- ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => "spec/db/test.sqlite3")
8
- ActiveRecord::Base.logger = Logger.new(File.open('tmp/database.log', 'a'))
6
+ require "logger"
7
+ require "active_record"
8
+ ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: "spec/db/test.sqlite3")
9
+ ActiveRecord::Base.logger = Logger.new(File.open("tmp/database.log", "a"))
10
+ ActiveRecord::Migrator.migrations_paths = File.expand_path("./spec/db/migrate")
9
11
  end
10
12
 
11
13
  desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x"
12
14
  task :migrate_db do
13
15
  setup_db
14
- ActiveRecord::Migrator.migrate('spec/db/migrate')
16
+ ActiveRecord::Tasks::DatabaseTasks.migrate
15
17
  end
16
18
 
17
19
  desc "Migrate down"
18
20
  task :migrate_down do
19
21
  setup_db
20
- ActiveRecord::Migrator.down('spec/db/migrate')
22
+ ActiveRecord::Migrator.new.migrate(:down)
21
23
  end
22
24
  end
23
25
 
24
26
  begin
25
- require 'rspec/core/rake_task'
27
+ require "rspec/core/rake_task"
26
28
  RSpec::Core::RakeTask.new do |t|
27
29
  t.rspec_opts = ["-c", "-f progress", "-r ./spec/spec_helper.rb"]
28
- t.pattern = 'spec/**/*_spec.rb'
30
+ t.pattern = "spec/**/*_spec.rb"
29
31
  end
30
- task :default => :spec
32
+ task default: :spec
31
33
  rescue LoadError
32
34
 
33
35
  end
34
36
 
37
+ begin
38
+ require "rubocop/rake_task"
39
+
40
+ RuboCop::RakeTask.new
41
+ rescue LoadError
42
+ end
@@ -2,11 +2,11 @@ module ToFactory
2
2
  AlreadyExists = Class.new ArgumentError
3
3
 
4
4
  class Collation
5
- def self.organize(a,b)
5
+ def self.organize(a, b)
6
6
  new(a, b).organize
7
7
  end
8
8
 
9
- def self.representations_from(a,b)
9
+ def self.representations_from(a, b)
10
10
  new(a, b).representations
11
11
  end
12
12
 
@@ -16,14 +16,14 @@ module ToFactory
16
16
  end
17
17
 
18
18
  def organize
19
- representations.group_by{|i| i.klass.name.underscore}.inject({}) do |o, (klass_name,r)|
20
- o[klass_name] = r.sort_by{|r| [r.hierarchy_order, r.name]}
19
+ representations.group_by { |i| i.klass.name.underscore }.inject({}) do |o, (klass_name, r)|
20
+ o[klass_name] = r.sort_by { |r| [r.hierarchy_order, r.name] }
21
21
  o
22
22
  end
23
23
  end
24
24
 
25
25
  def representations
26
- detect_collisions!(@a,@b)
26
+ detect_collisions!(@a, @b)
27
27
 
28
28
  inference = KlassInference.new(merged)
29
29
 
@@ -36,7 +36,7 @@ module ToFactory
36
36
  merged
37
37
  end
38
38
 
39
- def detect_collisions!(a,b)
39
+ def detect_collisions!(a, b)
40
40
  collisions = []
41
41
  a.each do |x|
42
42
  b.each do |y|
@@ -53,8 +53,8 @@ module ToFactory
53
53
  @merged ||= @a + @b
54
54
  end
55
55
 
56
- def raise_already_exists!(keys)
57
- raise ToFactory::AlreadyExists.new "an item for each of the following keys #{keys.inspect} already exists"
58
- end
56
+ def raise_already_exists!(keys)
57
+ fail ToFactory::AlreadyExists.new "an item for each of the following keys #{keys.inspect} already exists"
58
+ end
59
59
  end
60
60
  end
@@ -8,20 +8,20 @@ module ToFactory
8
8
  @factory_finder = ff
9
9
  end
10
10
 
11
- def perform(exclusions=[])
11
+ def perform(exclusions = [])
12
12
  @file_writer.write(all_representations exclusions)
13
13
  end
14
14
 
15
- def all_representations(exclusions=[])
15
+ def all_representations(exclusions = [])
16
16
  Collation.organize(
17
17
  new_representations(exclusions),
18
18
  existing_representations)
19
19
  end
20
20
 
21
- def new_representations(exclusions=[])
21
+ def new_representations(exclusions = [])
22
22
  instances = @model_finder.call(exclusions: exclusions)
23
23
 
24
- instances.map{|r| Representation.from(r) }
24
+ instances.map { |r| Representation.from(r) }
25
25
  end
26
26
 
27
27
  private
@@ -34,16 +34,16 @@ module ToFactory
34
34
  if m.respond_to?(:call)
35
35
  m
36
36
  else
37
- lambda{|exclusions|
37
+ lambda do|exclusions|
38
38
  exclusions ||= []
39
39
  records = if m.is_a?(ActiveRecord::Base)
40
- Array m
41
- else
42
- m
40
+ Array m
41
+ else
42
+ m
43
43
  end
44
44
 
45
- records.reject{|o,_| exclusions.include?(o.class)}
46
- }
45
+ records.reject { |o, _| exclusions.include?(o.class) }
46
+ end
47
47
  end
48
48
  end
49
49
  end
@@ -23,7 +23,7 @@ module ToFactory
23
23
  end
24
24
 
25
25
  def wrap_factories(definitions)
26
- out = "FactoryGirl.define do\n"
26
+ out = "FactoryBot.define do\n"
27
27
  out << indent(definitions).join("\n\n")
28
28
  out << "\n" unless out[-1] == "\n"
29
29
  out << "end"
@@ -22,7 +22,7 @@ module ToFactory
22
22
  def parse_file(f)
23
23
  ToFactory::Parsing::File.parse(f)
24
24
  rescue ToFactory::Parsing::File::EmptyFileException => e
25
- #ignore empty files
25
+ # ignore empty files
26
26
  end
27
27
  end
28
28
  end
@@ -22,7 +22,7 @@ module ToFactory
22
22
  matching_lines(file) do |match|
23
23
  klass = rescuing_require(file, match)
24
24
 
25
- klasses << klass unless exclusions.include?(klass)
25
+ klasses << klass unless exclusions.include?(klass)
26
26
  end
27
27
  end
28
28
 
@@ -52,9 +52,7 @@ module ToFactory
52
52
  end
53
53
 
54
54
  def get_active_record_instance(klass)
55
- if klass && klass.ancestors.include?(ActiveRecord::Base)
56
- klass.first
57
- end
55
+ klass.first if klass && klass.ancestors.include?(ActiveRecord::Base)
58
56
  rescue StandardError => e
59
57
  warn "Failed to get record from #{klass} #{e.message.inspect}"
60
58
  end
@@ -13,17 +13,15 @@ module ToFactory
13
13
  " #{setter}"
14
14
  end
15
15
 
16
- def inspect_value(value, nested=false)
16
+ def inspect_value(value, nested = false)
17
17
  formatted = format(value, nested)
18
18
 
19
- if !value.is_a?(Hash) && !nested
20
- formatted = " #{formatted}"
21
- end
19
+ formatted = " { #{formatted} }" if !value.is_a?(Hash) && !nested
22
20
 
23
21
  formatted
24
22
  end
25
23
 
26
- def format(value, nested=false)
24
+ def format(value, nested = false)
27
25
  case value
28
26
  when Time, DateTime
29
27
  inspect_time(value)
@@ -67,17 +65,17 @@ module ToFactory
67
65
  def inspect_hash(value, nested)
68
66
  formatted = value.keys.inject([]) do |a, key|
69
67
  a << key_value_pair(key, value)
70
- end.join(', ')
68
+ end.join(", ")
71
69
 
72
70
  if nested
73
71
  "{#{formatted}}"
74
72
  else
75
- "({#{formatted}})"
73
+ " { {#{formatted}} }"
76
74
  end
77
75
  end
78
76
 
79
77
  def inspect_array(value, nested)
80
- values = value.map{|v| format(v, nested)}.join(", ")
78
+ values = value.map { |v| format(v, nested) }.join(", ")
81
79
  "[#{values}]"
82
80
  end
83
81
 
@@ -89,5 +87,3 @@ module ToFactory
89
87
  end
90
88
  end
91
89
  end
92
-
93
-
@@ -28,7 +28,7 @@ module ToFactory
28
28
  def attributes
29
29
  to_skip = [:id, :created_at, :created_on, :updated_at, :updated_on]
30
30
 
31
- @representation.attributes.delete_if{|key, _| key.nil? || to_skip.include?(key.to_sym)}
31
+ @representation.attributes.delete_if { |key, _| key.nil? || to_skip.include?(key.to_sym) }
32
32
  end
33
33
 
34
34
  private
@@ -37,14 +37,14 @@ module ToFactory
37
37
  @representation.parent_name
38
38
  end
39
39
 
40
- def generic_header(factory_start, block_arg, ending, &block)
40
+ def generic_header(factory_start, block_arg, ending, &_block)
41
41
  out = "#{factory_start}(:#{name}#{parent_clause}) do#{block_arg}\n"
42
42
  out << yield.to_s
43
43
  out << "#{ending}\n"
44
44
  end
45
45
 
46
46
  def parent_clause
47
- has_parent? ? ", :parent => :#{add_quotes parent_name}" : ""
47
+ has_parent? ? ", :parent => :#{add_quotes parent_name}" : ""
48
48
  end
49
49
 
50
50
  def has_parent?
@@ -14,14 +14,12 @@ module ToFactory
14
14
  end
15
15
  end
16
16
 
17
- def infer(factory_name, count=0)
18
- count = count + 1
19
- result = @mapping[factory_name]
17
+ def infer(factory_name, count = 0)
18
+ count += 1
19
+ result = @mapping[factory_name]
20
20
  return [result, count] if result.is_a? Class
21
21
 
22
- if result.nil?
23
- raise CannotInferClass.new(factory_name)
24
- end
22
+ fail CannotInferClass.new(factory_name) if result.nil?
25
23
 
26
24
  infer(result, count)
27
25
  end
@@ -6,10 +6,10 @@ module ToFactory
6
6
 
7
7
  def get_instance
8
8
  args = case @options
9
- when ActiveRecord::Base
10
- from_record(@options)
11
- when Array
12
- from_array(*@options)
9
+ when ActiveRecord::Base
10
+ from_record(@options)
11
+ when Array
12
+ from_array(*@options)
13
13
  end
14
14
 
15
15
  Representation.new(*args)
@@ -1,35 +1,106 @@
1
- require 'ruby2ruby'
2
- require 'ruby_parser'
1
+ require "ruby2ruby"
2
+ require "ruby_parser"
3
3
  require "to_factory/parsing/ruby_parsing_helpers"
4
- require 'to_factory/parsing/syntax'
5
4
 
6
5
  module ToFactory
7
6
  module Parsing
7
+ ParseException = Class.new ::StandardError
8
+
9
+ class CouldNotInferClassException < ParseException
10
+ attr_reader :sexp
11
+
12
+ def initialize(sexp)
13
+ @sexp = sexp
14
+ end
15
+ end
16
+
8
17
  class File
9
18
  EmptyFileException = Class.new ArgumentError
10
19
 
11
- delegate :multiple_factories?, :header?, :parse, :to => :parser
12
- attr_reader :contents
20
+ include Parsing::RubyParsingHelpers
21
+ attr_accessor :contents
13
22
 
14
- def self.parse(filename)
15
- from_file(filename).parse
16
- end
23
+ class << self
24
+ def parse(filename)
25
+ from_file(filename).parse
26
+ end
17
27
 
18
- def self.from_file(filename)
19
- contents = ::File.read filename rescue nil
20
- raise EmptyFileException.new "Invalid file #{filename}" if contents.to_s.strip.length == 0
28
+ def from_file(filename)
29
+ begin
30
+ contents = ::File.read filename
31
+ rescue
32
+ nil
33
+ end
34
+ fail EmptyFileException.new "Invalid file #{filename}" if contents.to_s.strip.length == 0
21
35
 
22
- new(contents)
36
+ new(contents)
37
+ end
23
38
  end
24
39
 
25
40
  def initialize(contents)
26
41
  @contents = contents
27
42
  end
28
43
 
29
- def parser
30
- @parser ||= Syntax.new(@contents)
44
+ def multiple_factories?
45
+ factories_sexp[0] == :block
31
46
  end
32
47
 
48
+ def parse
49
+ factories.map do |x|
50
+ representation_from(x)
51
+ end
52
+
53
+ rescue Racc::ParseError, StringScanner::Error => e
54
+ raise ParseException.new("Original exception: #{e.message}\n #{e.backtrace.join("\n")}\nToFactory Error parsing \n#{@contents}\n o")
55
+ end
56
+
57
+ def header?
58
+ sexp[1][1][1] == :FactoryBot
59
+ rescue
60
+ false
61
+ end
62
+
63
+ private
64
+
65
+ def representation_from(x)
66
+ Representation.new(name_from(x), parent_from(x), to_ruby(x))
67
+ rescue CouldNotInferClassException => e
68
+ ruby = to_ruby(e.sexp)
69
+ Kernel.warn "ToFactory could not parse\n#{ruby}"
70
+ NullRepresentation.new(e.sexp)
71
+ end
72
+
73
+ def factories
74
+ if multiple_factories?
75
+ factories_sexp[1..-1]
76
+ else
77
+ [factories_sexp]
78
+ end
79
+ end
80
+
81
+ def factories_sexp
82
+ header? ? sexp[3] : sexp
83
+ end
84
+
85
+ def name_from(sexp)
86
+ sexp[1][3][1]
87
+ rescue NoMethodError
88
+ raise CouldNotInferClassException.new(sexp)
89
+ end
90
+
91
+ def parent_from(x)
92
+ # e.g.
93
+ # s(:call, nil, :factory, s(:lit, :admin), s(:hash, s(:lit, :parent), s(:lit, :"to_factory/user")))
94
+ x[1][4][2][1]
95
+ rescue NoMethodError
96
+ # e.g.
97
+ # s(:call, nil, :factory, s(:lit, :"to_factory/user"))
98
+ x[1][3][1]
99
+ end
100
+
101
+ def sexp
102
+ @sexp ||= ruby_parser.process(@contents)
103
+ end
33
104
  end
34
105
  end
35
106
  end
@@ -19,18 +19,19 @@ module ToFactory
19
19
  end
20
20
  end
21
21
 
22
-
23
22
  class Representation
24
- delegate :attributes, :to => :record
23
+ delegate :attributes, to: :record
25
24
  attr_accessor :klass, :name, :parent_name, :definition, :hierarchy_order, :record
26
25
 
27
26
  def self.from(options)
28
27
  OptionsParser.new(options).get_instance
29
28
  end
30
29
 
31
- def initialize(name, parent_name, definition=nil, record=nil)
32
- @name, @parent_name, @definition, @record =
33
- name.to_s, parent_name.to_s, definition, record
30
+ def initialize(name, parent_name, definition = nil, record = nil)
31
+ @name = name.to_s
32
+ @parent_name = parent_name.to_s
33
+ @definition = definition
34
+ @record = record
34
35
  end
35
36
 
36
37
  def inspect
@@ -38,7 +39,9 @@ module ToFactory
38
39
  end
39
40
 
40
41
  def klass_name_inspect
41
- @klass.name.inspect rescue "nil"
42
+ @klass.name.inspect
43
+ rescue
44
+ "nil"
42
45
  end
43
46
 
44
47
  def definition
@@ -1,3 +1,3 @@
1
1
  module ToFactory
2
- VERSION = "2.1.0"
2
+ VERSION = "3.0.0-pre"
3
3
  end
data/lib/to_factory.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'fileutils'
1
+ require "fileutils"
2
2
 
3
3
  require "to_factory/version"
4
4
  require "to_factory/config"
@@ -13,22 +13,21 @@ require "to_factory/parsing/file"
13
13
  require "to_factory/representation"
14
14
  require "to_factory/klass_inference"
15
15
  require "to_factory/options_parser"
16
- require "factory_girl"
16
+ #require "factory_bot"
17
17
 
18
18
  module ToFactory
19
- class MissingActiveRecordInstanceException < Exception;end
20
- class NotFoundError < Exception;end
19
+ class MissingActiveRecordInstanceException < Exception; end
20
+ class NotFoundError < Exception; end
21
21
 
22
22
  class << self
23
-
24
23
  def definition_for(item)
25
24
  if item.is_a? ActiveRecord::Base
26
25
  Representation.from(item).definition
27
26
  else
28
- if found = representations.find{|r| r.name.to_s == item.to_s }
27
+ if found = representations.find { |r| r.name.to_s == item.to_s }
29
28
  found.definition
30
29
  else
31
- raise NotFoundError.new "No definition found for #{item}"
30
+ fail NotFoundError.new "No definition found for #{item}"
32
31
  end
33
32
  end
34
33
  end
@@ -45,7 +44,7 @@ end
45
44
 
46
45
  public
47
46
 
48
- def ToFactory(args=nil)
47
+ def ToFactory(args = nil)
49
48
  exclusions = if args.is_a?(Hash)
50
49
  exclusions = Array(args.delete(:exclude) || [])
51
50
  args = nil if args.keys.length == 0
@@ -1,13 +1,13 @@
1
- class CreateUsers < ActiveRecord::Migration
2
- def self.up
1
+ class CreateUsers < ActiveRecord::Migration[6.1]
2
+ def up
3
3
  create_table :users do |t|
4
- t.column :name, :string, :null => false
4
+ t.column :name, :string, null: false
5
5
  t.column :email, :string
6
6
  t.integer :some_id
7
7
  end
8
8
  end
9
9
 
10
- def self.down
10
+ def down
11
11
  drop_table :users
12
12
  end
13
13
  end
@@ -1,13 +1,13 @@
1
- class CreateProjects < ActiveRecord::Migration
2
- def self.up
1
+ class CreateProjects < ActiveRecord::Migration[6.1]
2
+ def up
3
3
  create_table :projects do |t|
4
- t.column :name, :string, :null => false
4
+ t.column :name, :string, null: false
5
5
  t.column :objective, :string
6
6
  t.integer :some_id
7
7
  end
8
8
  end
9
9
 
10
- def self.down
10
+ def down
11
11
  drop_table :projects
12
12
  end
13
13
  end
@@ -1,11 +1,11 @@
1
- class CreateNotNamespaced < ActiveRecord::Migration
2
- def self.up
1
+ class CreateNotNamespaced < ActiveRecord::Migration[6.1]
2
+ def up
3
3
  create_table :not_namespaced_active_record_class_but_long_enough_it_shouldnt_cause_conflicts do |t|
4
- t.column :name, :string, :null => false
4
+ t.column :name, :string, null: false
5
5
  end
6
6
  end
7
7
 
8
- def self.down
8
+ def down
9
9
  drop_table :not_namespaced_active_record_class_but_long_enough_it_shouldnt_cause_conflicts
10
10
  end
11
11
  end
@@ -1,9 +1,9 @@
1
- class AddBirthdayToUsers < ActiveRecord::Migration
2
- def self.up
1
+ class AddBirthdayToUsers < ActiveRecord::Migration[6.1]
2
+ def up
3
3
  add_column :users, :birthday, :datetime
4
4
  end
5
5
 
6
- def self.down
6
+ def down
7
7
  remove_column :users, :birthday
8
8
  end
9
9
  end
@@ -1,9 +1,9 @@
1
- class AddSerializedAttributesToUsers < ActiveRecord::Migration
2
- def self.up
1
+ class AddSerializedAttributesToUsers < ActiveRecord::Migration[6.1]
2
+ def up
3
3
  add_column :users, :some_attributes, :text
4
4
  end
5
5
 
6
- def self.down
6
+ def down
7
7
  remove_column :users, :some_attributes
8
8
  end
9
9
  end
@@ -1,7 +1,7 @@
1
- factory(:admin, :parent => :"to_factory/user") do
2
- birthday "2014-07-08T15:30 UTC"
3
- email "admin@example.com"
4
- name "Admin"
5
- some_attributes({:a => 1})
6
- some_id 9
1
+ factory(:admin, parent: :"to_factory/user") do
2
+ birthday { "2014-07-08T15:30 UTC" }
3
+ email {"admin@example.com"}
4
+ name {"Admin"}
5
+ some_attributes {{a: 1}}
6
+ some_id { 9 }
7
7
  end