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 | doorkeeper-gem/doorkeeper-openid_connect | https://github.com/doorkeeper-gem/doorkeeper-openid_connect | lib/doorkeeper/openid_connect/claims/distributed_claim.rb | Ruby | mit | 200 | master | 202 | # frozen_string_literal: true
module Doorkeeper
module OpenidConnect
module Claims
class DistributedClaim < Claim
attr_accessor :endpoint, :access_token
end
end
end
end |
github | doorkeeper-gem/doorkeeper-openid_connect | https://github.com/doorkeeper-gem/doorkeeper-openid_connect | lib/doorkeeper/openid_connect/rails/routes.rb | Ruby | mit | 200 | master | 2,309 | # frozen_string_literal: true
require 'doorkeeper/openid_connect/rails/routes/mapping'
require 'doorkeeper/openid_connect/rails/routes/mapper'
module Doorkeeper
module OpenidConnect
module Rails
class Routes
module Helper
def use_doorkeeper_openid_connect(options = {}, &block)
... |
github | doorkeeper-gem/doorkeeper-openid_connect | https://github.com/doorkeeper-gem/doorkeeper-openid_connect | lib/doorkeeper/openid_connect/rails/routes/mapper.rb | Ruby | mit | 200 | master | 694 | # frozen_string_literal: true
module Doorkeeper
module OpenidConnect
module Rails
class Routes
class Mapper
def initialize(mapping = Mapping.new)
@mapping = mapping
end
def map(&block)
instance_eval(&block) if block
@mapping
... |
github | doorkeeper-gem/doorkeeper-openid_connect | https://github.com/doorkeeper-gem/doorkeeper-openid_connect | lib/doorkeeper/openid_connect/rails/routes/mapping.rb | Ruby | mit | 200 | master | 969 | # frozen_string_literal: true
module Doorkeeper
module OpenidConnect
module Rails
class Routes
class Mapping
attr_accessor :controllers, :as, :skips
def initialize
@controllers = {
userinfo: 'doorkeeper/openid_connect/userinfo',
discovery... |
github | doorkeeper-gem/doorkeeper-openid_connect | https://github.com/doorkeeper-gem/doorkeeper-openid_connect | lib/generators/doorkeeper/openid_connect/migration_generator.rb | Ruby | mit | 200 | master | 882 | # frozen_string_literal: true
require 'rails/generators/active_record'
module Doorkeeper
module OpenidConnect
class MigrationGenerator < ::Rails::Generators::Base
include ::Rails::Generators::Migration
source_root File.expand_path('templates', __dir__)
desc 'Installs Doorkeeper OpenID Connect ... |
github | doorkeeper-gem/doorkeeper-openid_connect | https://github.com/doorkeeper-gem/doorkeeper-openid_connect | lib/generators/doorkeeper/openid_connect/install_generator.rb | Ruby | mit | 200 | master | 589 | # frozen_string_literal: true
module Doorkeeper
module OpenidConnect
class InstallGenerator < ::Rails::Generators::Base
include ::Rails::Generators::Migration
source_root File.expand_path('templates', __dir__)
desc 'Installs Doorkeeper OpenID Connect.'
def install
template 'initi... |
github | doorkeeper-gem/doorkeeper-openid_connect | https://github.com/doorkeeper-gem/doorkeeper-openid_connect | lib/generators/doorkeeper/openid_connect/templates/initializer.rb | Ruby | mit | 200 | master | 2,629 | # frozen_string_literal: true
Doorkeeper::OpenidConnect.configure do
issuer do |resource_owner, application, request|
# Example implementation:
# request&.base_url || 'https://example.com'
'issuer string'
end
signing_key <<~KEY
-----BEGIN RSA PRIVATE KEY-----
....
-----END RSA PRIVATE KE... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | quickdraw.gemspec | Ruby | mit | 199 | main | 1,462 | # frozen_string_literal: true
require_relative "lib/quickdraw/version"
Gem::Specification.new do |spec|
spec.name = "quickdraw"
spec.version = Quickdraw::VERSION
spec.authors = ["Joel Drapper"]
spec.email = ["joel@drapper.me"]
spec.summary = "Experimental test framework"
spec.description = "Experimental test f... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | Gemfile | Ruby | mit | 199 | main | 271 | # frozen_string_literal: true
source "https://rubygems.org"
# Specify your gem's dependencies in quickdraw.gemspec
gemspec
gem "rspec-expectations"
gem "minitest"
gem "nokogiri"
if RUBY_ENGINE == "ruby"
group :development do
gem "rubocop"
gem "covered"
end
end |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | lib/quickdraw.rb | Ruby | mit | 199 | main | 1,234 | # frozen_string_literal: true
module Quickdraw
module NoBox
def self.require(...)
Kernel.require(...)
end
def self.const_missing(name)
Kernel.const_get(name).tap { |it| const_set(name, it) }
end
end
Box = (defined?(Ruby::Box) && ENV["RUBY_BOX"]) ? Ruby::Box.new : NoBox
Box.require("prism")
Box.re... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | lib/quickdraw/cluster.rb | Ruby | mit | 199 | main | 260 | # frozen_string_literal: true
class Quickdraw::Cluster
def initialize
@workers = []
end
def fork(&)
Quickdraw::Worker.fork(&).tap { |it| @workers << it }
end
def terminate
@workers.map(&:terminate)
end
def wait
@workers.map(&:wait)
end
end |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | lib/quickdraw/minitest.rb | Ruby | mit | 199 | main | 10,922 | # frozen_string_literal: true
begin
require "minitest/assertions"
rescue LoadError
raise LoadError.new("You need to add `minitest` to your Gemfile")
end
module Quickdraw
module Minitest
class Test < Quickdraw::BasicTest
def self.method_added(name)
name = name.to_s
return unless name.start_with?("test... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | lib/quickdraw/assertions.rb | Ruby | mit | 199 | main | 3,690 | # frozen_string_literal: true
module Quickdraw::Assertions
def assert_equal(actual, expected)
assert(actual == expected) do
if actual.is_a?(String) && expected.is_a?(String)
diff = Quickdraw::Diff.diff(expected, actual)
unless diff.empty?
next <<~MESSAGE
\e[34mDiff (expected vs actual):\e[0m
... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | lib/quickdraw/cli.rb | Ruby | mit | 199 | main | 2,637 | # frozen_string_literal: true
Quickdraw::Box.require("optparse")
class Quickdraw::CLI
CONFIG_PATH = File.expand_path("config/quickdraw.rb")
def initialize(args)
@args = args
end
def call
parse_options
parse_files
run
end
def parse_options
Quickdraw::Box::OptionParser.new do |parser|
parser.banne... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | lib/quickdraw/concurrent_array.rb | Ruby | mit | 199 | main | 500 | # frozen_string_literal: true
class Quickdraw::ConcurrentArray
def initialize
@array = []
@monitor = Monitor.new
end
def <<(value)
@monitor.synchronize { @array << value }
end
def each(&block)
@monitor.synchronize { @array.each(&block) }
end
def concat(other)
@monitor.synchronize { @array.concat(ot... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | lib/quickdraw/basic_test.rb | Ruby | mit | 199 | main | 1,914 | # frozen_string_literal: true
class Quickdraw::BasicTest
def self.test(description = nil, skip: false, &block)
$quickdraw_runner << [self, description, skip, block]
end
def initialize(description:, skip:, block:, runner:)
@description = description
@skip = skip
@block = block
@runner = runner
end
def ... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | lib/quickdraw/diff.rb | Ruby | mit | 199 | main | 6,275 | # frozen_string_literal: true
module Quickdraw
module Diff
class << self
# Computes a diff between two strings.
# @param old_text [String] The original/baseline text (e.g., expected)
# @param new_text [String] The changed text (e.g., actual)
# @return [String] Formatted diff with - for removals and + fo... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | lib/quickdraw/worker.rb | Ruby | mit | 199 | main | 463 | # frozen_string_literal: true
require "socket"
class Quickdraw::Worker
def self.fork
parent_socket, child_socket = UNIXSocket.pair
pid = Process.fork do
parent_socket.close
yield(child_socket)
end
child_socket.close
new(pid:, socket: parent_socket)
end
def initialize(pid:, socket:)
@pid = pid
... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | lib/quickdraw/concurrent_integer.rb | Ruby | mit | 199 | main | 262 | # frozen_string_literal: true
class Quickdraw::ConcurrentInteger
def initialize(value = 0)
@value = value
@monitor = Monitor.new
end
def increment(n = 1)
@monitor.synchronize { @value += n }
end
def value
@monitor.synchronize { @value }
end
end |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | lib/quickdraw/configuration.rb | Ruby | mit | 199 | main | 788 | # frozen_string_literal: true
class Quickdraw::Configuration
DEFAULT_PROCESSES = Quickdraw::Platform.supports_forking? ? Quickdraw::Platform.non_blocking_cores : 1
def initialize
@failure_symbol = "\e[31m⨯\e[0m"
@success_symbol = "\e[32m∘\e[0m"
@processes = DEFAULT_PROCESSES
@success_emoji = %w[💃 🕺 🎉 🎊 ... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | lib/quickdraw/html_prettifier.rb | Ruby | mit | 199 | main | 1,510 | # frozen_string_literal: true
require "nokogiri"
module Quickdraw::HTMLPrettifier
extend self
VOID_ELEMENTS = Set[
"area",
"base",
"br",
"col",
"embed",
"hr",
"img",
"input",
"link",
"meta",
"source",
"track",
].freeze
def prettify(html)
node = case html
when Nokogiri::HTML5::Documen... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | lib/quickdraw/platform.rb | Ruby | mit | 199 | main | 1,059 | # frozen_string_literal: true
require "etc"
module Quickdraw::Platform
extend self
# The number of CPU cores for an ideal balance of performance and user experience.
#
# In the case of an M-series Mac, this is all your performance cores, leaving the
# efficienty cores for other tasks. On other platforms, this i... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | lib/quickdraw/timer.rb | Ruby | mit | 199 | main | 318 | # frozen_string_literal: true
module Quickdraw::Timer
extend self
autoload :Duration, "quickdraw/timer/duration"
def time
start = Process.clock_gettime(Process::CLOCK_MONOTONIC, :nanosecond)
yield
finish = Process.clock_gettime(Process::CLOCK_MONOTONIC, :nanosecond)
Duration.new(finish - start)
end
end |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | lib/quickdraw/rspec.rb | Ruby | mit | 199 | main | 595 | # frozen_string_literal: true
begin
require "rspec/expectations"
rescue LoadError
raise LoadError.new("You need to add `rspec-expectations` to your Gemfile")
end
module Quickdraw::RSpec
autoload :Spec, "quickdraw/rspec/spec"
autoload :Matchers, "quickdraw/rspec/matchers"
autoload :Expectation, "quickdraw/rspec/e... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | lib/quickdraw/runner.rb | Ruby | mit | 199 | main | 4,215 | # frozen_string_literal: true
require "json"
require "io/console"
class Quickdraw::Runner
module Message
Fetch = "\x01"
Work = "\x02"
Stop = "\x03"
Stopping = "\x04"
end
def initialize(backtrace: false, processes:, files:, seed:)
@backtrace = backtrace
@processes = processes
@seed = seed
@random =... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | lib/quickdraw/timer/duration.rb | Ruby | mit | 199 | main | 685 | # frozen_string_literal: true
class Quickdraw::Timer::Duration
def initialize(nanoseconds)
@nanoseconds = Float(nanoseconds)
end
attr_reader :nanoseconds
def to_s
if @nanoseconds < 1_000
"#{format('%.0f', @nanoseconds)}ns"
elsif @nanoseconds < 1_000_000
"#{format('%.1f', @nanoseconds / 1_000)}μs"
e... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | lib/quickdraw/rspec/matchers.rb | Ruby | mit | 199 | main | 2,624 | # frozen_string_literal: true
module Quickdraw::RSpec::Matchers
define_method :all, ::RSpec::Matchers.instance_method(:all)
define_method :be, ::RSpec::Matchers.instance_method(:be)
define_method :be_a, ::RSpec::Matchers.instance_method(:be_a)
define_method :be_a_kind_of, ::RSpec::Matchers.instance_method(:be_a_ki... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | lib/quickdraw/rspec/expectation.rb | Ruby | mit | 199 | main | 658 | # frozen_string_literal: true
class Quickdraw::RSpec::Expectation
def initialize(subject, context:)
@subject = subject
@context = context
end
def to(matcher)
assert(matcher.matches?(@subject)) do
if matcher.respond_to?(:failure_message)
matcher.failure_message
else
"Failure"
end
end
end
... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | lib/quickdraw/rspec/spec.rb | Ruby | mit | 199 | main | 7,382 | # frozen_string_literal: true
class Quickdraw::RSpec::Spec < Quickdraw::BasicTest
include Quickdraw::RSpec::Matchers
class << self
def described_class
@described_class || (superclass.described_class if superclass.respond_to?(:described_class))
end
def describe(*descriptions, &block)
Class.new(self) do
... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | lib/ruby_lsp/quickdraw/addon.rb | Ruby | mit | 199 | main | 1,776 | # frozen_string_literal: true
require "ruby_lsp/addon"
module RubyLsp
module Quickdraw
class Addon < ::RubyLsp::Addon
def activate(global_state, outgoing_queue)
::RubyLsp::NodeContext.prepend(NodeContextPatch)
end
def deactivate; end
def name
"Quickdraw"
end
def version
"0.1.0"
... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | config/quickdraw.rb | Ruby | mit | 199 | main | 769 | # frozen_string_literal: true
Quickdraw.configure do |config|
# config here
end
class Runner
def initialize
@failures = []
@errors = []
@successes = 0
end
attr_reader :failures, :successes, :errors
def failure!(failure)
@failures << failure
end
def success!(description)
@successes += 1
end
def ... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | test/quickdraw.test.rb | Ruby | mit | 199 | main | 250 | # frozen_string_literal: true
class QuickdrawTest < Quickdraw::Test
test "assert" do
assert true
end
test "assert", skip: true do
assert false
end
test "refute" do
refute false
end
test "refute", skip: true do
refute true
end
end |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | test/diff.test.rb | Ruby | mit | 199 | main | 3,623 | # frozen_string_literal: true
class DiffTest < Quickdraw::Test
# diff(old, new) returns:
# - lines with "-" for content removed (was in old, not in new)
# - lines with "+" for content added (in new, not in old)
# - lines with " " for unchanged content
test "identical strings produce empty diff" do
diff = Quic... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | test/rspec.test.rb | Ruby | mit | 199 | main | 263 | # frozen_string_literal: true
require "quickdraw/rspec"
Quickdraw::RSpec.describe "RSpec" do
describe String do
describe "test" do
let(:example) { "Hello" }
subject { "Hello" }
it "works" do
expect(example).to eq(subject)
end
end
end
end |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | test/minitest.test.rb | Ruby | mit | 199 | main | 2,117 | # frozen_string_literal: true
require "quickdraw/minitest"
class MinitestTest < Quickdraw::Minitest::Test
def test_assert_equal
assert_equal(1, 1)
end
def test_assert_empty
assert_empty([])
end
def test_assert_in_delta
assert_in_delta(1.0, 1.0, 0.1)
end
def test_assert_in_epsilon
assert_in_epsilon(1... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | test/assertions/raises.test.rb | Ruby | mit | 199 | main | 808 | # frozen_string_literal: true
class RaisesTest < Quickdraw::Test
test "#assert_raises when raising the wrong argument error" do
assert_test(failures: 1) do
assert_raises(ArgumentError) do
raise "Test"
end
end
end
test "#assert_raises when nothing is raised" do
assert_test(failures: 1) do
assert_... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | test/assertions/equivalent_ruby.test.rb | Ruby | mit | 199 | main | 1,432 | # frozen_string_literal: true
class EquivalentRubyTest < Quickdraw::Test
test "#assert_equivalent_ruby pass with identical Ruby" do
assert_test(passes: 1) do
assert_equivalent_ruby "def foo; end", "def foo; end"
end
end
test "#assert_equivalent_ruby pass with identical multiline Ruby" do
assert_test(passe... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | test/assertions/equivalent_html.test.rb | Ruby | mit | 199 | main | 1,010 | # frozen_string_literal: true
class EquivalentHtmlTest < Quickdraw::Test
test "#assert_equivalent_html pass with identical HTML" do
assert_test(passes: 1) do
assert_equivalent_html "<div>Hello</div>", "<div>Hello</div>"
end
end
test "#assert_equivalent_html pass with equivalent HTML (different whitespace)" ... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | test/assertions/operator.test.rb | Ruby | mit | 199 | main | 1,387 | # frozen_string_literal: true
class OperatorTest < Quickdraw::Test
test "#assert_operator pass with >" do
assert_test(passes: 1) do
assert_operator 5, :>, 3
end
end
test "#assert_operator fail with >" do
assert_test(failures: 1) do
assert_operator 3, :>, 5
end
end
test "#assert_operator pass with ... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | test/assertions/equal.test.rb | Ruby | mit | 199 | main | 442 | # frozen_string_literal: true
class EqualTest < Quickdraw::Test
test "#assert_equal pass" do
assert_test(passes: 1) do
assert_equal 1, 1
end
end
test "#assert_equal failure" do
assert_test(failures: 1) do
assert_equal 1, 2
end
end
test "#refute_equal pass" do
assert_test(passes: 1) do
refute_... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | test/assertions/same.test.rb | Ruby | mit | 199 | main | 533 | # frozen_string_literal: true
class SameTest < Quickdraw::Test
test "#assert_same pass" do
object = Object.new
assert_test(passes: 1) do
assert_same object, object
end
end
test "#assert_same failure" do
assert_test(failures: 1) do
assert_same Object.new, Object.new
end
end
test "#refute_same pas... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | test/assertions/includes.test.rb | Ruby | mit | 199 | main | 499 | # frozen_string_literal: true
class IncludesTest < Quickdraw::Test
test "#assert_includes pass" do
assert_test(passes: 1) do
assert_includes([1, 2, 3], 2)
end
end
test "#assert_includes fail" do
assert_test(failures: 1) do
assert_includes([1, 2, 3], 4)
end
end
test "#refute_includes pass" do
ass... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | test/rspec/aliases.test.rb | Ruby | mit | 199 | main | 1,559 | # frozen_string_literal: true
require "quickdraw/rspec"
Quickdraw::RSpec.describe "aliases" do
describe "DSL aliases" do
describe "specify" do
specify "works as an alias for it" do
expect(true).to be(true)
end
specify { expect(1 + 1).to eq(2) }
end
describe "example" do
example "works as an a... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | test/rspec/describe.test.rb | Ruby | mit | 199 | main | 1,294 | # frozen_string_literal: true
require "quickdraw/rspec"
Quickdraw::RSpec.describe "describe" do
describe "with multiple arguments" do
describe String, "when empty" do
it "sets described_class from the Class argument" do
expect(described_class).to eq(String)
end
end
describe Array, "with elements", "... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | test/rspec/expectations.test.rb | Ruby | mit | 199 | main | 10,312 | # frozen_string_literal: true
require "quickdraw/rspec"
Quickdraw::RSpec.describe "expectations" do
describe "all" do
it "passes when all elements match" do
expect([1, 2, 3]).to all(be < 10)
end
it "fails when any element doesn't match" do
expect([1, 2, 30]).not_to all(be < 10)
end
end
describe "be... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | test/rspec/hooks.test.rb | Ruby | mit | 199 | main | 3,737 | # frozen_string_literal: true
require "quickdraw/rspec"
Quickdraw::RSpec.describe "hooks" do
describe "before(:each)" do
before do
@before_each_ran = true
@counter ||= 0
@counter += 1
end
it "runs before each test" do
expect(@before_each_ran).to be(true)
end
it "runs before each test independ... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | test/rspec/chaining.test.rb | Ruby | mit | 199 | main | 568 | # frozen_string_literal: true
require "quickdraw/rspec"
Quickdraw::RSpec.describe "and chaining" do
it "passes when both matchers pass" do
expect(5).to (be > 3).and(be < 10)
end
it "works with equality matchers" do
expect("hello").to be_a(String).and eq("hello")
end
end
Quickdraw::RSpec.describe "or chainin... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | test/rspec/described_class.test.rb | Ruby | mit | 199 | main | 394 | # frozen_string_literal: true
require "quickdraw/rspec"
Quickdraw::RSpec.describe String do
it "provides described_class" do
expect(described_class).to eq(String)
end
describe "nested" do
it "inherits described_class" do
expect(described_class).to eq(String)
end
end
describe Array do
it "overrides d... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | test/rspec/let/let_bang.test.rb | Ruby | mit | 199 | main | 648 | # frozen_string_literal: true
require "quickdraw/rspec"
Quickdraw::RSpec.describe "let!" do
let!(:eager_value) { @evaluated = true; "eager" }
it "is evaluated before the test runs" do
expect(@evaluated).to eq(true)
end
it "provides the value" do
expect(eager_value).to eq("eager")
end
it "memoizes the val... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | test/rspec/let/let.test.rb | Ruby | mit | 199 | main | 1,154 | # frozen_string_literal: true
require "quickdraw/rspec"
Quickdraw::RSpec.describe "let" do
let(:value) { "hello" }
it "provides the value" do
expect(value).to eq("hello")
end
it "memoizes the value" do
expect(value).to equal(value)
end
describe "with a counter" do
let(:counter) { @count ||= 0; @count +... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | test/rspec/shared_examples/isolation.test.rb | Ruby | mit | 199 | main | 2,697 | # frozen_string_literal: true
require "quickdraw/rspec"
# Define a global shared example for this test file
Quickdraw::RSpec.shared_examples "globally defined for isolation test" do
it "can be used from anywhere" do
expect(true).to eq(true)
end
end
Quickdraw::RSpec.describe "shared_examples isolation" do
descri... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | test/rspec/shared_examples/include_examples.test.rb | Ruby | mit | 199 | main | 2,442 | # frozen_string_literal: true
require "quickdraw/rspec"
Quickdraw::RSpec.describe "include_examples" do
shared_examples "basic example" do
it "runs in the current context" do
expect(true).to eq(true)
end
end
describe "includes examples in current context" do
include_examples "basic example"
it "can ac... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | test/rspec/shared_examples/global.test.rb | Ruby | mit | 199 | main | 344 | # frozen_string_literal: true
require "quickdraw/rspec"
Quickdraw::RSpec.shared_examples "globally defined" do
it "can be used from anywhere" do
expect(true).to eq(true)
end
end
Quickdraw::RSpec.describe "global shared_examples" do
it_behaves_like "globally defined"
describe "nested" do
it_behaves_like "glo... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | test/rspec/shared_examples/basic.test.rb | Ruby | mit | 199 | main | 1,114 | # frozen_string_literal: true
require "quickdraw/rspec"
Quickdraw::RSpec.describe "shared_examples" do
shared_examples "a string" do
it "responds to length" do
expect(subject).to respond_to(:length)
end
it "responds to upcase" do
expect(subject).to respond_to(:upcase)
end
end
describe "with a simpl... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | test/rspec/shared_examples/it_should_behave_like.test.rb | Ruby | mit | 199 | main | 1,917 | # frozen_string_literal: true
require "quickdraw/rspec"
Quickdraw::RSpec.describe "it_should_behave_like" do
shared_examples "a measurable object" do |measurement, measurement_methods|
measurement_methods.each do |measurement_method|
it "returns #{measurement} from ##{measurement_method}" do
expect(subject.... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | test/rspec/shared_examples/aliasing.test.rb | Ruby | mit | 199 | main | 2,458 | # frozen_string_literal: true
require "quickdraw/rspec"
Quickdraw::RSpec.describe "alias_it_should_behave_like_to" do
shared_examples "sortability" do
it "responds to <=>" do
expect(sortable).to respond_to(:<=>)
end
end
shared_examples "comparable" do
it "responds to <" do
expect(comparable).to respon... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | test/rspec/shared_examples/parameters.test.rb | Ruby | mit | 199 | main | 1,774 | # frozen_string_literal: true
require "quickdraw/rspec"
Quickdraw::RSpec.describe "shared_examples with parameters" do
shared_examples "a measurable object" do |measurement, measurement_methods|
measurement_methods.each do |measurement_method|
it "returns #{measurement} from ##{measurement_method}" do
expec... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | test/rspec/subject/subject.test.rb | Ruby | mit | 199 | main | 913 | # frozen_string_literal: true
require "quickdraw/rspec"
Quickdraw::RSpec.describe "subject" do
subject { "the subject" }
it "provides the subject" do
expect(subject).to eq("the subject")
end
it "memoizes the subject" do
expect(subject).to equal(subject)
end
describe "named subject" do
subject(:my_strin... |
github | yippee-fun/quickdraw | https://github.com/yippee-fun/quickdraw | test/rspec/subject/subject_bang.test.rb | Ruby | mit | 199 | main | 658 | # frozen_string_literal: true
require "quickdraw/rspec"
Quickdraw::RSpec.describe "subject!" do
subject! { @evaluated = true; "eager subject" }
it "is evaluated before the test runs" do
expect(@evaluated).to eq(true)
end
it "provides the subject" do
expect(subject).to eq("eager subject")
end
describe "na... |
github | jongilbraith/simple-private-messages | https://github.com/jongilbraith/simple-private-messages | Rakefile | Ruby | mit | 199 | master | 1,187 | require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
begin
require "jeweler"
Jeweler::Tasks.new do |gem|
gem.name = "simple-private-messages"
gem.summary = "Simple private messages plugin for Rails 3"
gem.files = Dir["{lib}/**/*", "{app}/**/*", "{config}/**/*"]
gem.email = "ferdinand.nied... |
github | jongilbraith/simple-private-messages | https://github.com/jongilbraith/simple-private-messages | test/test_helper.rb | Ruby | mit | 199 | master | 1,142 | require File.dirname(__FILE__) + '/../../../../config/environment'
require File.dirname(__FILE__) + '/../lib/professionalnerd/simple_private_messages/has_private_messages_extensions'
require File.dirname(__FILE__) + '/../lib/professionalnerd/simple_private_messages/private_message_extensions'
begin require 'redgreen'; ... |
github | jongilbraith/simple-private-messages | https://github.com/jongilbraith/simple-private-messages | test/schema.rb | Ruby | mit | 199 | master | 531 | ActiveRecord::Schema.define(:version => 2) do
create_table "messages", :force => true do |t|
t.integer "sender_id"
t.integer "recipient_id"
t.boolean "sender_deleted", :default => false
t.boolean "recipient_deleted", :default => false
t.string "subject"
t.text "body"
t.dateti... |
github | jongilbraith/simple-private-messages | https://github.com/jongilbraith/simple-private-messages | test/unit/user_model.rb | Ruby | mit | 199 | master | 348 | require File.dirname(__FILE__) + '/../test_helper'
class UserModelTest < Test::Unit::TestCase
def setup
@jerry = create_user(:login => "jerry")
@message = create_message
end
def test_unread_messages?
assert @jerry.unread_messages?
end
def test_unread_message_count
assert_equal @jerry.unrea... |
github | jongilbraith/simple-private-messages | https://github.com/jongilbraith/simple-private-messages | test/unit/message_model.rb | Ruby | mit | 199 | master | 1,258 | require File.dirname(__FILE__) + '/../test_helper'
class MessageModelTest < Test::Unit::TestCase
def setup
@jerry = create_user(:login => "jerry")
@george = create_user(:login => "george")
@message = create_message
end
def test_create_message
@message = create_message
assert_equal @mes... |
github | jongilbraith/simple-private-messages | https://github.com/jongilbraith/simple-private-messages | lib/has_private_messages_extensions.rb | Ruby | mit | 199 | master | 2,427 | module Professionalnerd #:nodoc:
module SimplePrivateMessages #:nodoc:
module HasPrivateMessagesExtensions #:nodoc:
def self.included(base) #:nodoc:
base.extend ActMethods
end
module ActMethods
# Sets up a model have private messages, defining the child class as specified in :c... |
github | jongilbraith/simple-private-messages | https://github.com/jongilbraith/simple-private-messages | lib/private_message_extensions.rb | Ruby | mit | 199 | master | 2,689 | module Professionalnerd # :nodoc:
module SimplePrivateMessages # :nodoc:
module PrivateMessageExtensions
def self.included(base) # :nodoc:
base.extend ActMethods
end
module ActMethods
# Sets up a model to be a private message model, defining the parent class as specified in :cl... |
github | jongilbraith/simple-private-messages | https://github.com/jongilbraith/simple-private-messages | lib/simple-private-messages/matchers.rb | Ruby | mit | 199 | master | 228 | require 'simple-private-messages/matchers/have_private_messages_matcher'
require 'simple-private-messages/matchers/be_private_message_matcher'
module SimplePrivateMessages
module Shoulda
module Matchers
end
end
end |
github | jongilbraith/simple-private-messages | https://github.com/jongilbraith/simple-private-messages | lib/simple-private-messages/railtie.rb | Ruby | mit | 199 | master | 247 | require 'simple-private-messages'
require 'rails'
require 'has_private_messages_extensions'
require 'private_message_extensions'
module SimplePrivateMessages
class Railtie < Rails::Railtie
#railtie_name :simple_private_messages
end
end |
github | jongilbraith/simple-private-messages | https://github.com/jongilbraith/simple-private-messages | lib/simple-private-messages/matchers/be_private_message_matcher.rb | Ruby | mit | 199 | master | 887 | module Professionalnerd # :nodoc:
module SimplePrivateMessages # :nodoc:
module Shoulda # :nodoc:
module Matchers # :nodoc:
def be_private_message
BePrivateMessage.new
end
class BePrivateMessage
def matches? subject
@subject = subject
@su... |
github | jongilbraith/simple-private-messages | https://github.com/jongilbraith/simple-private-messages | lib/simple-private-messages/matchers/have_private_messages_matcher.rb | Ruby | mit | 199 | master | 959 | module Professionalnerd # :nodoc:
module SimplePrivateMessages # :nodoc:
module Shoulda # :nodoc:
module Matchers # :nodoc:
def have_private_messages
HavePrivateMessagesMatcher.new
end
class HavePrivateMessagesMatcher # :nodoc:
def matches? subject
... |
github | jongilbraith/simple-private-messages | https://github.com/jongilbraith/simple-private-messages | lib/generators/simple_private_messages/scaffold/scaffold_generator.rb | Ruby | mit | 199 | master | 2,231 | require 'rails/generators'
module SimplePrivateMessages
module Generators
class ScaffoldGenerator < Rails::Generators::Base
desc "Creates a basic controller and a set of views."
argument :user_model_name, :required => false, :default => "User", :desc => "The user model name"
argument :message_model_name, :requ... |
github | jongilbraith/simple-private-messages | https://github.com/jongilbraith/simple-private-messages | lib/generators/simple_private_messages/scaffold/templates/controller.rb | Ruby | mit | 199 | master | 2,323 | class <%= plural_camel_case_name %>Controller < ApplicationController
before_filter :set_user
def index
if params[:mailbox] == "sent"
@<%= plural_lower_case_name %> = @<%= singular_lower_case_parent %>.sent_messages
else
@<%= plural_lower_case_name %> = @<%= singular_lower_case_parent %>.r... |
github | jongilbraith/simple-private-messages | https://github.com/jongilbraith/simple-private-messages | lib/generators/simple_private_messages/model/model_generator.rb | Ruby | mit | 199 | master | 2,033 | require 'rails/generators'
require 'rails/generators/migration'
module SimplePrivateMessages
module Generators
class ModelGenerator < Rails::Generators::Base
include Rails::Generators::Migration
desc "Creates the private message model."
argument :user_model_name, :required => false, :default => "User", :desc =>... |
github | jongilbraith/simple-private-messages | https://github.com/jongilbraith/simple-private-messages | lib/generators/simple_private_messages/model/templates/model.rb | Ruby | mit | 199 | master | 331 | class <%= singular_camel_case_name %> < ActiveRecord::Base
is_private_message<% unless singular_camel_case_parent == "User" %> :class_name => "<%= "#{singular_camel_case_parent}" %>"<% end %>
# The :to accessor is used by the scaffolding,
# uncomment it if using it or you can remove it if not
#attr_accessor... |
github | jongilbraith/simple-private-messages | https://github.com/jongilbraith/simple-private-messages | lib/generators/simple_private_messages/model/templates/migration.rb | Ruby | mit | 199 | master | 430 | class <%= "Create#{plural_camel_case_name}" %> < ActiveRecord::Migration
def self.up
create_table :<%= plural_lower_case_name %> do |t|
t.integer :sender_id, :recipient_id
t.boolean :sender_deleted, :recipient_deleted, :default => false
t.string :subject
t.text :body
t.datetime :read... |
github | thoughtbot/props_template | https://github.com/thoughtbot/props_template | Rakefile | Ruby | mit | 199 | main | 990 | require "bundler/setup"
require "bundler/gem_tasks"
require "standard/rake"
require "fileutils"
require "rake/testtask"
task :performance do
require "analyzer"
base = File.expand_path("../performance/rolftimmermans", __FILE__)
output_file = File.join(base, "report.png")
files = [
"props_template/oj.rb",
... |
github | thoughtbot/props_template | https://github.com/thoughtbot/props_template | Gemfile | Ruby | mit | 199 | main | 319 | source "https://rubygems.org"
gemspec
gem "rspec"
gem "byebug"
gem "rails", "~> 7.1.0"
gem "analyzer", git: "https://github.com/thoughtbot/analyzer.git"
gem "multi_json"
gem "rabl"
gem "turbostreamer"
gem "jbuilder"
gem "active_model_serializers"
gem "jsonapi-serializer"
gem "standard", group: [:development, :test] |
github | thoughtbot/props_template | https://github.com/thoughtbot/props_template | props_template.gemspec | Ruby | mit | 199 | main | 774 | $LOAD_PATH << File.expand_path("lib", __dir__)
require "props_template/version"
Gem::Specification.new do |s|
s.name = "props_template"
s.version = Props::VERSION
s.author = "Johny Ho"
s.email = "johny@thoughtbot.com"
s.license = "MIT"
s.homepage = "https://github.com/thoughtbot/props_template/"
s.summar... |
github | thoughtbot/props_template | https://github.com/thoughtbot/props_template | performance/rolftimmermans/lib.rb | Ruby | mit | 199 | main | 363 | $LOAD_PATH << File.expand_path('../lib', __FILE__)
require 'active_support'
require "active_support/core_ext"
struct = Struct.new(:name, :birthyear, :bio, :url)
$author = struct.new("Rolf", 1920, "Software developer", "http://example.com/")
$author.instance_eval { undef each } # Jbuilder doesn't like #each on non-arr... |
github | thoughtbot/props_template | https://github.com/thoughtbot/props_template | performance/rolftimmermans/props_base/oj.rb | Ruby | mit | 199 | main | 942 | require 'oj'
require 'props_template/base'
Props::Base.class_eval do
def self.encode!
json = new()
yield json
json.result!
end
alias_method :method_missing, :set!
private :method_missing
end
__SETUP__
Props::Base.encode! do |json|
json.article do
json.author do
json.name $author.nam... |
github | thoughtbot/props_template | https://github.com/thoughtbot/props_template | performance/rolftimmermans/jbuilder/oj.rb | Ruby | mit | 199 | main | 590 | require 'jbuilder'
require 'oj'
require 'multi_json'
MultiJson.use :oj
__SETUP__
Jbuilder.encode do |json|
json.article do
json.author($author, :name, :birthyear, :bio)
json.title "Profiling Jbuilder"
json.body "How to profile Jbuilder"
json.date $now
json.references $arr do |ref|
json.nam... |
github | thoughtbot/props_template | https://github.com/thoughtbot/props_template | performance/rolftimmermans/turbostreamer/wankel.rb | Ruby | mit | 199 | main | 1,117 | require 'turbostreamer'
TurboStreamer.set_default_encoder(:json, :wankel)
__SETUP__
TurboStreamer.encode(encoder: :wankel) do |json|
json.object! do
json.article do
json.object! do
json.author do
json.object! do
json.name $author.name
json.birthyear $author.birthy... |
github | thoughtbot/props_template | https://github.com/thoughtbot/props_template | performance/rolftimmermans/turbostreamer/oj.rb | Ruby | mit | 199 | main | 1,109 | require 'turbostreamer'
TurboStreamer.set_default_encoder(:json, :oj)
__SETUP__
TurboStreamer.encode(encoder: :oj) do |json|
json.object! do
json.article do
json.object! do
json.author do
json.object! do
json.name $author.name
json.birthyear $author.birthyear
... |
github | thoughtbot/props_template | https://github.com/thoughtbot/props_template | performance/rolftimmermans/ams/oj.rb | Ruby | mit | 199 | main | 2,571 | require 'active_model_serializers'
require 'oj'
Oj.optimize_rails
ActiveSupport::Notifications.unsubscribe(ActiveModelSerializers::Logging::RENDER_EVENT)
class Model < ActiveModelSerializers::Model
derive_attributes_from_names_and_fix_accessors
attr_writer :id
# At this time, just for organization of intent
... |
github | thoughtbot/props_template | https://github.com/thoughtbot/props_template | performance/rolftimmermans/props_template/oj.rb | Ruby | mit | 199 | main | 893 | require 'oj'
require 'props_template'
Props::Template.class_eval do
def self.encode!(**args)
json = new(**args)
yield json
json.result!
end
end
__SETUP__
Props::Template.encode! do |json|
json.article do
json.author do
json.name $author.name
json.birthyear $author.birthyear
js... |
github | thoughtbot/props_template | https://github.com/thoughtbot/props_template | performance/rolftimmermans/poro/oj.rb | Ruby | mit | 199 | main | 567 | require 'oj'
__SETUP__
Oj.dump({
author: {
name: $author.name,
birthyear: $author.birthyear,
bio: $author.bio
},
title: "Profiling Jbuilder",
body: "How to profile Jbuilder",
date: $now,
references: $arr.map{|ref| {
name: "Introduction to profiling",
url: "http://example.com",
}},
... |
github | thoughtbot/props_template | https://github.com/thoughtbot/props_template | performance/rolftimmermans/just_oj/oj.rb | Ruby | mit | 199 | main | 1,551 | require 'oj'
writer = ::Oj::StringWriter.new({mode: :rails})
JJJ = {
writer: writer
}
__SETUP__
j = JJJ[:writer]
j.push_object
j.push_key 'article'.freeze
j.push_object
j.push_key 'author'.freeze
j.push_object
j.push_key 'name'.freeze
j.push_value $author.name
j.push_key 'birthyear... |
github | thoughtbot/props_template | https://github.com/thoughtbot/props_template | performance/rolftimmermans/fast_jsonapi/oj.rb | Ruby | mit | 199 | main | 1,784 | require 'jsonapi/serializer'
require 'oj'
Article = Struct.new(:id, :title, :body, :date, :references, :comments, :author, :reference_ids, :comment_ids, :author_id)
Comment = Struct.new(:id, :email, :body, :date, :author, :author_id)
Author = Struct.new(:id, :name, :birthyear, :bio)
Reference = Struct.new(:id, :name, ... |
github | thoughtbot/props_template | https://github.com/thoughtbot/props_template | performance/dirk/lib.rb | Ruby | mit | 199 | main | 464 | $LOAD_PATH << File.expand_path('../lib', __FILE__)
require "active_support"
require 'action_view'
require 'action_view/testing/resolvers'
class FakeController
def perform_caching
true
end
def instrument_fragment_cache(a, b)
yield
end
def cache
Rails.cache
end
end
class FakeContext
attr_r... |
github | thoughtbot/props_template | https://github.com/thoughtbot/props_template | performance/dirk/turbostreamer/oj.rb | Ruby | mit | 199 | main | 1,564 | require 'turbostreamer'
require 'turbostreamer/handler'
require 'turbostreamer/template'
TurboStreamer.set_default_encoder(:json, :oj)
module Rails
def self.cache
@cache ||= ActiveSupport::Cache::MemoryStore.new
end
end
# Fill the cache
TurboStreamer::Template.encode FakeContext.new do |json|
json.object! d... |
github | thoughtbot/props_template | https://github.com/thoughtbot/props_template | performance/dirk/turbostreamer/wankel.rb | Ruby | mit | 199 | main | 1,566 | require 'turbostreamer'
require 'turbostreamer/handler'
require 'turbostreamer/template'
TurboStreamer.set_default_encoder(:json, :wankel)
module Rails
def self.cache
@cache ||= ActiveSupport::Cache::MemoryStore.new
end
end
# Fill the cache
TurboStreamer::Template.encode FakeContext.new do |json|
json.objec... |
github | thoughtbot/props_template | https://github.com/thoughtbot/props_template | performance/dirk/jbuilder/oj.rb | Ruby | mit | 199 | main | 1,159 | require 'jbuilder'
require 'jbuilder/jbuilder_template'
require 'oj'
require 'multi_json'
MultiJson.use :oj
module Rails
def self.cache
@cache ||= ActiveSupport::Cache::MemoryStore.new
end
end
# Fill the cache
JbuilderTemplate.encode FakeContext.new do |json|
json.cached do
json.cache! 'jbcached' do
... |
github | thoughtbot/props_template | https://github.com/thoughtbot/props_template | performance/dirk/rabl/oj.rb | Ruby | mit | 199 | main | 453 | require 'oj'
require 'rabl'
module Rails
def self.cache
@cache ||= ActiveSupport::Cache::MemoryStore.new
end
end
# Fill the cache
Rabl.render(
nil,
"template",
view_path: File.expand_path("./performance/dirk/rabl/views/"),
format: :json,
)
# Everthing before this is run once initially, after is the t... |
github | thoughtbot/props_template | https://github.com/thoughtbot/props_template | performance/dirk/props_template/oj.rb | Ruby | mit | 199 | main | 1,246 | require 'oj'
require 'props_template'
module Rails
def self.cache
@cache ||= ActiveSupport::Cache::MemoryStore.new
end
end
Props::Template.class_eval do
def self.encode!(context, options)
json = new(context, options)
yield json
json.result!
end
end
# Fill the cache
Props::Template.encode!(Fak... |
github | thoughtbot/props_template | https://github.com/thoughtbot/props_template | performance/dirk/ams/oj.rb | Ruby | mit | 199 | main | 1,054 | require 'active_model_serializers'
require 'oj'
Oj.optimize_rails
ActiveModelSerializers.config.perform_caching = true
ActiveModelSerializers.config.cache_store = ActiveSupport::Cache::MemoryStore.new
ActiveSupport::Notifications.unsubscribe(ActiveModelSerializers::Logging::RENDER_EVENT)
class CachedResource < Acti... |
github | thoughtbot/props_template | https://github.com/thoughtbot/props_template | spec/layout_spec.rb | Ruby | mit | 199 | main | 1,258 | require_relative "support/helper"
require_relative "support/rails_helper"
require "props_template/layout_patch"
require "action_controller"
class TestController < ActionController::Base
protect_from_forgery
def self.controller_path
""
end
end
RSpec.describe "Props::Template" do
it "uses a layout to rende... |
github | thoughtbot/props_template | https://github.com/thoughtbot/props_template | spec/searcher_spec.rb | Ruby | mit | 199 | main | 5,442 | require_relative "support/helper"
class Collection
def initialize(ary, rspec)
@ary = ary
@rspec = rspec
end
def member_by(key, value)
@rspec.expect(key).to @rspec.eql("id")
@rspec.expect(value).to @rspec.eql(1)
@ary.last
end
end
RSpec.describe "Searcher" do
it "searching for a child nod... |
github | thoughtbot/props_template | https://github.com/thoughtbot/props_template | spec/helper_spec.rb | Ruby | mit | 199 | main | 333 | require_relative "support/helper"
require_relative "support/rails_helper"
RSpec.describe "Props::Helper" do
it "returns Props::Options instance" do
json = render(<<~PROPS)
opts = with()
json.is_a_props_options opts.is_a? Props::Options
PROPS
expect(json).to eql_json({is_a_props_options: true... |
github | thoughtbot/props_template | https://github.com/thoughtbot/props_template | spec/child_spec.rb | Ruby | mit | 199 | main | 3,667 | require_relative "support/helper"
RSpec.describe "Props::Base child!" do
context "basic functionality" do
it "creates an array with child! blocks" do
json = Props::Base.new
json.array! do
json.child! do
json.set! :title, "hello world"
end
end
attrs = json.result... |
github | thoughtbot/props_template | https://github.com/thoughtbot/props_template | spec/child_searcher_spec.rb | Ruby | mit | 199 | main | 3,279 | require_relative "support/helper"
require_relative "support/rails_helper"
RSpec.describe "Props::Template child! with searcher" do
before do
@controller.request.path = "/some_url"
end
context "dig functionality with child!" do
it "finds specific child by index using dig" do
json = render(<<~PROPS)... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.