Skip to content

Commit

Permalink
Add mutant environment irb subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
mbj committed Oct 17, 2021
1 parent b8c17fd commit dbd7bdf
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 4 deletions.
7 changes: 7 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# v0.10.35 2021-10-17

* []()
Add `mutant environment irb` command. Starts an IRB session for the
configured mutant environment. Very useful for iterating on environment
setup issues.

# v0.10.34 2021-08-30

* [#1252](https://github.com/mbj/mutant/pull/1252)
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
mutant (0.10.34)
mutant (0.10.35)
diff-lcs (~> 1.3)
parser (~> 3.0.0)
regexp_parser (~> 2.0, >= 2.0.3)
Expand Down Expand Up @@ -69,4 +69,4 @@ DEPENDENCIES
rubocop (~> 1.7)

BUNDLED WITH
2.2.25
2.2.29
2 changes: 2 additions & 0 deletions lib/mutant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require 'diff/lcs/hunk'
require 'digest/sha1'
require 'etc'
require 'irb'
require 'json'
require 'open3'
require 'optparse'
Expand Down Expand Up @@ -194,6 +195,7 @@ module Mutant
require 'mutant/cli/command'
require 'mutant/cli/command/subscription'
require 'mutant/cli/command/environment'
require 'mutant/cli/command/environment/irb'
require 'mutant/cli/command/environment/run'
require 'mutant/cli/command/environment/show'
require 'mutant/cli/command/environment/subject'
Expand Down
21 changes: 21 additions & 0 deletions lib/mutant/cli/command/environment/irb.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

module Mutant
module CLI
class Command
class Environment
class IRB < self
NAME = 'irb'
SHORT_DESCRIPTION = 'Run irb with mutant environment loaded'
SUBCOMMANDS = EMPTY_ARRAY

private

def action
bootstrap.fmap { TOPLEVEL_BINDING.irb }
end
end # IRB
end # Environment
end # Command
end # CLI
end # Mutant
2 changes: 1 addition & 1 deletion lib/mutant/cli/command/root.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Mutant
module CLI
class Command
class Environment < self
SUBCOMMANDS = [Environment::Subject, Environment::Show, Environment::Test].freeze
SUBCOMMANDS = [Environment::Subject, Environment::Show, Environment::IRB, Environment::Test].freeze
end # Environment

class Root < self
Expand Down
2 changes: 1 addition & 1 deletion lib/mutant/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

module Mutant
# Current mutant version
VERSION = '0.10.34'
VERSION = '0.10.35'
end # Mutant
33 changes: 33 additions & 0 deletions spec/unit/mutant/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,39 @@ def self.main_body
end
end

context 'environment irb' do
include_context 'environment'

before do
allow(TOPLEVEL_BINDING).to receive(:irb) do
events << :irb_execution
end
end

let(:arguments) { %w[environment irb] }

context 'without additional arguments' do
let(:expected_exit) { true }

let(:expected_events) do
[
[
:load_config_file,
world
],
[
:bootstrap,
world,
bootstrap_config.inspect
],
:irb_execution
]
end

include_examples 'CLI run'
end
end

context 'environment test list' do
include_context 'environment'

Expand Down

0 comments on commit dbd7bdf

Please sign in to comment.