repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/config/routes.rb | config/routes.rb | Langchain::Engine.routes.draw do
end
| ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
patterns-ai-core/langchainrb | https://github.com/patterns-ai-core/langchainrb/blob/fca40568a1d5632d9efc8cf8779343bbbe03dc99/config/initializers/inflections.rb | config/initializers/inflections.rb | ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.acronym "AI21"
inflect.acronym "CSV"
inflect.acronym "HTML"
inflect.acronym "JSON"
inflect.acronym "JSONL"
inflect.acronym "LLM"
inflect.acronym "PDF"
inflect.acronym "OpenAI"
inflect.acronym "OpenAIResponse"
inflect.acronym "OpenAIMessa... | ruby | MIT | fca40568a1d5632d9efc8cf8779343bbbe03dc99 | 2026-01-04T15:59:30.394142Z | false |
sidekiq-cron/sidekiq-cron | https://github.com/sidekiq-cron/sidekiq-cron/blob/7b4ae4822f93ef4646f5cb55500ca4e25662db7c/test/test_helper.rb | test/test_helper.rb | $TESTING = true
ENV['RACK_ENV'] = 'test'
require 'simplecov'
if ENV['CI']
require 'simplecov-cobertura'
SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
end
SimpleCov.start do
add_filter 'test/'
add_group 'Sidekiq-Cron', 'lib/'
end
require 'minitest/autorun'
require 'rack/test'
require 'mocha/... | ruby | MIT | 7b4ae4822f93ef4646f5cb55500ca4e25662db7c | 2026-01-04T15:59:43.787029Z | false |
sidekiq-cron/sidekiq-cron | https://github.com/sidekiq-cron/sidekiq-cron/blob/7b4ae4822f93ef4646f5cb55500ca4e25662db7c/test/support/helpers.rb | test/support/helpers.rb | def capture_logging(level:)
original_logger = Sidekiq.logger
logdev = StringIO.new
logger = ::Logger.new(logdev)
logger.level = level
Sidekiq.configure_server { |c| c.logger = logger }
yield
logdev.string
ensure
Sidekiq.configure_server do |c|
c.logger = original_logger
end
end
| ruby | MIT | 7b4ae4822f93ef4646f5cb55500ca4e25662db7c | 2026-01-04T15:59:43.787029Z | false |
sidekiq-cron/sidekiq-cron | https://github.com/sidekiq-cron/sidekiq-cron/blob/7b4ae4822f93ef4646f5cb55500ca4e25662db7c/test/support/classes.rb | test/support/classes.rb | class CronTestClass
include Sidekiq::Worker
sidekiq_options retry: true
def perform args = {}
puts "super croned job #{args}"
end
end
class CronTestClassWithQueue
include Sidekiq::Worker
sidekiq_options queue: :super, retry: false, backtrace: true
def perform args = {}
puts "super croned job #{... | ruby | MIT | 7b4ae4822f93ef4646f5cb55500ca4e25662db7c | 2026-01-04T15:59:43.787029Z | false |
sidekiq-cron/sidekiq-cron | https://github.com/sidekiq-cron/sidekiq-cron/blob/7b4ae4822f93ef4646f5cb55500ca4e25662db7c/test/integration/performance_test.rb | test/integration/performance_test.rb | require './test/test_helper'
require 'benchmark'
JOBS_NUMBER = 10_000
MAX_SECONDS = 30
describe 'Performance Poller' do
before do
Sidekiq.redis(&:flushdb)
args = {
queue: "default",
cron: "*/2 * * * *",
klass: "CronTestClass"
}
JOBS_NUMBER.times do |i|
Sidekiq::Cron::Job.cr... | ruby | MIT | 7b4ae4822f93ef4646f5cb55500ca4e25662db7c | 2026-01-04T15:59:43.787029Z | false |
sidekiq-cron/sidekiq-cron | https://github.com/sidekiq-cron/sidekiq-cron/blob/7b4ae4822f93ef4646f5cb55500ca4e25662db7c/test/unit/schedule_loader_test.rb | test/unit/schedule_loader_test.rb | require './test/test_helper'
describe 'ScheduleLoader' do
before do
Sidekiq::Cron.reset!
Sidekiq::Options[:lifecycle_events][:startup].clear
# Loaded before cron_schedule_file is set as this is the case for users of the gem
load 'sidekiq/cron/schedule_loader.rb'
end
describe 'Schedule file does ... | ruby | MIT | 7b4ae4822f93ef4646f5cb55500ca4e25662db7c | 2026-01-04T15:59:43.787029Z | false |
sidekiq-cron/sidekiq-cron | https://github.com/sidekiq-cron/sidekiq-cron/blob/7b4ae4822f93ef4646f5cb55500ca4e25662db7c/test/unit/poller_test.rb | test/unit/poller_test.rb | # frozen_string_literal: true
require './test/test_helper'
# Prevents Sidekiq::Scheduler to run the safe_thread helper method
module Sidekiq
module Scheduled
class Poller
def start; end
end
end
end
describe 'Cron Poller' do
before do
Sidekiq::Cron.reset!
Sidekiq.redis(&:flushdb)
end
... | ruby | MIT | 7b4ae4822f93ef4646f5cb55500ca4e25662db7c | 2026-01-04T15:59:43.787029Z | false |
sidekiq-cron/sidekiq-cron | https://github.com/sidekiq-cron/sidekiq-cron/blob/7b4ae4822f93ef4646f5cb55500ca4e25662db7c/test/unit/web_extension_test.rb | test/unit/web_extension_test.rb | require './test/test_helper'
TOKEN = SecureRandom.base64(32).freeze
describe 'Cron web' do
include Rack::Test::Methods
def app
Sidekiq::Web
end
before do
env 'rack.session', { csrf: TOKEN }
env 'HTTP_X_CSRF_TOKEN', TOKEN
Sidekiq::Cron.reset!
Sidekiq.redis(&:flushdb)
Sidekiq::Cron.c... | ruby | MIT | 7b4ae4822f93ef4646f5cb55500ca4e25662db7c | 2026-01-04T15:59:43.787029Z | false |
sidekiq-cron/sidekiq-cron | https://github.com/sidekiq-cron/sidekiq-cron/blob/7b4ae4822f93ef4646f5cb55500ca4e25662db7c/test/unit/job_test.rb | test/unit/job_test.rb | # frozen_string_literal: true
require './test/test_helper'
describe "Cron Job" do
before do
Sidekiq::Cron.reset!
Sidekiq::Cron.configuration.available_namespaces = :auto
# Clear all previous saved data from Redis.
Sidekiq.redis do |conn|
conn.keys("cron_job*").each do |key|
conn.del(... | ruby | MIT | 7b4ae4822f93ef4646f5cb55500ca4e25662db7c | 2026-01-04T15:59:43.787029Z | true |
sidekiq-cron/sidekiq-cron | https://github.com/sidekiq-cron/sidekiq-cron/blob/7b4ae4822f93ef4646f5cb55500ca4e25662db7c/test/unit/namespace_test.rb | test/unit/namespace_test.rb | # frozen_string_literal: true
require './test/test_helper'
describe 'Namespaces' do
before do
Sidekiq::Cron.reset!
# Clear all previous saved data from Redis.
Sidekiq.redis do |conn|
conn.keys("cron_job*").each do |key|
conn.del(key)
end
end
# Clear all queues.
Sidekiq:... | ruby | MIT | 7b4ae4822f93ef4646f5cb55500ca4e25662db7c | 2026-01-04T15:59:43.787029Z | false |
sidekiq-cron/sidekiq-cron | https://github.com/sidekiq-cron/sidekiq-cron/blob/7b4ae4822f93ef4646f5cb55500ca4e25662db7c/test/unit/launcher_test.rb | test/unit/launcher_test.rb | require './test/test_helper'
describe 'Cron launcher' do
describe 'initialization' do
before do
Sidekiq::Cron.reset!
end
it 'initializes poller with default poll interval when not configured' do
Sidekiq::Cron::Poller.expects(:new).with do |options|
assert_equal 30, options[:cron_poll... | ruby | MIT | 7b4ae4822f93ef4646f5cb55500ca4e25662db7c | 2026-01-04T15:59:43.787029Z | false |
sidekiq-cron/sidekiq-cron | https://github.com/sidekiq-cron/sidekiq-cron/blob/7b4ae4822f93ef4646f5cb55500ca4e25662db7c/lib/sidekiq-cron.rb | lib/sidekiq-cron.rb | require "sidekiq"
require "sidekiq/cron"
require "sidekiq/options"
require "sidekiq/cron/job"
require "sidekiq/cron/namespace"
require "sidekiq/cron/poller"
require "sidekiq/cron/launcher"
require "sidekiq/cron/schedule_loader"
| ruby | MIT | 7b4ae4822f93ef4646f5cb55500ca4e25662db7c | 2026-01-04T15:59:43.787029Z | false |
sidekiq-cron/sidekiq-cron | https://github.com/sidekiq-cron/sidekiq-cron/blob/7b4ae4822f93ef4646f5cb55500ca4e25662db7c/lib/sidekiq/cron.rb | lib/sidekiq/cron.rb | module Sidekiq
module Cron
class << self
attr_accessor :configuration
end
def self.configure
self.configuration ||= Configuration.new
yield(configuration) if block_given?
end
def self.reset!
self.configuration = Configuration.new
end
class Configuration
# T... | ruby | MIT | 7b4ae4822f93ef4646f5cb55500ca4e25662db7c | 2026-01-04T15:59:43.787029Z | false |
sidekiq-cron/sidekiq-cron | https://github.com/sidekiq-cron/sidekiq-cron/blob/7b4ae4822f93ef4646f5cb55500ca4e25662db7c/lib/sidekiq/options.rb | lib/sidekiq/options.rb | # Module to access Sidekiq config
module Sidekiq
module Options
def self.[](key)
self.config[key]
end
def self.[]=(key, value)
self.config[key] = value
end
def self.config
options_field ? Sidekiq.public_send(options_field) : Sidekiq
end
def self.options_field
ret... | ruby | MIT | 7b4ae4822f93ef4646f5cb55500ca4e25662db7c | 2026-01-04T15:59:43.787029Z | false |
sidekiq-cron/sidekiq-cron | https://github.com/sidekiq-cron/sidekiq-cron/blob/7b4ae4822f93ef4646f5cb55500ca4e25662db7c/lib/sidekiq/cron/version.rb | lib/sidekiq/cron/version.rb | # frozen_string_literal: true
module Sidekiq
module Cron
VERSION = "2.3.1"
end
end
| ruby | MIT | 7b4ae4822f93ef4646f5cb55500ca4e25662db7c | 2026-01-04T15:59:43.787029Z | false |
sidekiq-cron/sidekiq-cron | https://github.com/sidekiq-cron/sidekiq-cron/blob/7b4ae4822f93ef4646f5cb55500ca4e25662db7c/lib/sidekiq/cron/poller.rb | lib/sidekiq/cron/poller.rb | # frozen_string_literal: true
require 'sidekiq/scheduled'
module Sidekiq
module Cron
# The Poller checks Redis every N seconds for scheduled cron jobs.
class Poller < Sidekiq::Scheduled::Poller
def initialize(config = nil)
super
end
def start
Sidekiq::Cron::Job.migrate_old... | ruby | MIT | 7b4ae4822f93ef4646f5cb55500ca4e25662db7c | 2026-01-04T15:59:43.787029Z | false |
sidekiq-cron/sidekiq-cron | https://github.com/sidekiq-cron/sidekiq-cron/blob/7b4ae4822f93ef4646f5cb55500ca4e25662db7c/lib/sidekiq/cron/namespace.rb | lib/sidekiq/cron/namespace.rb | module Sidekiq
module Cron
class Namespace
def self.all
namespaces = case (available_namespaces = Sidekiq::Cron.configuration.available_namespaces)
when NilClass then []
when Array then available_namespaces
when :auto
Sidekiq.redis do |conn|
co... | ruby | MIT | 7b4ae4822f93ef4646f5cb55500ca4e25662db7c | 2026-01-04T15:59:43.787029Z | false |
sidekiq-cron/sidekiq-cron | https://github.com/sidekiq-cron/sidekiq-cron/blob/7b4ae4822f93ef4646f5cb55500ca4e25662db7c/lib/sidekiq/cron/web_extension.rb | lib/sidekiq/cron/web_extension.rb | module Sidekiq
module Cron
module WebExtension
module Helpers
def cron_route_params(key)
if Gem::Version.new(Sidekiq::VERSION) >= Gem::Version.new("8.0.0")
route_params(key)
else
route_params[key]
end
end
# This method constructs... | ruby | MIT | 7b4ae4822f93ef4646f5cb55500ca4e25662db7c | 2026-01-04T15:59:43.787029Z | false |
sidekiq-cron/sidekiq-cron | https://github.com/sidekiq-cron/sidekiq-cron/blob/7b4ae4822f93ef4646f5cb55500ca4e25662db7c/lib/sidekiq/cron/launcher.rb | lib/sidekiq/cron/launcher.rb | # For Cron we need to add some methods to Launcher
# so look at the code below.
#
# We are creating new cron poller instance and
# adding start and stop commands to launcher.
module Sidekiq
module Cron
module Launcher
# Add cron poller to launcher.
attr_reader :cron_poller
# Add cron poller an... | ruby | MIT | 7b4ae4822f93ef4646f5cb55500ca4e25662db7c | 2026-01-04T15:59:43.787029Z | false |
sidekiq-cron/sidekiq-cron | https://github.com/sidekiq-cron/sidekiq-cron/blob/7b4ae4822f93ef4646f5cb55500ca4e25662db7c/lib/sidekiq/cron/web.rb | lib/sidekiq/cron/web.rb | require "sidekiq/cron/web_extension"
require "sidekiq/cron/job"
require "sidekiq/cron/namespace"
if defined?(Sidekiq::Web)
if Gem::Version.new(Sidekiq::VERSION) >= Gem::Version.new('8.0.0')
Sidekiq::Web.configure do |config|
config.register(
Sidekiq::Cron::WebExtension, # Class which contains the H... | ruby | MIT | 7b4ae4822f93ef4646f5cb55500ca4e25662db7c | 2026-01-04T15:59:43.787029Z | false |
sidekiq-cron/sidekiq-cron | https://github.com/sidekiq-cron/sidekiq-cron/blob/7b4ae4822f93ef4646f5cb55500ca4e25662db7c/lib/sidekiq/cron/job.rb | lib/sidekiq/cron/job.rb | # frozen_string_literal: true
require 'fugit'
require 'cronex'
require 'globalid'
require 'sidekiq/cron/support'
module Sidekiq
module Cron
class Job
# How long we would like to store information about previous enqueues.
REMEMBER_THRESHOLD = 24 * 60 * 60
# Time format for enqueued jobs.
... | ruby | MIT | 7b4ae4822f93ef4646f5cb55500ca4e25662db7c | 2026-01-04T15:59:43.787029Z | false |
sidekiq-cron/sidekiq-cron | https://github.com/sidekiq-cron/sidekiq-cron/blob/7b4ae4822f93ef4646f5cb55500ca4e25662db7c/lib/sidekiq/cron/schedule_loader.rb | lib/sidekiq/cron/schedule_loader.rb | module Sidekiq
module Cron
class ScheduleLoader
def load_schedule
if schedule.is_a?(Hash)
Sidekiq::Cron::Job.load_from_hash!(schedule, source: "schedule")
elsif schedule.is_a?(Array)
Sidekiq::Cron::Job.load_from_array!(schedule, source: "schedule")
else
... | ruby | MIT | 7b4ae4822f93ef4646f5cb55500ca4e25662db7c | 2026-01-04T15:59:43.787029Z | false |
sidekiq-cron/sidekiq-cron | https://github.com/sidekiq-cron/sidekiq-cron/blob/7b4ae4822f93ef4646f5cb55500ca4e25662db7c/lib/sidekiq/cron/support.rb | lib/sidekiq/cron/support.rb | module Sidekiq
module Cron
module Support
def self.safe_constantize(klass_name)
Object.const_get(klass_name)
rescue NameError
nil
end
def self.load_yaml(src)
if Psych::VERSION > "4.0"
YAML.safe_load(src, permitted_classes: [Symbol], aliases: true)
... | ruby | MIT | 7b4ae4822f93ef4646f5cb55500ca4e25662db7c | 2026-01-04T15:59:43.787029Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/configure.rb | configure.rb | require 'rbconfig'
VAR_PATTERN = /\$\((?<name>[a-z_]+)\)/i
REPLACEMENTS = Hash[RbConfig::MAKEFILE_CONFIG.map do |key, value|
["$(#{key})", value]
end]
def expand_config(path)
if path =~ VAR_PATTERN
new_path = path.gsub(VAR_PATTERN, REPLACEMENTS)
expand_config(new_path)
else
path
end
end
puts exp... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/ext/gitsh/extconf.rb | ext/gitsh/extconf.rb | require 'mkmf'
readline = Struct.new(:headers, :extra_check).new(["stdio.h"])
def readline.have_header(header)
if super(header, &extra_check)
headers.push(header)
return true
else
return false
end
end
def readline.have_var(var)
return super(var, headers)
end
def readline.require_var(var)
unles... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/spec_helper.rb | spec/spec_helper.rb | require 'pry'
$LOAD_PATH.unshift(File.expand_path('../../ext', __FILE__))
Dir[File.expand_path('../support/**/*.rb', __FILE__)].each do |path|
require path
end
RSpec.configure do |config|
config.order = 'random'
end
Pry.config.tap do |config|
config.output = STDOUT
config.input = STDIN
end
| ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/support/internal_command_shared_examples.rb | spec/support/internal_command_shared_examples.rb | shared_examples_for 'an internal command' do
it 'has a .help_message method' do
expect {
described_class.help_message
}.to_not raise_exception
end
end
| ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/support/fixtures.rb | spec/support/fixtures.rb | module FixturesHelper
def fake_git_path
File.expand_path('../../../spec/fixtures/fake_git', __FILE__)
end
end
RSpec.configure do |config|
config.include FixturesHelper
end
| ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/support/tokens.rb | spec/support/tokens.rb | require 'rltk'
module Tokens
def tokens(*tokens)
tokens.map.with_index do |token, i|
type, value = token
pos = RLTK::StreamPosition.new(i, 1, i, 10, nil)
RLTK::Token.new(type, value, pos)
end
end
end
RSpec.configure do |config|
config.include Tokens
end
| ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/support/working_directory.rb | spec/support/working_directory.rb | module WorkingDirectory
def cwd_basename
File.basename(Dir.getwd)
end
end
RSpec.configure do |config|
config.include WorkingDirectory
end
| ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/support/fake_line_editor.rb | spec/support/fake_line_editor.rb | require 'thread'
require 'gitsh/line_editor'
require 'gitsh/module_delegator'
class FakeLineEditor < ModuleDelegator
def initialize
@prompt_queue = Queue.new
@input_read, @input_write = IO.pipe
super(Gitsh::LineEditor)
end
def readline(prompt, add_to_history)
module_delegator_target.input = inpu... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/support/scripts.rb | spec/support/scripts.rb | module Scripts
def gitsh_path
File.expand_path('../../../bin/gitsh', __FILE__)
end
end
RSpec.configure do |config|
config.include Scripts
end
| ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/support/signalling_line_editor.rb | spec/support/signalling_line_editor.rb | class SignallingLineEditor
def initialize(signal)
@signal = signal
end
def readline(*args, &block)
Process.kill(signal, Process.pid)
nil
end
def method_missing(name, *args, &block)
end
private
attr_reader :signal
end
| ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/support/produce_tokens_matcher.rb | spec/support/produce_tokens_matcher.rb | RSpec::Matchers.define(:produce_tokens) do |expected|
match do |actual|
@expected = expected.join("\n")
@actual = described_class.lex(actual).map(&:to_s).join("\n")
values_match? @expected, @actual
end
diffable
end
| ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/support/gitsh_runner.rb | spec/support/gitsh_runner.rb | require 'thread'
require 'tempfile'
require 'tmpdir'
require 'gitsh/cli'
require 'gitsh/environment'
require 'gitsh/line_editor_history_filter'
require 'rspec/mocks/test_double'
require File.expand_path('../file_system', __FILE__)
class GitshRunner
include FileSystemHelper
UP_ARROW = "\033[A"
def self.interact... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/support/execute_matcher.rb | spec/support/execute_matcher.rb | RSpec::Matchers.define :execute do
chain :successfully do
@exit_status_matcher = eq(0)
@error_matcher = eq('')
end
chain :with_exit_status do |exit_status|
@exit_status_matcher = eq(exit_status)
end
chain :with_output_matching do |output_pattern|
@output_matcher = match_regex(output_pattern)... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/support/file_system.rb | spec/support/file_system.rb | module FileSystemHelper
DEFAULT_READLINE_CONFIG = 'set bell-style none'
DEFAULT_GIT_CONFIG = "[user]\n name = Test\n email = test@example.com"
def write_file(name, contents="Some content")
File.open(name, 'w') { |f| f << "#{contents}\n" }
end
def make_directory(name)
Dir.mkdir(name)
end
def t... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/support/delegate_matcher.rb | spec/support/delegate_matcher.rb | RSpec::Matchers.define :delegate do |original_method|
chain :to do |target_object, target_method|
@target_object = target_object
@target_method = target_method
end
match do |original_object|
result = double
allow(@target_object).to receive(@target_method).
and_return(result)
expect(ori... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/support/stubbed_method_result.rb | spec/support/stubbed_method_result.rb | class StubbedMethodResult
def initialize
@results = []
end
def raises(error, message = nil)
@results << proc { raise error.new(message) }
self
end
def returns(value)
@results << proc { value }
self
end
def next_result
@results.shift.call
end
end
| ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/support/colors.rb | spec/support/colors.rb | require 'gitsh/colors'
module Color
def self.included(other)
other.let(:clear) { Gitsh::Colors::CLEAR }
other.let(:red_background) { Gitsh::Colors::RED_BG }
other.let(:red) { Gitsh::Colors::RED_FG }
other.let(:yellow) { Gitsh::Colors::YELLOW_FG }
other.let(:cyan) { Gitsh::Colors::CYAN_FG }
ot... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/support/tab_completion.rb | spec/support/tab_completion.rb | module TabCompletionHelpers
def stub_text_matcher(text)
klass = Gitsh::TabCompletion::Matchers::TextMatcher
matcher = instance_double(klass)
allow(klass).to receive(:new).with(text).and_return(matcher)
matcher
end
end
RSpec.configure do |config|
config.include TabCompletionHelpers
end
| ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/integration/command_arguments_spec.rb | spec/integration/command_arguments_spec.rb | require 'spec_helper'
describe 'Command arguments' do
it 'supports empty strings' do
GitshRunner.interactive do |gitsh|
gitsh.type ':echo Hello "" World'
expect(gitsh).to output_no_errors
expect(gitsh).to output "Hello World\n"
end
end
end
| ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/integration/error_handling_spec.rb | spec/integration/error_handling_spec.rb | require 'spec_helper'
describe 'Handling errors' do
it 'does not explode when given an unknown internal command' do
GitshRunner.interactive do |gitsh|
gitsh.type(':foobar')
expect(gitsh).to output_error(/gitsh: foobar: command not found/)
end
end
it 'does not explode when given a badly form... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/integration/persistent_history_spec.rb | spec/integration/persistent_history_spec.rb | require 'spec_helper'
describe 'Gitsh history' do
it 'is persisted between sessions' do
GitshRunner.interactive do |gitsh|
gitsh.type('foobarbaz')
expect(gitsh).to output_error(/'foobarbaz' is not a git command/)
end
GitshRunner.interactive do |gitsh|
gitsh.type(GitshRunner::UP_ARROW *... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/integration/create_repository_spec.rb | spec/integration/create_repository_spec.rb | require 'spec_helper'
require 'gitsh/cli'
describe 'Creating a repository' do
it 'is possible through the gish CLI' do
GitshRunner.interactive do |gitsh|
expect(gitsh).to prompt_with "#{cwd_basename} uninitialized!! "
gitsh.type('init')
expect(gitsh).to output(/^Initialized empty Git reposito... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/integration/cd_command_spec.rb | spec/integration/cd_command_spec.rb | require 'spec_helper'
describe 'The :cd command' do
it 'changes the current working directory' do
GitshRunner.interactive do |gitsh|
gitsh.type 'init'
Dir.mktmpdir do |path|
gitsh.type ":cd #{path}"
expect(gitsh).to output_no_errors
expect(gitsh).to prompt_with "#{File.basen... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/integration/tab_completion_spec.rb | spec/integration/tab_completion_spec.rb | require 'spec_helper'
describe 'Completing things with tab' do
it 'completes known porcelain commands' do
GitshRunner.interactive do |gitsh|
gitsh.type('init')
gitsh.type("checko\t -b my-feature")
expect(gitsh).to prompt_with "#{cwd_basename} my-feature@ "
gitsh.type("com\t --allow-emp... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/integration/source_command_spec.rb | spec/integration/source_command_spec.rb | require 'spec_helper'
describe 'The :source command' do
context 'a source file is given' do
it 'executes the commands in the sourced file' do
GitshRunner.interactive do |gitsh|
write_file('.gitshrc', ':set source_worked "Yes it did!"')
gitsh.type ':source .gitshrc'
gitsh.type ':ech... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/integration/coloring_spec.rb | spec/integration/coloring_spec.rb | require 'spec_helper'
describe 'Color support' do
include Color
it 'is disabled for old terminals' do
GitshRunner.interactive do |gitsh|
expect(gitsh).to prompt_with "#{cwd_basename} uninitialized!! "
end
end
it 'is enabled for color xterm' do
GitshRunner.interactive(env: { 'TERM' => 'xterm... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/integration/greeting_spec.rb | spec/integration/greeting_spec.rb | require 'spec_helper'
describe 'Displaying a welcome message when gitsh starts' do
it 'helps users understand what is going on' do
GitshRunner.interactive do |gitsh|
expect(gitsh).to output(/gitsh #{Gitsh::VERSION}\nType :exit to exit/)
end
end
it 'can be disabled' do
settings = { 'gitsh.noGre... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/integration/magic_variables_spec.rb | spec/integration/magic_variables_spec.rb | require 'spec_helper'
describe 'Magic variables' do
context '$_prior' do
it 'evaluates to the name of the previous branch' do
GitshRunner.interactive do |gitsh|
gitsh.type('init')
gitsh.type('commit --allow-empty -m "Initial commit"')
gitsh.type('checkout -b my-feature-branch')
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/integration/variables_spec.rb | spec/integration/variables_spec.rb | require 'spec_helper'
describe 'Gitsh variables' do
it 'can be set with the :set command and read with a dollar prefix' do
GitshRunner.interactive do |gitsh|
gitsh.type('init')
gitsh.type(':set author "John Doe <john@example.com>"')
expect(gitsh).to output_no_errors
gitsh.type(':set mes... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/integration/running_scripts_spec.rb | spec/integration/running_scripts_spec.rb | require 'spec_helper'
describe 'Executing gitsh scripts' do
context 'when the path to the script is passed as an argument' do
it 'runs the script and exits' do
in_a_temporary_directory do
write_file('myscript.gitsh', "init\n\ncommit")
expect("#{gitsh_path} --git #{fake_git_path} myscript.g... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/integration/gitshrc_spec.rb | spec/integration/gitshrc_spec.rb | require 'spec_helper'
describe 'A .gitshrc file in the home directory' do
context 'when it exists' do
it 'is loaded when gitsh starts' do
with_a_temporary_home_directory do
write_file(gitshrc_path, ':set gitshrc_loaded "Config loaded"')
GitshRunner.interactive do |gitsh|
gitsh.typ... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/integration/default_git_path_spec.rb | spec/integration/default_git_path_spec.rb | require 'spec_helper'
describe 'Default git path' do
it 'can be overridden using a git-config variable' do
GitshRunner.interactive(
settings: { 'gitsh.gitCommand' => fake_git_path },
) do |gitsh|
gitsh.type('init')
expect(gitsh).to output_no_errors
expect(gitsh).to output(/^Fake git:... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/integration/help_command_spec.rb | spec/integration/help_command_spec.rb | require 'spec_helper'
describe 'The :help command' do
it 'outputs a list of available built-in commands' do
GitshRunner.interactive do |gitsh|
gitsh.type ':help'
expect(gitsh).to output_no_errors
expect(gitsh).to output %r(Type :help \[command\] for more specific info)
expect(gitsh).to o... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/integration/correction_spec.rb | spec/integration/correction_spec.rb | require 'spec_helper'
describe 'Correcting input' do
context 'when help.autocorrect is enabled' do
it 'removes the git prefix from a command' do
GitshRunner.interactive do |gitsh|
gitsh.type ':set help.autocorrect 1'
gitsh.type 'git init'
expect(gitsh).to output_no_errors
e... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/integration/chaining_spec.rb | spec/integration/chaining_spec.rb | require 'spec_helper'
describe 'Chaining methods' do
describe 'And' do
it 'runs init and status' do
GitshRunner.interactive do |gitsh|
gitsh.type('init && status')
expect(gitsh).to output(/nothing to commit/)
end
end
it 'runs fetch, fails, and short circuits' do
GitshRu... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/integration/subshell_spec.rb | spec/integration/subshell_spec.rb | require 'spec_helper'
describe 'Subshell' do
it 'supports subshells using $(...)' do
GitshRunner.interactive do |gitsh|
gitsh.type 'init'
gitsh.type ':echo prefix $(status) suffix'
expect(gitsh).to output_no_errors
expect(gitsh).to output(/prefix.*nothing to commit.*suffix/)
end
en... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/integration/shell_commands_spec.rb | spec/integration/shell_commands_spec.rb | require 'spec_helper'
describe 'Executing a shell command' do
it 'accepts a shell command prefixed with a !' do
GitshRunner.interactive do |gitsh|
gitsh.type '!echo Hello world'
expect(gitsh).to output_no_errors
expect(gitsh).to output 'Hello world'
end
end
it 'accepts a shell command... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/integration/arguments_spec.rb | spec/integration/arguments_spec.rb | require 'spec_helper'
require 'gitsh/cli'
require 'gitsh/environment'
describe '--version' do
it 'outputs the version, and then exits' do
output = StringIO.new
error = StringIO.new
env = Gitsh::Environment.new(output_stream: output, error_stream: error)
runner = lambda do
Gitsh::CLI.new(args: ... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/integration/default_command_spec.rb | spec/integration/default_command_spec.rb | require 'spec_helper'
describe 'Entering no command' do
it 'runs `git status`' do
GitshRunner.interactive do |gitsh|
gitsh.type('init')
gitsh.type('')
expect(gitsh).to output(/nothing to commit/)
end
end
it 'runs `git status` ignoring white space' do
GitshRunner.interactive do |gi... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/integration/comment_spec.rb | spec/integration/comment_spec.rb | require 'spec_helper'
describe 'Comments' do
it 'supports commenting out an entire command with #' do
GitshRunner.interactive do |gitsh|
gitsh.type '#cd'
expect(gitsh).to output_no_errors
expect(gitsh).to output_nothing
end
end
it 'supports commenting out part of a command with #' do
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/integration/prompt_spec.rb | spec/integration/prompt_spec.rb | # encoding: utf-8
require 'spec_helper'
describe 'The gitsh prompt' do
it 'defaults to the directory basename and the branch name' do
GitshRunner.interactive do |gitsh|
gitsh.type('init')
expect(gitsh).to prompt_with "#{cwd_basename} master@ "
end
end
it 'defaults to abbreviated branch nam... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/integration/inputrc_spec.rb | spec/integration/inputrc_spec.rb | require 'spec_helper'
describe 'A .inputrc file in the home directory' do
RELOAD_INPUTRC = "\cx\cr".freeze
it 'is used by gitsh' do
with_a_temporary_home_directory do
write_file(inputrc_path, <<-INPUTRC)
$if gitsh
"\\C-xx": ":echo this is a test"
$endif
INPUTRC
Git... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/integration/escaping_spec.rb | spec/integration/escaping_spec.rb | require 'spec_helper'
describe 'Escaping commands' do
it 'does not pass arbitrary strings to a shell' do
GitshRunner.interactive do |gitsh|
gitsh.type('init ; echo Injection')
expect(gitsh).not_to output(/Injection/)
expect(gitsh).to output_error(/echo/)
end
end
end
| ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/integration/multi_line_input_spec.rb | spec/integration/multi_line_input_spec.rb | require 'spec_helper'
describe 'Multi-line input' do
it 'supports escaped line breaks within commands' do
GitshRunner.interactive do |gitsh|
gitsh.type(':echo Hello \\')
expect(gitsh).to output_no_errors
expect(gitsh).to prompt_with('> ')
gitsh.type('world')
expect(gitsh).to outp... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/integration/completion_errors_spec.rb | spec/integration/completion_errors_spec.rb | require 'spec_helper'
require 'gitsh/tab_completion/dsl/parse_error'
describe 'Invalid completion file' do
context 'with syntax errors' do
it 'fails to start up in interactive mode' do
with_a_temporary_home_directory do |home|
config_path = "#{home}/.gitsh_completions"
write_file(config_pat... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/terminal_spec.rb | spec/units/terminal_spec.rb | require 'spec_helper'
require 'gitsh/terminal'
require 'rspec/mocks/standalone'
describe Gitsh::Terminal do
describe '#color_support?' do
context 'on a 256 color terminal' do
it 'returns true' do
stub_command 'tput colors', output: "256\n"
result = Gitsh::Terminal.instance.color_support?
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/argument_list_spec.rb | spec/units/argument_list_spec.rb | require 'spec_helper'
require 'gitsh/argument_list'
describe Gitsh::ArgumentList do
describe '#length' do
it 'returns the number of arguments' do
argument_list = Gitsh::ArgumentList.new(['hello', 'goodbye'])
expect(argument_list.length).to eq 2
end
end
describe '#values' do
it 'returns ... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/capturing_environment_spec.rb | spec/units/capturing_environment_spec.rb | require 'spec_helper'
require 'gitsh/capturing_environment'
describe Gitsh::CapturingEnvironment do
describe '#captured_output' do
it 'returns any output written to the output stream directly' do
env = double('env')
capturing_env = described_class.new(env)
capturing_env.output_stream.puts 'Hell... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/magic_variables_spec.rb | spec/units/magic_variables_spec.rb | require 'spec_helper'
require 'pathname'
require 'gitsh/magic_variables'
describe Gitsh::MagicVariables do
describe '#fetch' do
context 'with an unknown variable name and a block' do
it 'yields to the block' do
repo = double('GitRepository')
magic_variables = described_class.new(repo)
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/prompt_color_spec.rb | spec/units/prompt_color_spec.rb | require 'spec_helper'
require 'gitsh/prompt_color'
describe Gitsh::PromptColor do
include Color
describe '#status_color' do
context 'with an uninitialized repo' do
it 'uses the gitsh.color.uninitialized setting' do
color = double('color')
env = double('env', repo_config_color: color)
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/git_repository_spec.rb | spec/units/git_repository_spec.rb | require 'spec_helper'
require 'open3'
require 'gitsh/git_repository'
describe Gitsh::GitRepository do
include Color
describe '#git_dir' do
it 'returns the path to the .git directory' do
with_a_temporary_home_directory do
in_a_temporary_directory do
repo = Gitsh::GitRepository.new(env)
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/file_runner_spec.rb | spec/units/file_runner_spec.rb | require 'spec_helper'
require 'gitsh/file_runner'
describe Gitsh::FileRunner do
describe '#run' do
it 'executes the given script' do
input_strategy = stub_file_input_strategy
interpreter = stub_interpreter
env = double(:env)
runner = described_class.new(env: env, path: 'my/path')
r... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/cli_spec.rb | spec/units/cli_spec.rb | require 'spec_helper'
require 'gitsh/cli'
describe Gitsh::CLI do
describe '#run' do
context 'with valid arguments and no script file' do
it 'uses the interactive input strategy' do
interpreter = stub_interpreter
interactive_input_strategy = stub_interactive_input_strategy
cli = Gits... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/git_command_list_spec.rb | spec/units/git_command_list_spec.rb | require 'spec_helper'
require 'gitsh/git_command_list'
describe Gitsh::GitCommandList do
GIT_COMMAND = '/usr/bin/env git'.freeze
MODERN_LIST_COMMAND = "#{GIT_COMMAND} --list-cmds=main,nohelpers".freeze
MODERN_HELP_COMMAND = "#{GIT_COMMAND} help -a --no-verbose".freeze
LEGACY_HELP_COMMAND = "#{GIT_COMMAND} help... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/interpreter_spec.rb | spec/units/interpreter_spec.rb | require 'spec_helper'
require 'gitsh/interpreter'
require 'rltk'
describe Gitsh::Interpreter do
describe '#run' do
it 'reads, parses, and executes each command from the input strategy' do
env = double
command = double(:command, execute: nil)
parser = double(:parser, parse: command)
lexer ... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/shell_command_runner_spec.rb | spec/units/shell_command_runner_spec.rb | require 'spec_helper'
require 'gitsh/shell_command_runner'
describe Gitsh::ShellCommandRunner do
describe '#run' do
before do
allow(Process).to receive(:spawn).and_return(1)
allow(Process).to receive(:wait)
allow(Process).to receive(:kill)
ensure_exit_status_exists
end
it 'spawns... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/history_spec.rb | spec/units/history_spec.rb | require 'spec_helper'
require 'gitsh/history'
describe Gitsh::History do
before do
@history_file = Tempfile.new('history')
end
after do
@history_file.close
@history_file.unlink
end
let(:env) { { 'gitsh.historyFile' => @history_file.path } }
let(:line_editor) {
Class.new.tap { |line_editor... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/line_editor_spec.rb | spec/units/line_editor_spec.rb | require 'spec_helper'
require 'gitsh/line_editor'
describe Gitsh::LineEditor do
SAVED_ENV = %w[COLUMNS LINES]
before do
@saved_safe = $SAFE
@saved_env = ENV.values_at(*SAVED_ENV)
@saved_line_editor_settings = {
completer_quote_characters: described_class.completer_quote_characters || '',
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/line_editor_history_filter_spec.rb | spec/units/line_editor_history_filter_spec.rb | require 'spec_helper'
require 'gitsh/line_editor_history_filter'
describe Gitsh::LineEditorHistoryFilter do
describe '#readline' do
let(:fake_line_editor) { FakeLineEditor.new }
before { fake_line_editor::HISTORY.clear }
it 'enters non-blank lines into the history' do
line_editor_history_filter = ... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/parser_spec.rb | spec/units/parser_spec.rb | require 'spec_helper'
require 'gitsh/parser'
describe Gitsh::Parser do
describe '#parse' do
it 'parses commands' do
command = stub_lazy_command
result = parse(tokens([:WORD, 'commit'], [:EOS]))
expect(result).to eq command
expect(Gitsh::Commands::LazyCommand).to have_received(:new).with... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/lexer_spec.rb | spec/units/lexer_spec.rb | require 'spec_helper'
require 'gitsh/lexer'
describe Gitsh::Lexer do
describe '.lex' do
it 'recognises space separated words' do
expect('foo bar').
to produce_tokens ['WORD(foo)', 'SPACE', 'WORD(bar)', 'EOS']
expect('!./bin/setup --help').
to produce_tokens ['WORD(!./bin/setup)', 'SPA... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/quote_detector_spec.rb | spec/units/quote_detector_spec.rb | require 'spec_helper'
require 'gitsh/quote_detector'
describe Gitsh::QuoteDetector do
describe '#call' do
context 'for an escaped character' do
it 'returns true' do
expect(detect('a\\ b', 2)).to be true
expect(detect('\\ b', 1)).to be true
end
end
context 'for an unescaped ch... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/environment_spec.rb | spec/units/environment_spec.rb | require 'spec_helper'
require 'gitsh/environment'
describe Gitsh::Environment do
describe '#[]=' do
it 'sets a gitsh environment variable' do
repository = double('GitRepository', config: nil)
factory = double('RepositoryFactory', new: repository)
env = described_class.new(repository_factory: fa... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/prompter_spec.rb | spec/units/prompter_spec.rb | # encoding: utf-8
require 'spec_helper'
require 'gitsh/prompter'
describe Gitsh::Prompter do
include Color
describe '#prompt' do
context 'with the default prompt format' do
context 'an un-initialized git repository' do
it 'displays an uninitialized prompt' do
env = env_double(
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/arguments/variable_argument_spec.rb | spec/units/arguments/variable_argument_spec.rb | require 'spec_helper'
require 'gitsh/arguments/variable_argument'
describe Gitsh::Arguments::VariableArgument do
describe '#value' do
it 'returns the value of the variable passed to the initializer' do
env = { 'author' => 'George' }
argument = described_class.new('author')
expect(argument.valu... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/arguments/composite_argument_spec.rb | spec/units/arguments/composite_argument_spec.rb | require 'spec_helper'
require 'gitsh/arguments/composite_argument'
describe Gitsh::Arguments::CompositeArgument do
describe '#value' do
it 'returns the concatenated values of the arguments passed to the initializer' do
env = double('env')
first_argument = double('first_argument', value: 'Hello')
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/arguments/subshell_spec.rb | spec/units/arguments/subshell_spec.rb | require 'spec_helper'
require 'gitsh/arguments/subshell'
describe Gitsh::Arguments::Subshell do
describe '#value' do
it 'returns the result of executing the subshell' do
capturing_environment = stub_capturing_environment('expected output')
env = double('env')
wrapped_command = double(:command, ... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/arguments/string_argument_spec.rb | spec/units/arguments/string_argument_spec.rb | require 'spec_helper'
require 'gitsh/arguments/string_argument'
describe Gitsh::Arguments::StringArgument do
describe '#value' do
it 'returns the string passed to the initializer' do
arg = described_class.new('Hello world')
env = double('env')
expect(arg.value(env)).to eq 'Hello world'
end... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/input_strategies/file_spec.rb | spec/units/input_strategies/file_spec.rb | require 'spec_helper'
require 'stringio'
require 'gitsh/input_strategies/file'
describe Gitsh::InputStrategies::File do
describe '#setup' do
context 'with a file that does not exist' do
it 'raises a NoInputError' do
env = double('Environment')
input_strategy = described_class.new(
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/input_strategies/interactive_spec.rb | spec/units/input_strategies/interactive_spec.rb | require 'spec_helper'
require 'gitsh/input_strategies/interactive'
describe Gitsh::InputStrategies::Interactive do
before { stub_file_runner }
describe '#setup' do
it 'loads the history' do
input_strategy = build_input_strategy
input_strategy.setup
expect(history).to have_received(:load)
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/commands/internal_command_spec.rb | spec/units/commands/internal_command_spec.rb | require 'spec_helper'
require 'gitsh/commands/internal_command'
describe Gitsh::Commands::InternalCommand do
describe '.new' do
it 'returns a Set command when given the command "set"' do
command = described_class.new('set', %w(foo bar))
expect(command).to be_a described_class::Set
end
it 're... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/commands/lazy_command_spec.rb | spec/units/commands/lazy_command_spec.rb | require 'spec_helper'
require 'gitsh/commands/lazy_command'
require 'gitsh/arguments/string_argument'
require 'gitsh/arguments/variable_argument'
describe Gitsh::Commands::LazyCommand do
describe '#execute' do
it 'executes Git commands' do
env = double(:env)
command_instance = stub_command_class(Gits... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/commands/shell_command_spec.rb | spec/units/commands/shell_command_spec.rb | require 'spec_helper'
require 'gitsh/commands/shell_command'
describe Gitsh::Commands::ShellCommand do
describe '#execute' do
it 'delegates to the Gitsh::ShellCommandRunner' do
env = double(:env)
expected_result = double(:result)
mock_runner = double(:shell_command_runner, run: expected_result)... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/commands/git_command_spec.rb | spec/units/commands/git_command_spec.rb | require 'spec_helper'
require 'gitsh/commands/git_command'
describe Gitsh::Commands::GitCommand do
describe '#execute' do
it 'delegates to the Gitsh::ShellCommandRunner' do
env = double(
:env,
git_command: '/usr/bin/env git',
config_variables: {},
fetch: nil,
)
e... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/commands/tree_spec.rb | spec/units/commands/tree_spec.rb | require 'spec_helper'
require 'gitsh/commands/tree'
describe Gitsh::Commands::Tree do
let(:t) { double(execute: true) }
let(:f) { double(execute: false) }
let(:env) { double(:env) }
describe Gitsh::Commands::Tree::Or do
it 'executes f, then t' do
Gitsh::Commands::Tree::Or.new(f, t).execute(env)
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
thoughtbot/gitsh | https://github.com/thoughtbot/gitsh/blob/7b890ea6314cfc08a25f5a2c94322e5368a7ffa5/spec/units/commands/internal/unknown_spec.rb | spec/units/commands/internal/unknown_spec.rb | require 'spec_helper'
require 'gitsh/commands/internal_command'
describe Gitsh::Commands::InternalCommand::Unknown do
it_behaves_like "an internal command"
describe '#execute' do
it 'outputs an error message' do
env = spy('env', puts_error: nil)
command = described_class.new('notacommand', [])
... | ruby | BSD-3-Clause | 7b890ea6314cfc08a25f5a2c94322e5368a7ffa5 | 2026-01-04T15:59:22.546175Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.