source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
ganmacs/grpc_mock
https://github.com/ganmacs/grpc_mock
lib/grpc_mock/request_pattern.rb
Ruby
mit
45
master
601
# frozen_string_literal: true module GrpcMock class RequestPattern # @param path [String] def initialize(path) @path = path @block = nil @request = nil end def with(request = nil, &block) if request.nil? && !block_given? raise ArgumentError, '#with method invoked with...
github
ganmacs/grpc_mock
https://github.com/ganmacs/grpc_mock
lib/grpc_mock/api.rb
Ruby
mit
45
master
606
# frozen_string_literal: true require 'grpc_mock/request_stub' require 'grpc_mock/matchers/request_including_matcher' module GrpcMock module Api # @param path [String] def stub_request(path) GrpcMock.stub_registry.register_request_stub(GrpcMock::RequestStub.new(path)) end # @param values [Has...
github
ganmacs/grpc_mock
https://github.com/ganmacs/grpc_mock
lib/grpc_mock/grpc_stub_adapter.rb
Ruby
mit
45
master
3,945
# frozen_string_literal: true require 'grpc' require 'grpc_mock/errors' require 'grpc_mock/mocked_call' module GrpcMock class GrpcStubAdapter # To make hook point for GRPC::ClientStub # https://github.com/grpc/grpc/blob/bec3b5ada2c5e5d782dff0b7b5018df646b65cb0/src/ruby/lib/grpc/generic/service.rb#L150-L186 ...
github
ganmacs/grpc_mock
https://github.com/ganmacs/grpc_mock
lib/grpc_mock/request_stub.rb
Ruby
mit
45
master
1,513
# frozen_string_literal: true require 'grpc_mock/request_pattern' require 'grpc_mock/response' require 'grpc_mock/response_sequence' require 'grpc_mock/errors' module GrpcMock class RequestStub # @param path [String] gRPC path like /${service_name}/${method_name} def initialize(path) @request_pattern ...
github
ganmacs/grpc_mock
https://github.com/ganmacs/grpc_mock
lib/grpc_mock/matchers/request_including_matcher.rb
Ruby
mit
45
master
929
# frozen_string_literal: true require 'grpc_mock/matchers/hash_argument_matcher' module GrpcMock module Matchers class RequestIncludingMatcher < HashArgumentMatcher def ==(actual) if actual.respond_to?(:to_h) actual = actual.to_h end actual = Hash[GrpcMock::Matchers::Has...
github
ganmacs/grpc_mock
https://github.com/ganmacs/grpc_mock
lib/grpc_mock/matchers/hash_argument_matcher.rb
Ruby
mit
45
master
1,145
# frozen_string_literal: true module GrpcMock module Matchers # Base class for Hash matchers # https://github.com/rspec/rspec-mocks/blob/master/lib/rspec/mocks/argument_matchers.rb class HashArgumentMatcher def self.stringify_keys!(arg, options = {}) case arg when Array ar...
github
ganmacs/grpc_mock
https://github.com/ganmacs/grpc_mock
spec/grpc_mock_spec.rb
Ruby
mit
45
master
5,788
# frozen_string_literal: true require 'examples/hello/hello_client' require 'examples/request/request_services_pb' RSpec.describe GrpcMock do let(:client) do HelloClient.new end around do |blk| described_class.enable! blk.call described_class.disable! described_class.reset! end describ...
github
ganmacs/grpc_mock
https://github.com/ganmacs/grpc_mock
spec/spec_helper.rb
Ruby
mit
45
master
396
# frozen_string_literal: true require 'bundler/setup' require 'grpc_mock' RSpec.configure do |config| # Enable flags like --only-failures and --next-failure config.example_status_persistence_file_path = '.rspec_status' # Disable RSpec exposing methods globally on `Module` and `main` config.disable_monkey_pat...
github
ganmacs/grpc_mock
https://github.com/ganmacs/grpc_mock
spec/rspec_spec.rb
Ruby
mit
45
master
3,333
# frozen_string_literal: true require 'spec_helper' require 'examples/hello/hello_client' RSpec.describe 'grpc_mock/rspec' do require 'grpc_mock/rspec' before do GrpcMock.enable! GrpcMock.allow_net_connect! end let(:client) do HelloClient.new end context 'when request_response' do it { ...
github
ganmacs/grpc_mock
https://github.com/ganmacs/grpc_mock
spec/examples/request/request_services_pb.rb
Ruby
mit
45
master
701
# Generated by the protocol buffer compiler. DO NOT EDIT! # Source: request.proto for package 'request' require 'grpc' require 'examples/request/request_pb' module Request module Request class Service include GRPC::GenericService self.marshal_class_method = :encode self.unmarshal_class_meth...
github
ganmacs/grpc_mock
https://github.com/ganmacs/grpc_mock
spec/examples/request/request_pb.rb
Ruby
mit
45
master
1,552
# Generated by the protocol buffer compiler. DO NOT EDIT! # source: request.proto require 'google/protobuf' Google::Protobuf::DescriptorPool.generated_pool.build do add_message "request.HelloRequest" do optional :msg, :string, 1 optional :inner, :message, 2, "request.InnerRequest" optional :n, :int64, ...
github
ganmacs/grpc_mock
https://github.com/ganmacs/grpc_mock
spec/examples/hello/hello_client.rb
Ruby
mit
45
master
774
require_relative './hello_services_pb' class HelloClient def initialize @client = Hello::Hello::Stub.new('localhost:8000', :this_channel_is_insecure) end def send_message(msg, client_stream: false, server_stream: false, metadata: {}) if client_stream && server_stream m = Hello::HelloStreamRequest....
github
ganmacs/grpc_mock
https://github.com/ganmacs/grpc_mock
spec/examples/hello/hello_pb.rb
Ruby
mit
45
master
938
# Generated by the protocol buffer compiler. DO NOT EDIT! # source: hello.proto require 'google/protobuf' Google::Protobuf::DescriptorPool.generated_pool.build do add_message "hello.HelloRequest" do optional :msg, :string, 1 end add_message "hello.HelloResponse" do optional :msg, :string, 1 end add...
github
ganmacs/grpc_mock
https://github.com/ganmacs/grpc_mock
spec/examples/hello/hello_services_pb.rb
Ruby
mit
45
master
685
# Generated by the protocol buffer compiler. DO NOT EDIT! # Source: hello.proto for package 'hello' require 'grpc' require 'examples/hello/hello_pb' module Hello module Hello class Service include GRPC::GenericService self.marshal_class_method = :encode self.unmarshal_class_method = :decode...
github
ganmacs/grpc_mock
https://github.com/ganmacs/grpc_mock
spec/grpc_mock/request_stub_spec.rb
Ruby
mit
45
master
4,669
# frozen_string_literal: true RSpec.describe GrpcMock::RequestStub do let(:stub_request) do described_class.new(path) end let(:path) do '/service_name/method_name' end describe '#response' do let(:exception) { StandardError.new } let(:request1) { :request_1 } let(:request2) { :request_2...
github
ganmacs/grpc_mock
https://github.com/ganmacs/grpc_mock
spec/grpc_mock/mocked_call_spec.rb
Ruby
mit
45
master
4,192
require 'rspec' RSpec.describe GrpcMock::MockedCall do describe "#metadata" do it "returns metadata hash" do call = GrpcMock::MockedCall.new(metadata: { foo: 'bar' }) expect(call.metadata).to eq({ 'foo' => 'bar' }) end end describe "#sanitize_metadata" do def sanitize_metadata(metadata) ...
github
ganmacs/grpc_mock
https://github.com/ganmacs/grpc_mock
spec/grpc_mock/stub_registry_spec.rb
Ruby
mit
45
master
440
# frozen_string_literal: true RSpec.describe GrpcMock::StubRegistry do let(:registry) do described_class.new end let(:request_stub) do double(:request_stub, 'match?': true, response: 'response') end it 'registers and responses' do expect(registry.register_request_stub(request_stub)).to eq(reque...
github
ganmacs/grpc_mock
https://github.com/ganmacs/grpc_mock
spec/grpc_mock/request_pattern_spec.rb
Ruby
mit
45
master
1,358
# frozen_string_literal: true RSpec.describe GrpcMock::RequestPattern do let(:request_pattern) do described_class.new(path) end let(:path) do 'test_path' end describe '#with' do context 'with no argument' do it 'raises an error' do expect { request_pattern.with }.to raise_error(Ar...
github
ganmacs/grpc_mock
https://github.com/ganmacs/grpc_mock
spec/grpc_mock/matchers/request_including_matcher_spec.rb
Ruby
mit
45
master
948
# frozen_string_literal: true require 'grpc_mock/matchers/request_including_matcher' RSpec.describe GrpcMock::Matchers::RequestIncludingMatcher do let(:matcher) do described_class.new(values) end let(:values) do { key: 'value' } end it { expect(matcher == { 'key' => 'value', key2: 'value' }).to eq...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
Gemfile
Ruby
mit
45
main
264
# frozen_string_literal: true source "https://rubygems.org" # Specify your gem's dependencies in test_budget.gemspec gemspec gem "irb" gem "rake", "~> 13.0" gem "rspec", "~> 3.0" gem "simplecov", require: false gem "standardrb", "~> 1.0", group: :development
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
test_budget.gemspec
Ruby
mit
45
main
1,667
# frozen_string_literal: true require_relative "lib/test_budget/version" Gem::Specification.new do |spec| spec.name = "test_budget" spec.version = TestBudget::VERSION spec.authors = ["Matheus Richard"] spec.email = ["matheusrichardt@gmail.com"] spec.summary = "You have a time budget for tests. This gem enf...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
spec/spec_helper.rb
Ruby
mit
45
main
504
# frozen_string_literal: true if ENV["COVERAGE"] require "simplecov" SimpleCov.start do enable_coverage :branch add_filter "/spec/" end end require "test_budget" require_relative "support/file_helpers" require_relative "support/factory" RSpec.configure do |config| config.example_status_persistence_fi...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
spec/support/factory.rb
Ruby
mit
45
main
2,022
# frozen_string_literal: true module Factory def build_budget(per_test_case: nil, suite: nil, allowlist: []) TestBudget::Budget.new( path: nil, timings_path: nil, suite: TestBudget::Budget::Suite.new(max_duration: suite&.dig(:max_duration)), per_test_case: TestBudget::Budget::PerTestCase....
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
spec/support/file_helpers.rb
Ruby
mit
45
main
561
# frozen_string_literal: true require "tempfile" require "yaml" require "json" module FileHelpers def write_budget_file(data, &block) with_tempfile([".test_budget", ".yml"], data.to_yaml, &block) end def write_timings_file(examples, &block) with_tempfile(["test_timings", ".json"], JSON.generate("exampl...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
spec/test_budget/budget_spec.rb
Ruby
mit
45
main
10,156
# frozen_string_literal: true RSpec.describe TestBudget::Budget do it "loads configuration from YAML" do write_budget_file( "timings_path" => "tmp/results.json", "suite" => {"max_duration" => 600}, "per_test_case" => {"default" => 3, "system" => 10, "model" => 2}, "allowlist" => [{"test_c...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
spec/test_budget/warning_spec.rb
Ruby
mit
45
main
768
# frozen_string_literal: true RSpec.describe TestBudget::Warning do it "formats stale warning with reason" do warning = described_class.new(entry: build_entry, kind: :stale) expect(warning.message).to eq( "obsolete allowlist entry (stale)\nspec/models/user_spec.rb -- User is valid\nreason: legacy test...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
spec/test_budget/audit_spec.rb
Ruby
mit
45
main
1,328
# frozen_string_literal: true RSpec.describe TestBudget::Audit do it "returns no violations when all tests are within budget" do write_timings_file([ { "file_path" => "spec/models/user_spec.rb", "full_description" => "User is valid", "run_time" => 1.0, "status" => "passed" } ...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
spec/test_budget/allowlist_spec.rb
Ruby
mit
45
main
4,851
# frozen_string_literal: true RSpec.describe TestBudget::Allowlist do let(:future_date) { (Date.today + 365).to_s } describe "#allowed?" do it "returns matching entry" do allowlist = described_class.new([ {"test_case" => "spec/models/user_spec.rb -- User#slow", "reason" => "Legacy", "expires_on"...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
spec/test_budget/reporter_spec.rb
Ruby
mit
45
main
1,843
# frozen_string_literal: true RSpec.describe TestBudget::Reporter do let(:reporter) { described_class.new(budget_path: ".test_budget.yml") } it "prints all clear when no violations" do expect { reporter.report(build_result) }.to output(/all clear/).to_stdout end it "prints numbered violations" do vio...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
spec/test_budget/violation_spec.rb
Ruby
mit
45
main
2,418
# frozen_string_literal: true RSpec.describe TestBudget::Violation do describe "#message" do it "formats per_test_case violation message" do test_case = TestBudget::TestCase.new( file: "spec/models/user_spec.rb", name: "User#full_name", duration: 2.5, status: "passed", line_number: 4 ...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
spec/test_budget/cli_spec.rb
Ruby
mit
45
main
16,139
# frozen_string_literal: true RSpec.describe TestBudget::CLI do let(:cli) { described_class.new } it "returns 0 when all tests are within budget" do write_timings_file([ { "file_path" => "spec/models/user_spec.rb", "full_description" => "User is valid", "run_time" => 1.0, "status...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
spec/test_budget/test_case_spec.rb
Ruby
mit
45
main
8,401
# frozen_string_literal: true RSpec.describe TestBudget::TestCase do describe "#type" do { "spec/system/login_spec.rb" => :system, "spec/requests/api_spec.rb" => :request, "spec/models/user_spec.rb" => :model, "spec/controllers/users_controller_spec.rb" => :controller, "spec/helpers...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
spec/test_budget/auditor_spec.rb
Ruby
mit
45
main
4,994
# frozen_string_literal: true RSpec.describe TestBudget::Auditor do it "returns per_test_case violations" do budget = build_budget(per_test_case: {default: 2}) auditor = described_class.new(budget) result = auditor.audit(build_test_run([build_test_case(duration: 3.0)])) expect(result.violations.siz...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
spec/test_budget/test_run_spec.rb
Ruby
mit
45
main
3,706
# frozen_string_literal: true RSpec.describe TestBudget::TestRun do describe "#over?" do it "returns nil when under budget" do budget = build_budget(suite: {max_duration: 600}) test_run = described_class.new(test_cases: [], wall_time: 500) expect(test_run.over?(budget)).to be_nil end ...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
spec/test_budget/budget/estimate_spec.rb
Ruby
mit
45
main
6,110
# frozen_string_literal: true RSpec.describe TestBudget::Budget::Estimate do around do |example| Dir.mktmpdir do |dir| Dir.chdir(dir) { example.run } end end describe "#generate" do context "with a results file" do it "generates config with correct YAML structure" do write_timing...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
spec/test_budget/test_run/diff_spec.rb
Ruby
mit
45
main
5,525
# frozen_string_literal: true RSpec.describe TestBudget::TestRun::Diff do describe "#to_s" do it "returns empty string when runs are identical" do test_cases = [ build_test_case(file: "spec/models/user_spec.rb", duration: 2.0), build_test_case(file: "spec/system/login_spec.rb", duration: 50...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
spec/test_budget/test_run/breakdown_spec.rb
Ruby
mit
45
main
4,425
# frozen_string_literal: true RSpec.describe TestBudget::TestRun::Breakdown do describe "#to_s" do it "groups test cases by type and sorts by duration descending" do test_run = TestBudget::TestRun.new( test_cases: [ build_test_case(file: "spec/models/user_spec.rb", duration: 2.0), ...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
spec/test_budget/parser/rspec_spec.rb
Ruby
mit
45
main
3,426
# frozen_string_literal: true RSpec.describe TestBudget::Parser::Rspec do let(:fixture_path) { File.expand_path("../../fixtures/rspec_output.json", __dir__) } let(:test_run) { described_class.parse(fixture_path) } it "parses RSpec JSON output into TestCase objects" do expect(test_run.test_cases.size).to eq(...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
spec/test_budget/allowlist/entry_spec.rb
Ruby
mit
45
main
2,913
# frozen_string_literal: true RSpec.describe TestBudget::Allowlist::Entry do it "stores test_case_key, reason, and expires_on" do entry = described_class.new(test_case_key: "spec/models/user_spec.rb -- User#slow", reason: "Legacy test", expires_on: Date.today + 30) expect(entry.test_case_key).to eq("spec/mo...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
lib/test_budget.rb
Ruby
mit
45
main
1,002
# frozen_string_literal: true require_relative "test_budget/version" require_relative "test_budget/inflector" require_relative "test_budget/allowlist" require_relative "test_budget/test_case" require_relative "test_budget/violation" require_relative "test_budget/warning" require_relative "test_budget/budget" require_r...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
lib/test_budget/cli.rb
Ruby
mit
45
main
4,748
# frozen_string_literal: true require "optparse" require "argument_parser" module TestBudget class CLI def call(argv) args = argv.dup return print_help if args.empty? || (args & %w[--help -h]).any? return print_version if (args & %w[--version -v]).any? parsed = command_parser.parse!(ar...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
lib/test_budget/test_case.rb
Ruby
mit
45
main
1,508
# frozen_string_literal: true module TestBudget class TestCase < Data.define(:file, :name, :duration, :status, :line_number) def initialize(file:, name:, duration:, status:, line_number:) super(file: file.delete_prefix("./"), name: name, duration: duration, status: status, line_number: line_number) end...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
lib/test_budget/reporter.rb
Ruby
mit
45
main
902
# frozen_string_literal: true module TestBudget class Reporter def initialize(budget_path:) @budget_path = budget_path end def report(result) violations = result.violations if violations.empty? puts "Test budget: all clear" else puts "Test budget: #{violations.si...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
lib/test_budget/test_run.rb
Ruby
mit
45
main
880
# frozen_string_literal: true module TestBudget class TestRun < Data.define(:test_cases, :wall_time) Group = Data.define(:type, :count, :duration, :test_run) do def percent_count = count * 100.0 / test_run.size def percent_duration = duration * 100.0 / test_run.total_time end def size = tes...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
lib/test_budget/allowlist.rb
Ruby
mit
45
main
1,590
# frozen_string_literal: true require "date" module TestBudget class Allowlist def initialize(raw_entries = []) @entries = raw_entries.map do |entry| Entry.new( test_case_key: entry["test_case"], reason: entry["reason"], expires_on: parse_date(entry["expires_on"]) ...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
lib/test_budget/inflector.rb
Ruby
mit
45
main
419
# frozen_string_literal: true module TestBudget module Inflector IRREGULARS = { "entry" => "entries", "policy" => "policies", "factory" => "factories", "query" => "queries" }.freeze def self.pluralize(word, count) (count == 1) ? word : (IRREGULARS[word] || "#{word}s") e...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
lib/test_budget/auditor.rb
Ruby
mit
45
main
780
# frozen_string_literal: true module TestBudget class Auditor TOLERANCE = 0.1 def initialize(budget, tolerant: false) @budget = tolerant ? budget.inflate_by(TOLERANCE) : budget end def audit(test_run) Audit::Result.new( violations: violations_for(test_run), warnings: war...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
lib/test_budget/budget.rb
Ruby
mit
45
main
3,132
# frozen_string_literal: true require "date" require "yaml" module TestBudget class Budget < Data.define(:path, :timings_path, :suite, :per_test_case, :allowlist) DEFAULT_EXPIRATION_DAYS = 60 Suite = Data.define(:max_duration) PerTestCase = Data.define(:default, :types) def self.estimate(...) = Es...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
lib/test_budget/violation.rb
Ruby
mit
45
main
486
# frozen_string_literal: true module TestBudget Violation = Data.define(:test_case, :duration, :limit, :kind) do def message if kind == :suite "Suite total time (%.2fs) exceeds limit (%.2fs)" % [duration, limit] else format("%s (%.2fs) exceeds %s limit (%.2fs)", test_case.key, duratio...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
lib/test_budget/warning.rb
Ruby
mit
45
main
274
# frozen_string_literal: true module TestBudget Warning = Data.define(:entry, :kind) do def message reason_line = entry.reason ? "\nreason: #{entry.reason}" : "" "obsolete allowlist entry (#{kind})\n#{entry.test_case_key}#{reason_line}" end end end
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
lib/test_budget/statistics.rb
Ruby
mit
45
main
774
# frozen_string_literal: true module TestBudget module Statistics def self.p99(values, tolerance: 0) = percentile(0.99, values, tolerance: tolerance) private_class_method def self.percentile(rank, values, tolerance: 0) sorted = values.sort n = sorted.size return apply_tolerance(sorted[0], ...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
lib/test_budget/format.rb
Ruby
mit
45
main
666
# frozen_string_literal: true module TestBudget module Format extend self def duration(seconds) if seconds >= 60 minutes = (seconds / 60).to_i secs = (seconds % 60).round "#{minutes}m #{secs}s" else "#{seconds.round}s" end end def signed_duration(se...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
lib/test_budget/audit.rb
Ruby
mit
45
main
561
# frozen_string_literal: true module TestBudget class Audit Result = Data.define(:violations, :warnings) do def passed? = violations.empty? end def initialize(budget_path:, tolerant: false) @budget_path = budget_path @tolerant = tolerant end def perform budget = Budget.l...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
lib/test_budget/table.rb
Ruby
mit
45
main
1,329
# frozen_string_literal: true module TestBudget class Table def initialize(columns) @columns = columns end def render(rows, footer:) all_rows = [headers, *rows, footer] widths = resolve_widths(all_rows) header = format_row(headers, widths) body = rows.map { |cells| format_...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
lib/test_budget/test_run/delta.rb
Ruby
mit
45
main
623
# frozen_string_literal: true module TestBudget class TestRun Delta = Data.define(:label, :before, :after) do def count = after.count - before.count def duration = after.duration - before.duration def new? = before.count == 0 def removed? = after.count == 0 def zero? = count == 0 &...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
lib/test_budget/test_run/breakdown.rb
Ruby
mit
45
main
1,185
# frozen_string_literal: true module TestBudget class TestRun class Breakdown < Data.define(:test_run, :sort) SORT_OPTIONS = %i[duration count type].freeze TABLE = Table.new([ ["Test Type", :left], ["Count", :right], ["%", :right], ["Duration", :right], ["%", :...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
lib/test_budget/test_run/diff.rb
Ruby
mit
45
main
1,553
# frozen_string_literal: true module TestBudget class TestRun class Diff < Data.define(:before, :after) TABLE = Table.new([ ["Test Type", :left], ["Δ Count", :right], ["%", :right], ["Δ Duration", :right], ["%", :right] ]) def to_s rows = delta_r...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
lib/test_budget/budget/estimate.rb
Ruby
mit
45
main
2,242
# frozen_string_literal: true require "yaml" module TestBudget class Budget class Estimate TOLERANCE = 0.10 PER_TEST_CASE_DEFAULTS = {"default" => 3, "system" => 6, "request" => 3, "model" => 1.5}.freeze def initialize(timings_path: nil, force: false) @timings_path = timings_path ...
github
thoughtbot/test_budget
https://github.com/thoughtbot/test_budget
lib/test_budget/parser/rspec.rb
Ruby
mit
45
main
1,423
# frozen_string_literal: true require "json" module TestBudget module Parser module Rspec extend self def parse(pattern) paths = Dir.glob(pattern) raise TestBudget::Error, "No timing files found matching: #{pattern}" if paths.empty? groups = paths.flat_map { |path| parse_fi...
github
y10k/rims
https://github.com/y10k/rims
Rakefile
Ruby
mit
45
master
3,483
# -*- coding: utf-8 -*- require 'bundler/gem_tasks' require 'pathname' require 'rake/clean' require 'rake/testtask' require 'rdoc/task' Rake::TestTask.new do |task| if ((ENV.key? 'RUBY_DEBUG') && (! ENV['RUBY_DEBUG'].empty?)) then task.ruby_opts << '-d' end end Rake::TestTask.new(:test_cmd) do |task| task....
github
y10k/rims
https://github.com/y10k/rims
rims.gemspec
Ruby
mit
45
master
1,400
# -*- coding: utf-8 -*- lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'rims/version' Gem::Specification.new do |spec| spec.name = 'rims' spec.version = RIMS::VERSION spec.authors = ['TOKI Yoshinori'] spec.email = ['toki@...
github
y10k/rims
https://github.com/y10k/rims
lib/rims.rb
Ruby
mit
45
master
2,041
# -*- coding: utf-8 -*- require "rims/version" autoload :OpenSSL, 'openssl' module RIMS autoload :Authentication, 'rims/auth' autoload :Checksum_KeyValueStore, 'rims/cksum_kvs' autoload :Cmd, 'rims/cmd' autoload :CommandSizeTooLargeError, 'rims/protocol' autoload :DB, ...
github
y10k/rims
https://github.com/y10k/rims
lib/rims/dump.rb
Ruby
mit
45
master
3,919
# -*- coding: utf-8 -*- require 'fileutils' module RIMS module Dump PLUG_IN = {} # :nodoc: class << self def add_plug_in(name, reader_class, writer_class) PLUG_IN[name] = { ReaderClass: reader_class, WriterClass: writer_class } self end...
github
y10k/rims
https://github.com/y10k/rims
lib/rims/protocol.rb
Ruby
mit
45
master
2,525
# -*- coding: utf-8 -*- module RIMS class ProtocolError < Error end class ReadSizeError < ProtocolError end class LineTooLongError < ReadSizeError end class RecoverableReadSizeError < ReadSizeError def initialize(message=nil, command_tag=nil, **kw_args) super(message, **kw_args) @comma...
github
y10k/rims
https://github.com/y10k/rims
lib/rims/mail_store.rb
Ruby
mit
45
master
16,025
# -*- coding: utf-8 -*- require 'forwardable' require 'logger' require 'set' module RIMS class MailStore extend Forwardable MSG_FLAG_NAMES = %w[ answered flagged deleted seen draft recent ].each{|n| n.freeze }.freeze def initialize(meta_db, msg_db, &mbox_db_factory) # :yields: mbox_id @rw_lock =...
github
y10k/rims
https://github.com/y10k/rims
lib/rims/db.rb
Ruby
mit
45
master
21,846
# -*- coding: utf-8 -*- require 'logger' require 'set' module RIMS module DB class Core def initialize(kvs) @kvs = kvs end def sync @kvs.sync self end def close @kvs.close self end def destroy @kvs.destroy nil ...
github
y10k/rims
https://github.com/y10k/rims
lib/rims/test.rb
Ruby
mit
45
master
14,112
# -*- coding: utf-8 -*- require 'digest' require 'fileutils' require 'pp' if $DEBUG require 'set' require 'stringio' module RIMS module Test module AssertUtility def literal(text_string) "{#{text_string.bytesize}}\r\n#{text_string}" end module_function :literal def make_header_t...
github
y10k/rims
https://github.com/y10k/rims
lib/rims/error.rb
Ruby
mit
45
master
725
# -*- coding: utf-8 -*- module RIMS class Error < StandardError def initialize(*args, **kw_args) super(*args) @optional_data = kw_args.dup.freeze end attr_reader :optional_data def self.trace_error_chain(exception) return enum_for(:trace_error_chain, exception) unless block_given?...
github
y10k/rims
https://github.com/y10k/rims
lib/rims/gdbm_kvs.rb
Ruby
mit
45
master
1,251
# -*- coding: utf-8 -*- require 'gdbm' module RIMS class GDBM_KeyValueStore < KeyValueStore def initialize(gdbm, path) @db = gdbm @path = path end class << self def exist?(path) gdbm_path = path + '.gdbm' File.exist? gdbm_path end def open(path, *optional)...
github
y10k/rims
https://github.com/y10k/rims
lib/rims/hash_kvs.rb
Ruby
mit
45
master
1,119
# -*- coding: utf-8 -*- module RIMS class Hash_KeyValueStore < KeyValueStore def initialize(hash) @db = hash end def [](key) unless (key.is_a? String) then raise "not a string key: #{key}" end @db[key.b] end def []=(key, value) unless (key.is_a? String) the...
github
y10k/rims
https://github.com/y10k/rims
lib/rims/cksum_kvs.rb
Ruby
mit
45
master
1,159
# -*- coding: utf-8 -*- require 'digest' module RIMS class Checksum_KeyValueStore < KeyValueStore def initialize(kvs) @kvs = kvs end def md5_cksum_parse(key, s) if (s) then s =~ /\A md5 \s (\S+?) \n/x or raise "checksum format error at key: #{key}" md5_cksum = $1 val...
github
y10k/rims
https://github.com/y10k/rims
lib/rims/passwd.rb
Ruby
mit
45
master
7,193
# -*- coding: utf-8 -*- require 'digest' require 'securerandom' module RIMS module Password # expected behavior of a typical password source. # 1. a password source plug-in file is loaded by a # configuration file item of <tt>load_libraries</tt>. # (exceptions: RIMS::Password::Plai...
github
y10k/rims
https://github.com/y10k/rims
lib/rims/service.rb
Ruby
mit
45
master
46,545
# -*- coding: utf-8 -*- require 'etc' require 'json' require 'logger' require 'logger/joint' require 'pathname' require 'riser' require 'socket' require 'yaml' module RIMS class Service class Configuration class << self def stringify_symbol(collection) case (collection) when Ha...
github
y10k/rims
https://github.com/y10k/rims
lib/rims/auth.rb
Ruby
mit
45
master
3,446
# -*- coding: utf-8 -*- require 'digest' require 'openssl' require 'securerandom' module RIMS class Authentication PLUG_IN = {} # :nodoc: class << self def unique_user_id(username) Digest::SHA256.hexdigest(username).freeze end def make_time_source proc{ Tim...
github
y10k/rims
https://github.com/y10k/rims
lib/rims/simple_dump.rb
Ruby
mit
45
master
3,325
# -*- coding: utf-8 -*- require 'digest' module RIMS class SimpleText_DumpReader < DumpReader def each # :yields: filename, contnet, valid return enum_for(:each) unless block_given? while (line = @input.gets) line.chomp! header_size, checksum = line.split(',', 2) ...
github
y10k/rims
https://github.com/y10k/rims
lib/rims/lock.rb
Ruby
mit
45
master
4,034
# -*- coding: utf-8 -*- require 'logger' module RIMS class LockError < Error end class IllegalLockError < LockError end class ReadLockError < LockError end class ReadLockTimeoutError < ReadLockError end class WriteLockError < LockError end class WriteLockTimeoutError < LockError end cl...
github
y10k/rims
https://github.com/y10k/rims
lib/rims/channel.rb
Ruby
mit
45
master
4,569
# -*- coding: utf-8 -*- require 'forwardable' module RIMS class ServerResponseChannelError < Error end class ServerResponseChannelAttachError < ServerResponseChannelError end class ServerResponseChannelDetachError < ServerResponseChannelError end class ServerResponseChannelPublishError < ServerRespon...
github
y10k/rims
https://github.com/y10k/rims
lib/rims/kvs.rb
Ruby
mit
45
master
2,006
# -*- coding: utf-8 -*- module RIMS class KeyValueStore def [](key) raise NotImplementedError, 'abstract' end def []=(key, value) raise NotImplementedError, 'abstract' end def delete(key) raise NotImplementedError, 'abstract' end def key?(key) raise NotImplement...
github
y10k/rims
https://github.com/y10k/rims
lib/rims/cmd.rb
Ruby
mit
45
master
54,928
# -*- coding: utf-8 -*- require 'json' require 'net/imap' require 'optparse' require 'pp'if $DEBUG require 'riser' require 'yaml' OptionParser.accept(JSON) do |json_data, *_| begin JSON.load(json_data) rescue raise OptionParser::InvalidArgument, json_data end end module RIMS module Cmd CMDs = {} ...
github
y10k/rims
https://github.com/y10k/rims
lib/rims/protocol/connection.rb
Ruby
mit
45
master
1,747
# -*- coding: utf-8 -*- require 'riser' module RIMS module Protocol class ConnectionLimits def initialize(read_polling_interval_seconds, command_wait_timeout_seconds) @mutex = Thread::Mutex.new @read_polling_interval_seconds = read_polling_interval_seconds self.command_wait_timeout...
github
y10k/rims
https://github.com/y10k/rims
lib/rims/protocol/decoder.rb
Ruby
mit
45
master
76,121
# -*- coding: utf-8 -*- require 'logger' require 'net/imap' require 'pp' require 'time' module RIMS module Protocol class Decoder # to use `StringIO' as mock in unit test using Riser::CompatibleStringIO def self.new_decoder(*args, **opts) InitialDecoder.new(*args, **opts) end ...
github
y10k/rims
https://github.com/y10k/rims
lib/rims/protocol/parser.rb
Ruby
mit
45
master
43,353
# -*- coding: utf-8 -*- require 'set' require 'time' module RIMS module Protocol FetchBody = Struct.new(:symbol, :option, :section, :section_list, :partial_origin, :partial_size) class FetchBody def fetch_att_name s = '' s << symbol s << '.' << option if option s << '[...
github
y10k/rims
https://github.com/y10k/rims
load_test/Rakefile
Ruby
mit
45
master
2,295
# -*- coding: utf-8 -*- require 'rake/clean' require 'yaml' def start_pgrp(*cmds) pgid = fork{ Process.setpgid($$, $$) sh *cmds } Process.setpgid(pgid, pgid) pgid end def run_server(*options) pgid = start_pgrp('rims', 'server', *options) begin sleep 1 yield ensure Process.kill('TER...
github
y10k/rims
https://github.com/y10k/rims
test/test_protocol.rb
Ruby
mit
45
master
3,588
# -*- coding: utf-8 -*- require 'pp' if $DEBUG require 'rims' require 'test/unit' require 'time' module RIMS::Test class TimeTest < Test::Unit::TestCase def test_parse_date_time assert_equal(Time.utc(1975, 11, 19, 3, 34, 56), Time.parse('19-Nov-1975 12:34:56 +0900')) assert_raise(ArgumentError) { Ti...
github
y10k/rims
https://github.com/y10k/rims
test/test_simple_dump.rb
Ruby
mit
45
master
3,999
# -*- coding: utf-8 -*- require 'digest' require 'pp' if $DEBUG require 'rims' require 'set' require 'stringio' require 'test/unit' module RIMS::Test class SimpleText_DumpTest < Test::Unit::TestCase include RIMS::Test::DumpTestUtility include RIMS::Test::ProtocolFetchMailSample def get_dump_name ...
github
y10k/rims
https://github.com/y10k/rims
test/test_db_recovery.rb
Ruby
mit
45
master
28,965
# -*- coding: utf-8 -*- require 'logger' require 'pp' if $DEBUG require 'rims' require 'test/unit' module RIMS::Test class DBRecoveryTest < Test::Unit::TestCase def setup @logger = Logger.new(STDOUT) @logger.level = ($DEBUG) ? Logger::DEBUG : Logger::FATAL @kvs = {} @kvs_open = proc{|na...
github
y10k/rims
https://github.com/y10k/rims
test/test_auth.rb
Ruby
mit
45
master
6,408
# -*- coding: utf-8 -*- require 'pp' if $DEBUG require 'rims' require 'test/unit' module RIMS::Test class AuthenticationTest < Test::Unit::TestCase include RIMS::Test::PseudoAuthenticationUtility def setup src_time = Time.at(1404046689) random_seed = 70100924388646298230620504594645040907 ...
github
y10k/rims
https://github.com/y10k/rims
test/test_lock.rb
Ruby
mit
45
master
4,237
# -*- coding: utf-8 -*- require 'rims' require 'test/unit' Thread.abort_on_exception = true if $DEBUG module RIMS::Test class ReadWriteLockTest < Test::Unit::TestCase def setup @lock = RIMS::ReadWriteLock.new end def test_read_lock count = 0 @lock.read_synchronize{ count += 1 } ...
github
y10k/rims
https://github.com/y10k/rims
test/test_service.rb
Ruby
mit
45
master
72,124
# -*- coding: utf-8 -*- require 'fileutils' require 'logger' require 'pathname' require 'rims' require 'socket' require 'test/unit' require 'yaml' module RIMS::Test class ServiceConfigurationClassMethodTest < Test::Unit::TestCase data('symbol' => [ 'foo', :foo ], 'arra...
github
y10k/rims
https://github.com/y10k/rims
test/test_hash_kvs.rb
Ruby
mit
45
master
3,402
# -*- coding: utf-8 -*- require 'pp' if $DEBUG require 'rims' require 'test/unit' module RIMS::Test class Hash_KeyValueStoreTest < Test::Unit::TestCase def setup @db = {} @kvs = RIMS::Hash_KeyValueStore.new(@db) end def teardown pp @db if $DEBUG end def test_store_fetch ...
github
y10k/rims
https://github.com/y10k/rims
test/test_gdbm_kvs.rb
Ruby
mit
45
master
556
# -*- coding: utf-8 -*- require 'gdbm' require 'rims' require 'test/unit' module RIMS::Test class GDBM_KeyValueStoreTest < Test::Unit::TestCase include KeyValueStoreTestUtility def open_database GDBM.new(@name) end def make_key_value_store RIMS::GDBM_KeyValueStore.new(@db, @name) e...
github
y10k/rims
https://github.com/y10k/rims
test/test_protocol_request.rb
Ruby
mit
45
master
14,838
# -*- coding: utf-8 -*- require 'logger' require 'rims' require 'stringio' require 'test/unit' module RIMS::Test class ProtocolRequestReaderTest < Test::Unit::TestCase extend AssertUtility include AssertUtility LINE_LENGTH_LIMIT = 128 LITERAL_SIZE_LIMIT = 1024**2 COMMAND_SIZE_LIMIT = LITERAL_S...
github
y10k/rims
https://github.com/y10k/rims
test/test_channel.rb
Ruby
mit
45
master
3,962
# -*- coding: utf-8 -*- require 'rims' require 'test/unit' module RIMS::Test class ServerResponseChannelTest < Test::Unit::TestCase def setup @channel = RIMS::ServerResponseChannel.new end def test_pub_sub_fetch_message pub1, sub1 = @channel.make_pub_sub_pair(0) pub2, sub2 = @channel....
github
y10k/rims
https://github.com/y10k/rims
test/test_protocol_search.rb
Ruby
mit
45
master
29,856
# -*- coding: utf-8 -*- require 'rims' require 'test/unit' require 'time' module RIMS::Test class ProtocolSearchParserTest < Test::Unit::TestCase include ProtocolFetchMailSample def setup @kv_store = {} @kvs_open = proc{|path| RIMS::Hash_KeyValueStore.new(@kv_store[path] = {}) } @mail_sto...
github
y10k/rims
https://github.com/y10k/rims
test/test_mail_store.rb
Ruby
mit
45
master
30,936
# -*- coding: utf-8 -*- require 'logger' require 'pp' if $DEBUG require 'rims' require 'test/unit' require 'time' module RIMS::Test class MailStoreTest < Test::Unit::TestCase include AssertUtility def setup @kvs = Hash.new{|h, k| h[k] = Hash.new } @kvs_open = proc{|name| RIMS::Hash_KeyValueStor...
github
y10k/rims
https://github.com/y10k/rims
test/test_error.rb
Ruby
mit
45
master
1,913
# -*- coding: utf-8 -*- require 'rims' require 'test/unit' module RIMS::Test class ErrorTest < Test::Unit::TestCase def test_optional_data error = RIMS::Error.new('test', foo: 1, bar: '2') assert_equal('test', error.message) assert_equal({ foo: 1, bar: '2' }, error.optional_data) end ...
github
y10k/rims
https://github.com/y10k/rims
test/test_protocol_decoder.rb
Ruby
mit
45
master
242,833
# -*- coding: utf-8 -*- require 'forwardable' require 'logger' require 'net/imap' require 'pp' if $DEBUG require 'rims' require 'riser' require 'socket' require 'stringio' require 'test/unit' require 'time' module RIMS::Test class ProtocolDecoderTest < Test::Unit::TestCase include RIMS::Test::AssertUtility ...
github
y10k/rims
https://github.com/y10k/rims
test/test_protocol_fetch.rb
Ruby
mit
45
master
62,331
# -*- coding: utf-8 -*- require 'digest' require 'logger' require 'rims' require 'set' require 'stringio' require 'test/unit' require 'time' module RIMS::Test class ProtocolFetchParserTest < Test::Unit::TestCase include AssertUtility include ProtocolFetchMailSample include RIMS::Protocol::FetchParser::U...
github
y10k/rims
https://github.com/y10k/rims
test/test_cmd.rb
Ruby
mit
45
master
1,330
# -*- coding: utf-8 -*- require 'rims' require 'test/unit' module RIMS::Test class CmdTest < Test::Unit::TestCase data('string' => [ :foo, 'foo' ], 'hash' => [ { foo: 'bar' }, { 'foo' => 'bar' } ], 'hash_hash' => [...
github
y10k/rims
https://github.com/y10k/rims
test/test_protocol_connection.rb
Ruby
mit
45
master
1,390
# -*- coding: utf-8 -*- require 'rims' require 'test/unit' module RIMS::Test class ProtocolConnectionTimerTest < Test::Unit::TestCase def setup @read_io, @write_io = IO.pipe @limits = RIMS::Protocol::ConnectionLimits.new(0.001, 0.1) @timer = RIMS::Protocol::ConnectionTimer.new(@limits, @read_i...