factory_bot_instrumentation 0.8.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8794ba99bd73700545f3106b65facc07d8f90ae0701f5be87791a1e6ddcd070c
4
- data.tar.gz: d9584ba5ebc51c7158d99b437f920a3cef8b34cc0f540efbe987a6946cfa3019
3
+ metadata.gz: 8fad506387bc8c52339b3868ba4026a436bb3b4602747eabd30dcf3f41ecd855
4
+ data.tar.gz: a6c8adffc73924cbea80296c721ed264ba9378bba8f7bee7a1ec296871f17b79
5
5
  SHA512:
6
- metadata.gz: 4fd871835d825fa92c6a6313b9b952f004ad776ca6a795166e828babedbd4f802a4f783127146f34966f2bd293a4856d0a0797604388f138a0ab4dd1b898fa22
7
- data.tar.gz: d5af83c7a13d2d3a73ee5de68105c5a56132dbe48351d04fc9fe8e00bf8ff59cca1dfa700cd411625461111e8fbb0d6939456d8037b945585fd01d0b2532828a
6
+ metadata.gz: 24790a2a645d22cc50edefb2ee19c3215cfd173ac88bf3bced467a1b71ec73a984ae28e88e57d09f6ff938266c38d89262dfec1596a55516b74449e6e6de0437
7
+ data.tar.gz: 741ac435c5ed84bcc622ac327598be7b37e1b98757772ee189eb5f01446ae766ee8b443380dbc97767d240b6ba329416d988f6d8dd1e1a8420b7ea83345a598f
@@ -9,16 +9,17 @@ concurrency:
9
9
  jobs:
10
10
  docs:
11
11
  name: Build gem documentation
12
- runs-on: ubuntu-20.04
12
+ runs-on: ubuntu-22.04
13
13
  timeout-minutes: 5
14
14
  steps:
15
- - uses: actions/checkout@v2
15
+ - uses: actions/checkout@v3
16
16
 
17
17
  - name: Install the correct Ruby version
18
18
  uses: ruby/setup-ruby@v1
19
19
  with:
20
20
  ruby-version: 2.5
21
21
  bundler-cache: true
22
+ rubygems: '3.3.26'
22
23
 
23
24
  - name: Prepare the virtual environment
24
25
  uses: hausgold/actions/ci@master
@@ -13,23 +13,24 @@ concurrency:
13
13
  jobs:
14
14
  test:
15
15
  name: 'Test the gem (Ruby ${{ matrix.ruby }}, Rails ${{ matrix.rails }})'
16
- runs-on: ubuntu-20.04
16
+ runs-on: ubuntu-22.04
17
17
  timeout-minutes: 5
18
18
  strategy:
19
19
  fail-fast: false
20
20
  matrix:
21
- ruby: [2.4, 2.5, 2.6]
22
- rails: ['5.0', 5.1, 5.2]
21
+ ruby: ['2.5', '2.7']
22
+ rails: ['5.2']
23
23
  env:
24
24
  BUNDLE_GEMFILE: 'gemfiles/rails_${{ matrix.rails }}.gemfile'
25
25
  steps:
26
- - uses: actions/checkout@v2
26
+ - uses: actions/checkout@v3
27
27
 
28
28
  - name: Install the correct Ruby version
29
29
  uses: ruby/setup-ruby@v1
30
30
  with:
31
31
  ruby-version: ${{ matrix.ruby }}
32
32
  bundler-cache: true
33
+ rubygems: '3.3.26'
33
34
 
34
35
  - name: Prepare the virtual environment
35
36
  uses: hausgold/actions/ci@master
@@ -46,7 +47,7 @@ jobs:
46
47
 
47
48
  trigger-docs:
48
49
  name: Trigger the documentation upload
49
- runs-on: ubuntu-20.04
50
+ runs-on: ubuntu-22.04
50
51
  timeout-minutes: 2
51
52
  needs: test
52
53
  if: github.ref == 'refs/heads/master'
data/.rspec CHANGED
@@ -1,3 +1,3 @@
1
+ --backtrace
2
+ --force-color
1
3
  --format documentation
2
- --color
3
- --require spec_helper
data/.rubocop.yml CHANGED
@@ -1,14 +1,19 @@
1
- require: rubocop-rspec
1
+ require:
2
+ - rubocop-rspec
3
+ - rubocop-rails
2
4
 
3
5
  Rails:
4
6
  Enabled: true
5
7
 
6
- Documentation:
8
+ Style/Documentation:
7
9
  Enabled: true
8
10
 
9
11
  AllCops:
12
+ NewCops: enable
13
+ SuggestExtensions: false
10
14
  DisplayCopNames: true
11
15
  TargetRubyVersion: 2.5
16
+ TargetRailsVersion: 5.2
12
17
  Exclude:
13
18
  - bin/**/*
14
19
  - vendor/**/*
@@ -24,6 +29,14 @@ Metrics/BlockLength:
24
29
  - '**/*.rake'
25
30
  - doc/**/*.rb
26
31
 
32
+ # MFA is not yet enabled for our gems yet.
33
+ Gemspec/RequireMFA:
34
+ Enabled: false
35
+
36
+ # We stay with the original Ruby Style Guide recommendation.
37
+ Layout/LineLength:
38
+ Max: 80
39
+
27
40
  # Document all the things.
28
41
  Style/DocumentationMethod:
29
42
  Enabled: true
data/.simplecov CHANGED
@@ -1,3 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'simplecov-html'
4
+ require 'simplecov_json_formatter'
5
+
6
+ SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new(
7
+ [
8
+ SimpleCov::Formatter::HTMLFormatter,
9
+ SimpleCov::Formatter::JSONFormatter
10
+ ]
11
+ )
12
+
1
13
  SimpleCov.start 'test_frameworks' do
2
14
  add_filter '/vendor/bundle/'
3
15
  end
data/Appraisals CHANGED
@@ -1,13 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- appraise 'rails-5.0' do
4
- gem 'rails', '~> 5.0.7'
5
- end
6
-
7
- appraise 'rails-5.1' do
8
- gem 'rails', '~> 5.1.6'
9
- end
10
-
11
3
  appraise 'rails-5.2' do
12
- gem 'rails', '~> 5.2.2'
4
+ gem 'rails', '~> 5.2.0'
13
5
  end
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ### 1.0.0
2
+
3
+ * Bundler >= 2.3 is from now on required as minimal version (#12)
4
+ * Dropped support for Ruby < 2.5 (#12)
5
+ * Dropped support for Rails < 5.2 (#12)
6
+ * Updated all development/runtime gems to their latest
7
+ Ruby 2.5 compatible version (#12)
8
+
1
9
  ### 0.8.0
2
10
 
3
11
  * Added `FactoryBot.reload` to the initializer code to ensure the factories
data/Dockerfile ADDED
@@ -0,0 +1,28 @@
1
+ FROM hausgold/ruby:2.5
2
+ MAINTAINER Hermann Mayer <hermann.mayer@hausgold.de>
3
+
4
+ # Update system gem
5
+ RUN gem update --system '3.3.26'
6
+
7
+ # Install system packages and the latest bundler
8
+ RUN apt-get update -yqqq && \
9
+ apt-get install -y \
10
+ build-essential locales sudo vim \
11
+ ca-certificates \
12
+ bash-completion inotify-tools && \
13
+ echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen && /usr/sbin/locale-gen && \
14
+ gem install bundler -v '~> 2.3.0' --no-document --no-prerelease
15
+
16
+ # Add new web user
17
+ RUN mkdir /app && \
18
+ adduser web --home /home/web --shell /bin/bash \
19
+ --disabled-password --gecos ""
20
+ COPY config/docker/* /home/web/
21
+ RUN chown web:web -R /app /home/web /usr/local/bundle && \
22
+ mkdir -p /home/web/.ssh
23
+
24
+ # Set the root password and grant root access to web
25
+ RUN echo 'root:root' | chpasswd
26
+ RUN echo 'web ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
27
+
28
+ WORKDIR /app
data/Envfile ADDED
@@ -0,0 +1,3 @@
1
+ LANG=en_US.UTF-8
2
+ LANGUAGE=en_US.UTF-8
3
+ LC_ALL=en_US.UTF-8
data/Guardfile ADDED
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ # A sample Guardfile
4
+ # More info at https://github.com/guard/guard#readme
5
+
6
+ ## Uncomment and set this to only include directories you want to watch
7
+ (directories %w[app lib spec]).select do |d|
8
+ if Dir.exist?(d)
9
+ d
10
+ else
11
+ UI.warning("Directory #{d} does not exist")
12
+ end
13
+ end
14
+
15
+ ## Note: if you are using the `directories` clause above and you are not
16
+ ## watching the project directory ('.'), then you will want to move
17
+ ## the Guardfile to a watched dir and symlink it back, e.g.
18
+ #
19
+ # $ mkdir config
20
+ # $ mv Guardfile config/
21
+ # $ ln -s config/Guardfile .
22
+ #
23
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
24
+
25
+ # NOTE: The cmd option is now required due to the increasing number of ways
26
+ # rspec may be run, below are examples of the most common uses.
27
+ # * bundler: 'bundle exec rspec'
28
+ # * bundler binstubs: 'bin/rspec'
29
+ # * spring: 'bin/rspec' (This will use spring if running and you have
30
+ # installed the spring binstubs per the docs)
31
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
32
+ # * 'just' rspec: 'rspec'
33
+
34
+ guard :rspec, cmd: 'bundle exec rspec' do
35
+ watch('spec/spec_helper.rb') { 'spec' }
36
+ watch(%r{^lib/factory_bot_instrumentation.rb}) { 'spec' }
37
+ watch(%r{^spec/.+_spec\.rb$})
38
+ watch(%r{^app/controllers/([^\\]+)/(.*)\.rb$}) do |m|
39
+ "spec/controllers/#{m[1]}/#{m[2]}_spec.rb"
40
+ end
41
+ watch(%r{^lib/factory_bot/instrumentation/([^\\]+)\.rb$}) do |m|
42
+ "spec/#{m[1]}_spec.rb"
43
+ end
44
+ watch(%r{^lib/factory_bot/instrumentation/([^\\]+)/(.*)\.rb$}) do |m|
45
+ "spec/#{m[1]}/#{m[2]}_spec.rb"
46
+ end
47
+ end
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2017 HAUSGOLD | talocasa GmbH
3
+ Copyright (c) 2023 HAUSGOLD | talocasa GmbH
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/Makefile CHANGED
@@ -9,6 +9,7 @@ SHELL := bash
9
9
  # Environment switches
10
10
  MAKE_ENV ?= docker
11
11
  COMPOSE_RUN_SHELL_FLAGS ?= --rm
12
+ BASH_RUN_SHELL_FLAGS ?=
12
13
 
13
14
  # Directories
14
15
  VENDOR_DIR ?= vendor/bundle
@@ -22,9 +23,11 @@ MKDIR ?= mkdir
22
23
  RM ?= rm
23
24
 
24
25
  # Container binaries
25
- BUNDLE ?= bundle
26
26
  APPRAISAL ?= appraisal
27
+ BUNDLE ?= bundle
28
+ GUARD ?= guard
27
29
  RAKE ?= rake
30
+ RSPEC ?= rspec
28
31
  RUBOCOP ?= rubocop
29
32
  YARD ?= yard
30
33
 
@@ -39,8 +42,9 @@ ifeq ($(MAKE_ENV),docker)
39
42
  define run-shell
40
43
  $(COMPOSE) run $(COMPOSE_RUN_SHELL_FLAGS) \
41
44
  -e LANG=en_US.UTF-8 -e LANGUAGE=en_US.UTF-8 -e LC_ALL=en_US.UTF-8 \
42
- -e HOME=/tmp -e BUNDLE_APP_CONFIG=/app/.bundle \
43
- -u `$(ID) -u` test bash -c 'sleep 0.1; echo; $(1)'
45
+ -e HOME=/home/web -e BUNDLE_APP_CONFIG=/app/.bundle \
46
+ -u `$(ID) -u` test \
47
+ bash $(BASH_RUN_SHELL_FLAGS) -c 'sleep 0.1; echo; $(1)'
44
48
  endef
45
49
  else ifeq ($(MAKE_ENV),baremetal)
46
50
  define run-shell
@@ -52,9 +56,13 @@ all:
52
56
  # factory_bot_instrumentation
53
57
  #
54
58
  # install Install the dependencies
55
- # test Run the whole test suite
59
+ # update Update the local Gemset dependencies
56
60
  # clean Clean the dependencies
57
61
  #
62
+ # test Run the whole test suite
63
+ # test-style Test the code styles
64
+ # watch Watch for code changes and rerun the test suite
65
+ #
58
66
  # docs Generate the Ruby documentation of the library
59
67
  # stats Print the code statistics (library and test suite)
60
68
  # notes Print all the notes from the code
@@ -63,12 +71,25 @@ all:
63
71
  # shell Run an interactive shell on the container
64
72
  # shell-irb Run an interactive IRB shell on the container
65
73
 
74
+ .interactive:
75
+ @$(eval BASH_RUN_SHELL_FLAGS = --login)
76
+
66
77
  install:
67
78
  # Install the dependencies
68
79
  @$(MKDIR) -p $(VENDOR_DIR)
69
80
  @$(call run-shell,$(BUNDLE) check || $(BUNDLE) install --path $(VENDOR_DIR))
70
81
  @$(call run-shell,$(BUNDLE) exec $(APPRAISAL) install)
71
82
 
83
+ update:
84
+ # Install the dependencies
85
+ @$(MKDIR) -p $(VENDOR_DIR)
86
+ @$(call run-shell,$(BUNDLE) update)
87
+ @$(call run-shell,$(BUNDLE) exec $(APPRAISAL) update)
88
+
89
+ watch: install .interactive
90
+ # Watch for code changes and rerun the test suite
91
+ @$(call run-shell,$(BUNDLE) exec $(GUARD))
92
+
72
93
  test: \
73
94
  test-specs \
74
95
  test-style
@@ -80,7 +101,7 @@ test-specs:
80
101
  $(TEST_GEMFILES): GEMFILE=$(@:test-%=%)
81
102
  $(TEST_GEMFILES):
82
103
  # Run the whole test suite ($(GEMFILE))
83
- @$(call run-shell,$(BUNDLE) exec $(APPRAISAL) $(GEMFILE) $(RAKE))
104
+ @$(call run-shell,$(BUNDLE) exec $(APPRAISAL) $(GEMFILE) $(RSPEC))
84
105
 
85
106
  test-style: \
86
107
  test-style-ruby
@@ -92,6 +113,10 @@ test-style-ruby:
92
113
  clean:
93
114
  # Clean the dependencies
94
115
  @$(RM) -rf $(VENDOR_DIR)
116
+ @$(RM) -rf $(GEMFILES_DIR)/vendor
117
+ @$(RM) -rf $(GEMFILES_DIR)/*.lock
118
+ @$(RM) -rf .bundle .yardoc coverage pkg Gemfile.lock doc/api \
119
+ .rspec_status
95
120
 
96
121
  clean-containers:
97
122
  # Clean running containers
@@ -99,7 +124,15 @@ ifeq ($(MAKE_ENV),docker)
99
124
  @$(COMPOSE) down
100
125
  endif
101
126
 
102
- distclean: clean clean-containers
127
+ clean-images:
128
+ # Clean build images
129
+ ifeq ($(MAKE_ENV),docker)
130
+ @-$(DOCKER) images | $(GREP) $(shell basename "`pwd`") \
131
+ | $(AWK) '{ print $$3 }' \
132
+ | $(XARGS) -rn1 $(DOCKER) rmi -f
133
+ endif
134
+
135
+ distclean: clean clean-containers clean-images
103
136
 
104
137
  shell:
105
138
  # Run an interactive shell on the container
data/Rakefile CHANGED
@@ -4,11 +4,9 @@
4
4
  ENV['RAILS_ENV'] = 'test'
5
5
  ENV['DISABLE_DATABASE_ENVIRONMENT_CHECK'] = '1'
6
6
 
7
- require 'bundler/setup'
8
7
  require 'bundler/gem_tasks'
9
8
  require 'rspec/core/rake_task'
10
- require 'rails/code_statistics'
11
- require 'pp'
9
+ require 'countless/rake_tasks'
12
10
 
13
11
  APP_RAKEFILE = File.expand_path('spec/dummy/Rakefile', __dir__)
14
12
  load 'rails/tasks/engine.rake'
@@ -17,9 +15,6 @@ Bundler::GemHelper.install_tasks
17
15
 
18
16
  Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each { |f| load f }
19
17
 
20
- require 'rspec/core'
21
- require 'rspec/core/rake_task'
22
-
23
18
  desc 'Run all specs in spec directory (excluding plugin specs)'
24
19
  RSpec::Core::RakeTask.new(spec: [
25
20
  'db:drop', 'db:create', 'db:migrate', 'db:setup'
@@ -27,66 +22,20 @@ RSpec::Core::RakeTask.new(spec: [
27
22
 
28
23
  task default: :spec
29
24
 
30
- # Load some railties tasks
31
- load 'rails/tasks/statistics.rake'
32
- load 'rails/tasks/annotations.rake'
33
-
34
- # Clear the default statistics directory constant
35
- #
36
- # rubocop:disable Style/MutableConstant because we define it
37
- Object.send(:remove_const, :STATS_DIRECTORIES)
38
- ::STATS_DIRECTORIES = []
39
- # rubocop:enable Style/MutableConstant
40
-
41
- # Monkey patch the Rails +CodeStatistics+ class to support configurable
42
- # patterns per path. This is reuqired to support top-level only file matches.
43
- class CodeStatistics
44
- DEFAULT_PATTERN = /^(?!\.).*?\.(rb|js|coffee|rake)$/.freeze
45
-
46
- # Pass the possible +pattern+ argument down to the
47
- # +calculate_directory_statistics+ method call.
48
- def calculate_statistics
49
- Hash[@pairs.map do |pair|
50
- [pair.first, calculate_directory_statistics(*pair[1..-1])]
51
- end]
52
- end
53
-
54
- # Match the pattern against the individual file name and the relative file
55
- # path. This allows top-level only matches.
56
- def calculate_directory_statistics(directory, pattern = DEFAULT_PATTERN)
57
- stats = CodeStatisticsCalculator.new
58
-
59
- Dir.foreach(directory) do |file_name|
60
- path = "#{directory}/#{file_name}"
61
-
62
- if File.directory?(path) && (/^\./ !~ file_name)
63
- stats.add(calculate_directory_statistics(path, pattern))
64
- elsif file_name =~ pattern || path =~ pattern
65
- stats.add_by_file_path(path)
66
- end
67
- end
68
-
69
- stats
70
- end
71
- end
72
-
73
25
  # Configure all code statistics directories
74
- vendors = [
75
- [:unshift, 'Top-levels', 'lib'],
76
- [:unshift, 'Top-levels specs', 'spec', %r{spec/[^/]+_spec\.rb$}],
77
- [:unshift, 'Javascript', 'app/assets'],
78
- [:unshift, 'Controllers', 'app/controllers'],
79
- [:unshift, 'Controllers specs', 'spec/controllers']
80
- ].reverse
81
-
82
- vendors.each do |method, type, dir, pattern|
83
- ::STATS_DIRECTORIES.send(method, [type, dir, pattern].compact)
84
- ::CodeStatistics::TEST_TYPES << type if type.include? 'specs'
85
- end
86
-
87
- # Setup annotations
88
- ENV['SOURCE_ANNOTATION_DIRECTORIES'] = 'spec,doc'
89
- desc 'Enumerate all annotations'
90
- task :notes do
91
- SourceAnnotationExtractor.enumerate '@?OPTIMIZE|@?FIXME|@?TODO', tag: true
26
+ Countless.configure do |config|
27
+ config.stats_base_directories = [
28
+ { name: 'Top-levels', dir: 'lib',
29
+ pattern: %r{/lib/[^/]+\.rb$} },
30
+ { name: 'Top-levels specs', test: true, dir: 'spec',
31
+ pattern: %r{/spec/[^/]+_spec\.rb$} },
32
+ { name: 'Libraries',
33
+ pattern: 'lib/factory_bot/**/*_spec.rb' },
34
+ { name: 'Javascript', pattern: 'app/assets/**/*.js' },
35
+ { name: 'Stylesheets', pattern: 'app/assets/**/*.css' },
36
+ { name: 'Views', pattern: 'app/views/**/*.erb' },
37
+ { name: 'Controllers', pattern: 'app/controllers/**/*.rb' },
38
+ { name: 'Controllers specs', test: true,
39
+ pattern: 'spec/controllers/**/*_spec.rb' }
40
+ ]
92
41
  end
@@ -45,12 +45,12 @@ module FactoryBot
45
45
  FactoryBot::Instrumentation.configuration.render_entity.call(
46
46
  self, entity
47
47
  )
48
- rescue StandardError => err
48
+ rescue StandardError => e
49
49
  # Handle any error gracefully with the configured error handler
50
- FactoryBot::Instrumentation.configuration.render_error.call(self, err)
50
+ FactoryBot::Instrumentation.configuration.render_error.call(self, e)
51
51
  end
52
52
 
53
- private
53
+ protected
54
54
 
55
55
  # Parse the given parameters from the request and build
56
56
  # a valid FactoryBot options set.
@@ -72,7 +72,7 @@ module FactoryBot
72
72
  [
73
73
  data.fetch(:factory).to_sym,
74
74
  *data.fetch(:traits, []).map(&:to_sym),
75
- **overwrite
75
+ { **overwrite }
76
76
  ]
77
77
  end
78
78
  # rubocop:enable Metrics/MethodLength
@@ -109,8 +109,8 @@ module FactoryBot
109
109
  #
110
110
  # @return [Hash{Regexp => String}] the group mapping
111
111
  def groups
112
- instrumentation['groups'].each_with_object({}) do |(key, val), memo|
113
- memo[Regexp.new(Regexp.quote(key))] = val
112
+ instrumentation['groups'].transform_keys do |key|
113
+ Regexp.new(Regexp.quote(key))
114
114
  end
115
115
  end
116
116
 
@@ -0,0 +1,3 @@
1
+ if [ -f ~/.bashrc ]; then
2
+ . ~/.bashrc
3
+ fi
@@ -0,0 +1,48 @@
1
+ # ~/.bashrc: executed by bash(1) for non-login shells.
2
+ # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
3
+ # for examples
4
+
5
+ _GEM_PATHS=$(ls -d1 ${HOME}/.gem/ruby/*/bin 2>/dev/null | paste -sd ':')
6
+ _APP_PATHS=$(ls -d1 /app/vendor/bundle/ruby/*/bin 2>/dev/null | paste -sd ':')
7
+
8
+ export PATH="${_GEM_PATHS}:${_APP_PATHS}:${PATH}"
9
+ export PATH="/app/node_modules/.bin:${HOME}/.bin:/app/bin:${PATH}"
10
+ export MAKE_ENV=baremetal
11
+
12
+ # Disable the autostart of all supervisord units
13
+ sudo sed -i 's/autostart=.*/autostart=false/g' /etc/supervisor/conf.d/*
14
+
15
+ # Start the supervisord (empty, no units)
16
+ sudo supervisord >/dev/null 2>&1 &
17
+
18
+ # Wait for supervisord
19
+ while ! supervisorctl status >/dev/null 2>&1; do sleep 1; done
20
+
21
+ # Boot the mDNS stack
22
+ echo '# Start the mDNS stack'
23
+ sudo supervisorctl start dbus avahi
24
+ echo
25
+
26
+ function watch-make-test()
27
+ {
28
+ while [ 1 ]; do
29
+ inotifywait --quiet -r `pwd` -e close_write --format '%e -> %w%f'
30
+ make test
31
+ done
32
+ }
33
+
34
+ function watch-make()
35
+ {
36
+ while [ 1 ]; do
37
+ inotifywait --quiet -r `pwd` -e close_write --format '%e -> %w%f'
38
+ make $@
39
+ done
40
+ }
41
+
42
+ function watch-run()
43
+ {
44
+ while [ 1 ]; do
45
+ inotifywait --quiet -r `pwd` -e close_write --format '%e -> %w%f'
46
+ bash -c "$@"
47
+ done
48
+ }
@@ -0,0 +1,17 @@
1
+ # mappings for Ctrl-left-arrow and Ctrl-right-arrow for word moving
2
+ "\e[1;5C": forward-word
3
+ "\e[1;5D": backward-word
4
+ "\e[5C": forward-word
5
+ "\e[5D": backward-word
6
+ "\e\e[C": forward-word
7
+ "\e\e[D": backward-word
8
+
9
+ # handle common Home/End escape codes
10
+ "\e[1~": beginning-of-line
11
+ "\e[4~": end-of-line
12
+ "\e[7~": beginning-of-line
13
+ "\e[8~": end-of-line
14
+ "\eOH": beginning-of-line
15
+ "\eOF": end-of-line
16
+ "\e[H": beginning-of-line
17
+ "\e[F": end-of-line
data/docker-compose.yml CHANGED
@@ -1,7 +1,8 @@
1
1
  version: "3"
2
2
  services:
3
3
  test:
4
- image: ruby:2.4
4
+ build: .
5
+ env_file: Envfile
5
6
  network_mode: bridge
6
7
  working_dir: /app
7
8
  volumes:
@@ -5,34 +5,49 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  require 'factory_bot/instrumentation/version'
6
6
 
7
7
  Gem::Specification.new do |spec|
8
- spec.name = 'factory_bot_instrumentation'
9
- spec.version = FactoryBot::Instrumentation::VERSION
10
- spec.authors = ['Hermann Mayer']
11
- spec.email = ['hermann.mayer92@gmail.com']
8
+ spec.name = 'factory_bot_instrumentation'
9
+ spec.version = FactoryBot::Instrumentation::VERSION
10
+ spec.authors = ['Hermann Mayer']
11
+ spec.email = ['hermann.mayer92@gmail.com']
12
12
 
13
- spec.summary = 'Allow your testers to generate test data on demand'
14
- spec.description = 'Allow your testers to generate test data on demand'
15
- spec.homepage = 'https://github.com/hausgold/factory_bot_instrumentation'
13
+ spec.license = 'MIT'
14
+ spec.summary = 'Allow your testers to generate test data on demand'
15
+ spec.description = 'Allow your testers to generate test data on demand'
16
+
17
+ base_uri = "https://github.com/hausgold/#{spec.name}"
18
+ spec.metadata = {
19
+ 'homepage_uri' => base_uri,
20
+ 'source_code_uri' => base_uri,
21
+ 'changelog_uri' => "#{base_uri}/blob/master/CHANGELOG.md",
22
+ 'bug_tracker_uri' => "#{base_uri}/issues",
23
+ 'documentation_uri' => "https://www.rubydoc.info/gems/#{spec.name}"
24
+ }
16
25
 
17
26
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
27
  f.match(%r{^(test|spec|features)/})
19
28
  end
20
- spec.bindir = 'exe'
21
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+
30
+ spec.bindir = 'exe'
31
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
32
  spec.require_paths = ['lib']
23
33
 
24
- spec.add_runtime_dependency 'factory_bot'
25
- spec.add_runtime_dependency 'rails', '>= 5.0'
26
-
27
- spec.add_development_dependency 'appraisal'
28
- spec.add_development_dependency 'bundler', '>= 1.16', '< 3'
29
- spec.add_development_dependency 'railties', '>= 4.2.0', '< 6.1'
30
- spec.add_development_dependency 'rspec-rails', '~> 3.8'
31
- spec.add_development_dependency 'rubocop', '~> 0.63.1'
32
- spec.add_development_dependency 'rubocop-rspec', '~> 1.31'
33
- spec.add_development_dependency 'simplecov', '< 0.18'
34
- spec.add_development_dependency 'sqlite3', '~> 1.3.6'
35
- spec.add_development_dependency 'timecop', '~> 0.9.1'
36
- spec.add_development_dependency 'yard', '~> 0.9.18'
37
- spec.add_development_dependency 'yard-activesupport-concern', '~> 0.0.1'
34
+ spec.required_ruby_version = '>= 2.5'
35
+
36
+ spec.add_runtime_dependency 'factory_bot', '~> 6.2'
37
+ spec.add_runtime_dependency 'rails', '>= 5.2'
38
+
39
+ spec.add_development_dependency 'appraisal', '~> 2.4'
40
+ spec.add_development_dependency 'bundler', '~> 2.3'
41
+ spec.add_development_dependency 'countless', '~> 1.1'
42
+ spec.add_development_dependency 'guard-rspec', '~> 4.7'
43
+ spec.add_development_dependency 'railties', '>= 5.2'
44
+ spec.add_development_dependency 'rspec-rails', '~> 5.1'
45
+ spec.add_development_dependency 'rubocop', '~> 1.28'
46
+ spec.add_development_dependency 'rubocop-rails', '~> 2.14'
47
+ spec.add_development_dependency 'rubocop-rspec', '~> 2.10'
48
+ spec.add_development_dependency 'simplecov', '>= 0.22'
49
+ spec.add_development_dependency 'sqlite3', '~> 1.5'
50
+ spec.add_development_dependency 'timecop', '>= 0.9.6'
51
+ spec.add_development_dependency 'yard', '>= 0.9.28'
52
+ spec.add_development_dependency 'yard-activesupport-concern', '>= 0.0.1'
38
53
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", "~> 5.2.2"
5
+ gem "rails", "~> 5.2.0"
6
6
 
7
7
  gemspec path: "../"
@@ -15,8 +15,13 @@ module FactoryBot
15
15
 
16
16
  FactoryBot::Instrumentation.configure do |conf|
17
17
  # Set the application name dynamically
18
- conf.application_name \
19
- ||= Rails.application.class.parent_name.titleize
18
+ conf.application_name ||= begin
19
+ app_class = Rails.application.class
20
+ parent_name = app_class.module_parent_name \
21
+ if app_class.respond_to?(:module_parent_name)
22
+ parent_name ||= app_class.parent_name
23
+ parent_name.titleize
24
+ end
20
25
  end
21
26
  end
22
27
  end
@@ -1,7 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FactoryBot
4
+ # The gem version details.
4
5
  module Instrumentation
5
- VERSION = '0.8.0'
6
+ # The version of the +factory_bot_instrumentation+ gem
7
+ VERSION = '1.0.0'
8
+
9
+ class << self
10
+ # Returns the version of gem as a string.
11
+ #
12
+ # @return [String] the gem version as string
13
+ def version
14
+ VERSION
15
+ end
16
+
17
+ # Returns the version of the gem as a +Gem::Version+.
18
+ #
19
+ # @return [Gem::Version] the gem version as object
20
+ def gem_version
21
+ Gem::Version.new VERSION
22
+ end
23
+ end
6
24
  end
7
25
  end
metadata CHANGED
@@ -1,207 +1,237 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factory_bot_instrumentation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hermann Mayer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-10 00:00:00.000000000 Z
11
+ date: 2023-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: factory_bot
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '6.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '6.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rails
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '5.0'
33
+ version: '5.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '5.0'
40
+ version: '5.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: appraisal
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '2.4'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '2.4'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
60
67
  - !ruby/object:Gem::Version
61
- version: '1.16'
62
- - - "<"
68
+ version: '2.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: countless
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
63
74
  - !ruby/object:Gem::Version
64
- version: '3'
75
+ version: '1.1'
65
76
  type: :development
66
77
  prerelease: false
67
78
  version_requirements: !ruby/object:Gem::Requirement
68
79
  requirements:
69
- - - ">="
80
+ - - "~>"
70
81
  - !ruby/object:Gem::Version
71
- version: '1.16'
72
- - - "<"
82
+ version: '1.1'
83
+ - !ruby/object:Gem::Dependency
84
+ name: guard-rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '4.7'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
73
95
  - !ruby/object:Gem::Version
74
- version: '3'
96
+ version: '4.7'
75
97
  - !ruby/object:Gem::Dependency
76
98
  name: railties
77
99
  requirement: !ruby/object:Gem::Requirement
78
100
  requirements:
79
101
  - - ">="
80
102
  - !ruby/object:Gem::Version
81
- version: 4.2.0
82
- - - "<"
83
- - !ruby/object:Gem::Version
84
- version: '6.1'
103
+ version: '5.2'
85
104
  type: :development
86
105
  prerelease: false
87
106
  version_requirements: !ruby/object:Gem::Requirement
88
107
  requirements:
89
108
  - - ">="
90
109
  - !ruby/object:Gem::Version
91
- version: 4.2.0
92
- - - "<"
93
- - !ruby/object:Gem::Version
94
- version: '6.1'
110
+ version: '5.2'
95
111
  - !ruby/object:Gem::Dependency
96
112
  name: rspec-rails
97
113
  requirement: !ruby/object:Gem::Requirement
98
114
  requirements:
99
115
  - - "~>"
100
116
  - !ruby/object:Gem::Version
101
- version: '3.8'
117
+ version: '5.1'
102
118
  type: :development
103
119
  prerelease: false
104
120
  version_requirements: !ruby/object:Gem::Requirement
105
121
  requirements:
106
122
  - - "~>"
107
123
  - !ruby/object:Gem::Version
108
- version: '3.8'
124
+ version: '5.1'
109
125
  - !ruby/object:Gem::Dependency
110
126
  name: rubocop
111
127
  requirement: !ruby/object:Gem::Requirement
112
128
  requirements:
113
129
  - - "~>"
114
130
  - !ruby/object:Gem::Version
115
- version: 0.63.1
131
+ version: '1.28'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '1.28'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop-rails
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '2.14'
116
146
  type: :development
117
147
  prerelease: false
118
148
  version_requirements: !ruby/object:Gem::Requirement
119
149
  requirements:
120
150
  - - "~>"
121
151
  - !ruby/object:Gem::Version
122
- version: 0.63.1
152
+ version: '2.14'
123
153
  - !ruby/object:Gem::Dependency
124
154
  name: rubocop-rspec
125
155
  requirement: !ruby/object:Gem::Requirement
126
156
  requirements:
127
157
  - - "~>"
128
158
  - !ruby/object:Gem::Version
129
- version: '1.31'
159
+ version: '2.10'
130
160
  type: :development
131
161
  prerelease: false
132
162
  version_requirements: !ruby/object:Gem::Requirement
133
163
  requirements:
134
164
  - - "~>"
135
165
  - !ruby/object:Gem::Version
136
- version: '1.31'
166
+ version: '2.10'
137
167
  - !ruby/object:Gem::Dependency
138
168
  name: simplecov
139
169
  requirement: !ruby/object:Gem::Requirement
140
170
  requirements:
141
- - - "<"
171
+ - - ">="
142
172
  - !ruby/object:Gem::Version
143
- version: '0.18'
173
+ version: '0.22'
144
174
  type: :development
145
175
  prerelease: false
146
176
  version_requirements: !ruby/object:Gem::Requirement
147
177
  requirements:
148
- - - "<"
178
+ - - ">="
149
179
  - !ruby/object:Gem::Version
150
- version: '0.18'
180
+ version: '0.22'
151
181
  - !ruby/object:Gem::Dependency
152
182
  name: sqlite3
153
183
  requirement: !ruby/object:Gem::Requirement
154
184
  requirements:
155
185
  - - "~>"
156
186
  - !ruby/object:Gem::Version
157
- version: 1.3.6
187
+ version: '1.5'
158
188
  type: :development
159
189
  prerelease: false
160
190
  version_requirements: !ruby/object:Gem::Requirement
161
191
  requirements:
162
192
  - - "~>"
163
193
  - !ruby/object:Gem::Version
164
- version: 1.3.6
194
+ version: '1.5'
165
195
  - !ruby/object:Gem::Dependency
166
196
  name: timecop
167
197
  requirement: !ruby/object:Gem::Requirement
168
198
  requirements:
169
- - - "~>"
199
+ - - ">="
170
200
  - !ruby/object:Gem::Version
171
- version: 0.9.1
201
+ version: 0.9.6
172
202
  type: :development
173
203
  prerelease: false
174
204
  version_requirements: !ruby/object:Gem::Requirement
175
205
  requirements:
176
- - - "~>"
206
+ - - ">="
177
207
  - !ruby/object:Gem::Version
178
- version: 0.9.1
208
+ version: 0.9.6
179
209
  - !ruby/object:Gem::Dependency
180
210
  name: yard
181
211
  requirement: !ruby/object:Gem::Requirement
182
212
  requirements:
183
- - - "~>"
213
+ - - ">="
184
214
  - !ruby/object:Gem::Version
185
- version: 0.9.18
215
+ version: 0.9.28
186
216
  type: :development
187
217
  prerelease: false
188
218
  version_requirements: !ruby/object:Gem::Requirement
189
219
  requirements:
190
- - - "~>"
220
+ - - ">="
191
221
  - !ruby/object:Gem::Version
192
- version: 0.9.18
222
+ version: 0.9.28
193
223
  - !ruby/object:Gem::Dependency
194
224
  name: yard-activesupport-concern
195
225
  requirement: !ruby/object:Gem::Requirement
196
226
  requirements:
197
- - - "~>"
227
+ - - ">="
198
228
  - !ruby/object:Gem::Version
199
229
  version: 0.0.1
200
230
  type: :development
201
231
  prerelease: false
202
232
  version_requirements: !ruby/object:Gem::Requirement
203
233
  requirements:
204
- - - "~>"
234
+ - - ">="
205
235
  - !ruby/object:Gem::Version
206
236
  version: 0.0.1
207
237
  description: Allow your testers to generate test data on demand
@@ -221,7 +251,10 @@ files:
221
251
  - ".yardopts"
222
252
  - Appraisals
223
253
  - CHANGELOG.md
254
+ - Dockerfile
255
+ - Envfile
224
256
  - Gemfile
257
+ - Guardfile
225
258
  - LICENSE
226
259
  - Makefile
227
260
  - README.md
@@ -246,6 +279,9 @@ files:
246
279
  - app/views/factory_bot_instrumentation/_styles.html.erb
247
280
  - app/views/layouts/factory_bot/instrumentation/application.html.erb
248
281
  - bin/rails
282
+ - config/docker/.bash_profile
283
+ - config/docker/.bashrc
284
+ - config/docker/.inputrc
249
285
  - config/instrumentation.yml
250
286
  - config/routes.rb
251
287
  - doc/assets/blocks.png
@@ -255,16 +291,20 @@ files:
255
291
  - doc/assets/regular.png
256
292
  - docker-compose.yml
257
293
  - factory_bot_instrumentation.gemspec
258
- - gemfiles/rails_5.0.gemfile
259
- - gemfiles/rails_5.1.gemfile
260
294
  - gemfiles/rails_5.2.gemfile
261
295
  - lib/factory_bot/instrumentation/configuration.rb
262
296
  - lib/factory_bot/instrumentation/engine.rb
263
297
  - lib/factory_bot/instrumentation/version.rb
264
298
  - lib/factory_bot_instrumentation.rb
265
- homepage: https://github.com/hausgold/factory_bot_instrumentation
266
- licenses: []
267
- metadata: {}
299
+ homepage:
300
+ licenses:
301
+ - MIT
302
+ metadata:
303
+ homepage_uri: https://github.com/hausgold/factory_bot_instrumentation
304
+ source_code_uri: https://github.com/hausgold/factory_bot_instrumentation
305
+ changelog_uri: https://github.com/hausgold/factory_bot_instrumentation/blob/master/CHANGELOG.md
306
+ bug_tracker_uri: https://github.com/hausgold/factory_bot_instrumentation/issues
307
+ documentation_uri: https://www.rubydoc.info/gems/factory_bot_instrumentation
268
308
  post_install_message:
269
309
  rdoc_options: []
270
310
  require_paths:
@@ -273,14 +313,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
273
313
  requirements:
274
314
  - - ">="
275
315
  - !ruby/object:Gem::Version
276
- version: '0'
316
+ version: '2.5'
277
317
  required_rubygems_version: !ruby/object:Gem::Requirement
278
318
  requirements:
279
319
  - - ">="
280
320
  - !ruby/object:Gem::Version
281
321
  version: '0'
282
322
  requirements: []
283
- rubygems_version: 3.2.16
323
+ rubygems_version: 3.3.8
284
324
  signing_key:
285
325
  specification_version: 4
286
326
  summary: Allow your testers to generate test data on demand
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 5.0.7"
6
-
7
- gemspec path: "../"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 5.1.6"
6
-
7
- gemspec path: "../"