Skip to content

Commit

Permalink
Merge pull request #6 from apainintheneck/add-command-tests
Browse files Browse the repository at this point in the history
Add command tests
  • Loading branch information
apainintheneck authored Dec 8, 2024
2 parents 8b86c19 + 33ebb99 commit fbb2934
Show file tree
Hide file tree
Showing 12 changed files with 2,323 additions and 7 deletions.
7 changes: 4 additions & 3 deletions lib/gemview/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@ def call(*)
register "author", Author
register "releases", Releases
register "updates", Updates
register "version", Version, aliases: ["v", "-v", "--version"]
register "version", Version

def self.start
Dry::CLI.new(self).call
# @param arguments [Array<String>] defaults to ARGV
def self.start(arguments: ARGV)
Dry::CLI.new(self).call(arguments: arguments)
end
end
end
4 changes: 2 additions & 2 deletions lib/gemview/terminal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ def self.page(content)
end

# @param prompt [String]
# @param choices [Array<String>] where all choices are unique
# @param choices [Array<String>] or [Hash<String, String>] where all choices are unique
# @yield [String] yields until the user exits the prompt gracefully
def self.choose(message, choices, per_page: 6)
def self.choose(message:, choices:, per_page: 6)
while (choice = selector.select(message, choices, per_page))
yield choice
end
Expand Down
4 changes: 2 additions & 2 deletions lib/gemview/view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def self.info(gem:)
More info:
PROMPT

Terminal.choose(prompt, %w[Readme Changelog Dependencies Versions]) do |choice|
Terminal.choose(message: prompt, choices: %w[Readme Changelog Dependencies Versions]) do |choice|
case choice
when "Readme"
Terminal.page([gem.header_str, gem.fetch_readme].join("\n"))
Expand All @@ -30,7 +30,7 @@ def self.list(gems:)
[gem.selector_str, gem]
end

Terminal.choose("What gem would you like to look at?", gems_by_description) do |gem|
Terminal.choose(message: "What gem would you like to look at?", choices: gems_by_description) do |gem|
info(gem: gem)
end
end
Expand Down
505 changes: 505 additions & 0 deletions spec/fixtures/cassettes/gem-versions-for-standard.yml

Large diffs are not rendered by default.

76 changes: 76 additions & 0 deletions spec/fixtures/cassettes/standard-gem-readme.yml

Large diffs are not rendered by default.

Loading

0 comments on commit fbb2934

Please sign in to comment.