# frozen_string_literal: true RSpec.describe "hanami console", type: :integration do context "irb" do it "starts console" do project_name = "bookshelf_console_irb" with_project(project_name, console: :irb) do setup_model console do |input, _, _| input.puts("Hanami::VERSION") input.puts("Web::App") input.puts("Web.routes") input.puts("BookRepository.new.all.to_a") input.puts("exit") end expect(out).to include(Hanami::VERSION) expect(out).to include("Web::App") expect(out).to include("#') end end end # irb xit "returns error when known engine isn't bundled" do with_project("bookshelf_console_irb", console: :irb) do output = "Missing gem for `pry' console engine. Please make sure to add it to `Gemfile'." run_cmd "hanami console --engine=pry", output, exit_status: 1 end end it "returns error when unknown engine is requested" do with_project("bookshelf_console_irb", console: :irb) do output = "Unknown console engine: `foo'." run_cmd "hanami console --engine=foo", output, exit_status: 1 end end it "prints help message" do with_project do output = <<~OUT Command: hanami console Usage: hanami console Description: Starts Hanami console Options: --engine=VALUE # Force a specific console engine: (pry/ripl/irb) --help, -h # Print this help Examples: hanami console # Uses the bundled engine hanami console --engine=pry # Force to use Pry OUT run_cmd "hanami console --help", output end end # TODO: test with pry # TODO: test with ripl end