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 | infinum/dox | https://github.com/infinum/dox | lib/dox/html_renderer.rb | Ruby | mit | 237 | master | 2,273 | module Dox
class HtmlRenderer
def initialize(spec_path, output_path, adapter: Dox::RedoclyAdapter.new)
@spec_path = spec_path
@output_path = output_path
@adapter = adapter
end
def render
spec = JSON.load_file(spec_path)
resolved = resolve_file_refs(spec, ::File.dirname(spec_... |
github | infinum/dox | https://github.com/infinum/dox | lib/dox/config.rb | Ruby | mit | 237 | master | 1,879 | module Dox
class Config
attr_reader :schema_request_folder_path
attr_reader :schema_response_folder_path
attr_reader :schema_response_fail_file_path
attr_accessor :headers_whitelist
attr_accessor :openapi_version
attr_accessor :api_version
attr_accessor :title
attr_accessor :header_des... |
github | infinum/dox | https://github.com/infinum/dox | lib/dox/formatter.rb | Ruby | mit | 237 | master | 3,031 | require 'rspec/core'
require 'rspec/core/formatters/base_formatter'
require 'rspec/core/formatters/console_codes'
module Dox
class Formatter < RSpec::Core::Formatters::BaseFormatter
extend Forwardable
RSpec::Core::Formatters.register self, :example_passed, :stop, :dump_summary
def initialize(output)
... |
github | infinum/dox | https://github.com/infinum/dox | lib/dox/dsl/resource_group.rb | Ruby | mit | 237 | master | 528 | module Dox
module DSL
class ResourceGroup
include AttrProxy
attr_writer :name
attr_writer :desc
def initialize(name, &block)
self.name = name
instance_eval(&block) if block_given?
raise(Dox::Errors::InvalidResourceGroupError, 'Resource group name is required!') i... |
github | infinum/dox | https://github.com/infinum/dox | lib/dox/dsl/documentation.rb | Ruby | mit | 237 | master | 775 | module Dox
module DSL
class Documentation
attr_accessor :subject
attr_accessor :_resource
attr_accessor :_action
attr_accessor :_group
def initialize(opts = {})
self.subject = opts.fetch :subject
end
def resource(name, &block)
self._resource = Resource.n... |
github | infinum/dox | https://github.com/infinum/dox | lib/dox/dsl/action.rb | Ruby | mit | 237 | master | 1,057 | module Dox
module DSL
class Action
include AttrProxy
attr_writer :name
attr_writer :verb
attr_writer :path
attr_writer :desc
attr_writer :params
attr_writer :query_params
attr_writer :request_schema
attr_writer :response_schema_success
attr_writer :resp... |
github | infinum/dox | https://github.com/infinum/dox | lib/dox/dsl/attr_proxy.rb | Ruby | mit | 237 | master | 221 | module Dox
module DSL
module AttrProxy
def method_missing(name, value)
setter = "#{name}="
return super unless respond_to? setter
public_send setter, value
end
end
end
end |
github | infinum/dox | https://github.com/infinum/dox | lib/dox/dsl/resource.rb | Ruby | mit | 237 | master | 1,014 | module Dox
module DSL
class Resource
include AttrProxy
attr_writer :name
attr_writer :group
attr_writer :endpoint
attr_writer :desc
def initialize(name, &block)
self.name = name
instance_eval(&block)
raise(Dox::Errors::InvalidResourceError, 'Resourc... |
github | infinum/dox | https://github.com/infinum/dox | lib/dox/dsl/syntax.rb | Ruby | mit | 237 | master | 698 | module Dox
module DSL
module Syntax
extend ActiveSupport::Concern
def document(subject, &block)
documentation = _subjects[subject] = Documentation.new(subject: subject)
documentation.instance_eval(&block)
end
def const_missing(name)
documentation = _subjects[infer... |
github | infinum/dox | https://github.com/infinum/dox | lib/dox/formatters/json.rb | Ruby | mit | 237 | master | 371 | module Dox
module Formatters
class Json < Dox::Formatters::Base
def format
# in cases where the body isn't valid JSON
# and the headers specify the Content-Type is application/json
# an error should be raised
return '' if body.nil? || body.length < 2
JSON.pretty_gene... |
github | infinum/dox | https://github.com/infinum/dox | lib/dox/formatters/plain.rb | Ruby | mit | 237 | master | 292 | module Dox
module Formatters
class Plain < Dox::Formatters::Base
def format
return body if body.encoding == Encoding::UTF_8
body.encode(Encoding::UTF_8)
rescue Encoding::UndefinedConversionError
"#{body.encoding} stream"
end
end
end
end |
github | infinum/dox | https://github.com/infinum/dox | lib/dox/formatters/xml.rb | Ruby | mit | 237 | master | 309 | module Dox
module Formatters
class Xml < Dox::Formatters::Base
def format
doc = REXML::Document.new(body)
formatter = REXML::Formatters::Pretty.new
formatter.compact = true
result = ''
formatter.write(doc, result)
result
end
end
end
end |
github | infinum/dox | https://github.com/infinum/dox | lib/dox/formatters/base.rb | Ruby | mit | 237 | master | 408 | module Dox
module Formatters
class Base
def initialize(http_env)
@http_env = http_env
http_env_body = http_env.body
@body = http_env_body.respond_to?(:read) ? http_env_body.read : http_env_body
end
def format
raise 'no format method defined in formatter'
en... |
github | infinum/dox | https://github.com/infinum/dox | lib/dox/formatters/multipart.rb | Ruby | mit | 237 | master | 503 | require 'rack'
module Dox
module Formatters
class Multipart
def initialize(http_env)
@http_env = http_env
end
def format
JSON.pretty_generate(extracted_multipart)
end
private
def extracted_multipart
rewind_input
Rack::Multipart.extract_multip... |
github | infinum/dox | https://github.com/infinum/dox | lib/dox/entities/action.rb | Ruby | mit | 237 | master | 2,195 | module Dox
module Entities
class Action
attr_reader :name
attr_reader :desc
attr_reader :verb
attr_reader :path
attr_reader :resource
attr_reader :params
attr_accessor :examples
def initialize(details, request)
@request = request
@name = details[:ac... |
github | infinum/dox | https://github.com/infinum/dox | lib/dox/entities/example.rb | Ruby | mit | 237 | master | 2,910 | module Dox
module Entities
class Example
extend Forwardable
attr_reader :desc
attr_reader :name
attr_reader :request_schema
attr_reader :response_schema_success
attr_reader :response_schema_fail
def_delegator :request, :method, :request_method
def_delegator :respo... |
github | infinum/dox | https://github.com/infinum/dox | lib/dox/entities/resource.rb | Ruby | mit | 237 | master | 358 | module Dox
module Entities
class Resource
attr_reader :name
attr_reader :desc
attr_reader :group
attr_accessor :actions
def initialize(details)
@name = details[:resource_name]
@group = details[:resource_group_name]
@desc = details[:resource_desc]
@act... |
github | infinum/dox | https://github.com/infinum/dox | lib/dox/entities/resource_group.rb | Ruby | mit | 237 | master | 309 | module Dox
module Entities
class ResourceGroup
attr_reader :name
attr_accessor :desc
attr_accessor :resources
def initialize(details)
@name = details[:resource_group_name]
@desc = details[:resource_group_desc]
@resources = {}
end
end
end
end |
github | infinum/dox | https://github.com/infinum/dox | lib/dox/printers/example_request_printer.rb | Ruby | mit | 237 | master | 2,043 | module Dox
module Printers
class ExampleRequestPrinter < BasePrinter
def print(example)
self.example = example
add_example_request
end
private
attr_accessor :example
def add_example_request
spec['parameters'] = add_new_header_params(find_or_add(spec, 'param... |
github | infinum/dox | https://github.com/infinum/dox | lib/dox/printers/base_printer.rb | Ruby | mit | 237 | master | 1,352 | require 'rexml/document'
module Dox
module Printers
class BasePrinter
attr_reader :spec
def initialize(spec)
@spec = spec || {}
end
def print
raise NotImplementedError
end
def find_or_add(hash, key, default = {})
return hash[key] if hash.key?(key)
... |
github | infinum/dox | https://github.com/infinum/dox | lib/dox/printers/resource_group_printer.rb | Ruby | mit | 237 | master | 721 | module Dox
module Printers
class ResourceGroupPrinter < BasePrinter
def print(resource_group)
self.resource_group = resource_group
add_resource_group
resource_group.resources.each_value do |resource|
resource_printer.print(resource)
end
end
private
... |
github | infinum/dox | https://github.com/infinum/dox | lib/dox/printers/action_printer.rb | Ruby | mit | 237 | master | 937 | module Dox
module Printers
class ActionPrinter < BasePrinter
def print(action)
self.action = action
@action_hash = find_or_add(find_or_add(spec, action.path.to_s), action.verb.downcase.to_sym)
add_action
add_action_params
print_examples
end
private
... |
github | infinum/dox | https://github.com/infinum/dox | lib/dox/printers/example_response_printer.rb | Ruby | mit | 237 | master | 2,316 | module Dox
module Printers
class ExampleResponsePrinter < BasePrinter
def print(example)
self.example = example
add_example_response
end
private
attr_accessor :example
def add_example_response
add_statuses(find_or_add(find_or_add(spec, 'responses'), example... |
github | infinum/dox | https://github.com/infinum/dox | lib/dox/printers/resource_printer.rb | Ruby | mit | 237 | master | 778 | module Dox
module Printers
class ResourcePrinter < BasePrinter
def print(resource)
self.resource = resource
add_resources
resource.actions.each_value do |action|
action_printer.print(action)
end
end
private
attr_accessor :resource
def add... |
github | infinum/dox | https://github.com/infinum/dox | lib/dox/printers/document_printer.rb | Ruby | mit | 237 | master | 1,214 | module Dox
module Printers
class DocumentPrinter < BasePrinter
def initialize(output)
super(body)
@output = output
end
def print(passed_examples)
spec['paths'] = {}
spec['tags'] = []
spec['x-tagGroups'] = []
passed_examples.sort.each do |_, resou... |
github | infinum/dox | https://github.com/infinum/dox | lib/dox/util/file.rb | Ruby | mit | 237 | master | 391 | module Dox
module Util
module File
def self.file_path(path, config_root_path: Dox.config.descriptions_location)
return '' unless config_root_path
config_root_path.each do |root_path|
full_path = ::File.join(root_path, path)
next unless ::File.exist?(full_path)
... |
github | infinum/dox | https://github.com/infinum/dox | lib/dox/util/http.rb | Ruby | mit | 237 | master | 2,379 | module Dox
module Util
module Http
VERB = ['POST', 'GET', 'PUT', 'PATCH', 'DELETE', 'HEAD'].freeze
HTTP_STATUS_CODES = {
100 => 'Continue',
101 => 'Switching Protocols',
102 => 'Processing',
103 => 'Early Hints',
200 => 'OK',
201 => 'Created',
20... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | pbt.gemspec | Ruby | mit | 237 | main | 1,358 | # frozen_string_literal: true
require_relative "lib/pbt/version"
Gem::Specification.new do |spec|
spec.name = "pbt"
spec.version = Pbt::VERSION
spec.authors = ["ohbarye"]
spec.email = ["over.rye@gmail.com"]
spec.summary = "Property-Based Testing tool for Ruby, utilizing Ractor for parallelizing test cases.... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | Rakefile | Ruby | mit | 237 | main | 1,685 | # frozen_string_literal: true
require "bundler/gem_tasks"
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)
require "standard/rake"
task default: %i[spec standard]
namespace :benchmark do
task all: ["success:simple", "success:cpu_bound", "success:io_bound", "failure:simple"]
namespace :success d... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | benchmark/success_io_bound.rb | Ruby | mit | 237 | main | 611 | require "pbt"
require "benchmark/ips"
# Read file generated by https://www.lipsum.com/
# 150 paragraphs, 13689 words, 92206 bytes.
def task(str)
File.read(File.join(__dir__, "example.txt")) + str
end
seed = 17243810592888013452170775373100387856
Benchmark.ips do |x|
x.report("ractor") do
Pbt.assert(worker: :... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | benchmark/failure_simple.rb | Ruby | mit | 237 | main | 619 | require "pbt"
require "benchmark/ips"
# With this seed, the 4th case fails and it shrinks happens 13 times.
seed = 17243810592888013452170775373100387856
def task(x) = (x > 100) ? raise : nil
Benchmark.ips do |x|
x.report("ractor") do
Pbt.assert(worker: :ractor, seed:, num_runs: 100) do
Pbt.property(Pbt.... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | benchmark/success_cpu_bound.rb | Ruby | mit | 237 | main | 798 | require "pbt"
require "benchmark/ips"
# tarai function with
# (x=10, y=5, z=0) calls 343073 times.
# (x=10, y=4, z=0) calls 271097 times.
# (x=9, y=5, z=0) calls 71973 times.
# (x=9, y=4, z=0) calls 55229 times.
# (x=8, y=4, z=0) calls 12605 times.
# (x=8, y=3, z=0) calls 305 times.
def task(x, y, z)
(x <= y) ... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | benchmark/success_simple.rb | Ruby | mit | 237 | main | 449 | require "pbt"
require "benchmark/ips"
seed = 17243810592888013452170775373100387856
def task(x) = x + 1
Benchmark.ips do |x|
x.report("ractor") do
Pbt.assert(worker: :ractor, seed:, num_runs: 100) do
Pbt.property(Pbt.integer) do |x|
task(x)
end
end
end
x.report("none") do
Pbt.a... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | spec/spec_helper.rb | Ruby | mit | 237 | main | 366 | # frozen_string_literal: true
require "pbt"
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_patching!
config.expect_with :... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | spec/e2e/stateful_e2e_spec.rb | Ruby | mit | 237 | main | 5,573 | # frozen_string_literal: true
RSpec.describe Pbt do
describe ".assert with .stateful" do
it "runs a stateful property through the existing runner" do
Pbt.assert(seed: 2, num_runs: 1) do
Pbt.stateful(model: PassingCounterModel.new, sut: -> { Object.new }, max_steps: 5)
end
end
it "run... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | spec/e2e/e2e_spec.rb | Ruby | mit | 237 | main | 15,127 | # frozen_string_literal: true
require_relative "example/pbt_test_target"
RSpec.describe Pbt do
describe ".property" do
describe "arguments" do
it "passes a value that the given single arbitrary generates" do
Pbt.assert do
Pbt.property(Pbt.integer) do |n|
raise unless n.is_a?(... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | spec/e2e/example/pbt_test_target.rb | Ruby | mit | 237 | main | 508 | # frozen_string_literal: true
module PbtTestTarget
def self.biggest(arr, max = nil)
return max if arr.empty?
head, *tail = arr
if !max || head >= max
biggest(tail, head)
else
biggest(tail, max)
end
end
def self.multiplicative_inverse(number)
# This method raises ZeroDivisionE... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | spec/pbt/arbitrary/generate_default_rng_spec.rb | Ruby | mit | 237 | main | 2,161 | # frozen_string_literal: true
RSpec.describe "generate with default rng" do
describe "primitives" do
it "generates an integer without rng" do
val = Pbt.integer.generate
expect(val).to be_a(Integer)
end
it "generates a boolean without rng" do
val = Pbt.boolean.generate
expect([tru... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | spec/pbt/arbitrary/fixed_hash_arbitrary_spec.rb | Ruby | mit | 237 | main | 1,881 | # frozen_string_literal: true
RSpec.describe Pbt::Arbitrary::FixedHashArbitrary do
describe "#generate" do
it "generates a Hash" do
val = Pbt::Arbitrary::FixedHashArbitrary.new(x: Pbt.integer, y: Pbt.integer).generate(Random.new)
expect(val).to be_a(Hash)
end
it "generates an array of given ... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | spec/pbt/arbitrary/arbitrary_methods_spec.rb | Ruby | mit | 237 | main | 14,720 | # frozen_string_literal: true
RSpec.describe Pbt::Arbitrary::ArbitraryMethods do
describe ".hexa" do
it "generates a hexadecimal character" do
val = Pbt.hexa.generate(Random.new)
expect(val).to be_a(String)
expect(val.size).to eq(1)
end
describe "#shrink" do
it "returns an Enumer... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | spec/pbt/arbitrary/choose_arbitrary_spec.rb | Ruby | mit | 237 | main | 1,185 | # frozen_string_literal: true
RSpec.describe Pbt::Arbitrary::ChooseArbitrary do
describe "#generate" do
it "generates an integer" do
val = Pbt::Arbitrary::ChooseArbitrary.new(1..10).generate(Random.new)
expect(val).to be_a(Integer)
end
it "generates an integer in given range" do
aggreg... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | spec/pbt/arbitrary/array_arbitrary_spec.rb | Ruby | mit | 237 | main | 2,090 | # frozen_string_literal: true
RSpec.describe Pbt::Arbitrary::ArrayArbitrary do
describe "#initialize" do
it "does not allow negative min" do
expect { Pbt::Arbitrary::ArrayArbitrary.new(Pbt.integer, -1) }.to raise_error(ArgumentError)
end
end
describe "#generate" do
it "generates an array" do
... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | spec/pbt/arbitrary/filter_arbitrary_spec.rb | Ruby | mit | 237 | main | 1,039 | # frozen_string_literal: true
RSpec.describe Pbt::Arbitrary::FilterArbitrary do
describe "#initialize" do
it do
arb = Pbt.integer.filter { |n| n % 2 == 0 }
expect(arb).to be_a(Pbt::Arbitrary::FilterArbitrary)
end
end
describe "#generate" do
it "generates filtered values of given arbitrar... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | spec/pbt/arbitrary/map_arbitrary_spec.rb | Ruby | mit | 237 | main | 1,136 | # frozen_string_literal: true
RSpec.describe Pbt::Arbitrary::MapArbitrary do
describe "#initialize" do
it do
arb = Pbt.integer.map(->(n) { n.to_s }, ->(n) { n.to_i })
expect(arb).to be_a(Pbt::Arbitrary::MapArbitrary)
end
end
describe "#generate" do
it "generates mapped values of given ar... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | spec/pbt/arbitrary/one_of_arbitrary_spec.rb | Ruby | mit | 237 | main | 1,073 | # frozen_string_literal: true
RSpec.describe Pbt::Arbitrary::OneOfArbitrary do
describe "#generate" do
it "generates any integer in given array" do
aggregate_failures do
choices = [:a, 1, "A", 2.0, {foo: :bar}, [1], String]
100.times do
val = Pbt::Arbitrary::OneOfArbitrary.new(cho... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | spec/pbt/arbitrary/integer_arbitrary_spec.rb | Ruby | mit | 237 | main | 3,135 | # frozen_string_literal: true
RSpec.describe Pbt::Arbitrary::IntegerArbitrary do
describe "#generate" do
it "generates an integer" do
val = Pbt.integer.generate(Random.new)
expect(val).to be_a(Integer)
end
it "allows to specify range with min and max" do
aggregate_failures do
1... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | spec/pbt/arbitrary/tuple_arbitrary_spec.rb | Ruby | mit | 237 | main | 1,630 | # frozen_string_literal: true
RSpec.describe Pbt::Arbitrary::TupleArbitrary do
describe "#generate" do
it "generates an array" do
val = Pbt::Arbitrary::TupleArbitrary.new(Pbt.integer, Pbt.integer).generate(Random.new)
expect(val).to be_a(Array)
end
it "generates an array of given arbitrary" ... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | spec/pbt/arbitrary/constant_arbitrary_spec.rb | Ruby | mit | 237 | main | 633 | # frozen_string_literal: true
RSpec.describe Pbt::Arbitrary::ConstantArbitrary do
describe "#generate" do
it "generates itself" do
val = Pbt::Arbitrary::ConstantArbitrary.new(1).generate(Random.new)
expect(val).to be_a(Integer)
end
end
describe "#shrink" do
it "returns an Enumerator" do
... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | spec/pbt/check/runner_methods_spec.rb | Ruby | mit | 237 | main | 1,453 | # frozen_string_literal: true
RSpec.describe Pbt::Check::RunnerMethods do
let(:runner_host) do
Class.new do
include Pbt::Check::RunnerMethods
end.new
end
describe "#wait_ractor_result" do
it "uses value when available" do
ractor = double("ractor")
allow(ractor).to receive(:respond_... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | spec/pbt/check/configuration_spec.rb | Ruby | mit | 237 | main | 8,561 | # frozen_string_literal: true
RSpec.describe Pbt::Check::Configuration do
describe "configuration" do
describe "scope" do
describe "for each runners" do
it "can be configured for each runner" do
runs = 0
Pbt.assert num_runs: 5, worker: :none do
Pbt.property(Pbt.integ... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | spec/pbt/stateful/property_spec.rb | Ruby | mit | 237 | main | 22,973 | # frozen_string_literal: true
RSpec.describe Pbt do
describe ".stateful" do
let(:model) { StackModel.new }
it "returns a property-like object" do
property = Pbt.stateful(model:, sut: -> { CorrectStack.new })
expect(property).to respond_to(:generate)
expect(property).to respond_to(:shrink)... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | lib/pbt.rb | Ruby | mit | 237 | main | 3,554 | # frozen_string_literal: true
require_relative "pbt/version"
require_relative "pbt/arbitrary/arbitrary_methods"
require_relative "pbt/check/runner_methods"
require_relative "pbt/check/property"
require_relative "pbt/check/configuration"
require_relative "pbt/stateful/property"
module Pbt
# Represents a property-bas... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | lib/pbt/reporter/run_execution.rb | Ruby | mit | 237 | main | 3,196 | # frozen_string_literal: true
require "pbt/reporter/run_details"
module Pbt
module Reporter
# Represents the result of a single run of a property test.
class RunExecution
# A tree node of the execution for verbose output.
ExecutionTreeNode = Struct.new(
:result,
:value,
:... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | lib/pbt/reporter/run_details.rb | Ruby | mit | 237 | main | 426 | # frozen_string_literal: true
module Pbt
module Reporter
# Details of a single run of a property test.
RunDetails = Struct.new(
:failed,
:num_runs,
:num_shrinks,
:seed,
:counterexample,
:counterexample_path,
:error_message,
:error_instance,
:failures,
... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | lib/pbt/reporter/run_details_reporter.rb | Ruby | mit | 237 | main | 2,853 | # frozen_string_literal: true
module Pbt
module Reporter
# Reporter for the run details of a property test.
class RunDetailsReporter
# @param run_details [Pbt::Reporter::RunExecution]
def initialize(run_details)
@run_details = run_details
end
# Report the run details of a pro... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | lib/pbt/arbitrary/arbitrary_methods.rb | Ruby | mit | 237 | main | 11,334 | # frozen_string_literal: true
require "pbt/arbitrary/arbitrary"
require "pbt/arbitrary/constant"
require "pbt/arbitrary/constant_arbitrary"
require "pbt/arbitrary/array_arbitrary"
require "pbt/arbitrary/integer_arbitrary"
require "pbt/arbitrary/tuple_arbitrary"
require "pbt/arbitrary/fixed_hash_arbitrary"
require "pbt... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | lib/pbt/arbitrary/arbitrary.rb | Ruby | mit | 237 | main | 2,190 | # frozen_string_literal: true
module Pbt
module Arbitrary
class EmptyDomainError < ArgumentError; end
# Abstract class for generating random values on type `T`.
#
# @abstract
class Arbitrary
# Generate a value of type `T`, based on the provided random number generator.
#
# @abs... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | lib/pbt/arbitrary/choose_arbitrary.rb | Ruby | mit | 237 | main | 631 | # frozen_string_literal: true
module Pbt
module Arbitrary
# Generates a random value from a range.
class ChooseArbitrary < Arbitrary
# @param range [Range<Integer>]
def initialize(range)
@range = range
end
# @see Arbitrary#generate
def generate(rng = Random.new)
... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | lib/pbt/arbitrary/constant.rb | Ruby | mit | 237 | main | 1,353 | # frozen_string_literal: true
require "date"
require "set" # For 3.1 or prior. Set became built-in library since Ruby 3.2.0
module Pbt
module Arbitrary
HEXA_CHARS = [*("0".."9"), *("a".."f")].freeze
CHAR_RANGE = (0..0x10FFFF)
SYMBOL_SAFE_CHARS = [*("a".."z"), "-"].freeze
ALPHANUMERIC_CHARS = [*("a".... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | lib/pbt/arbitrary/filter_arbitrary.rb | Ruby | mit | 237 | main | 971 | # frozen_string_literal: true
module Pbt
module Arbitrary
# Generates values from another arbitrary, but only if they pass a predicate.
class FilterArbitrary < Arbitrary
# @param arb [Arbitrary] Arbitrary to generate values to be filtered.
# @param refinement [Proc] Predicate proc to test each pr... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | lib/pbt/arbitrary/map_arbitrary.rb | Ruby | mit | 237 | main | 879 | # frozen_string_literal: true
module Pbt
module Arbitrary
# Generates a mapped value from another arbitrary.
class MapArbitrary < Arbitrary
# @param arb [Arbitrary] Arbitrary to generate values to be mapped.
# @param mapper [Proc] Proc to map generated values. Mainly used for generation.
# ... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | lib/pbt/arbitrary/tuple_arbitrary.rb | Ruby | mit | 237 | main | 881 | # frozen_string_literal: true
module Pbt
module Arbitrary
# Generates a tuple of arbitrary values.
class TupleArbitrary < Arbitrary
# @param arbs [Array<Arbitrary>] Arbitraries used to generate the values of the tuple.
def initialize(*arbs)
@arbs = arbs
end
# @see Arbitrary#g... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | lib/pbt/arbitrary/fixed_hash_arbitrary.rb | Ruby | mit | 237 | main | 863 | # frozen_string_literal: true
module Pbt
module Arbitrary
# Generates a hash with fixed keys and arbitrary values.
class FixedHashArbitrary < Arbitrary
# @param hash [Hash<Object, Arbitrary<T>>] Hash with any keys and arbitraries as values.
def initialize(hash)
@keys = hash.keys
@... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | lib/pbt/arbitrary/one_of_arbitrary.rb | Ruby | mit | 237 | main | 735 | # frozen_string_literal: true
module Pbt
module Arbitrary
# Generates one of the given choices.
class OneOfArbitrary < Arbitrary
# @param choices [Array] List of choices.
def initialize(choices)
@choices = choices
@idx_arb = IntegerArbitrary.new(0, choices.size - 1)
end
... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | lib/pbt/arbitrary/integer_arbitrary.rb | Ruby | mit | 237 | main | 1,505 | # frozen_string_literal: true
module Pbt
module Arbitrary
# Generates random integers between `min` and `max`.
class IntegerArbitrary < Arbitrary
DEFAULT_TARGET = 0
private_constant :DEFAULT_TARGET
# @param min [Integer] Minimum value to generate.
# @param max [Integer] Maximum value... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | lib/pbt/arbitrary/array_arbitrary.rb | Ruby | mit | 237 | main | 1,878 | # frozen_string_literal: true
module Pbt
module Arbitrary
# Generates arrays of values generated by `value_arb` with type `T`.
class ArrayArbitrary < Arbitrary
DEFAULT_MAX_SIZE = 10
private_constant :DEFAULT_MAX_SIZE
# @param value_arb [Arbitrary] Arbitrary to generate values.
# @par... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | lib/pbt/arbitrary/constant_arbitrary.rb | Ruby | mit | 237 | main | 422 | # frozen_string_literal: true
module Pbt
module Arbitrary
# Generates a constant value.
class ConstantArbitrary < Arbitrary
# @param val [Object]
def initialize(val)
@val = val
end
# @see Arbitrary#generate
def generate(rng = Random.new)
@val
end
# ... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | lib/pbt/check/runner_iterator.rb | Ruby | mit | 237 | main | 1,846 | # frozen_string_literal: true
require "delegate"
require "pbt/reporter/run_execution"
module Pbt
module Check
# This class is an iterator of the generated/shrunken values.
#
# @private
# @!attribute [r] run_execution [Reporter::RunExecution]
class RunnerIterator < DelegateClass(Array)
attr... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | lib/pbt/check/configuration.rb | Ruby | mit | 237 | main | 1,923 | # frozen_string_literal: true
module Pbt
module Check
# Configuration for Pbt.
Configuration = Struct.new(
:verbose,
:worker,
:num_runs,
:seed,
:thread_report_on_exception,
keyword_init: true
) do
# @param verbose [Boolean] Whether to print verbose output. Defaul... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | lib/pbt/check/runner_methods.rb | Ruby | mit | 237 | main | 5,129 | # frozen_string_literal: true
require "pbt/check/runner_iterator"
require "pbt/check/tosser"
require "pbt/check/case"
require "pbt/reporter/run_details_reporter"
module Pbt
module Check
# Module to be
module RunnerMethods
include Check::Tosser
# Run a property based test and report its result.
... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | lib/pbt/check/property.rb | Ruby | mit | 237 | main | 1,426 | # frozen_string_literal: true
module Pbt
module Check
# Represents a property to be tested.
# This class holds an arbitrary to generate values and a predicate to test them.
class Property
# @param arb [Array<Arbitrary>]
# @param predicate [Proc] Predicate proc to test the generated values. Li... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | lib/pbt/check/tosser.rb | Ruby | mit | 237 | main | 779 | # frozen_string_literal: true
module Pbt
module Check
# Module to be included in classes that need to generate values to test.
module Tosser
# Generate values.
#
# @param arb [Arbitrary] Arbitrary to generate a value.
# @param seed [Integer] Random number generator's seed.
# @re... |
github | ohbarye/pbt | https://github.com/ohbarye/pbt | lib/pbt/stateful/property.rb | Ruby | mit | 237 | main | 11,307 | # frozen_string_literal: true
module Pbt
module Stateful
# Property-compatible wrapper for command-based stateful testing.
# It provides `generate`, `shrink` and `run`, so existing runners can execute it.
class Property
ARG_AWARE_GENERATION_ATTEMPTS = 5
REQUIRED_COMMAND_METHODS = %i[
... |
github | rwz/nestive | https://github.com/rwz/nestive | nestive.gemspec | Ruby | mit | 237 | master | 837 | require File.expand_path("../lib/nestive/version", __FILE__)
Gem::Specification.new do |s|
s.name = "nestive"
s.version = Nestive::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Justin French", "Pavel Pravosud"]
s.email = ["justin@indent.com.au", "pavel@pravosud.com"... |
github | rwz/nestive | https://github.com/rwz/nestive | Appraisals | Ruby | mit | 237 | master | 455 | appraise "rails-3-1" do
gem "test-unit"
gem "rails", "~> 3.1.0"
end
appraise "rails-3-2" do
gem "test-unit"
gem "rails", "~> 3.2.0"
end
appraise "rails-4-0" do
gem "mime-types", "~> 2.99"
gem "rails", "~> 4.0.0"
end
appraise "rails-4-1" do
gem "mime-types", "~> 2.99"
gem "rails", "~> 4.1.0"
end
appr... |
github | rwz/nestive | https://github.com/rwz/nestive | lib/nestive/railtie.rb | Ruby | mit | 237 | master | 218 | # encoding: utf-8
module Nestive
class Railtie < Rails::Railtie
initializer 'nestive.initialize' do
ActiveSupport.on_load(:action_view) do
include Nestive::LayoutHelper
end
end
end
end |
github | rwz/nestive | https://github.com/rwz/nestive | lib/nestive/layout_helper.rb | Ruby | mit | 237 | master | 9,132 | module Nestive
# The Nestive LayoutHelper provides a handful of helper methods for use in your layouts and views.
#
# See the documentation for each individual method for detailed information, but at a high level,
# your parent layouts define `area`s of content. You can define an area and optionally add conten... |
github | rwz/nestive | https://github.com/rwz/nestive | spec/spec_helper.rb | Ruby | mit | 237 | master | 233 | require 'bundler'
Bundler.setup
require 'rails'
require 'combustion'
require 'nestive'
Combustion.initialize! :action_controller
require 'rspec/rails'
RSpec.configure do |config|
config.infer_spec_type_from_file_location!
end |
github | rwz/nestive | https://github.com/rwz/nestive | spec/internal/app/controllers/nestive_controller.rb | Ruby | mit | 237 | master | 305 | class NestiveController < ApplicationController
def extended_one
render layout: 'extend_one'
end
def extended_two
render layout: 'extend_two'
end
def extended_three
render layout: 'extend_one'
end
def extended_without_yield
render layout: 'extend_without_yield'
end
end |
github | rwz/nestive | https://github.com/rwz/nestive | spec/controllers/nestive_spec.rb | Ruby | mit | 237 | master | 2,219 | require 'spec_helper'
describe NestiveController do
render_views
context '#area' do
it 'is empty by default' do
get :index
assert_select '#empty-area', ''
end
it 'shows initial value if any' do
get :index
assert_select 'title', 'Nestive'
end
it 'can accept blocks as i... |
github | airbnb/interferon | https://github.com/airbnb/interferon | interferon.gemspec | Ruby | mit | 237 | master | 1,471 | # frozen_string_literal: true
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'interferon/version'
Gem::Specification.new do |gem|
gem.name = 'interferon'
gem.version = Interferon::VERSION.dup
gem.authors = ['Igor Serebryany', 'Jimmy Ng... |
github | airbnb/interferon | https://github.com/airbnb/interferon | spec/spec_helper.rb | Ruby | mit | 237 | master | 2,938 | # frozen_string_literal: true
# This file was generated by the `rspec --init` command.
# require the thing we're testing
require 'interferon'
require 'helpers/logging_helper.rb'
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config|
config.expect_with :rspec do |expectations... |
github | airbnb/interferon | https://github.com/airbnb/interferon | spec/lib/work_hours_helper_spec.rb | Ruby | mit | 237 | master | 1,615 | # frozen_string_literal: true
require 'spec_helper'
require 'interferon/work_hours_helper'
describe Interferon::WorkHoursHelper do
subject { described_class }
describe '.now_is_work_hour?' do
context 'when it is a work hour in a work day' do
it 'return true' do
expect(
subject.is_work... |
github | airbnb/interferon | https://github.com/airbnb/interferon | spec/lib/interferon_spec.rb | Ruby | mit | 237 | master | 15,972 | # frozen_string_literal: true
require 'spec_helper'
require 'helpers/mock_alert'
require 'interferon/destinations/datadog'
include Interferon
describe Interferon::Destinations::Datadog do
let(:the_existing_alerts) { mock_existing_alerts }
let(:dest) { MockDest.new(the_existing_alerts) }
let(:datadog) do
In... |
github | airbnb/interferon | https://github.com/airbnb/interferon | spec/lib/interferon/loaders_spec.rb | Ruby | mit | 237 | master | 3,510 | # frozen_string_literal: true
require 'spec_helper'
require 'helpers/loader_helper'
describe 'DynamicLoader' do
describe 'custom class retrieval' do
it 'properly loads a custom test source of given type' do
test_loader = TestLoader.new(['./spec/fixtures/loaders'])
expect(test_loader.get_klass('test_... |
github | airbnb/interferon | https://github.com/airbnb/interferon | spec/lib/interferon/alert_spec.rb | Ruby | mit | 237 | master | 1,470 | # frozen_string_literal: true
require 'spec_helper'
require 'interferon/alert'
describe Interferon::Alert do
let(:sample_alert_repo_path) { './spec/fixtures/files/' }
let(:sample_alert_path) { File.join(sample_alert_repo_path, 'sample_alert.rb') }
describe '#initialize' do
it 'reads a file' do
expect... |
github | airbnb/interferon | https://github.com/airbnb/interferon | spec/lib/interferon/alert_yaml_spec.rb | Ruby | mit | 237 | master | 7,710 | # frozen_string_literal: true
require 'spec_helper'
require 'interferon/alert_yaml'
describe Interferon::AlertYaml do
let(:sample_alert_repo_path) { './spec/fixtures/files/' }
let(:sample_alert_yml_path) { File.join(sample_alert_repo_path, 'sample_alert.yml') }
describe '#initialize' do
it 'reads a file' do... |
github | airbnb/interferon | https://github.com/airbnb/interferon | spec/lib/interferon/host_sources/optica_services_spec.rb | Ruby | mit | 237 | master | 2,093 | # frozen_string_literal: true
require 'spec_helper'
require 'helpers/optica_helper'
require 'interferon/host_sources/optica_services'
describe Interferon::HostSources::OpticaServices do
let(:optica_services) { Interferon::HostSources::OpticaServices.new('host' => '127.0.0.1') }
describe '.list_hosts' do
befo... |
github | airbnb/interferon | https://github.com/airbnb/interferon | spec/lib/interferon/host_sources/optica_spec.rb | Ruby | mit | 237 | master | 974 | # frozen_string_literal: true
require 'spec_helper'
require 'helpers/optica_helper'
require 'interferon/host_sources/optica'
describe Interferon::HostSources::Optica do
let(:optica) { Interferon::HostSources::Optica.new('host' => '127.0.0.1') }
describe '.list_hosts' do
before do
expect(optica).to rece... |
github | airbnb/interferon | https://github.com/airbnb/interferon | spec/lib/interferon/alerts_sources/filesystem_spec.rb | Ruby | mit | 237 | master | 4,203 | # frozen_string_literal: true
require 'spec_helper'
require 'interferon/alert_sources/filesystem'
describe Interferon::AlertSources::Filesystem do
describe '#initialize' do
before do
@options = []
end
it 'requires alert_types as an option' do
expect { described_class.new }.to raise_error(Ar... |
github | airbnb/interferon | https://github.com/airbnb/interferon | spec/lib/interferon/group_sources/filesystem_spec.rb | Ruby | mit | 237 | master | 2,831 | # frozen_string_literal: true
require 'spec_helper'
require 'interferon/group_sources/filesystem'
describe Interferon::GroupSources::Filesystem do
let(:fs_loader) { Interferon::GroupSources::Filesystem.new('paths' => ['/tmp']) }
describe 'list_groups' do
context 'with basic groups' do
before do
... |
github | airbnb/interferon | https://github.com/airbnb/interferon | spec/lib/interferon/destinations/datadog_spec.rb | Ruby | mit | 237 | master | 9,333 | # frozen_string_literal: true
require 'spec_helper'
require 'interferon/destinations/datadog'
describe Interferon::Destinations::Datadog do
let(:retries) { 3 }
let(:max_mute_minutes) { 60 }
let(:base_datadog_config) do
{
'api_key' => 'TEST_API_KEY',
'app_key' => 'TEST_APP_KEY',
'retries' =... |
github | airbnb/interferon | https://github.com/airbnb/interferon | spec/helpers/optica_helper.rb | Ruby | mit | 237 | master | 2,910 | # frozen_string_literal: true
class OpticaHelper
def self.example_node_1
{
'ip' => '10.1.1.1',
'environment' => 'production',
'role' => 'role1',
'hostname' => 'box1',
'uptime' => 37_335_310,
'az' => 'us-east-1a',
'security_groups' => ['internal'],
'instance_type' =... |
github | airbnb/interferon | https://github.com/airbnb/interferon | spec/helpers/logging_helper.rb | Ruby | mit | 237 | master | 264 | # frozen_string_literal: true
# disable logging during spec runs
module Interferon::Logging
class EmptyLogger < StringIO
def write(input)
# do nothing
end
end
def self.configure_logger_for(_clasname)
Logger.new(EmptyLogger.new)
end
end |
github | airbnb/interferon | https://github.com/airbnb/interferon | spec/helpers/loader_helper.rb | Ruby | mit | 237 | master | 373 | # frozen_string_literal: true
### some helpers to make this work ###
# define the module we're working in
module ::Interferon::TestSources; end
# define a test loader we'll be using
class TestLoader < Interferon::DynamicLoader
def initialize_attributes
@loader_for = 'test fixtures'
@type_path = 'test_source... |
github | airbnb/interferon | https://github.com/airbnb/interferon | spec/helpers/mock_alert.rb | Ruby | mit | 237 | master | 252 | # frozen_string_literal: true
module Interferon
class MockAlert < Alert
def initialize(dsl)
@filename = 'MOCKALERT'
@dsl = dsl
end
def []=(key, val)
@dsl.get_or_set(('@' + key).to_sym, val, nil, nil)
end
end
end |
github | airbnb/interferon | https://github.com/airbnb/interferon | lib/interferon.rb | Ruby | mit | 237 | master | 11,245 | # frozen_string_literal: true
require 'interferon/version'
require 'interferon/logging'
require 'interferon/loaders'
require 'interferon/alert'
require 'interferon/alert_dsl'
require 'interferon/alert_yaml'
# require 'pry' #uncomment if you're debugging
require 'erb'
require 'ostruct'
require 'parallel'
require 's... |
github | airbnb/interferon | https://github.com/airbnb/interferon | lib/interferon/logging.rb | Ruby | mit | 237 | master | 541 | # frozen_string_literal: true
require 'logger'
require 'statsd'
module Interferon
module Logging
def statsd
@statsd ||= Statsd.new(
Statsd::DEFAULT_HOST,
Statsd::DEFAULT_PORT,
namespace: 'alerts_framework'
)
end
def log
@log ||= Logging.configure_logger_for(sel... |
github | airbnb/interferon | https://github.com/airbnb/interferon | lib/interferon/loaders.rb | Ruby | mit | 237 | master | 3,566 | # frozen_string_literal: true
module Interferon
# lets create namespaces for things we'll be loading
module Destinations; end
module AlertSources; end
module HostSources; end
module GroupSources; end
# this is a type of class that can dynamically load other classes based on
# a 'type' string
class Dyn... |
github | airbnb/interferon | https://github.com/airbnb/interferon | lib/interferon/alert.rb | Ruby | mit | 237 | master | 971 | # frozen_string_literal: true
module Interferon
class Alert
def initialize(alert_repo_path, alert_file_path, options = {})
@path = alert_file_path
@filename = alert_file_path.sub(/^#{File.join(alert_repo_path, '/')}/, '')
@suffix = options[:suffix]
@text = File.read(alert_file_path)
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.