Skip to content

Commit

Permalink
Fix all automated tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
vkononov committed Feb 2, 2024
1 parent 04a9419 commit 1984040
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 9 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,22 @@ gem install package-audit
package-audit --group staging --group production [DIR]
```

* To show how risk is calculated for the above report run:
* To produce the same report in a CSV format run:

```bash
package-audit risk
package-audit --format csv
```

* To produce the same report in a CSV format run:
* To produce the same report in a Markdown format run:

```bash
package-audit --format md
```

* To show how risk is calculated for the above report run:

```bash
package-audit --csv
package-audit risk
```

#### For a list of all commands and their options run:
Expand Down
22 changes: 20 additions & 2 deletions test/package/audit/test_cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
module Package
module Audit
class Cli < Minitest::Test
def test_that_it_the_version_command_works
def test_that_it_version_command_works
output = `bundle exec package-audit --version`

assert_match VERSION, output
end

def test_that_it_the_risk_command_works
def test_that_it_risk_command_works
output = `bundle exec package-audit risk`

stdout = StringIO.new
Expand All @@ -37,6 +37,24 @@ def test_that_unknown_commands_give_an_appropriate_error
assert_match '"invalid" is not a valid directory', output
end

def test_that_that_config_option_works
output = `bundle exec package-audit test/files/gemfile/empty --config test/files/config/.package-audit.yml`

assert_match 'There are no deprecated, outdated or vulnerable ruby packages!', output
end

def test_that_that_config_option_alias_works
output = `bundle exec package-audit test/files/gemfile/empty -c test/files/config/.package-audit.yml`

assert_match 'There are no deprecated, outdated or vulnerable ruby packages!', output
end

def test_that_that_config_option_returns_an_appropriate_error
output = `bundle exec package-audit test/files/gemfile/empty -c test/files/config/invalid`

assert_match 'Configuration file not found: test/files/config/invalid', output
end

def test_that_that_include_ignored_option_works
output = `bundle exec package-audit test/files/gemfile/empty --include-ignored`

Expand Down
5 changes: 2 additions & 3 deletions test/package/audit/test_printer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_that_an_error_is_shown_for_invalid_fields
end
end

def test_that_the_dependencies_are_displayed_correctly
def test_that_the_dependencies_are_displayed_correctly # rubocop:disable Metrics/AbcSize
PackagePrinter.new({}, @gems).print(%i[name version latest_version latest_version_date])
lines = @output.string.split("\n")

Expand All @@ -55,7 +55,7 @@ def test_that_the_dependencies_are_displayed_correctly
assert_equal "rails #{Util::BashColor.orange('6.0.0')} 7.0.4.3 #{@today} ", lines[5]
end

def test_that_the_dependencies_are_displayed_correctly_in_markdown
def test_that_the_dependencies_are_displayed_correctly_in_markdown # rubocop:disable Metrics/AbcSize
options = {Enum::Option::FORMAT => Enum::Format::MARKDOWN}
PackagePrinter.new(options, @gems).print(%i[name version latest_version latest_version_date])
lines = @output.string.split("\n")
Expand All @@ -66,7 +66,6 @@ def test_that_the_dependencies_are_displayed_correctly_in_markdown
assert_equal "| fileutils | 1.#{Util::BashColor.yellow('5.0')} | 1.7.1 | #{@today} |", lines[2]
assert_equal "| puma | 5.1.1 | 5.1.1 | #{Util::BashColor.yellow('2020-12-10')} |", lines[3]
assert_equal "| rails | #{Util::BashColor.orange('6.0.0')} | 7.0.4.3 | #{@today} |", lines[4]

end

def test_that_the_dependencies_are_displayed_correctly_in_csv_with_headers # rubocop:disable Metrics/AbcSize
Expand Down

0 comments on commit 1984040

Please sign in to comment.