Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to fix failures related to changes in Thor 1.3.0 #913

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion test/lib/maintenance_tasks/cli_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ class CLITest < ActiveSupport::TestCase
OUTPUT

assert_output(Regexp.union(expected_output)) do
Thor::Base.shell.any_instance.stubs(:terminal_width).returns(200)
CLI.start(["help", "perform"])
end
end
Expand Down
3 changes: 3 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# Configure Rails Environment
ENV["RAILS_ENV"] = "test"

# Don't wrap output in tests
ENV["THOR_COLUMNS"] = "200"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirmed this had the expected consequence for both Thor 1.2.2 and Thor 1.3.0:

      require "thor/version"
      puts Thor::VERSION
      if Thor::VERSION >= "1.3.0"
        assert_equal 200, Thor::Shell::Terminal.terminal_width
      else
        assert_equal 200, Thor::Base.shell.new.terminal_width
      end

Unfortunately, the output is still wrapped when using Thor 1.3.0:

Failure:
MaintenanceTasks::CLITest#test_`help_perform`_loads_all_tasks_and_displays_them [test/lib/maintenance_tasks/cli_test.rb:104]:
In stdout.
Expected /\ \ `maintenance_tasks\ perform`\ will\ run\ the\ Maintenance\ Task\ specified\ by\ the\ \[TASK\ NAME\]\ argument\.\n\n\ \ Available\ Tasks:\n\n\ \ Task1\n\n\ \ Task2\n/ to match "Usage:\n  cli_test.rb perform [TASK NAME]\n\nOptions:\n  [--csv=CSV]              # Supply a CSV file to be processed by a CSV Task, --csv path/to/csv/file.csv\n  [--arguments=key:value]  # Supply arguments for a Task that accepts parameters as a set of <key>:<value> pairs.\n\nDescription:\n`maintenance_tasks perform` will run the Maintenance Task specified by\nthe [TASK NAME] argument.\n\nAvailable Tasks:\n\nTask1\n\nTask2\n".

Cleaning up, we have:

Failure:
MaintenanceTasks::CLITest#test_`help_perform`_loads_all_tasks_and_displays_them [test/lib/maintenance_tasks/cli_test.rb:104]:
In stdout.
Expected /
  `maintenance_tasks perform` will run the Maintenance Task specified by the [TASK NAME] argument.

  Available Tasks:

  Task1

  Task2
/ to match "
Usage:
  cli_test.rb perform [TASK NAME]
Options:
  [--csv=CSV]              # Supply a CSV file to be processed by a CSV Task, --csv path/to/csv/file.csv
  [--arguments=key:value]  # Supply arguments for a Task that accepts parameters as a set of <key>:<value> pairs.

Description:
`maintenance_tasks perform` will run the Maintenance Task specified by
the [TASK NAME] argument.

Available Tasks:

Task1

Task2
".
  1. Thor CLI output was cut after specified by (70 characters), even though Thor::Shell::Terminal.terminal_width returns 200.
  2. The Thor CLI output also seems to be missing indentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirmed the CLI output changed:

Before

Usage:
  maintenance_tasks perform [TASK NAME]

Options:
  [--csv=CSV]              # Supply a CSV file to be processed by a CSV Task, --csv path/to/csv/file.csv
  [--arguments=key:value]  # Supply arguments for a Task that accepts parameters as a set of <key>:<value> pairs.

Description:
  `maintenance_tasks perform` will run the Maintenance Task specified by the [TASK NAME] argument.

  Available Tasks:

  Maintenance::BatchImportPostsTask

  Maintenance::CallbackTestTask

  etc...

After

cd test/dummy && ../../exe/maintenance_tasks help perform
Usage:
  maintenance_tasks perform [TASK NAME]

Options:
  [--csv=CSV]              # Supply a CSV file to be processed by a CSV Task, --csv path/to/csv/file.csv
  [--arguments=key:value]  # Supply arguments for a Task that accepts parameters as a set of <key>:<value> pairs.

Description:
`maintenance_tasks perform` will run the Maintenance Task specified by
the [TASK NAME] argument.

Available Tasks:

Maintenance::BatchImportPostsTask

Maintenance::CallbackTestTask

etc...

The description is now cut at 70 at not indented.


require_relative "../test/dummy/config/environment"
ActiveRecord::Migrator.migrations_paths =
[File.expand_path("../test/dummy/db/migrate", __dir__)]
Expand Down
Loading