Skip to content

Commit 80998d2

Browse files
CodeMeisterneilvcarvalho
authored andcommitted
Developer Console Feature
- `bin/console` opens an IRB console, with factory_bot already loaded. - The session method `reload!` will reload all gem files.
1 parent 95bbb98 commit 80998d2

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

.irbrc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
def reload!
2+
# Undefine FactoryBot so we can reload Constants and fresh code
3+
Object.send(:remove_const, :FactoryBot) if Object.const_defined?(:FactoryBot)
4+
5+
# Remove all files from the 'loaded' register
6+
$LOADED_FEATURES.grep(/factory_bot/).each do |path|
7+
$LOADED_FEATURES.delete(path)
8+
end
9+
10+
# re-load it again
11+
require "factory_bot"
12+
puts "\nfactory_bot reloaded!\n\n"
13+
true
14+
end

bin/console

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
lib = File.expand_path("../lib", __dir__)
5+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6+
7+
require "bundler/setup"
8+
require "factory_bot"
9+
10+
# Add any other fixtures and/or initialization code here.
11+
12+
require "irb"
13+
require "irb/completion"
14+
IRB.start(__FILE__)

bin/setup

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
IFS=$'\n\t'
4+
set -vx
5+
6+
bundle install
7+

0 commit comments

Comments
 (0)