-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
71 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe '`fakerbot search` command', type: :cli do | ||
it 'executes `fakerbot help search` command successfully' do | ||
output = `fakerbot help search` | ||
expected_output = <<~OUT | ||
Usage: | ||
fakerbot search [Faker] | ||
Options: | ||
-h, [--help], [--no-help] # Display usage information | ||
-v, [--verbose], [--no-verbose] # Display Faker constants methods with examples | ||
Search Faker method(s) | ||
OUT | ||
|
||
expect(output).to eq(expected_output) | ||
end | ||
|
||
context 'when search query exists' do | ||
it 'returns results' do | ||
output = `fakerbot search name` | ||
expect(output).to match(/Faker::/) | ||
expect(output).to match(/└──/) | ||
end | ||
end | ||
|
||
context 'when search query does not exist' do | ||
it 'returns a not found message' do | ||
output = `fakerbot search asdasdhk` | ||
expect(output).to match(/Sorry, we couldn't find a match/) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
require 'fakerbot/commands/search' | ||
|
||
RSpec.describe FakerBot::Commands::Search do | ||
let(:output) { StringIO.new } | ||
let(:options) { {} } | ||
let(:command) { described_class.new(options) } | ||
|
||
context 'when query object exists' do | ||
before do | ||
command.execute('image', output: output) | ||
end | ||
|
||
it 'returns results' do | ||
expect(output.string).to match(/Faker/) | ||
expect(output.string.lines.size).to be_positive | ||
end | ||
end | ||
|
||
context 'when query object does not exist' do | ||
before do | ||
command.execute('hasjdhaksjd', output: output) | ||
end | ||
|
||
it 'returns nil' do | ||
expect(output.string).to be_empty | ||
end | ||
end | ||
end |