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
YusukeIwaki/capybara-playwright-driver
https://github.com/YusukeIwaki/capybara-playwright-driver
spec/feature/timeout_spec.rb
Ruby
mit
243
main
2,305
require 'spec_helper' RSpec.describe 'timeout', sinatra: true do before do sinatra.get('/sleep') do sleep params[:s].to_i 'OK' end sinatra.get('/ng_to_ok') do <<~HTML <body> NG </body> <script type="text/javascript"> setTimeout(() => { document.body...
github
YusukeIwaki/capybara-playwright-driver
https://github.com/YusukeIwaki/capybara-playwright-driver
spec/feature/drop_spec.rb
Ruby
mit
243
main
3,085
# frozen_string_literal: true require 'spec_helper' require 'tempfile' RSpec.describe 'Node#drop', sinatra: true do def with_tempfile(content = 'hello') Tempfile.create('drop_test') do |f| f.write(content) f.flush yield f end end before do sinatra.get '/' do <<~HTML ...
github
YusukeIwaki/capybara-playwright-driver
https://github.com/YusukeIwaki/capybara-playwright-driver
spec/feature/allow_label_click_spec.rb
Ruby
mit
243
main
5,064
require 'spec_helper' require 'timeout' RSpec.describe 'allow_label_click with hidden inputs (ref: https://github.com/YusukeIwaki/capybara-playwright-driver/issues/120 )', sinatra: true do before do skip 'allow_label_click native patch is enabled only on Ruby >= 2.7' if Gem::Version.new(RUBY_VERSION) < Gem::Vers...
github
YusukeIwaki/capybara-playwright-driver
https://github.com/YusukeIwaki/capybara-playwright-driver
spec/feature/fill_options_spec.rb
Ruby
mit
243
main
7,382
# frozen_string_literal: true require 'spec_helper' # Ported from https://github.com/teamcapybara/capybara/blob/3.40.0/spec/shared_selenium_session.rb RSpec.describe 'fill_in options', sinatra: true do before do # Ignore older versions without `#active_element` definition. skip if Gem::Version.new(Capybara:...
github
YusukeIwaki/capybara-playwright-driver
https://github.com/YusukeIwaki/capybara-playwright-driver
spec/capybara/playwright_spec.rb
Ruby
mit
243
main
2,485
# frozen_string_literal: true require 'spec_helper' require 'capybara/spec/spec_helper' module TestSessions Playwright = Capybara::Session.new(:playwright, TestApp) end Capybara::SpecHelper.run_specs TestSessions::Playwright, 'Playwright' do |example| # example: # CAPYBARA_SPEC_FILTER=shadow_root bundle exec ...
github
YusukeIwaki/capybara-playwright-driver
https://github.com/YusukeIwaki/capybara-playwright-driver
spec/capybara/playwright/dialog_event_handler_spec.rb
Ruby
mit
243
main
1,101
require 'spec_helper' RSpec.describe Capybara::Playwright::DialogEventHandler do let(:handler) { Capybara::Playwright::DialogEventHandler.new } let(:mock_dialog) { double('dialog', message: 'dialog message') } it 'can add handler' do callback = double('callback') expect(callback).to receive(:called) ...
github
YusukeIwaki/capybara-playwright-driver
https://github.com/YusukeIwaki/capybara-playwright-driver
lib/capybara/playwright.rb
Ruby
mit
243
main
487
# frozen_string_literal: true require 'capybara' require 'playwright' require 'capybara/playwright/browser' require 'capybara/playwright/browser_runner' require 'capybara/playwright/browser_options' require 'capybara/playwright/dialog_event_handler' require 'capybara/playwright/driver' require 'capybara/playwright/no...
github
YusukeIwaki/capybara-playwright-driver
https://github.com/YusukeIwaki/capybara-playwright-driver
lib/capybara/playwright/driver_extension.rb
Ruby
mit
243
main
2,844
module Capybara module Playwright module DriverExtension # Register screenshot save process. # The callback is called just before page is closed. # (just before #reset_session!) # # The **binary** (String) of the page screenshot is called back into the given block def on_save_r...
github
YusukeIwaki/capybara-playwright-driver
https://github.com/YusukeIwaki/capybara-playwright-driver
lib/capybara/playwright/driver.rb
Ruby
mit
243
main
5,086
require_relative './driver_extension' module Capybara module Playwright class Driver < ::Capybara::Driver::Base extend Forwardable include DriverExtension def initialize(app, **options) @browser_runner = BrowserRunner.new(options) @page_options = PageOptions.new(options) ...
github
YusukeIwaki/capybara-playwright-driver
https://github.com/YusukeIwaki/capybara-playwright-driver
lib/capybara/playwright/page_options.rb
Ruby
mit
243
main
1,106
module Capybara module Playwright class PageOptions def initialize(options) @options = options end NEW_PAGE_PARAMS = { acceptDownloads: nil, bypassCSP: nil, colorScheme: nil, deviceScaleFactor: nil, extraHTTPHeaders: nil, geolocation: nil,...
github
YusukeIwaki/capybara-playwright-driver
https://github.com/YusukeIwaki/capybara-playwright-driver
lib/capybara/playwright/page.rb
Ruby
mit
243
main
5,579
require 'fileutils' module Capybara module Playwright module PageExtension def initialize(*args, **kwargs) if kwargs.empty? super(*args) else super(*args, **kwargs) end capybara_initialize end private def _update_internal_logger(internal_logg...
github
YusukeIwaki/capybara-playwright-driver
https://github.com/YusukeIwaki/capybara-playwright-driver
lib/capybara/playwright/dialog_event_handler.rb
Ruby
mit
243
main
1,117
require 'securerandom' module Capybara module Playwright # LILO event handler class DialogEventHandler class Item def initialize(dialog_proc) @id = SecureRandom.uuid @proc = dialog_proc end attr_reader :id def call(dialog) @proc.call(dialo...
github
YusukeIwaki/capybara-playwright-driver
https://github.com/YusukeIwaki/capybara-playwright-driver
lib/capybara/playwright/node.rb
Ruby
mit
243
main
36,374
module Capybara module ElementClickOptionPatch def perform_click_action(keys, **options) # Expose `wait` value to the block given to perform_click_action. if options[:wait].is_a?(Numeric) options[:_playwright_wait] = options[:wait] end # Playwright has own auto-waiting feature. ...
github
YusukeIwaki/capybara-playwright-driver
https://github.com/YusukeIwaki/capybara-playwright-driver
lib/capybara/playwright/shadow_root_node.rb
Ruby
mit
243
main
1,314
require_relative './node' module Capybara module Playwright class ShadowRootNode < Node def initialize(driver, internal_logger, page, element) super @shadow_root_element = element.evaluate_handle('el => el.shadowRoot') end def all_text assert_element_not_stale { ...
github
YusukeIwaki/capybara-playwright-driver
https://github.com/YusukeIwaki/capybara-playwright-driver
lib/capybara/playwright/browser.rb
Ruby
mit
243
main
13,028
require 'addressable/uri' require_relative './tmpdir_owner' module Capybara module Playwright # Responsibility of this class is: # - Handling Capybara::Driver commands. # - Managing Playwright browser contexts and pages. # # Note that this class doesn't manage Playwright::Browser. # We should...
github
YusukeIwaki/capybara-playwright-driver
https://github.com/YusukeIwaki/capybara-playwright-driver
lib/capybara/playwright/tmpdir_owner.rb
Ruby
mit
243
main
811
module Capybara module Playwright module TmpdirOwner require 'tmpdir' def tmpdir return @tmpdir if @tmpdir dir = Dir.mktmpdir ObjectSpace.define_finalizer(self, TmpdirRemover.new(dir)) @tmpdir = dir end def remove_tmpdir if @tmpdir FileU...
github
YusukeIwaki/capybara-playwright-driver
https://github.com/YusukeIwaki/capybara-playwright-driver
lib/capybara/playwright/browser_options.rb
Ruby
mit
243
main
698
module Capybara module Playwright class BrowserOptions def initialize(options) @options = options end LAUNCH_PARAMS = { args: nil, channel: nil, chromiumSandbox: nil, devtools: nil, downloadsPath: nil, env: nil, executablePath: nil...
github
YusukeIwaki/capybara-playwright-driver
https://github.com/YusukeIwaki/capybara-playwright-driver
lib/capybara/playwright/browser_runner.rb
Ruby
mit
243
main
3,945
module Capybara module Playwright # playwright-ruby-client provides 3 methods to launch/connect browser. # # Playwright.create do |playwright| # playwright.chromium.launch do |browser| # # Playwright.connect_to_playwright_server do |playwright| ... # playwright.chromium...
github
SimplyBuilt/SimonSays
https://github.com/SimplyBuilt/SimonSays
simon_says.gemspec
Ruby
mit
241
master
1,241
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'simon_says/version' Gem::Specification.new do |spec| spec.name = "simon_says" spec.version = SimonSays::VERSION spec.authors = ["Michael Coyne", "Cameron Craig", "Simpl...
github
SimplyBuilt/SimonSays
https://github.com/SimplyBuilt/SimonSays
Rakefile
Ruby
mit
241
master
449
require "bundler/gem_tasks" require "rake/testtask" require 'rdoc/task' Rake::TestTask.new :test do |t| t.libs << 'test' t.pattern = 'test/**/*_test.rb' t.verbose = false end namespace :docs do RDoc::Task.new :generate do |rdoc| rdoc.title = "SimonSays RDOC" rdoc.main = "README.md" rdoc.rdoc_dir ...
github
SimplyBuilt/SimonSays
https://github.com/SimplyBuilt/SimonSays
Guardfile
Ruby
mit
241
master
513
# A sample Guardfile # More info at https://github.com/guard/guard#readme guard :minitest do # with Minitest::Unit watch(%r{^test/(.*)\/?(.*)_test\.rb$}) watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}#{m[2]}_test.rb" } watch(%r{^test/test_helper\.rb$}) { 'test' } # watch test Rails app wa...
github
SimplyBuilt/SimonSays
https://github.com/SimplyBuilt/SimonSays
lib/simon_says.rb
Ruby
mit
241
master
381
require 'active_support' require 'active_support/core_ext' require "simon_says/version" require "simon_says/roleable" require "simon_says/authorizer" begin require 'i18n' unless defined? I18n if defined? I18n I18n.load_path += Dir[File.join( File.expand_path(File.join('..', 'config', 'locales'), __dir_...
github
SimplyBuilt/SimonSays
https://github.com/SimplyBuilt/SimonSays
lib/generators/active_record/simon_says_generator.rb
Ruby
mit
241
master
576
require 'rails/generators/active_record' module ActiveRecord module Generators class SimonSaysGenerator < ActiveRecord::Generators::Base source_root File.expand_path("../templates", __FILE__) def copy_simon_says_migration migration_template "migration.rb", "db/migrate/simon_says_add_to_#{tab...
github
SimplyBuilt/SimonSays
https://github.com/SimplyBuilt/SimonSays
lib/generators/active_record/templates/migration.rb
Ruby
mit
241
master
223
class SimonSaysAddTo<%= table_name.camelize %> < ActiveRecord::Migration<%= migration_version %> def change add_column :<%= table_name %>, :<%= role_attribute_name %>_mask, :integer, default: 0, null: false end end
github
SimplyBuilt/SimonSays
https://github.com/SimplyBuilt/SimonSays
lib/simon_says/roleable.rb
Ruby
mit
241
master
3,874
module SimonSays module Roleable extend ActiveSupport::Concern module ClassMethods # Provides a declarative method to introduce role based # access controller through a give integer mask. # # By default it'll use an attributed named +role_mask+. You can # use the +:as+ option to...
github
SimplyBuilt/SimonSays
https://github.com/SimplyBuilt/SimonSays
lib/simon_says/authorizer.rb
Ruby
mit
241
master
9,410
module SimonSays module Authorizer extend ActiveSupport::Concern class Denied < StandardError attr_reader :role_attr # @private def initialize(role_attr, required, actual) @role_attr = role_attr if defined? I18n required_text = I18n.translate( 'simon_...
github
SimplyBuilt/SimonSays
https://github.com/SimplyBuilt/SimonSays
test/test_helper.rb
Ruby
mit
241
master
1,193
require "minitest/autorun" require 'mocha/minitest' $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) require 'simon_says' # HELLO SIMON # Load test/rails_app ENV["RAILS_ENV"] = "test" require File.expand_path("../rails_app/config/environment.rb", __FILE__) require "rails/test_help" Rails.backtrace_cleane...
github
SimplyBuilt/SimonSays
https://github.com/SimplyBuilt/SimonSays
test/rails_app/config/application.rb
Ruby
mit
241
master
424
require File.expand_path('../boot', __FILE__) require 'rails/all' require 'responders' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) module RailsApp class Application < Rails::Application end end unless defined? S...
github
SimplyBuilt/SimonSays
https://github.com/SimplyBuilt/SimonSays
test/rails_app/config/environments/test.rb
Ruby
mit
241
master
1,819
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suit...
github
SimplyBuilt/SimonSays
https://github.com/SimplyBuilt/SimonSays
test/rails_app/app/controllers/documents_controller.rb
Ruby
mit
241
master
982
class DocumentsController < ApplicationController respond_to :json authenticate :user find_and_authorize :document, through: :memberships, only: :show # any role find_and_authorize :document, :edit, through: :memberships, only: [:edit, :update] find_and_authorize :document, :delete, through: :memberships, o...
github
SimplyBuilt/SimonSays
https://github.com/SimplyBuilt/SimonSays
test/rails_app/app/controllers/application_controller.rb
Ruby
mit
241
master
509
class ApplicationController < ActionController::Base include SimonSays::Authorizer self.default_authorization_scope = :current_user # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception # This would be provided by some...
github
SimplyBuilt/SimonSays
https://github.com/SimplyBuilt/SimonSays
test/rails_app/app/controllers/images_controller.rb
Ruby
mit
241
master
206
class ImagesController < ApplicationController respond_to :json authenticate :user find_resource :image, find_attribute: :token, only: :show # any role def show respond_with @image end end
github
SimplyBuilt/SimonSays
https://github.com/SimplyBuilt/SimonSays
test/rails_app/app/controllers/admin/reports_controller.rb
Ruby
mit
241
master
676
class Admin::ReportsController < ApplicationController respond_to :json self.default_authorization_scope = :current_admin authorize :support find_resource :report, namespace: :admin, except: [:index, :new, :create] def index @reports = Admin::Report.all respond_with @reports end def create ...
github
SimplyBuilt/SimonSays
https://github.com/SimplyBuilt/SimonSays
test/rails_app/db/schema.rb
Ruby
mit
241
master
2,098
# This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # # Note that this schema.rb definition is the authoritative source for your # dat...
github
SimplyBuilt/SimonSays
https://github.com/SimplyBuilt/SimonSays
test/rails_app/db/migrate/20141016183633_create_memberships.rb
Ruby
mit
241
master
241
class CreateMemberships < ActiveRecord::Migration[5.0] def change create_table :memberships do |t| t.references :user t.references :document t.integer :roles_mask, default: 0 t.timestamps end end end
github
SimplyBuilt/SimonSays
https://github.com/SimplyBuilt/SimonSays
test/simon_says/roleable_test.rb
Ruby
mit
241
master
4,281
require 'test_helper' class RoleableTest < ActiveSupport::TestCase test "adds constant" do assert_equal [:download, :fork, :edit, :delete], Membership::ROLES end test "adds constant with :as option" do assert_equal [:support, :content, :marketing], Admin::ACCESS end test "adds roles method" do ...
github
SimplyBuilt/SimonSays
https://github.com/SimplyBuilt/SimonSays
test/simon_says/authorizer_test.rb
Ruby
mit
241
master
4,834
require 'test_helper' class AuthorizerTest < ActiveSupport::TestCase setup do @controller = Class.new(ApplicationController) do # These would be defined by Devise or some authenication library attr_accessor :current_user, :current_admin, :sites attr_reader :params def params=(params) ...
github
SimplyBuilt/SimonSays
https://github.com/SimplyBuilt/SimonSays
test/simon_says/authorizer_denied_test.rb
Ruby
mit
241
master
2,872
require 'test_helper' class AuthorizerAccessDeniedTest < ActiveSupport::TestCase test 'one required and none set' do err = SimonSays::Authorizer::Denied.new(:roles, %w(foo), []) assert_equal 'Access denied: foo is required; however, you have no roles set', err.message end test 'two required and none se...
github
SimplyBuilt/SimonSays
https://github.com/SimplyBuilt/SimonSays
test/controllers/images_controller_test.rb
Ruby
mit
241
master
492
require 'test_helper' class ImagesControllerTest < ActionController::TestCase setup do @image = images(:image_one) @controller.current_admin = users(:bob) end test 'get show with correct id parameter' do get :show, params: { id: @image.token }, format: :json assert_response :success end t...
github
SimplyBuilt/SimonSays
https://github.com/SimplyBuilt/SimonSays
test/controllers/documents_controller_test.rb
Ruby
mit
241
master
1,757
require 'test_helper' class DocumentsControllerTest < ActionController::TestCase setup do @alpha = documents(:alpha) @beta = documents(:beta) @bob = users(:bob) @jim = users(:jim) end def as_bob! @controller.current_user = @bob end def as_jim! @controller.current_user = @jim end...
github
SimplyBuilt/SimonSays
https://github.com/SimplyBuilt/SimonSays
test/controllers/admin/reports_controller_test.rb
Ruby
mit
241
master
2,244
require 'test_helper' class Admin::ReportsControllerTest < ActionController::TestCase setup do @support = admins(:support) @marketing = admins(:marketing) end test "index with access" do @controller.current_admin = @support get :index, params: { format: :json } assert_response :success e...
github
enspirit/bmg
https://github.com/enspirit/bmg
bmg.gemspec
Ruby
mit
241
master
1,069
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__) require 'bmg/version' require 'date' Gem::Specification.new do |s| s.name = 'bmg' s.version = Bmg::VERSION s.date = Date.today.to_s s.summary = "Bmg is Alf's successor." s.description = "Bmg is Alf's relational algebra for ruby, bu...
github
enspirit/bmg
https://github.com/enspirit/bmg
Rakefile
Ruby
mit
241
master
209
# # Install all tasks found in tasks folder # # See .rake files there for complete documentation. # Dir["tasks/*.rake"].each do |taskfile| load taskfile end # We run tests by default task :default => :test
github
enspirit/bmg
https://github.com/enspirit/bmg
tasks/test.rake
Ruby
mit
241
master
917
namespace :test do require "rspec/core/rake_task" tests = [] desc "Runs unit tests" RSpec::Core::RakeTask.new(:unit) do |t| t.pattern = "spec/unit/**/test_*.rb" t.rspec_opts = ["-Ilib", "-Ispec/unit", "--color", "--backtrace", "--format=progress"] end tests << :unit desc "Runs integration tests...
github
enspirit/bmg
https://github.com/enspirit/bmg
tasks/gem.rake
Ruby
mit
241
master
952
require 'rubygems/package_task' # Dynamically load the gem spec gemspec_file = File.expand_path('../../bmg.gemspec', __FILE__) gemspec = Kernel.eval(File.read(gemspec_file)) Gem::PackageTask.new(gemspec) do |t| # Name of the package t.name = gemspec.name # Version of the package t.version = gemspec.ver...
github
enspirit/bmg
https://github.com/enspirit/bmg
contrib/bmg-redis/bmg-redis.gemspec
Ruby
mit
241
master
810
$LOAD_PATH.unshift File.expand_path('../../../lib', __FILE__) require 'bmg/version' require 'date' Gem::Specification.new do |s| s.name = 'bmg-redis' s.version = Bmg::VERSION s.date = Date.today.to_s s.summary = "Expose redis as relations." s.description = "bmg-redis provides an adapter...
github
enspirit/bmg
https://github.com/enspirit/bmg
contrib/bmg-redis/spec/spec_helper.rb
Ruby
mit
241
master
914
require 'rspec' require 'bmg' require 'bmg/redis' module SpecHelpers def redis @redis ||= Redis.new end def suppliers [ { sid: 'S1', name: 'Smith', city: 'Paris' }, { sid: 'S2', name: 'Jones', city: 'London' } ] end def suppliers_type Bmg::Type::ANY .with_attrlist([:sid, ...
github
enspirit/bmg
https://github.com/enspirit/bmg
contrib/bmg-redis/spec/integration/redis/relation/test_restrict.rb
Ruby
mit
241
master
1,124
require 'spec_helper' module Bmg::Redis describe Relation, "restrict" do let(:relvar) do suppliers_relvar end context 'with a predicate that allows optimizing' do before do expect(redis).not_to receive(:scan_each) allow(redis).to receive(:get).and_call_original end ...
github
enspirit/bmg
https://github.com/enspirit/bmg
contrib/bmg-redis/spec/integration/redis/relation/test_delete.rb
Ruby
mit
241
master
1,048
require 'spec_helper' module Bmg::Redis describe Relation, "delete" do let(:relvar) do suppliers_relvar end context 'without predicate' do subject do relvar.delete end it 'removes all tuples' do expect(subject).to be(relvar) expected = [].to_set ...
github
enspirit/bmg
https://github.com/enspirit/bmg
contrib/bmg-redis/spec/integration/redis/relation/test_each.rb
Ruby
mit
241
master
638
require 'spec_helper' module Bmg::Redis describe Relation, "each" do subject do suppliers_relvar(type) end context 'when a valid type is provided' do let(:type) do suppliers_type end it 'works' do expect(subject).to be_a(Bmg::Relation) end it 'retur...
github
enspirit/bmg
https://github.com/enspirit/bmg
contrib/bmg-redis/spec/integration/redis/relation/test_update.rb
Ruby
mit
241
master
1,984
require 'spec_helper' module Bmg::Redis describe Relation, "update" do let(:relvar) do suppliers_relvar end context 'without predicate' do before do allow(redis).to receive(:scan_each).and_call_original end subject do relvar.update(city: 'Brussels') end ...
github
enspirit/bmg
https://github.com/enspirit/bmg
contrib/bmg-redis/tasks/test.rake
Ruby
mit
241
master
622
namespace :test do require "rspec/core/rake_task" tests = [] desc "Runs unit tests" RSpec::Core::RakeTask.new(:unit) do |t| t.pattern = "spec/unit/**/test_*.rb" t.rspec_opts = ["-Ilib", "-Ispec/unit", "--color", "--backtrace", "--format=progress"] end tests << :unit desc "Runs integration tests...
github
enspirit/bmg
https://github.com/enspirit/bmg
contrib/bmg-redis/tasks/gem.rake
Ruby
mit
241
master
958
require 'rubygems/package_task' # Dynamically load the gem spec gemspec_file = File.expand_path('../../bmg-redis.gemspec', __FILE__) gemspec = Kernel.eval(File.read(gemspec_file)) Gem::PackageTask.new(gemspec) do |t| # Name of the package t.name = gemspec.name # Version of the package t.version = gemsp...
github
enspirit/bmg
https://github.com/enspirit/bmg
contrib/bmg-redis/lib/bmg/redis/relation.rb
Ruby
mit
241
master
3,410
module Bmg module Redis class Relation include Bmg::Relation DEFAULT_OPTIONS = { serializer: :marshal } def initialize(type, options) @type = type @options = DEFAULT_OPTIONS.merge(options) serializer! candidate_key! end attr_accessor :...
github
enspirit/bmg
https://github.com/enspirit/bmg
contrib/bmg-redis/lib/bmg/redis/singleton.rb
Ruby
mit
241
master
744
module Bmg module Redis class Singleton include Bmg::Relation def initialize(type, parent, tuple) @type = type @parent = parent @tuple = tuple end attr_accessor :type def each return to_enum unless block_given? yield(@tuple) if @tuple ...
github
enspirit/bmg
https://github.com/enspirit/bmg
contrib/bmg-redis/lib/bmg/redis/serializer/marshal.rb
Ruby
mit
241
master
332
module Bmg module Redis class Serializer class Marshal < Serializer def serialize(tuple) ::Marshal.dump(tuple) end def deserialize(serialized) ::Marshal.load(serialized) end end # class Marshal end # class Serializer end # module Redis end #...
github
enspirit/bmg
https://github.com/enspirit/bmg
contrib/bmg-redis/lib/bmg/redis/serializer/json.rb
Ruby
mit
241
master
369
module Bmg module Redis class Serializer class Json < Serializer def serialize(tuple) tuple.to_json end def deserialize(serialized) parsed = JSON.parse(serialized) TupleAlgebra.symbolize_keys(parsed) end end # class Json end # class ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/test_spying.rb
Ruby
mit
241
master
353
require 'spec_helper' module Bmg describe "The spying mechanism" do it 'lets install a main spy that applies to all relations' do seen = [] Bmg.main_spy = ->(r) { seen << r } r = Relation.new([{a: 1},{a: 2}]).restrict(a: 2) expect(r.to_a).to eql([{a: 2}]) expect(seen...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/test_type.rb
Ruby
mit
241
master
13,772
require 'spec_helper' module Bmg describe Type do let(:any){ Type::ANY } let(:suppliers_attrlist) { [:sid, :name, :status, :city] } let(:suppliers){ Type::ANY.with_attrlist(suppliers_attrlist) } let(:supplies_attrlist) { [:sid, :pid, :qty] } let(:supplies){ ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/spec_helper.rb
Ruby
mit
241
master
952
require 'rspec' require 'bmg' require 'bmg/sequel' require 'path' module SpecHelper SEQUEL_DB = Sequel.connect("sqlite://#{Path.dir.parent}/suppliers-and-parts.db") shared_examples_for "a Relation-compatible" do it 'is a relation' do expect(subject).to be_a(Bmg::Relation) end it 'each without...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/test_readme.rb
Ruby
mit
241
master
842
require 'spec_helper' describe "Bmg's README" do describe 'generate' do it 'has a correct first example' do r = Bmg .generate(1, 10, :step => 2, :as => :index) .restrict(:index => 5) expect(r.count).to eql(1) expect(r.one).to eql({ index: 5 }) end it 'has a correct sec...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/test_relation.rb
Ruby
mit
241
master
18,554
require 'spec_helper' module Bmg describe Relation do shared_examples_for "an operator method" do it_behaves_like "a Relation-compatible" end describe 'new' do it "accepts arrays but enclosed them as Leafs" do tuple = { a: 1, b: 2 } rel = Relation.new([tuple]) expect...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/optimizer/test_constants.rb
Ruby
mit
241
master
4,650
require 'spec_helper' module Bmg describe "constants optimization" do let(:relation) { Relation.new([ { a: 1, b: 2 }, { a: 11, b: 2 } ]) } let(:constants) { { c: 3 } } context "constants.page" do subject{ relation.constants(constants).page(order...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/optimizer/test_matching.rb
Ruby
mit
241
master
2,371
require 'spec_helper' module Bmg describe "matching optimization" do context "matching.restrict" do let(:left_data) { [ { a: 1, b: 2 }, { a: 3, b: 4 } ] } let(:left) { Relation.new(left_data) } let(:right_data) { [ { a:...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/optimizer/test_project.rb
Ruby
mit
241
master
1,135
require 'spec_helper' module Bmg describe 'project optimization' do context 'project.restrict' do let(:relation) { Relation.new([ { a: 1, b: 2 }, { a: 11, b: 2 } ]) } let(:predicate) { Predicate.gt(:a, 10) } let(:projected) { [:a...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/optimizer/test_image.rb
Ruby
mit
241
master
8,171
require 'spec_helper' module Bmg describe "image optimization" do let(:left_data) { [ { a: 1, b: 2 }, { a: 3, b: 4 } ] } let(:left) { Relation.new(left_data) } let(:right_data) { [ { a: 1, c: 4 }, { a: 1, c: 5 } ] } let(:rig...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/optimizer/test_empty.rb
Ruby
mit
241
master
858
require 'spec_helper' module Bmg describe "emty optimization" do let(:empty) { Relation::Empty.new(Type::ANY) } [ [:allbut, []], [:autosummarize, []], [:autowrap, []], [:constants, {}], [:extend, []], [:image, [ Relation.new([]) ]], [:project, []], [...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/optimizer/test_allbut.rb
Ruby
mit
241
master
4,207
require 'spec_helper' module Bmg describe "allbut optimization" do let(:relation) { Relation.new([ { a: 1, b: 2, c: 3 }, { a: 11, b: 2, c: 33 } ]) } before do class Operator::Page public :ordering, :page_index, :options end class Operator::Matching ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/optimizer/test_summarize.rb
Ruby
mit
241
master
2,416
require 'spec_helper' module Bmg describe "summarize optimization" do context "summarize.restrict" do subject { Relation.new([ { a: 1, b: 2 }, { a: 11, b: 2 } ]).summarize(by, sums).restrict(predicate) } context 'when no optimization is possible' do ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/optimizer/test_join.rb
Ruby
mit
241
master
6,080
require 'spec_helper' module Bmg describe "join optimization" do let(:options) { { :split => '-' } } # context "join.autowrap" do # let(:left) { # Relation.new([ # { a: 1, b: 2 }, # { a: 3, b: 4 } # ], Type.new.with_attrlist([:a, :b])) # } # le...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/optimizer/test_autowrap.rb
Ruby
mit
241
master
14,646
require 'spec_helper' module Bmg describe "autowrap optimization" do let(:options) { { :split => '-' } } let(:relation) { Relation.new([ { :a => 1, :"b-id" => 2, :"c$id" => 3 }, { :a => 11, :"b-id" => 2, :"c$id" => 3 } ], type) } let(:untyped_relation) { ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/optimizer/test_restrict.rb
Ruby
mit
241
master
619
require 'spec_helper' module Bmg describe "restrict optimization" do context "restrict.restrict" do let(:p1) { Predicate.gt(:a, 10) } let(:p2) { Predicate.gt(:b, 10) } subject { Relation.new([ { a: 1, b: 2 }, { a: 11, b: 2 } ])....
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/optimizer/test_extend.rb
Ruby
mit
241
master
11,254
require 'spec_helper' module Bmg describe "extend optimization" do let(:relation) { Relation.new([ { a: 1, b: 2 }, { a: 11, b: 2 } ]) } let(:c_ext) { ->(t){ 12 } } let(:d_ext) { ->(t){ 13 } } context 'extend with empty extension' do subjec...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/optimizer/test_union.rb
Ruby
mit
241
master
3,505
require 'spec_helper' module Bmg describe "union_nary optimization" do let(:left) { Relation.new([ { a: 1 }, ]) } let(:right) { Relation.new([ { a: 2 }, ]) } let(:third) { Relation.new([ { a: 3 }, ]) } let(:fourth) { Rel...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/optimizer/test_any_relation.rb
Ruby
mit
241
master
485
require 'spec_helper' module Bmg describe "shared optimization" do let(:a_relation) { Relation.new([{a: 1}]) } let(:empty) { Relation.empty } it "includes the fact that any relation returns self if unioned with empty" do expect(a_relation.union(empty)).to be(a_relation) en...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/optimizer/test_not_matching.rb
Ruby
mit
241
master
903
require 'spec_helper' module Bmg describe "not_matching optimization" do context "not_matching.restrict" do let(:left_data) { [ { a: 1, b: 2 }, { a: 3, b: 4 } ] } let(:left) { Relation.new(left_data) } let(:right_data) { [ ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/optimizer/test_autosummarize.rb
Ruby
mit
241
master
1,193
require 'spec_helper' module Bmg describe "autosummarize optimization" do context "autosummarize.restrict" do subject { Relation.new([ { a: 1, b: 2, c: 7 }, { a: 1, b: 3, c: 8 } ]).autosummarize([:x], b: :group).restrict(predicate) } context 'when the predic...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/optimizer/test_transform.rb
Ruby
mit
241
master
6,254
require 'spec_helper' module Bmg describe "transform optimization" do let(:relation) { Relation.new([ { a: 1, b: 2 }, { a: 11, b: 2 } ]) } before do class Operator::Transform public :transformation end class Operator::Project public :attrlis...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/optimizer/test_rename.rb
Ruby
mit
241
master
2,377
require 'spec_helper' module Bmg describe "rename optimization" do let(:relation) { Relation.new([ { x: 1, b: 2 }, { x: 11, b: 2 } ]) } context 'when renaming can be simplified or removed' do subject{ relation.rename(renaming) } context 'with empty...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/optimizer/test_group.rb
Ruby
mit
241
master
1,336
require 'spec_helper' module Bmg describe "group optimization" do context "group.restrict" do let(:relation) { Relation.new([ { a: 1, b: 2 }, { a: 11, b: 2 } ]) } subject{ relation.group([:b], :newone).restrict(predicate) } context 'whe...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/test_relation.rb
Ruby
mit
241
master
3,628
require 'sql_helper' module Bmg module Sql describe Relation do let(:suppliers) { Bmg.sql(:suppliers) } context 'a base one' do it 'compiles to expected SQL' do r = suppliers expect(r.to_sql).to eql(%Q{SELECT "t1".* FROM "suppliers" AS "t1"}) end ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/builder/test_from_clause.rb
Ruby
mit
241
master
1,174
require 'sql_helper' module Bmg module Sql describe Builder, "from_clause" do context 'with a table name' do subject{ builder.from_clause(:table, :t1) } let(:expected){ [:from_clause, [:table_as, [:table_name, :table], [:range_var_name, :t1]] ] } it{ ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/builder/test_order_by_clause.rb
Ruby
mit
241
master
1,479
require 'sql_helper' module Bmg module Sql describe Builder, "order_by_clause" do let(:ordering){ [[:name, :asc], [:city, :desc]] } context 'without desaliaser' do subject{ builder.order_by_clause(ordering) } let(:expected){ [:order_by_clause, [:order_by_term, ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/builder/test_group_by_clause.rb
Ruby
mit
241
master
1,066
require 'sql_helper' module Bmg module Sql describe Builder, "group_by_clause" do let(:attrs){ [:name, :city] } context 'without desaliaser' do subject{ builder.group_by_clause(attrs) } let(:expected){ [:group_by_clause, [ :column_name, 'name' ], [ ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/helpers/ast.rb
Ruby
mit
241
master
6,414
module SqlHelpers module Ast def builder(start = 0) @builder ||= Bmg::Sql::Builder.new(start) end def sexpr(arg) Bmg::Sql::Grammar.sexpr(arg) end def with_exp(spec, selection = select_ab) sexpr [:with_exp, with_spec(spec), selection] end def with_spec(spec = nil) ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/support/test_from_clause_orderer.rb
Ruby
mit
241
master
6,039
require 'sql_helper' module Bmg module Sql module Support describe FromClauseOrderer do subject{ FromClauseOrderer.new.call(expr) } def collect FromClauseOrderer.new.send(:collect, expr) end def on(t1, a1, t2, a2) left_attr = qualified...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/nodes/select_item/test_as_name.rb
Ruby
mit
241
master
421
require 'sql_helper' module Bmg module Sql describe SelectItem, "as_name" do subject{ expr.as_name } context 'on a select item with no real renaming' do let(:expr){ select_item("a", "a") } it{ should eq("a") } end context 'on a select item with with real renaming' do ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/nodes/select_list/test_is_table_dee.rb
Ruby
mit
241
master
403
require 'sql_helper' module Bmg module Sql describe SelectList, "is_table_dee" do subject{ expr.is_table_dee? } context 'on a normal select list' do let(:expr){ select_list } it{ should be(false) } end context 'on a is_table_dee select list' do let(:expr){ Build...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/nodes/select_list/test_desaliaser.rb
Ruby
mit
241
master
1,311
require 'sql_helper' module Bmg module Sql describe SelectList, "desaliaser" do context 'when for_predicate is false' do let(:expr){ sexpr([ :select_list, select_item("foo", "bar"), select_item("baz", "ban"), select_item(literal(23), "lit"),...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/nodes/select_exp/test_order_by_clause.rb
Ruby
mit
241
master
411
require 'sql_helper' module Bmg module Sql describe SelectExp, "order_by_clause" do subject{ expr.order_by_clause } context 'when an order by clause' do let(:expr){ select_all.push(order_by_clause) } it{ should eq(order_by_clause) } end context 'without such clause' do ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/nodes/select_exp/test_is_table_dee.rb
Ruby
mit
241
master
388
require 'sql_helper' module Bmg module Sql describe SelectExp, "is_table_dee?" do subject{ expr.is_table_dee? } context 'when normal select' do let(:expr){ select_all } it{ should be(false) } end context 'when a select is table dee' do let(:expr){ select_is_tabl...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/nodes/order_by_clause/test_to_ordering.rb
Ruby
mit
241
master
593
require 'sql_helper' module Bmg module Sql describe OrderByClause, "to_ordering" do subject{ expr.to_ordering } let(:ordering){ [[:a, :asc], [:b, :desc]] } context 'when not qualified' do let(:expr){ builder.order_by_clause(ordering) } it{ should eq(ordering) } ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/nodes/order_by_term/test_qualifier.rb
Ruby
mit
241
master
420
require 'sql_helper' module Bmg module Sql describe OrderByTerm, "qualifier" do subject{ expr.qualifier } context 'when qualified' do let(:expr){ order_by_term(qualified_name('t1', 'a'), "asc") } it{ should eq('t1') } end context 'when not qualified' do let(:exp...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/nodes/order_by_term/test_as_name.rb
Ruby
mit
241
master
416
require 'sql_helper' module Bmg module Sql describe OrderByTerm, "as_name" do subject{ expr.as_name } context 'when qualified' do let(:expr){ order_by_term(qualified_name('t1', 'a'), "asc") } it{ should eq('a') } end context 'when not qualified' do let(:expr){ o...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/nodes/order_by_term/test_direction.rb
Ruby
mit
241
master
424
require 'sql_helper' module Bmg module Sql describe OrderByTerm, "direction" do subject{ expr.direction } context 'when qualified' do let(:expr){ order_by_term(qualified_name('t1', 'a'), "asc") } it{ should eq('asc') } end context 'when not qualified' do let(:ex...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/processor/test_on_set_operator.rb
Ruby
mit
241
master
540
require 'sql_helper' module Bmg module Sql describe Processor, "on_set_operator" do let(:clazz){ Class.new(Processor){ def on_select_exp(sexpr) [:foo, :bar, sexpr] end } } subject{ clazz.new(Builder.new).on_set_operator(expr) } let(:expr){...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/processor/test_on_select_exp.rb
Ruby
mit
241
master
549
require 'sql_helper' module Bmg module Sql describe Processor, "on_select_exp" do let(:clazz){ Class.new(Processor){ def on_select_list(sexpr) [:foo, :bar, sexpr] end } } subject{ clazz.new(Builder.new).on_select_exp(expr) } let(:expr){ ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/processor/test_distinct.rb
Ruby
mit
241
master
464
require 'sql_helper' module Bmg module Sql class Processor describe Distinct do subject{ Distinct.new(Builder.new).call(expr) } context 'on a select_exp' do let(:expr){ select_all } it{ should eq(select_distinct) } end context 'on a with_exp' do ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/processor/test_clip.rb
Ruby
mit
241
master
446
require 'sql_helper' module Bmg module Sql class Processor describe Clip do subject{ Clip.new([:a], Builder.new).call(expr) } context 'on a select_exp' do let(:expr){ select_ab } it{ should eq(select_a) } end context 'on a with_exp' do let(:e...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/processor/test_rename.rb
Ruby
mit
241
master
480
require 'sql_helper' module Bmg module Sql class Processor describe Rename do subject{ Rename.new({:a => :b}, Builder.new).call(expr) } context 'on a select_exp' do let(:expr){ select_all_a } it{ should eq(select_all_a_as_b) } end context 'on a with_ex...