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

Refs #7451 - allow skipping message tests #292

Merged
merged 1 commit into from Nov 7, 2018

Conversation

Projects
None yet
4 participants
@tstrachota
Copy link
Member

tstrachota commented Oct 26, 2018

No description provided.

@ofedoren
Copy link
Member

ofedoren left a comment

I think we could extend the checking process somehow, see the inline comment.

all_subcommands(main_cmd, parent).each do |cmd|
next if except.any? { |except_cmd| cmd == except_cmd }

This comment has been minimized.

@ofedoren

ofedoren Oct 26, 2018

Member

This will skip the whole command, but what if we want to skip checking the success message only and be sure that description hasn't a period at the end?

I'd suggest some changes:

  def check_command_messages(cmd, except = nil)
    except ||= []
    cmd.recognised_options.each do |opt|
      check_option_description(cmd, opt)
    end
    # we could skip checking only particular messages from a command
    refute_msg_period(cmd, :desc) unless except.include?(:desc)
    assert_msg_period(cmd, :success_message) unless except.include?(:success_message)
    refute_msg_period(cmd, :failure_message) unless except.include?(:failure_message)
  end

  def check_all_command_messages(main_cmd, parent = HammerCLI::AbstractCommand, opts = {})
    except = opts[:except] || {}

    all_subcommands(main_cmd, parent).each do |cmd|
      # skip the whole command if nothing particular was specified
      next if except.key?(cmd.to_s) && except[cmd.to_s].empty?
      it "test messages of #{cmd}" do
        check_command_messages(cmd, except[cmd.to_s])
      end
    end
  end

Those changes would lead to changes in theforeman/hammer-cli-foreman#352 as:

  check_all_command_messages(
    HammerCLI::MainCommand,
    HammerCLIForeman::Command,
    except: {
      'HammerCLIForeman::PersonalAccessToken::CreateCommand' => [:success_message]
    }
  )
@@ -42,8 +42,11 @@ def check_command_messages(cmd)
refute_msg_period(cmd, :failure_message)
end

def check_all_command_messages(main_cmd, parent=HammerCLI::AbstractCommand)
def check_all_command_messages(main_cmd, parent=HammerCLI::AbstractCommand, opts = {})

This comment has been minimized.

@mbacovsky

mbacovsky Oct 29, 2018

Member

@tstrachota what do you think about keyword argument for except?

@tstrachota tstrachota changed the title Refx #7451 - allow skipping message tests Refs #7451 - allow skipping message tests Nov 1, 2018

@tstrachota tstrachota force-pushed the tstrachota:exclude_msg_tests branch from 12dae9b to 91103ab Nov 1, 2018

@tstrachota

This comment has been minimized.

Copy link
Member Author

tstrachota commented Nov 1, 2018

@ofedoren

This comment has been minimized.

Copy link
Member

ofedoren commented Nov 7, 2018

@tstrachota, works nice, I've got nothing to add :)

@mbacovsky

This comment has been minimized.

Copy link
Member

mbacovsky commented Nov 7, 2018

👍 Thanks @tstrachota, @ofedoren

@mbacovsky mbacovsky merged commit 61bd20f into theforeman:master Nov 7, 2018

1 check passed

hammer Build finished. 2007 tests run, 0 skipped, 0 failed.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.