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
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/processor/bind/test_on_select_exp.rb
Ruby
mit
241
master
725
require 'sql_helper' module Bmg module Sql class Processor describe Bind, "on_select_exp" do subject{ Bind.new(binding, Builder.new(1)).apply(expr) } let(:placeholder){ Predicate.placeholder } let(:binding) { { placeholder => 12 } ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/processor/constants/test_on_select_list.rb
Ruby
mit
241
master
707
require 'sql_helper' module Bmg module Sql class Processor describe Constants, "on_select_list" do subject{ Constants.new({foo: "bar", baz: 2, hello: nil}, Builder.new).on_select_list(expr) } context 'when included' do let(:expr){ select_list_ab ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/processor/transform/test_split_supported.rb
Ruby
mit
241
master
2,315
require 'sql_helper' module Bmg module Sql class Processor describe Transform, "split_supported" do subject{ Transform.split_supported(t, &recognizer) } let(:recognizer) { ->(x){ x == String || x == :to_s || x == :to_i } } ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/processor/transform/test_on_select_list.rb
Ruby
mit
241
master
967
require 'sql_helper' module Bmg module Sql class Processor describe Transform, "on_select_list" do subject{ Transform.new({ :a => Date }, {}, Builder.new).on_select_list(expr) } let(:expr){ sexpr [:select_list, [:select_item, ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/processor/order_by/test_on_select_exp.rb
Ruby
mit
241
master
445
require 'sql_helper' module Bmg module Sql class Processor describe OrderBy, "on_select_exp" do subject{ OrderBy.new(ordering, builder).on_select_exp(expr) } context 'when not already ordered' do let(:expr){ select_all } let(:expected){ ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/processor/distinct/test_on_set_quantified.rb
Ruby
mit
241
master
598
require 'sql_helper' module Bmg module Sql class Processor describe Distinct, "on_set_quantified" do subject{ Distinct.new(Builder.new).on_set_quantified(expr) } let(:expected){ [:x, distinct] } context 'when already distinct' do let(:expr){ ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/processor/requalify/test_on_select_exp.rb
Ruby
mit
241
master
708
require 'sql_helper' module Bmg module Sql class Processor describe Requalify, "on_select_exp" do subject{ Requalify.new(Builder.new(1)).on_select_exp(expr) } context 'when not already ordered' do let(:expr){ select_all } let(:expected){ ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/processor/requalify/test_on_where_clause.rb
Ruby
mit
241
master
527
require 'sql_helper' module Bmg module Sql class Processor describe Requalify, "on_where_clause" do subject{ Requalify.new(Builder.new(1)).apply(expr) } context 'with a predicate to requalify' do let(:expr){ sexpr [:where_clause, Predicate.eq(:x, 1).qualify(:t1).sexpr...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/processor/requalify/test_on_inner_join.rb
Ruby
mit
241
master
1,111
require 'sql_helper' module Bmg module Sql class Processor describe Requalify, "on_inner_join" do subject{ Requalify.new(Builder.new(2)).apply(expr) } context 'with a predicate to requalify' do let(:expr){ sexpr [ :inner_join, [:table_as, [:table_name, :...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/processor/rename/test_on_select_item.rb
Ruby
mit
241
master
643
require 'sql_helper' module Bmg module Sql class Processor describe Rename, "on_select_item" do subject{ Rename.new({:a => :x}, Builder.new).on_select_item(expr) } context 'when included' do let(:expr){ select_item('a', 'a') } it{ should eq(select_item('a', 'x')) } ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/processor/rename/test_on_select_list.rb
Ruby
mit
241
master
441
require 'sql_helper' module Bmg module Sql class Processor describe Rename, "on_select_list" do subject{ Rename.new({:a => :b, :c => :d}, Builder.new).on_select_list(expr) } let(:expr){ select_list("a" => "a", "x" => "c", "y" => "z") } let(:expected){ s...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/processor/summarize/test_on_select_exp.rb
Ruby
mit
241
master
1,225
require 'sql_helper' module Bmg module Sql class Processor describe Summarize, "on_select_exp" do subject{ Summarize.new([:a], { :b => Bmg::Summarizer.sum(:b), :c => Bmg::Summarizer.min(:a) }, Builder.new(1)).on_select_exp(expr) } context...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/processor/from_self/test_on_with_exp.rb
Ruby
mit
241
master
423
require 'sql_helper' module Bmg module Sql class Processor describe FromSelf, "on_with_exp" do subject{ FromSelf.new(builder(1)).on_with_exp(expr) } let(:expr){ with_exp({t1: select_all}, select_all_t2) } let(:expected){ with_exp({t1: select_all, t2: se...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/processor/from_self/test_on_nonjoin_exp.rb
Ruby
mit
241
master
1,044
require 'sql_helper' module Bmg module Sql class Processor describe FromSelf, "on_nonjoin_exp" do subject{ FromSelf.new(builder).on_nonjoin_exp(expr) } context 'on select_exp' do let(:expr){ select_all } let(:expected){ with_exp(t1: se...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/processor/merge/test_on_with_exp.rb
Ruby
mit
241
master
1,354
require 'sql_helper' module Bmg module Sql class Processor describe Merge, "on_with_exp" do subject{ Merge.new(:intersect, false, right, builder(1)).on_with_exp(expr) } context 'when right is a simple exp' do let(:expr){ # with t1 AS ... # SELECT * FR...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/processor/merge/test_on_select_exp.rb
Ruby
mit
241
master
1,655
require 'sql_helper' module Bmg module Sql class Processor describe Merge, "on_select_exp" do subject{ Merge.new(:intersect, false, right, builder(1)).on_select_exp(expr) } context 'when right a simple select_exp' do let(:expr){ # SELECT * FROM t1 select_a...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/processor/merge/test_on_nonjoin_exp.rb
Ruby
mit
241
master
698
require 'sql_helper' module Bmg module Sql class Processor describe Merge, "on_nonjoin_exp" do subject{ Merge.new(:intersect, false, right, builder(1)).on_nonjoin_exp(expr) } context 'when left is an intersect already' do let(:expr){ # SELECT * FROM t1 INTERSECT SELEC...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/processor/clip/test_on_select_list.rb
Ruby
mit
241
master
871
require 'sql_helper' module Bmg module Sql class Processor describe Clip, "on_select_list" do context 'allbut = false' do subject{ Clip.new([:a], false, :is_table_dee, Builder.new).on_select_list(expr) } context 'when included' do let(:expr){ ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/processor/clip/test_on_select_exp.rb
Ruby
mit
241
master
731
require 'sql_helper' module Bmg module Sql class Processor describe Clip, "on_select_exp" do subject{ Clip.new([:a], false, :is_table_dee, Builder.new).on_select_exp(expr) } context 'normal_case' do let(:expr){ select_all } it{ should eq(select_all_a)...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/processor/reorder/test_on_select_list.rb
Ruby
mit
241
master
365
require 'sql_helper' module Bmg module Sql class Processor describe Reorder, "on_select_list" do subject{ Reorder.new([:b, :a], Builder.new).on_select_list(expr) } let(:expr){ select_list_ab } let(:expected){ select_list_ba } it{ should...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sql/processor/star/test_on_select_exp.rb
Ruby
mit
241
master
466
require 'sql_helper' module Bmg module Sql class Processor describe Star, "on_select_list" do subject{ Star.new(Builder.new).on_select_exp(expr) } context 'on select_all' do let(:expr){ select_all } it{ should eq(select_all_star) } end context 'on sele...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/reader/test_text_file.rb
Ruby
mit
241
master
3,531
require 'spec_helper' module Bmg module Reader describe TextFile do let(:file) { Path.dir/("example.txt") } let(:csv) { csv = TextFile.new(Type::ANY, file, options) } context 'without options' do let(:options){ {} } it 'works' do ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/reader/test_excel.rb
Ruby
mit
241
master
4,918
require 'spec_helper' module Bmg module Reader describe Excel do subject { Excel.new(Type::ANY, input, options) } context "with a .xlsx file" do let(:input) { Path.dir/("example.xlsx") } let(:options) { { skip: 1 } } it_behav...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/reader/test_csv.rb
Ruby
mit
241
master
2,471
require 'spec_helper' module Bmg module Reader describe Csv do subject { Csv.new(Type::ANY, input) } context 'when a .csv file' do let(:input){ Path.dir/("example.csv") } it_behaves_like "a Relation-compatible" it 'works' do expect(subject.to_a).to e...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/update/test_project.rb
Ruby
mit
241
master
846
require 'spec_helper' module Bmg module Operator describe Project, "Update logic" do let(:project_op){ Project.new(Type::ANY, operand, [:a]) } let(:operand){ Object.new } subject{ project_op.update(updated) } context 'with a valid tuple' do let(:upda...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/update/test_constants.rb
Ruby
mit
241
master
1,283
require 'spec_helper' module Bmg module Operator describe Constants, "Update logic" do let(:constants){ Constants.new(Type::ANY, operand, { b: 12 }) } let(:operand){ Object.new } subject{ constants.update(updated) } context 'with a valid tuple' do le...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/update/test_allbut.rb
Ruby
mit
241
master
836
require 'spec_helper' module Bmg module Operator describe Allbut, "Update logic" do let(:allbut){ Allbut.new(Type::ANY, operand, [:b]) } let(:operand){ Object.new } subject{ allbut.update(updated) } context 'with a valid tuple' do let(:updated){ ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/update/test_extend.rb
Ruby
mit
241
master
929
require 'spec_helper' module Bmg module Operator describe Extend, "Update logic" do let(:extend_op){ Extend.new(Type::ANY, operand, { b: ->(t){ 12 } }) } let(:operand){ Object.new } subject{ extend_op.update(updated) } context 'with a valid tuple' do ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/update/test_rename.rb
Ruby
mit
241
master
589
require 'spec_helper' module Bmg module Operator describe Rename, "Update logic" do let(:rename){ Rename.new(Type::ANY, operand, { :a => :b }) } let(:operand){ Object.new } subject{ rename.update(updated) } context 'with a tuple' do let(:updated){ ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sequel/test_type_inference.rb
Ruby
mit
241
master
605
require 'spec_helper' module Bmg module Sequel describe TypeInference do let(:inference) { TypeInference.new(sequel_db) } describe 'attrlist' do it 'supports inference attrlist on a table name' do expected = [:sid, :name, :status, :city] expect(inference.at...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sequel/test_assumptions.rb
Ruby
mit
241
master
247
require 'spec_helper' describe "Assumptions about Sequel" do it 'supports matching where' do london_suppliers = sequel_db[:suppliers] .where{|t| t.city.like("Lon%") } .to_a expect(london_suppliers.size).to eql(2) end end
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sequel/test_relation.rb
Ruby
mit
241
master
1,711
require 'spec_helper' module Bmg module Sequel describe Relation do let(:suppliers_type) { Type::ANY.with_attrlist([:sid, :name, :city, :status]) } subject { relation } context 'starting with a table name' do let(:relation) { Bmg.sequel(:supplier...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sequel/test_factory.rb
Ruby
mit
241
master
1,684
require 'spec_helper' module Bmg describe Sequel, "Relation factory" do describe 'sequel_params' do let(:a_type) { Type.new.with_attrlist([:sid, :name, :status, :city]) } let(:dataset) { sequel_db[:suppliers] } it 'supports a dataset if a type is provided' do ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sequel/write/test_delete.rb
Ruby
mit
241
master
473
require 'spec_helper' module Bmg module Sequel describe Relation, "delete" do around do |bl| sequel_db.transaction do bl.call raise ::Sequel::Rollback end end let(:relation) { Bmg.sequel(:suppliers, sequel_db) } context "on a base relati...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sequel/write/test_update.rb
Ruby
mit
241
master
511
require 'spec_helper' module Bmg module Sequel describe Relation, "update" do around do |bl| sequel_db.transaction do bl.call raise ::Sequel::Rollback end end let(:relation) { Bmg.sequel(:suppliers, sequel_db) } context "on a base relati...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/sequel/write/test_insert.rb
Ruby
mit
241
master
541
require 'spec_helper' module Bmg module Sequel describe Relation, "insert" do around do |bl| sequel_db.transaction do bl.call raise ::Sequel::Rollback end end let(:relation) { Bmg.sequel(:suppliers, sequel_db) } context "on a base relati...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/writer/test_csv.rb
Ruby
mit
241
master
3,263
require 'spec_helper' module Bmg module Writer describe Csv do subject{ relation.to_csv(*args) } let(:relation) { Relation.new [ {id: "1", name: "Bernard Lambeau"}, {id: "2", name: "Yoann;Guyot"} ] } context 'with default options and no output' do ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/writer/test_xlsx.rb
Ruby
mit
241
master
819
require 'spec_helper' require 'date' require 'bmg/writer/xlsx' module Bmg module Writer describe Xlsx do subject{ relation.to_xlsx(*args) } let(:date) { Date.parse('2021/04/23') } let(:relation) { Relation.new [ { id: 1, name: "Bernard", nonnum: "1", when: date...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/writer/test_text.rb
Ruby
mit
241
master
1,536
require 'spec_helper' module Bmg module Writer describe Text do subject do Text.new.render(input) end describe "on a Relation" do let(:input){ Relation.new([ { id: 1 }, { id: 2 }, ]) } let(:expected){ "+----+...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/algebra/shortcuts/test_join.rb
Ruby
mit
241
master
1,697
require 'spec_helper' module Bmg module Algebra describe Shortcuts, "join" do let(:left) { Relation.new([ { a: "foo", b: 2 }, { a: "bar", b: 2 } ], Type::ANY.with_attrlist([:a, :b])) } let(:right) { Relation.new([ { z: "foo", c: 4 }, ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/algebra/shortcuts/test_images.rb
Ruby
mit
241
master
1,194
require 'spec_helper' module Bmg module Algebra describe Shortcuts, "images" do let(:left) { Relation.new([ { a: "foo", b: 2 }, { a: "bar", b: 2 } ], Type::ANY.with_attrlist([:a, :b])) } let(:r1) { Relation.new([ { a: "foo", c: 4 }, ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/algebra/shortcuts/test_suffix.rb
Ruby
mit
241
master
871
require 'spec_helper' module Bmg module Algebra describe Shortcuts, "suffix" do let(:relation) { Relation.new([ { a: "foo", b: 2 }, { a: "bar", b: 2 } ], Type::ANY.with_attrlist([:a, :b])) } context 'when used without option' do subject { ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/algebra/shortcuts/test_prefix.rb
Ruby
mit
241
master
858
require 'spec_helper' module Bmg module Algebra describe Shortcuts, "prefix" do let(:relation) { Relation.new([ { a: "foo", b: 2 }, { a: "bar", b: 2 } ], Type::ANY.with_attrlist([:a, :b])) } context 'without options' do subject { relation...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/algebra/shortcuts/test_cross_product.rb
Ruby
mit
241
master
2,257
require 'spec_helper' module Bmg module Algebra describe Shortcuts, "cross_product" do let(:left) { Relation.new([ { a: "foo", xyz: 1 }, { a: "bar", xyz: 2 } ], Type::ANY.with_attrlist([:xyz, :b])) } let(:right) { Relation.new([ { c: "baz...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/algebra/shortcuts/test_matching.rb
Ruby
mit
241
master
943
require 'spec_helper' module Bmg module Algebra describe Shortcuts, "matching" do let(:left) { Relation.new([ { a: "foo", b: 2 }, { a: "bar", b: 2 } ], Type::ANY.with_attrlist([:a, :b])) } let(:right) { Relation.new([ { z: "foo", c: 4 },...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/algebra/shortcuts/test_image.rb
Ruby
mit
241
master
1,141
require 'spec_helper' module Bmg module Algebra describe Shortcuts, "image" do let(:left) { Relation.new([ { a: "foo", b: 2 }, { a: "bar", b: 2 } ], Type::ANY.with_attrlist([:a, :b])) } let(:right) { Relation.new([ { z: "foo", c: 4 }, ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/algebra/shortcuts/test_not_matching.rb
Ruby
mit
241
master
954
require 'spec_helper' module Bmg module Algebra describe Shortcuts, "not_matching" do let(:left) { Relation.new([ { a: "foo", b: 2 }, { a: "bar", b: 2 } ], Type::ANY.with_attrlist([:a, :b])) } let(:right) { Relation.new([ { z: "foo", c: ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/algebra/shortcuts/test_unwrap.rb
Ruby
mit
241
master
462
require 'spec_helper' module Bmg module Algebra describe Shortcuts, "unwrap" do let(:relation) { Relation.new([ { :a => "foo", :c => {:b => 2} }, { :a => "bar", :c => {:b => 2} } ]) } subject { relation.unwrap(:c) } it 'works as expected...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/algebra/shortcuts/test_exclude.rb
Ruby
mit
241
master
453
require 'spec_helper' module Bmg module Algebra describe Shortcuts, "exclude" do let(:relation) { Relation.new([ { a: "foo", b: 2 }, { a: "bar", b: 2 } ], Type::ANY.with_attrlist([:a, :b])) } subject { relation.exclude(:a => "foo") } i...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/algebra/shortcuts/test_where.rb
Ruby
mit
241
master
449
require 'spec_helper' module Bmg module Algebra describe Shortcuts, "where" do let(:relation) { Relation.new([ { a: "foo", b: 2 }, { a: "bar", b: 2 } ], Type::ANY.with_attrlist([:a, :b])) } subject { relation.where(:a => "foo") } it 'w...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/algebra/shortcuts/test_rxmatch.rb
Ruby
mit
241
master
1,724
require 'spec_helper' module Bmg module Algebra describe Shortcuts, "rxmatch" do let(:data) { [ { a: "foo", b: 2 }, { a: "bar", b: 2 } ] } let(:options) { {} } subject { Relation.new(data, Type::ANY).rxmatch(attrs, matcher, opt...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/algebra/shortcuts/test_ungroup.rb
Ruby
mit
241
master
509
require 'spec_helper' module Bmg module Algebra describe Shortcuts, "ungroup" do let(:relation) { Relation.new([ { :a => "foo", :c => [{:b => 2}, {:b => 3}] }, { :a => "bar", :c => [{:b => 2}] } ]) } subject { relation.ungroup(:c) } it '...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/operator/test_image.rb
Ruby
mit
241
master
4,579
require 'spec_helper' module Bmg module Operator describe Image do subject { Image.new(Type::ANY, left, right, :values, on, options) } context 'with a single attribute as shared key' do let(:on){ [:id] } let(:left) { Relation.new([ { id: 1, label...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/operator/test_summarize.rb
Ruby
mit
241
master
1,117
require 'spec_helper' module Bmg module Operator describe Summarize do let(:data) { [ { a: 1, b: 2 }, { a: 11, b: 2 } ] } context 'with an empty by' do subject { Summarize.new Type::ANY, data, [], { :count => :count, ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/operator/test_allbut.rb
Ruby
mit
241
master
402
require 'spec_helper' module Bmg module Operator describe Allbut do it 'works' do allbut = Allbut.new Type::ANY, [{ a: 1, b: 2 }], [:b] expect(allbut.to_a).to eql([{ a: 1 }]) end it 'removes duplicates' do allbut = Allbut.new Type::ANY, [{ a: 1, b: 2 }, { a: 1, b: 3 }],...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/operator/test_minus.rb
Ruby
mit
241
master
763
require 'spec_helper' module Bmg module Operator describe Minus do let(:r1) { [ { a: 1 }, { a: 2 }, { a: 3 }, { a: 4 }, { a: 5 }, { a: 6 }, { a: 7 }, { a: 8 }, ] } let(:r2) { [ { a...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/operator/test_extend.rb
Ruby
mit
241
master
488
require 'spec_helper' module Bmg module Operator describe Extend do it 'works' do extended = Extend.new Type::ANY, [ { a: 1 } ], { b: ->(t){ 2 } } expect(extended.to_a).to eql([{ a: 1, b: 2}]) end it 'works with a symbol' do extended ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/operator/test_not_matching.rb
Ruby
mit
241
master
614
require 'spec_helper' module Bmg module Operator describe NotMatching do let(:left) { [ { id: 1, label: "Main 1" }, { id: 2, label: "Main 2" } ] } let(:right) { [ { id: 1, x: "foo", y: "hello" }, { id: 1, x: "bar", y: "world" } ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/operator/test_constants.rb
Ruby
mit
241
master
247
require 'spec_helper' module Bmg module Operator describe Constants do it 'works' do extended = Constants.new Type::ANY, [{ a: 1 }], { b: 2 } expect(extended.to_a).to eql([{ a: 1, b: 2 }]) end end end end
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/operator/test_autosummarize.rb
Ruby
mit
241
master
7,296
require 'spec_helper' module Bmg module Operator describe Autosummarize do context 'with empty by and no sums' do let(:by) { [] } let(:sums){ {} } it 'filters same tuples' do autosummarize = Autosummarize.new Type::ANY, [ { a: 1 }, { a: 1 } ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/operator/test_unwrap.rb
Ruby
mit
241
master
579
require 'spec_helper' module Bmg module Operator describe Unwrap do let(:operand) { Relation.new [ { id: 1, :wrapped => { label: "Main 1", hobby: "foo" } }, { id: 2, :wrapped => { label: "Main 2", hobby: "baz" } } ] } subject { Unwrap.new(Type::ANY, ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/operator/test_page.rb
Ruby
mit
241
master
2,561
require 'spec_helper' module Bmg module Operator describe Page do let(:operand) { (1...100).map{|i| { a: i, b: 100-i } } } subject { Page.new(Type::ANY, operand, ordering, page_index, page_size: page_size) } let(:page_size){ 2 } context 'wi...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/operator/test_project.rb
Ruby
mit
241
master
405
require 'spec_helper' module Bmg module Operator describe Project do it 'works' do allbut = Project.new Type::ANY, [{ a: 1, b: 2 }], [:b] expect(allbut.to_a).to eql([{ b: 2 }]) end it 'removes duplicates' do allbut = Project.new Type::ANY, [{ a: 1, b: 2 }, { a: 2, b: 2 ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/operator/test_undress.rb
Ruby
mit
241
master
3,040
require 'spec_helper' module Bmg module Operator describe Undress do it 'works on an empty Relation' do got = Relation.empty.undress expect(got.to_set).to eql(Relation.empty.to_set) end it 'works on an singleton with nothing to undress' do rel = Relation.new([ ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/operator/test_restrict.rb
Ruby
mit
241
master
675
require 'spec_helper' module Bmg module Operator describe Restrict do let(:data) { Relation.new([ { a: 1, b: 2 }, { a: 11, b: 2 } ]) } subject { Restrict.new Type::ANY, data, Predicate.gt(:a, 10) } it 'works' do expect(subject.t...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/operator/test_autowrap.rb
Ruby
mit
241
master
4,796
require 'spec_helper' module Bmg module Operator describe 'Autowrap' do context 'when called in default mode' do it 'works as an array by default' do autowrap = Autowrap.new Type::ANY, [{ a: 1, b: 2 }] expect(autowrap.to_a).to eql([{ a: 1, b: 2 }]) end it 'wrap...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/operator/test_generator.rb
Ruby
mit
241
master
2,126
require 'spec_helper' module Bmg module Operator describe Generator do it 'works' do g = Generator.new(Type::ANY, 2, 4) expect(g.to_a).to eql([ { i: 2 }, { i: 3 }, { i: 4 }, ]) end it 'supports an :as' do g = Generator.new(Type::ANY...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/operator/test_union.rb
Ruby
mit
241
master
744
require 'spec_helper' module Bmg module Operator describe Union do let(:r1) { [ { a: 1 }, { a: 2 } ] } let(:r2) { [ { a: 1 }, { a: 3 }, { a: 4 } ] } let(:r3) { [ { a: 1 }, ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/operator/test_transform.rb
Ruby
mit
241
master
860
require 'spec_helper' module Bmg module Operator describe Transform do it 'works' do extended = Transform.new Type::ANY, [{ a: 1 }], { a: ->(a){ a*2 } } expect(extended.to_a).to eql([{ a: 2 }]) end it 'can be used to coerce a relation with a type' do transformer = Type....
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/operator/test_matching.rb
Ruby
mit
241
master
608
require 'spec_helper' module Bmg module Operator describe Matching do let(:left) { [ { id: 1, label: "Main 1" }, { id: 2, label: "Main 2" } ] } let(:right) { [ { id: 1, x: "foo", y: "hello" }, { id: 1, x: "bar", y: "world" } ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/operator/test_group.rb
Ruby
mit
241
master
828
require 'spec_helper' module Bmg module Operator describe Group do let(:operand) { Relation.new [ { id: 1, label: "Main 1", hobby: "foo" }, { id: 1, label: "Main 1", hobby: "bar" }, { id: 2, label: "Main 2", hobby: "baz" } ] } subject { Gro...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/operator/test_rename.rb
Ruby
mit
241
master
243
require 'spec_helper' module Bmg module Operator describe Rename do it 'works' do rename = Rename.new Type::ANY, [{ a: 1, b: 2 }], :a => :x expect(rename.to_a).to eql([{ x: 1, b: 2 }]) end end end end
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/operator/test_join.rb
Ruby
mit
241
master
4,315
require 'spec_helper' module Bmg module Operator describe Join do let(:left) { [ { a: 1, b: 1, x: "a" }, { a: 1, b: 2, x: "b" }, { a: 2, b: 7, x: "c" } ] } let(:right) { [ { a: 1, c: 8, x: "8" }, { a: 1, c: 9, x: "9" ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/operator/test_ungroup.rb
Ruby
mit
241
master
3,953
require 'spec_helper' module Bmg module Operator describe Ungroup do subject { Ungroup.new(Type::ANY.with_keys(keys), operand, attrlist) } context 'with a candidate key that does not use the attrlist' do let(:keys) { [[:id], [:id, :grouped]] } describ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/operator/image/test_jit_optimize.rb
Ruby
mit
241
master
4,842
require 'spec_helper' module Bmg module Operator describe Image, "jit_optimize" do class Image public :left, :right, :on, :as, :options end class Restrict public :operand, :predicate end class Allbut public :operand, :butlist end let(:rel) { ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/operator/autowrap/test_same_options.rb
Ruby
mit
241
master
608
require 'spec_helper' module Bmg module Operator describe Autowrap, "same_options?" do it 'default options are equal to nothing' do a = Autowrap.new(Type::ANY, []) expect(a.same_options?({})).to eql(true) end it 'split options are equal' do a = Autowrap.new(Type::ANY, [...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/operator/autowrap/test_support.rb
Ruby
mit
241
master
486
require 'spec_helper' module Bmg module Operator class Autowrap describe Support do include Support it 'has wrapped_roots utility' do expect(wrapped_roots([:a], "_")).to eql([]) expect(wrapped_roots([:a, :b_id, :b_name], "_")).to eql([:b]) expect(wrapped_roots(...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/relation/test_y_by_x.rb
Ruby
mit
241
master
586
require 'spec_helper' module Bmg describe Relation, "y_by_x" do let(:relation) { Relation.new [ { a: 1, b: 1, order: 5 }, { a: 1, b: 2, order: 2 }, { a: 1, b: 3, order: 3 }, { a: 2, b: 1, order: 1 }, { a: 1, b: 2, order: 1 } ] } subject{ relation.y_by_...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/relation/test_spied.rb
Ruby
mit
241
master
2,022
require 'spec_helper' module Bmg module Relation describe Spied do let(:base) { Relation.new [{a: 1}] } let(:spied) { base.spied(spy) } let(:spy) { ->(r){ puts r } } class SpyWithMeasure attr_accessor :seen def measure(relation...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/relation/test_materialized.rb
Ruby
mit
241
master
800
require 'spec_helper' module Bmg module Relation describe Materialized do class SourceRel include Enumerable def initialize @called = 0 end attr_reader :called def type Type::ANY end def each @called += 1 yie...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/relation/test_visit.rb
Ruby
mit
241
master
1,540
require 'spec_helper' module Bmg describe Relation, "visit" do let(:first) { Relation.new [ { a: 1, b: 1, order: 5 }, { a: 1, b: 2, order: 2 } ] } let(:second) { Relation.new [ { a: 1, b: 3, order: 3 }, { a: 2, b: 1, order: 1 }, { a: 1, b: 2, ord...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/relation/test_proxy.rb
Ruby
mit
241
master
1,281
require 'spec_helper' require 'ostruct' require 'json' module Bmg module Relation describe Proxy do class ProxyTuple < OpenStruct end class ProxyTest include Proxy def _proxy_tuple(tuple) ProxyTuple.new(tuple) end end let(:rel) { Relation...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/relation/test_ys_by_x.rb
Ruby
mit
241
master
1,048
require 'spec_helper' module Bmg describe Relation, "ys_by_x" do let(:relation) { Relation.new [ { a: 1, b: 1, order: 5 }, { a: 1, b: 2, order: 2 }, { a: 1, b: 3, order: 3 }, { a: 2, b: 1, order: 1 }, { a: 1, b: 2, order: 1 } ] } subject{ relation....
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/summarizer/test_count.rb
Ruby
mit
241
master
358
require 'spec_helper' module Bmg class Summarizer describe Count do it 'should work when used standalone' do expect(Count.new.summarize([])).to eql(0) expect(Count.new.summarize([{}])).to eql(1) end it 'should install factory methods' do expect(Summarizer.count).to be_a...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/summarizer/test_variance.rb
Ruby
mit
241
master
712
require 'spec_helper' module Bmg class Summarizer describe Variance do let(:rel){[ {:qty => 10}, {:qty => 20}, {:qty => 30}, {:qty => 40} ]} let(:expected) { vals = rel.map{|t| t[:qty]} mean = vals.inject(:+) / vals.size.to_f vals.collect...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/summarizer/test_max.rb
Ruby
mit
241
master
502
require 'spec_helper' module Bmg class Summarizer describe Max do let(:rel){[ {:qty => 10}, {:qty => 0} ]} it 'should work when used standalone' do expect(Max.new(:qty).summarize([])).to eql(nil) expect(Max.new(:qty).summarize(rel)).to eql(10) end ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/summarizer/test_value_by.rb
Ruby
mit
241
master
2,730
require 'spec_helper' module Bmg class Summarizer describe ValueBy do let(:rel){[ {:serie => "foo", :qty => 10}, {:serie => "bar", :qty => 20}, {:serie => "baz", :qty => 30} ]} context 'with default options' do let(:value_by){ ValueBy.new(:qty, :by => ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/summarizer/test_avg.rb
Ruby
mit
241
master
448
require 'spec_helper' module Bmg class Summarizer describe Avg do let(:rel){[ {:qty => 10}, {:qty => 1} ]} it 'should work when used standalone' do expect(Avg.new(:qty).summarize(rel)).to eql(5.5) end it 'should install factory methods' do expect(S...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/summarizer/test_collect.rb
Ruby
mit
241
master
592
require 'spec_helper' module Bmg class Summarizer describe Collect do let(:rel){[ {:qty => 10}, {:qty => 20}, {:qty => 30}, {:qty => 40} ]} it 'should work when used standalone' do expect(Collect.new(:qty).summarize([])).to eql([]) expect(Collec...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/summarizer/test_distinct_count.rb
Ruby
mit
241
master
728
require 'spec_helper' module Bmg class Summarizer describe DistinctCount do let(:rel){[ {:qty => 10}, {:qty => 20}, {:qty => 20}, {:qty => 40} ]} it 'has correct name' do expect(DistinctCount.new(:qty).to_summarizer_name).to eql(:distinct_count) en...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/summarizer/test_min.rb
Ruby
mit
241
master
500
require 'spec_helper' module Bmg class Summarizer describe Min do let(:rel){[ {:qty => 10}, {:qty => 0} ]} it 'should work when used standalone' do expect(Min.new(:qty).summarize([])).to eql(nil) expect(Min.new(:qty).summarize(rel)).to eql(0) end i...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/summarizer/test_stddev.rb
Ruby
mit
241
master
602
require 'spec_helper' module Bmg class Summarizer describe Stddev do let(:rel){[ {:qty => 10}, {:qty => 20}, {:qty => 30}, {:qty => 40} ]} let(:expected) { Math.sqrt(Variance.new(:qty).summarize(rel)) } it 'should work when used standalone' ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/summarizer/test_by_proc.rb
Ruby
mit
241
master
928
require 'spec_helper' module Bmg class Summarizer describe ByProc do let(:rel){[ {:qty => 10}, {:qty => 20}, {:qty => 20}, {:qty => 40} ]} let(:p){ ->(t,memo){ (memo||0)+t[:qty] } } it 'should work when used standalone' do ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/summarizer/test_distinct.rb
Ruby
mit
241
master
590
require 'spec_helper' module Bmg class Summarizer describe Distinct do let(:rel){[ {:qty => 10}, {:qty => 20}, {:qty => 20}, {:qty => 40} ]} it 'should work when used standalone' do expect(Distinct.new(:qty).summarize([])).to eql([]) expect(Disti...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/summarizer/test_first.rb
Ruby
mit
241
master
872
require 'spec_helper' module Bmg class Summarizer describe First do let(:rel){[ {:rownum => 1, :qty => 10}, {:rownum => 2, :qty => 11} ]} it 'raises when order is missing' do expect{ First.new(:qty).summarize([]) }.to raise_error(ArgumentError) e...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/summarizer/test_percentile.rb
Ruby
mit
241
master
1,841
require 'spec_helper' module Bmg class Summarizer describe Percentile do let(:rel){[ {:qty => 10}, {:qty => 1}, {:qty => 8}, {:qty => 15}, {:qty => 7} ]} it 'should work when used standalone' do expect(Percentile.new(:qty).summarize(rel)).to eql(...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/summarizer/test_last.rb
Ruby
mit
241
master
864
require 'spec_helper' module Bmg class Summarizer describe Last do let(:rel){[ {:rownum => 1, :qty => 10}, {:rownum => 2, :qty => 11} ]} it 'raises when order is missing' do expect{ Last.new(:qty).summarize([]) }.to raise_error(ArgumentError) end...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/summarizer/test_bucketize.rb
Ruby
mit
241
master
7,249
require 'spec_helper' module Bmg class Summarizer describe Bucketize do def bucketizer(attr, opts) Bucketize.new(attr, options.merge(opts)) end let(:options) { { } } context 'with distinct values' do let(:rel){[ {:sid => 'S1', :qty => 10}, ...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/summarizer/test_concat.rb
Ruby
mit
241
master
1,163
require 'spec_helper' module Bmg class Summarizer describe Concat do let(:rel){[ {:qty => 10}, {:qty => 20}, {:qty => 30}, {:qty => 40} ]} it 'should work when used standalone' do expect(Concat.new(:qty).summarize([])).to eql("") expect(Concat.n...
github
enspirit/bmg
https://github.com/enspirit/bmg
spec/unit/summarizer/test_sum.rb
Ruby
mit
241
master
501
require 'spec_helper' module Bmg class Summarizer describe Sum do let(:rel){[ {:qty => 10}, {:qty => 20} ]} it 'should work when used standalone' do expect(Sum.new(:qty).summarize([])).to eql(0) expect(Sum.new(:qty).summarize(rel)).to eql(30) end i...