Skip to content

Commit

Permalink
Rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
robotdana committed Dec 3, 2023
1 parent 1cef205 commit cad03d2
Show file tree
Hide file tree
Showing 20 changed files with 314 additions and 207 deletions.
5 changes: 3 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ AllCops:
- .bundle/**/*
- tmp/**/*
- vendor/**/*
- github-cctray/**/*
DisplayCopNames: true
DisplayStyleGuide: true

Expand Down Expand Up @@ -59,14 +60,14 @@ Metrics:
CountComments: false

Metrics/BlockLength:
ExcludedMethods:
AllowedMethods:
- configure
- describe
- context
- it

Layout/LineLength:
Max: 80
Max: 120
IgnoreCopDirectives: true

Metrics/MethodLength:
Expand Down
1 change: 1 addition & 0 deletions .spellr_wordlists/english.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ coreaudiod
cppflags
cruisecontrol
cwd
cyclomatic
dest
diffable
diffr
Expand Down
77 changes: 39 additions & 38 deletions Brewfile
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
tap "heroku/brew"
tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/cask-fonts"
tap "homebrew/core"
tap "homebrew/services"
brew "fnm"
brew "rust"
brew "pcre"
brew "bash"
brew "chruby"
brew "ruby-install"
brew "exercism"
brew "diffr"
brew "git"
brew "git-lfs"
brew "gnupg"
brew "jq"
brew "pinentry-mac"
brew "pkg-config"
brew "rbspy"
brew "shellcheck"
brew "wget"
brew "yq"
cask "finicky"
cask "textmate"
cask "1password"
cask "docker"
cask "dropbox"
cask "firefox"
cask "font-inconsolata"
cask "google-chrome"
cask "istat-menus"
cask "visual-studio-code"
cask "ccmenu"
cask "slack"
cask "spotify"
cask "textmate"
# frozen_string_literal: true

tap 'heroku/brew'
tap 'homebrew/bundle'
tap 'homebrew/cask'
tap 'homebrew/cask-fonts'
tap 'homebrew/core'
tap 'homebrew/services'
brew 'fnm'
brew 'rust'
brew 'pcre'
brew 'bash'
brew 'chruby'
brew 'ruby-install'
brew 'exercism'
brew 'diffr'
brew 'git'
brew 'git-lfs'
brew 'gnupg'
brew 'jq'
brew 'pinentry-mac'
brew 'pkg-config'
brew 'rbspy'
brew 'shellcheck'
brew 'wget'
brew 'yq'
cask 'finicky'
cask 'textmate'
cask '1password'
cask 'docker'
cask 'dropbox'
cask 'firefox'
cask 'font-inconsolata'
cask 'google-chrome'
cask 'istat-menus'
cask 'visual-studio-code'
cask 'ccmenu'
cask 'slack'
cask 'spotify'
cask 'textmate'
8 changes: 5 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gem 'spellr'
gem 'rspec'
gem 'tty_string'
gem 'pry'
gem 'rspec'
gem 'rubocop'
gem 'rubocop-rspec'
gem 'spellr'
gem 'tty_string'
54 changes: 28 additions & 26 deletions spec/bash_support_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

COLOR_RED = ENV.fetch('COLOR_RED')
COLOR_GREEN = ENV.fetch('COLOR_GREEN')
COLOR_YELLOW = ENV.fetch('COLOR_YELLOW')
Expand All @@ -11,14 +13,14 @@
RSpec.describe 'bash_support' do
it 'returns current ruby version' do
copy_file '.ruby-version'
expect(run 'ruby -v').to have_output(
expect(run('ruby -v')).to have_output(
"ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin22]\n"
)
end

describe 'echoerr' do
it 'returns red text for echoerr' do
expect(run 'echoerr No', expect_exit: 1).to have_output(
expect(run('echoerr No', expect_exit: 1)).to have_output(
stderr: "#{COLOR_RED}error: No#{COLOR_RESET}\n",
stdout: nil
)
Expand All @@ -27,156 +29,156 @@

describe 'echodo' do
it 'returns grey text for echodo to stderr and does the thing to stdout' do
expect(run "echodo echo 1").to have_output(
expect(run('echodo echo 1')).to have_output(
stderr: "#{COLOR_GREY}echo 1#{COLOR_RESET}\n",
stdout: "1\n"
)
end

it 'removes unnecessary single quotes' do
expect(run "echodo echo '1'").to have_output(
expect(run("echodo echo '1'")).to have_output(
stderr: "#{COLOR_GREY}echo 1#{COLOR_RESET}\n",
stdout: "1\n"
)
end

it 'removes unnecessary double quotes' do
expect(run 'echodo echo "1"').to have_output(
expect(run('echodo echo "1"')).to have_output(
stderr: "#{COLOR_GREY}echo 1#{COLOR_RESET}\n",
stdout: "1\n"
)
end

it 'retains quoted empty double quoted strings' do
expect(run 'echodo echo ""').to have_output(
expect(run('echodo echo ""')).to have_output(
stderr: "#{COLOR_GREY}echo ''#{COLOR_RESET}\n",
stdout: "\n"
)
end

it 'retains quoted empty single quoted strings' do
expect(run "echodo echo ''").to have_output(
expect(run("echodo echo ''")).to have_output(
stderr: "#{COLOR_GREY}echo ''#{COLOR_RESET}\n",
stdout: "\n"
)
end

it 'uses single quotes to escape spaces when given a single quoted string' do
expect(run "echodo echo '1 and 2'").to have_output(
expect(run("echodo echo '1 and 2'")).to have_output(
stderr: "#{COLOR_GREY}echo '1 and 2'#{COLOR_RESET}\n",
stdout: "1 and 2\n"
)
end

it 'uses single quotes to escape spaces when given a double quoted string' do
expect(run 'echodo echo "1 and 2"').to have_output(
expect(run('echodo echo "1 and 2"')).to have_output(
stderr: "#{COLOR_GREY}echo '1 and 2'#{COLOR_RESET}\n",
stdout: "1 and 2\n"
)
end

it 'uses single quotes to escape spaces when given a backslash escaped string' do
expect(run "echodo echo 1\\ and\\ 2").to have_output(
expect(run('echodo echo 1\\ and\\ 2')).to have_output(
stderr: "#{COLOR_GREY}echo '1 and 2'#{COLOR_RESET}\n",
stdout: "1 and 2\n"
)
end

it 'uses single quotes to escape \\(whatever\\)' do
expect(run "echodo echo \\(whatever\\)").to have_output(
expect(run('echodo echo \\(whatever\\)')).to have_output(
stderr: "#{COLOR_GREY}echo '(whatever)'#{COLOR_RESET}\n",
stdout: "(whatever)\n"
)
end

it "uses single quotes to escape '(whatever)'" do
expect(run "echodo echo '(whatever)'").to have_output(
expect(run("echodo echo '(whatever)'")).to have_output(
stderr: "#{COLOR_GREY}echo '(whatever)'#{COLOR_RESET}\n",
stdout: "(whatever)\n"
)
end

it "uses single quotes to escape '[whatever]" do
expect(run "echodo echo '[whatever]'").to have_output(
expect(run("echodo echo '[whatever]'")).to have_output(
stderr: "#{COLOR_GREY}echo '[whatever]'#{COLOR_RESET}\n",
stdout: "[whatever]\n"
)
end

it "uses single quotes to escape 'what)ever]'" do
expect(run "echodo echo 'what)ever]'").to have_output(
expect(run("echodo echo 'what)ever]'")).to have_output(
stderr: "#{COLOR_GREY}echo 'what)ever]'#{COLOR_RESET}\n",
stdout: "what)ever]\n"
)
end

it "uses single quotes to escape 'what) ever]'" do
expect(run "echodo echo 'what) ever]'").to have_output(
expect(run("echodo echo 'what) ever]'")).to have_output(
stderr: "#{COLOR_GREY}echo 'what) ever]'#{COLOR_RESET}\n",
stdout: "what) ever]\n"
)
end

it "uses single quotes to escape 'what)ever'" do
expect(run "echodo echo 'what)ever'").to have_output(
expect(run("echodo echo 'what)ever'")).to have_output(
stderr: "#{COLOR_GREY}echo 'what)ever'#{COLOR_RESET}\n",
stdout: "what)ever\n"
)
end

it "uses single quotes to escape 'what>ever'" do
expect(run "echodo echo 'what>ever'").to have_output(
expect(run("echodo echo 'what>ever'")).to have_output(
stderr: "#{COLOR_GREY}echo 'what>ever'#{COLOR_RESET}\n",
stdout: "what>ever\n"
)
end

it "uses single quotes to escape 'what<ever'" do
expect(run "echodo echo 'what<ever'").to have_output(
expect(run("echodo echo 'what<ever'")).to have_output(
stderr: "#{COLOR_GREY}echo 'what<ever'#{COLOR_RESET}\n",
stdout: "what<ever\n"
)
end

it "uses single quotes to escape 'what\\n\\never'" do
expect(run "echodo echo 'what\n\never'").to have_output(
expect(run("echodo echo 'what\n\never'")).to have_output(
stderr: "#{COLOR_GREY}echo 'what\n\never'#{COLOR_RESET}\n",
stdout: "what\n\never\n"
)
end

it "uses single quotes to escape '$dance'" do
expect(run "echodo echo '$dance'").to have_output(
expect(run("echodo echo '$dance'")).to have_output(
stderr: "#{COLOR_GREY}echo '$dance'#{COLOR_RESET}\n",
stdout: "$dance\n"
)
end

it %{uses single quotes to escape '"$dance"'} do
expect(run %{echodo echo '"$dance"'}).to have_output(
expect(run(%{echodo echo '"$dance"'})).to have_output(
stderr: %{#{COLOR_GREY}echo '"$dance"'#{COLOR_RESET}\n},
stdout: %{"$dance"\n}
)
end

it 'uses double quotes to escape single quotes' do
expect(run "echodo echo don\\'t").to have_output(
expect(run("echodo echo don\\'t")).to have_output(
stderr: %{#{COLOR_GREY}echo "don't"#{COLOR_RESET}\n},
stdout: "don't\n"
)
end

it 'uses single quotes to escape double quotes' do
expect(run %{echodo echo 'do or do not there is no "try"'})
expect(run(%{echodo echo 'do or do not there is no "try"'}))
.to have_output(
stderr: %{#{COLOR_GREY}echo 'do or do not there is no \"try\"'#{COLOR_RESET}\n},
stderr: %{#{COLOR_GREY}echo 'do or do not there is no "try"'#{COLOR_RESET}\n},
stdout: %{do or do not there is no "try"\n}
)
end

it 'uses double quotes to escape both types of quotes' do
# because "\"" works and '\'' doesn't
expect(run %{echodo echo "do or don't "'there is no "try"'})
expect(run(%{echodo echo "do or don't "'there is no "try"'}))
.to have_output(
stderr: %{#{COLOR_GREY}echo "do or don't there is no \\"try\\""#{COLOR_RESET}\n},
stdout: %{do or don't there is no "try"\n}
Expand All @@ -187,7 +189,7 @@
# I never want history expansion
# so I `set +H` in bash_profile
# so I don't need to escape `!`
expect(run %{echodo echo !}).to have_output(
expect(run(%{echodo echo !})).to have_output(
stderr: %{#{COLOR_GREY}echo !#{COLOR_RESET}\n},
stdout: %{!\n}
)
Expand Down
28 changes: 15 additions & 13 deletions spec/git_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,45 +1,47 @@
# frozen_string_literal: true

RSpec.describe 'git helper spec' do
describe 'git_web_url' do
before { git("init") }
before { git('init') }

it 'returns the github web url for https git' do
git("remote add origin https://github.com/robotdana/dotfiles.git")
expect(run 'git_web_url').to have_output(
git('remote add origin https://github.com/robotdana/dotfiles.git')
expect(run('git_web_url')).to have_output(
"https://github.com/robotdana/dotfiles\n"
)
end

it 'returns the github web url for ssh git' do
git("remote add upstream [email protected]:robotdana/dotfiles.git")
expect(run 'git_web_url upstream').to have_output(
git('remote add upstream [email protected]:robotdana/dotfiles.git')
expect(run('git_web_url upstream')).to have_output(
"https://github.com/robotdana/dotfiles\n"
)
end

it 'returns the bitbucket web url for https git' do
git("remote add origin https://bitbucket.org/robotdana/dotfiles.git")
expect(run 'git_web_url').to have_output(
git('remote add origin https://bitbucket.org/robotdana/dotfiles.git')
expect(run('git_web_url')).to have_output(
"https://bitbucket.org/robotdana/dotfiles\n"
)
end

it 'returns the bitbucket web url for ssh git' do
git("remote add upstream [email protected]:robotdana/dotfiles.git")
expect(run 'git_web_url upstream').to have_output(
git('remote add upstream [email protected]:robotdana/dotfiles.git')
expect(run('git_web_url upstream')).to have_output(
"https://bitbucket.org/robotdana/dotfiles\n"
)
end

it 'returns the gitlab web url for https git' do
git("remote add origin https://gitlab.com/robotdana/dotfiles.git")
expect(run 'git_web_url').to have_output(
git('remote add origin https://gitlab.com/robotdana/dotfiles.git')
expect(run('git_web_url')).to have_output(
"https://gitlab.com/robotdana/dotfiles\n"
)
end

it 'returns the gitlab web url for ssh git' do
git("remote add upstream [email protected]:robotdana/dotfiles.git")
expect(run 'git_web_url upstream').to have_output(
git('remote add upstream [email protected]:robotdana/dotfiles.git')
expect(run('git_web_url upstream')).to have_output(
"https://gitlab.com/robotdana/dotfiles\n"
)
end
Expand Down
Loading

0 comments on commit cad03d2

Please sign in to comment.