Skip to content

Commit f95b41b

Browse files
authored
Add CLI specs using aruba gem (#43)
This PR adds `aruba` to the project and also adds some CLI specs. This is my first time using the gem so there may be better ways of doing things.
1 parent bb37f5b commit f95b41b

File tree

4 files changed

+36
-5
lines changed

4 files changed

+36
-5
lines changed

Gemfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ gem "rake"
66
gem "rspec"
77

88
group :development, :test do
9+
gem "aruba", "~> 2.1.0", require: false
910
gem "byebug"
1011
gem "guard-rspec", require: false
1112

@@ -17,7 +18,3 @@ group :development, :test do
1718
gem "pry-byebug", require: false
1819
end
1920
end
20-
21-
group :test do
22-
gem "git", require: false
23-
end

exe/annotaterb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env ruby
22
# frozen_string_literal: true
33

4-
unless File.exist?("./Rakefile") || File.exist?("./Gemfile")
4+
if !File.exist?("./Rakefile") && !File.exist?("./Gemfile")
55
abort "Please run annotaterb from the root of the project."
66
end
77

spec/integration/cli.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# frozen_string_literal: true
2+
3+
RSpec.describe "CLI", type: "aruba" do
4+
context "when running in a non-Rails project directory" do
5+
before do
6+
# Assumes there's no Rakefile or Gemfile
7+
run_command("annotaterb")
8+
end
9+
10+
let(:error_message) { "Please run annotaterb from the root of the project." }
11+
12+
it "exits and outputs an error message" do
13+
expect(last_command_started).to have_exit_status(1)
14+
expect(last_command_started).to have_output_on_stderr(error_message)
15+
end
16+
end
17+
18+
context "when running in a directory with a Rakefile and a Gemfile" do
19+
before do
20+
touch("Rakefile", "Gemfile")
21+
run_command("annotaterb")
22+
end
23+
24+
let(:help_banner_fragment) { "Usage: annotaterb [command] [options]" }
25+
26+
it "outputs the help message" do
27+
expect(last_command_started).to be_successfully_executed
28+
expect(last_command_started.stdout).to include(help_banner_fragment)
29+
end
30+
end
31+
end

spec/support/aruba.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# frozen_string_literal: true
2+
3+
require "aruba/rspec"

0 commit comments

Comments
 (0)