Skip to content

Commit ce6a076

Browse files
authored
refactor: Move from rspec to minitest (#18)
test: Add cucumber features for issue completion, and whoami commands refactor: Adds trailblazer gem and operations for some commands
1 parent 0eb665a commit ce6a076

38 files changed

+386
-152
lines changed

.rspec

Lines changed: 0 additions & 3 deletions
This file was deleted.

.rubocop.yml

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,39 @@
11
---
22
plugins:
3+
- rubocop-minitest
4+
- rubocop-performance
35
- rubocop-rake
4-
- rubocop-rspec
56

67
AllCops:
78
TargetRubyVersion: 3.4.0
89
NewCops: enable
10+
SuggestExtensions: false
11+
12+
Metrics/ClassLength:
13+
CountAsOne: ['array', 'heredoc', 'hash']
14+
Max: 115
15+
16+
Metrics/ModuleLength:
17+
CountAsOne: ['array', 'heredoc', 'hash']
18+
Max: 115
19+
Exclude:
20+
- 'spec/**/*.rb'
21+
22+
Metrics/MethodLength:
23+
CountAsOne: ['array', 'heredoc', 'hash']
24+
25+
Metrics/BlockLength:
26+
CountAsOne: ['array', 'heredoc', 'hash']
27+
Exclude:
28+
- 'test/**/*'
29+
- '*.gemspec'
30+
31+
Layout/LineLength:
32+
Max: 120
33+
AllowedPatterns: ['\A#']
34+
35+
Style/CommentedKeyword:
36+
Enabled: false
937

1038
Style/StringLiterals:
1139
Enabled: true
@@ -14,6 +42,3 @@ Style/StringLiterals:
1442
Style/StringLiteralsInInterpolation:
1543
Enabled: true
1644
EnforcedStyle: double_quotes
17-
18-
Layout/LineLength:
19-
Max: 120

Gemfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ group :development, :test do
99
gem 'changelog-rb', '~> 0.3'
1010
gem 'cucumber', '~> 9.1'
1111
gem 'gem-release', '~> 2.2'
12+
gem 'minitest', '~> 5.0'
1213
gem 'rake', '~> 13.0'
13-
gem 'rspec', '~> 3.0'
1414
gem 'rubocop', '~> 1.21'
15+
gem 'rubocop-minitest', require: false
16+
gem 'rubocop-performance', require: false
1517
gem 'rubocop-rake', require: false
16-
gem 'rubocop-rspec', require: false
18+
gem 'shoulda-context', '~> 2.0'
1719
end
1820

1921
# Specify your gem's dependencies in linear-cli.gemspec

Rakefile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
# frozen_string_literal: true
22

33
require 'bundler/gem_tasks'
4-
require 'rspec/core/rake_task'
4+
require 'rake/testtask'
55

6-
RSpec::Core::RakeTask.new(:spec)
6+
Rake::TestTask.new(:test) do |t|
7+
t.libs << 'test'
8+
t.libs << 'lib'
9+
t.test_files = FileList['test/**/*_test.rb']
10+
end
711

812
require 'rubocop/rake_task'
913

1014
RuboCop::RakeTask.new
1115

12-
task default: %i[spec rubocop]
16+
desc 'Run Cucumber features'
17+
task :cucumber do
18+
sh 'cucumber --format pretty'
19+
end
20+
21+
task default: %i[rubocop test cucumber]

exe/scripts/lc.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ elif [ $result -gt 1 ]; then
2929
printf "\n\nlc: linear-cli interrupted\n" >&2
3030
exit 130
3131
fi
32-
printf "lc: linear-cli failed %s\n" $result >&2
33-
lc "$@" --help 2>&1
34-
exit 1
32+
exit $result
3533
fi
34+
exit $result

features/completion.feature

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ Feature: Completion
66
# TODO: Make this not raise an exception and just show the usage instead
77
Scenario: Showing exception when no shell is given
88
When I run `lc completion`
9-
Then the output should contain:
10-
"""
11-
missing keyword: :shell (ArgumentError)
12-
"""
9+
Then the output should match /missing keyword: :shell \(ArgumentError\)/
1310

1411
Scenario: Showing exception when an invalid shell is given
1512
When I run `lc completion invalid`
@@ -22,5 +19,9 @@ Feature: Completion
2219
When I run `lc completion bash`
2320
Then the output should contain:
2421
"""
25-
# lc completion -*- shell-script -*-
22+
# linear-cli completion -*- shell-script -*-
23+
"""
24+
And the output should contain:
25+
"""
26+
complete -F _linear-cli_completions lc
2627
"""

features/issue_list.feature

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Feature: Issue List
2+
As a user
3+
I want to list issues
4+
So that I can see what I need to work on
5+
6+
Scenario: Listing my issues
7+
When I run `lc issue list`
8+
Then the output should match /[\w-]+/
9+
10+
Scenario: Listing all issues
11+
When I run `lc issue list --no-mine`
12+
Then the output should match /[\w-]+/
13+
14+
Scenario: Listing specific issue
15+
When I run `lc issue list NOCRY-123`
16+
Then the exit status should be 66
17+
And the output should match /Record not found/

features/team_list.feature

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Feature: Team List
2+
As a user
3+
I want to list teams
4+
So that I can see what teams are available
5+
6+
Scenario: Listing my teams
7+
When I run `lc team list`
8+
Then the output should match /[\w-]+/
9+
10+
Scenario: Listing all teams
11+
When I run `lc team list --no-mine`
12+
Then the output should match /[\w-]+/

features/whoami.feature

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Feature: WhoAmI
2+
As a user
3+
I want to know who I am logged in as
4+
So that I can verify my credentials
5+
6+
Scenario: Displaying the current user
7+
When I run `lc whoami`
8+
Then the output should match /[\w-]+: .+ <.+>/

lib/linear.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# frozen_string_literal: true
22

33
require 'pathname'
4+
require 'trailblazer'
5+
require 'trailblazer/operation'
46
require 'semantic_logger'
57
SemanticLogger.default_level = :info
68
SemanticLogger.add_appender(io: $stderr, formatter: :color)
@@ -21,6 +23,7 @@ module Linear
2123
ROOT = (Pathname(__FILE__)/'../..').expand_path
2224
LIBROOT = ROOT/:lib/:linear
2325
MODEL_ROOT = ROOT/:lib/:linear/:models
26+
OPERATION_ROOT = ROOT/:lib/:linear/:operations
2427
SPEC_ROOT = ROOT/:spec
2528
FEATURE_ROOT = ROOT/:features
2629
DEBUG_LEVELS = %i[warn info debug trace].freeze
@@ -41,6 +44,10 @@ def self.L(*libraries) # rubocop:disable Naming/MethodName
4144
def self.M(*models) # rubocop:disable Naming/MethodName
4245
Array(models).each { |model| require MODEL_ROOT/model }
4346
end
47+
48+
def self.O(*operations) # rubocop:disable Naming/MethodName
49+
Array(operations).each { |operation| require OPERATION_ROOT/operation }
50+
end
4451
# rubocop:enable Layout/SpaceAroundOperators
4552

4653
def self.verbosity

0 commit comments

Comments
 (0)