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 | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-relation/relation/test_equality.rb | Ruby | mit | 49 | master | 1,350 | require 'spec_helper'
module Alf
describe Relation, "equality" do
let(:rel) { Relation[id: Integer].coerce(id: 12) }
let(:subrel){ Relation[id: Fixnum].coerce(id: 12) }
let(:suprel){ Relation[id: Numeric].coerce(id: 12) }
context '==' do
it 'returns true for all pairs above' do
rel... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-relation/relation/test_each.rb | Ruby | mit | 49 | master | 484 | require 'spec_helper'
module Alf
describe "Relation#each" do
let(:rel){ Relation(:sid => ['S1', 'S2', 'S3']) }
it 'iterates tuples' do
count = 0
rel.each do |t|
t.should be_a(Tuple)
count += 1
end
count.should eq(3)
end
it 'iterates tuples of exact same class... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-relation/relation/test_heading.rb | Ruby | mit | 49 | master | 299 | require 'spec_helper'
module Alf
describe "Relation#heading" do
let(:rel){
Relation([
{:max => 2, :name => "Jones"},
{:max => 7.3, :name => "Jones"},
])
}
subject{ rel.heading }
it{ should eq(Heading(:max => Numeric, :name => String)) }
end
end |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-relation/relation/test_to_a.rb | Ruby | mit | 49 | master | 754 | require 'spec_helper'
module Alf
describe "Relation#to_a" do
let(:rel){Alf::Relation(sid: ['S2', 'S1', 'S3']) }
specify "without an ordering key" do
rel.to_a.sort{|k1,k2| k1[:sid] <=> k2[:sid]}.should eq([
{:sid => 'S1'},
{:sid => 'S2'},
{:sid => 'S3'}
])
end
spe... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-relation/relation/test_relation.rb | Ruby | mit | 49 | master | 1,857 | require 'spec_helper'
module Alf
describe Relation do
let(:tuples){[
{:sid => 'S1', :name => 'Smith', :status => 20, :city => 'London'},
{:sid => 'S2', :name => 'Jones', :status => 10, :city => 'Paris'},
{:sid => 'S3', :name => 'Blake', :status => 30, :city => 'Paris'}
]}
let(:tuples2){... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-relation/relation/class/test_dum.rb | Ruby | mit | 49 | master | 327 | require 'spec_helper'
module Alf
describe Relation, '.dum' do
let(:type){ Relation[name: String, status: Integer] }
subject{ type.dum }
it 'returns a Relation' do
subject.should be_a(type)
subject.should be_a(Relation)
end
it 'is empty' do
subject.should be_empty
end
e... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-relation/relation/class/test_recursive_type.rb | Ruby | mit | 49 | master | 983 | require 'spec_helper'
module Alf
describe Relation, '.type for recursive types' do
shared_examples_for 'the expected recursive type' do
it{ should be_a(Class) }
it 'should have correct super class' do
subject.superclass.should be(Relation)
end
it 'should have correct heading' do... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-relation/relation/class/test_coerce.rb | Ruby | mit | 49 | master | 1,326 | require 'spec_helper'
module Alf
describe Relation, '.coerce' do
let(:heading) { {sid: String} }
let(:type) { Relation[heading] }
let(:tuple) { {sid: 'S1'} }
let(:tuples) { Set.new << Tuple(tuple) }
let(:expected){ type.new(tuples) }
subject{ Relation... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-relation/relation/class/test_type.rb | Ruby | mit | 49 | master | 699 | require 'spec_helper'
module Alf
describe Relation, '.type' do
let(:heading){ {name: String, status: Integer} }
subject{ Relation.type(heading) }
it 'returns a subclass' do
subject.should be_a(Class)
subject.superclass.should be(Alf::Relation)
end
it 'coerces the heading' do
s... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-relation/relation/factored-types/test_rename.rb | Ruby | mit | 49 | master | 252 | require 'spec_helper'
module Alf
describe Relation, '.rename' do
let(:type){ Relation[name: String, status: Integer] }
subject{ type.rename(name: :first_name) }
it{ should eq(Relation[first_name: String, status: Integer]) }
end
end |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-relation/relation/factored-types/test_split.rb | Ruby | mit | 49 | master | 686 | require 'spec_helper'
module Alf
describe Relation, '.split' do
let(:type){ Relation[name: String, status: Integer] }
subject{ type.split(attr_list) }
context 'with an empty attribute list' do
let(:attr_list){ AttrList.new([]) }
it 'splits as expected' do
subject.should eq([ Relati... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-relation/relation/factored-types/test_triple_equal.rb | Ruby | mit | 49 | master | 1,012 | require 'spec_helper'
module Alf
describe Relation, '===' do
let(:type){ Relation[heading] }
subject{ type === value }
context 'when the exact types' do
let(:heading){ Heading.new(name: String, status: Fixnum) }
context 'on a valid value built with itself' do
let(:value){ type.coer... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-relation/relation/factored-types/test_comparisons.rb | Ruby | mit | 49 | master | 1,637 | require 'spec_helper'
module Alf
describe Relation, '<=>' do
let(:type) { Relation[name: String, status: Integer] }
let(:supertype){ Relation[name: String, status: Numeric] }
let(:subtype) { Relation[name: String, status: Fixnum] }
subject{ type <=> other }
context 'on something else' do
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-relation/relation/factored-types/test_allbut.rb | Ruby | mit | 49 | master | 758 | require 'spec_helper'
module Alf
describe Relation, '.allbut' do
let(:type){ Relation[name: String, status: Integer] }
subject{ type.allbut(attr_list) }
context 'with an empty attribute list' do
let(:attr_list){ AttrList.new([]) }
it 'allbuts as expected' do
subject.should be(type)... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-relation/relation/factored-types/test_to_ruby_literal.rb | Ruby | mit | 49 | master | 402 | require 'spec_helper'
module Alf
describe Relation, 'to_ruby_literal' do
let(:type){ Relation[name: String, status: Integer] }
subject{ type.to_ruby_literal }
it 'should be human friendly' do
subject.should eq("Alf::Relation[{:name => String, :status => Integer}]")
end
it 'should allow e... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-relation/relation/factored-types/test_coerce.rb | Ruby | mit | 49 | master | 1,328 | require 'spec_helper'
module Alf
describe Relation, '.coerce' do
subject{ type.coerce(tuples) }
context 'on single attributes' do
let(:type) { Relation[name: String, status: Fixnum] }
let(:expected){ Relation(name: "Smith", status: 20) }
let(:tuples){
[ {'name' => "Smith"... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-relation/relation/factored-types/test_project.rb | Ruby | mit | 49 | master | 764 | require 'spec_helper'
module Alf
describe Relation, '.project' do
let(:type){ Relation[name: String, status: Integer] }
subject{ type.project(attr_list) }
context 'with an empty attribute list' do
let(:attr_list){ AttrList.new([]) }
it 'projects as expected' do
subject.should be(Re... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-relation/relation/factored-types/test_equality.rb | Ruby | mit | 49 | master | 521 | require 'spec_helper'
module Alf
describe Relation, '==' do
let(:type){ Relation[name: String, status: Integer] }
subject{ type == other }
context 'with itself' do
let(:other){ type }
it{ should be_true }
end
context 'with another equivalent' do
let(:other){ Relation[name: S... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/test_clip.rb | Ruby | mit | 49 | master | 854 | require 'spec_helper'
module Alf
module Engine
describe Clip do
it 'should work on an empty operand' do
Clip.new([], AttrList[:name], true).to_a.should eq([])
Clip.new([], AttrList[:name], false).to_a.should eq([])
end
let(:operand){[
{:name => "Jones", :city => "Lond... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/test_generator.rb | Ruby | mit | 49 | master | 529 | require 'spec_helper'
module Alf
module Engine
describe Generator do
it 'should generate tuples from 0' do
exp = [
{:id => 0},
{:id => 1}
]
Generator.new(:id, 0, 1, 2).to_a.should eq(exp)
end
it 'should allow specifying an offset, step and count' do
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/test_to_array.rb | Ruby | mit | 49 | master | 1,922 | require 'spec_helper'
module Alf
module Engine
describe ToArray do
subject{ ToArray.new(rel, ordering).to_a }
context 'when ordering is nil' do
let(:rel){[
{name: "Jones", parts: Relation::DEE},
{name: "Smith", parts: Relation::DUM}
]}
let(:ordering){ nil ... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/test_unwrap.rb | Ruby | mit | 49 | master | 367 | require 'spec_helper'
module Alf
module Engine
describe Unwrap do
let(:input) {[
{:wrapped => {:a => "a", :b => "b"}, :c => "c"}
]}
let(:expected) {[
{:a => "a", :b => "b", :c => "c"},
]}
it "should unwrap as expected" do
Unwrap.new(input, :wrapped).to_a.sh... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/test_concat.rb | Ruby | mit | 49 | master | 838 | require 'spec_helper'
module Alf
module Engine
describe Concat do
it 'should work on no operand at all' do
Concat.new([]).to_a.should eq([])
end
it 'should work with only one operand' do
rel = [
{:name => "Jones"},
{:name => "Smith"}
]
Concat... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/test_filter.rb | Ruby | mit | 49 | master | 1,145 | require 'spec_helper'
module Alf
module Engine
describe Filter do
subject{ Filter.new(operand, predicate).to_a }
context 'on an empty operand' do
let(:operand) { Leaf.new([]) }
let(:predicate){ Predicate.coerce(true) }
it{ should eq([]) }
end
context ... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/test_sort.rb | Ruby | mit | 49 | master | 724 | require 'spec_helper'
module Alf
module Engine
describe Sort do
it 'should work on an empty operand' do
Sort.new([], Ordering[[]]).to_a.should eq([])
end
it 'should work with ascending' do
rel = [
{:name => "Jones"},
{:name => "Smith"}
]
Sort... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/test_set_attr.rb | Ruby | mit | 49 | master | 1,374 | require 'spec_helper'
module Alf
module Engine
describe SetAttr do
it 'should work on an empty operand' do
SetAttr.new(Leaf.new([]), TupleComputation[{}]).to_a.should eq([])
end
it 'should allow implementing UPDATE' do
rel = Leaf.new [
{:name => "Jones"},
{:... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/test_compact.rb | Ruby | mit | 49 | master | 746 | require 'spec_helper'
module Alf
module Engine
describe Compact do
it 'should work on an empty operand' do
Compact.new([]).to_a.should eq([])
end
it 'should work when no duplicate is present' do
rel = [
{:name => "Jones"},
{:name => "Smith"}
]
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/test_coerce.rb | Ruby | mit | 49 | master | 945 | require 'spec_helper'
module Alf
module Engine
describe Coerce do
it 'should work on an empty operand' do
Coerce.new([], Heading[:price => Float]).to_a.should eq([])
end
let(:operand){[
{:name => "Jones", :price => "12.0"},
{:name => "Smith", :price => "-10.0"}
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/test_type_safe.rb | Ruby | mit | 49 | master | 810 | require 'spec_helper'
module Alf
module Engine
describe TypeSafe do
let(:heading){ Heading.new(name: String, status: Fixnum) }
let(:cog){ TypeSafe.new(tuples, TypeCheck.new(heading, false)) }
context 'when all valid tuples' do
let(:tuples){
[ {name: "Smith", status: 20}, {nam... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/test_take.rb | Ruby | mit | 49 | master | 1,053 | require 'spec_helper'
module Alf
module Engine
describe Take do
it 'should work on an empty operand' do
Take.new(Leaf.new([]), 1, 1).to_a.should eq([])
end
it 'should filter according to the offset' do
rel = Leaf.new [
{:name => "Jones"},
{:name => "Smith"}
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/test_ungroup.rb | Ruby | mit | 49 | master | 747 | require 'spec_helper'
module Alf
module Engine
describe Ungroup do
let(:input){[
{:city => "London", :suppliers => [
{:name => "Smith"},
{:name => "Blake"}
]},
{:city => "Paris", :suppliers => [
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/test_rename.rb | Ruby | mit | 49 | master | 622 | require 'spec_helper'
module Alf
module Engine
describe Rename do
it 'should work on an empty operand' do
Rename.new([], Renaming[{}]).to_a.should eq([])
end
it 'should work on a non empty operand' do
rel = [
{:name => "Jones", :city => "London"},
{:name => ... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/test_autonum.rb | Ruby | mit | 49 | master | 549 | require 'spec_helper'
module Alf
module Engine
describe Autonum do
it 'should work on an empty operand' do
Autonum.new([], :autonum).to_a.should eq([])
end
it 'should work on a non empty operand' do
rel = [
{:name => "Jones"},
{:name => "Smith"}
]
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/test_wrap.rb | Ruby | mit | 49 | master | 561 | require 'spec_helper'
module Alf
module Engine
describe Wrap do
let(:input) {[
{:a => "a", :b => "b", :c => "c"},
]}
let(:expected) {[
{:wrapped => {:a => "a", :b => "b"}, :c => "c"}
]}
it "should wrap as expected" do
wrap = Wrap.new(input, AttrList[:a, :b]... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/test_hierarchize.rb | Ruby | mit | 49 | master | 1,905 | require 'spec_helper'
module Alf
module Engine
describe Hierarchize do
let(:type){
Relation.type(id: Fixnum, parent: Fixnum, name: String){|r| {subs: r} }
}
let(:operand){[
{id: 1, parent: 1, name: "USA"},
{id: 5, parent: 3, name: "Brussels"},
{id: 2, parent: 2,... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/test_infer_heading.rb | Ruby | mit | 49 | master | 1,470 | require 'spec_helper'
module Alf
module Engine
describe InferHeading do
subject{ InferHeading.new(input).first }
context 'on empty input' do
let(:input){ [] }
it { should eq({}) }
end
context 'with simple tuples' do
let(:input){
[
{tested: ... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/test_aggregate.rb | Ruby | mit | 49 | master | 704 | require 'spec_helper'
module Alf
module Engine
describe Aggregate do
it 'should work on an empty operand' do
Autonum.new(Leaf.new([]), Summarization[{}]).to_a.should eq([])
end
it 'should work on a non empty operand' do
rel = Leaf.new [
{:name => "Jones", :price => 12... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/test_defaults.rb | Ruby | mit | 49 | master | 986 | require 'spec_helper'
module Alf
module Engine
describe Defaults do
it 'should work on an empty operand' do
Defaults.new(Leaf.new([]), TupleComputation[:id => 1]).to_a.should eq([])
end
it 'should replace nil by the default value' do
rel = Leaf.new [
{:name => "Jones"... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/join/test_hash.rb | Ruby | mit | 49 | master | 1,694 | require 'spec_helper'
module Alf
module Engine
describe Join::Hash do
let(:suppliers) {[
{:sid => 'S1', :city => 'London'},
{:sid => 'S2', :city => 'Paris'},
{:sid => 'S3', :city => 'Paris'}
]}
let(:statuses) {[
{:sid => 'S1', :status => 20},
{:sid => 'S... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/sort/test_in_memory.rb | Ruby | mit | 49 | master | 764 | require 'spec_helper'
module Alf
module Engine
describe Sort::InMemory do
it 'should work on an empty operand' do
Sort::InMemory.new([], Ordering[[]]).to_a.should eq([])
end
it 'should work with ascending' do
rel = [
{:name => "Jones"},
{:name => "Smith"}
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/group/test_hash.rb | Ruby | mit | 49 | master | 1,503 | require 'spec_helper'
module Alf
module Engine
describe Group::Hash do
context 'the normal case' do
let(:operand){[
{name: "Smith", city: "London"},
{name: "Jones", city: "Paris"},
{name: "Blake", city: "London"},
]}
let(:expected){[
{ city: ... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/quota/test_cesure.rb | Ruby | mit | 49 | master | 1,056 | require 'spec_helper'
module Alf
module Engine
describe Quota::Cesure do
let(:input) {[
{:a => "via_method", :time => 1},
{:a => "via_method", :time => 2},
{:a => "via_method", :time => 3},
{:a => "via_reader", :time => 2},
{:a => "via_reader", :time => 4},
]}
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/image/test_hash.rb | Ruby | mit | 49 | master | 1,626 | require 'spec_helper'
module Alf
module Engine
describe Image::Hash do
context 'the normal case' do
let(:left){Relation([
{sid: "S1", city: "London"},
{sid: "S2", city: "Paris"},
{sid: "S3", city: "London"},
{sid: "S4", city: "Athens"},
])}
l... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/materialize/test_hash.rb | Ruby | mit | 49 | master | 2,451 | require 'spec_helper'
module Alf
module Engine
describe Materialize::Hash do
let(:operand){[
{:name => "Smith", :city => "London"},
{:name => "Jones", :city => "Paris"},
{:name => "Smith", :city => "Athens"},
]}
it 'should act as a normal cog' do
op = Materializ... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/materialize/test_array.rb | Ruby | mit | 49 | master | 759 | require 'spec_helper'
module Alf
module Engine
describe Materialize::Array do
let(:operand){[
{:name => "Smith", :city => "London"},
{:name => "Jones", :city => "Paris"},
{:name => "Blake", :city => "Athens"},
]}
it 'should act as a normal cog' do
op = Materi... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/semi/test_hash.rb | Ruby | mit | 49 | master | 1,601 | require 'spec_helper'
module Alf
module Engine
describe Semi::Hash do
let(:suppliers) {[
{:sid => 'S1', :city => 'London'},
{:sid => 'S2', :city => 'Paris'},
{:sid => 'S3', :city => 'Paris'}
]}
let(:statuses) {[
{:sid => 'S1', :status => 20},
{:sid => 'S... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/compact/test_set.rb | Ruby | mit | 49 | master | 766 | require 'spec_helper'
module Alf
module Engine
describe Compact::Set do
it 'should work on an empty operand' do
Compact::Set.new([]).to_a.should eq([])
end
it 'should work when no duplicate is present' do
rel = [
{:name => "Jones"},
{:name => "Smith"}
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/compact/test_uniq.rb | Ruby | mit | 49 | master | 752 | require 'spec_helper'
module Alf
module Engine
describe Compact::Uniq do
it 'should work on an empty operand' do
Compact::Uniq.new([]).to_a.should eq([])
end
it 'should work when no duplicate is present' do
rel = [
{:name => "Jones"},
{:name => "Smith"}
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/infer_heading/test_heading.rb | Ruby | mit | 49 | master | 813 | require 'spec_helper'
module Alf
module Engine
describe InferHeading, 'heading' do
let(:ih){ InferHeading.new([]) }
subject{ ih.send(:heading, tuple) }
context 'on a single tuple' do
let(:tuple){ {id: 1, name: "Jones"} }
it{ should eq(Heading.new(id: Fixnum, name: String)) }
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/summarize/test_cesure.rb | Ruby | mit | 49 | master | 978 | require 'spec_helper'
module Alf
module Engine
describe Summarize::Cesure do
let(:input) {Leaf.new [
{:a => "via_method", :time => 1},
{:a => "via_method", :time => 1},
{:a => "via_method", :time => 2},
{:a => "via_reader", :time => 4},
{:a => "via_reader", :time => ... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/summarize/test_hash.rb | Ruby | mit | 49 | master | 976 | require 'spec_helper'
module Alf
module Engine
describe Summarize::Cesure do
let(:input) {[
{:a => "via_method", :time => 1},
{:a => "via_method", :time => 1},
{:a => "via_method", :time => 2},
{:a => "via_reader", :time => 4},
{:a => "via_reader", :time => 2},
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/cog/test_to_ascii_tree.rb | Ruby | mit | 49 | master | 264 | require 'spec_helper'
module Alf
module Engine
describe Cog, "to_cog" do
let(:cog){ Clip.new([], AttrList[:name], true) }
subject{ cog.to_ascii_tree }
it { should eq("Clip ..., [:name], {:allbut => true}\n+-- []\n") }
end
end
end |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/rank/test_cesure.rb | Ruby | mit | 49 | master | 1,569 | require 'spec_helper'
module Alf
module Engine
describe Rank::Cesure do
let(:input) {[
{:pid => 'P1', :weight => 12.0},
{:pid => 'P5', :weight => 12.0},
{:pid => 'P4', :weight => 14.0},
{:pid => 'P2', :weight => 17.0},
{:pid => 'P3', :weight => 17.0},
{:pid =... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/leaf/test_each.rb | Ruby | mit | 49 | master | 326 | require 'spec_helper'
module Alf
module Engine
describe Leaf, 'each' do
let(:input) {[
{"foo" => "bar"},
]}
let(:leaf){
Leaf.new(input)
}
subject{ leaf.each.to_a }
let(:expected) {[
{foo: "bar"}
]}
it{ should eq(expected) }
end
en... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-engine/hierarchize/test_renamer.rb | Ruby | mit | 49 | master | 359 | require 'spec_helper'
module Alf
module Engine
describe Hierarchize, "renaming" do
let(:hierarchize){
Hierarchize.new([], AttrList[:id, :subid], AttrList[:parent, :subparent], :children)
}
subject{
hierarchize.send(:renamer)
}
it{ should eq(Renaming[parent: :id, su... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-compiler/test_principle.rb | Ruby | mit | 49 | master | 8,107 | require 'compiler_helper'
module Alf
describe Compiler, "the overall principle" do
# This is a compiler dedicated to specific adapters, e.g. SQL
class DedicatedCompiler < Compiler
def supports_reuse?
true
end
def reuse(plan, compiled)
compiled
end
def on_proje... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-compiler/default/test_allbut.rb | Ruby | mit | 49 | master | 1,589 | require 'compiler_helper'
module Alf
class Compiler
describe Default, "allbut" do
subject{
compiler.call(expr)
}
shared_examples_for "a compacted compilation result" do
it_should_behave_like "a traceable compiled"
it 'has a Compact cog' do
subject.should be_... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-compiler/default/test_not_matching.rb | Ruby | mit | 49 | master | 736 | require 'compiler_helper'
module Alf
class Compiler
describe Default, "not_matching" do
subject{
compiler.call(expr)
}
let(:right){
compact(an_operand(leaf))
}
let(:expr){
not_matching(an_operand(leaf), right)
}
it_should_behave_like "a traceab... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-compiler/default/test_extend.rb | Ruby | mit | 49 | master | 639 | require 'compiler_helper'
module Alf
class Compiler
describe Default, "extend" do
subject{
compiler.call(expr)
}
let(:expr){
extend(an_operand(leaf), computation)
}
let(:computation){
TupleComputation[{ foo: "12" }]
}
it_should_behave_like "a t... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-compiler/default/test_union.rb | Ruby | mit | 49 | master | 697 | require 'compiler_helper'
module Alf
class Compiler
describe Default, "union" do
subject{
compiler.call(expr)
}
let(:right){
clip(an_operand(leaf), [:a])
}
let(:expr){
union(an_operand(leaf), right)
}
it_should_behave_like "a traceable compiled... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-compiler/default/test_unwrap.rb | Ruby | mit | 49 | master | 552 | require 'compiler_helper'
module Alf
class Compiler
describe Default, "unwrap" do
subject{
compiler.call(expr)
}
let(:expr){
unwrap(an_operand(leaf), :a)
}
it_should_behave_like "a traceable compiled"
it 'has a Unwrap cog' do
subject.should be_a(Engi... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-compiler/default/test_page.rb | Ruby | mit | 49 | master | 2,455 | require 'compiler_helper'
module Alf
class Compiler
describe Default, "page" do
subject{
compiler.call(expr)
}
let(:ordering){
Ordering.new([[:a, :asc]])
}
shared_examples_for "the expected Take" do
it_should_behave_like "a traceable compiled"
it '... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-compiler/default/test_group.rb | Ruby | mit | 49 | master | 750 | require 'compiler_helper'
module Alf
class Compiler
describe Default, "group" do
subject{
compiler.call(expr)
}
let(:expr){
group(an_operand(leaf), [:foo, :bar], :baz, allbut: true)
}
it_should_behave_like "a traceable compiled"
it 'has a Group cog' do
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-compiler/default/test_generator.rb | Ruby | mit | 49 | master | 556 | require 'compiler_helper'
module Alf
class Compiler
describe Default, "generator" do
subject{
compiler.call(expr)
}
let(:expr){
generator(100, :foo)
}
it_should_behave_like "a traceable compiled"
it 'is a Generator cog' do
subject.should be_a(Engine:... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-compiler/default/test_wrap.rb | Ruby | mit | 49 | master | 746 | require 'compiler_helper'
module Alf
class Compiler
describe Default, "wrap" do
subject{
compiler.call(expr)
}
let(:expr){
wrap(an_operand(leaf), [:foo, :bar], :baz, allbut: true)
}
it_should_behave_like "a traceable compiled"
it 'has a Wrap cog' do
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-compiler/default/test_join.rb | Ruby | mit | 49 | master | 620 | require 'compiler_helper'
module Alf
class Compiler
describe Default, "join" do
subject{
compiler.call(expr)
}
let(:right){
compact(an_operand)
}
let(:expr){
join(an_operand(leaf), right)
}
it_should_behave_like "a traceable compiled"
it... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-compiler/default/test_defaults.rb | Ruby | mit | 49 | master | 1,100 | require 'compiler_helper'
module Alf
class Compiler
describe Default, "defaults" do
subject{
compiler.call(expr)
}
shared_examples_for 'the expected Defaults' do
it_should_behave_like "a traceable compiled"
it 'has a Defaults cog' do
subject.should be_a(Engi... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-compiler/default/test_coerce.rb | Ruby | mit | 49 | master | 571 | require 'compiler_helper'
module Alf
class Compiler
describe Default, "coerce" do
subject{
compiler.call(expr)
}
let(:expr){
coerce(an_operand(leaf), a: String)
}
it_should_behave_like "a traceable compiled"
it 'has a Coerce cog' do
subject.should be... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-compiler/default/test_quota.rb | Ruby | mit | 49 | master | 2,357 | require 'compiler_helper'
module Alf
class Compiler
describe Default, "quota" do
subject{
compiler.call(expr)
}
let(:summarization){
Summarization[{ max: Aggregator.max{ qty } }]
}
let(:ordering){
Ordering.new([[:b, :asc]])
}
shared_examples_fo... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-compiler/default/test_compact.rb | Ruby | mit | 49 | master | 450 | require 'compiler_helper'
module Alf
class Compiler
describe Default, "compact" do
subject{
compiler.call(expr)
}
let(:expr){
compact(an_operand(leaf))
}
it_should_behave_like "a traceable compiled"
it 'has a Compact cog' do
subject.should be_a(Engin... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-compiler/default/test_image.rb | Ruby | mit | 49 | master | 629 | require 'compiler_helper'
module Alf
class Compiler
describe Default, "image" do
subject{
compiler.call(expr)
}
let(:right){
compact(an_operand)
}
let(:expr){
image(an_operand(leaf), right, :as)
}
it_should_behave_like "a traceable compiled"
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-compiler/default/test_matching.rb | Ruby | mit | 49 | master | 727 | require 'compiler_helper'
module Alf
class Compiler
describe Default, "matching" do
subject{
compiler.call(expr)
}
let(:right){
compact(an_operand(leaf))
}
let(:expr){
matching(an_operand(leaf), right)
}
it_should_behave_like "a traceable compi... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-compiler/default/test_rename.rb | Ruby | mit | 49 | master | 564 | require 'compiler_helper'
module Alf
class Compiler
describe Default, "rename" do
subject{
compiler.call(expr)
}
let(:expr){
rename(an_operand(leaf), a: :b)
}
it_should_behave_like "a traceable compiled"
it 'has a Rename cog' do
subject.should be_a(E... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-compiler/default/test_intersect.rb | Ruby | mit | 49 | master | 637 | require 'compiler_helper'
module Alf
class Compiler
describe Default, "intersect" do
subject{
compiler.call(expr)
}
let(:right){
compact(an_operand(leaf))
}
let(:expr){
intersect(an_operand(leaf), right)
}
it_should_behave_like "a traceable com... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-compiler/default/test_frame.rb | Ruby | mit | 49 | master | 1,980 | require 'compiler_helper'
module Alf
class Compiler
describe Default, "frame" do
subject{
compiler.call(expr)
}
let(:ordering){
Ordering.new([[:a, :asc]])
}
shared_examples_for "the expected Take" do
it_should_behave_like "a traceable compiled"
it ... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-compiler/default/test_clip.rb | Ruby | mit | 49 | master | 556 | require 'compiler_helper'
module Alf
class Compiler
describe Default, "clip" do
subject{
compiler.call(expr)
}
let(:expr){
clip(an_operand(leaf), [:a])
}
it_should_behave_like "a traceable compiled"
it 'has a Clip cog' do
subject.should be_a(Engine::... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-compiler/default/test_ungroup.rb | Ruby | mit | 49 | master | 556 | require 'compiler_helper'
module Alf
class Compiler
describe Default, "ungroup" do
subject{
compiler.call(expr)
}
let(:expr){
ungroup(an_operand(leaf), :a)
}
it_should_behave_like "a traceable compiled"
it 'has a Ungroup cog' do
subject.should be_a(E... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-compiler/default/test_hierarchize.rb | Ruby | mit | 49 | master | 860 | require 'compiler_helper'
module Alf
class Compiler
describe Compiler, 'on_hierarchize' do
subject{
compiler.call(expr)
}
let(:operand){
an_operand.with_heading(id: Fixnum, parent: Integer).with_keys([:id])
}
let(:expr){
a_lispy.hierarchize(an_operand(leaf)... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-compiler/default/test_minus.rb | Ruby | mit | 49 | master | 722 | require 'compiler_helper'
module Alf
class Compiler
describe Default, "minus" do
subject{
compiler.call(expr)
}
let(:right){
compact(an_operand(leaf))
}
let(:expr){
minus(an_operand(leaf), right)
}
it_should_behave_like "a traceable compiled"
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-compiler/default/test_completude.rb | Ruby | mit | 49 | master | 371 | require 'compiler_helper'
module Alf
class Compiler
describe Default, "completude over algebra" do
Algebra::Operator.registered.each do |operator|
next if operator.ancestors.include?(Algebra::Shortcut)
it "support #{operator}" do
compiler.should respond_to(:"on_#{operator.rubycas... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-compiler/default/test_rank.rb | Ruby | mit | 49 | master | 1,800 | require 'compiler_helper'
module Alf
class Compiler
describe Default, "rank" do
subject{
compiler.call(expr)
}
let(:ordering){
Ordering.new([[:a, :asc]])
}
shared_examples_for "the expected Rank::Cesure" do
it_should_behave_like "a traceable compiled"
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-compiler/default/test_autonum.rb | Ruby | mit | 49 | master | 555 | require 'compiler_helper'
module Alf
class Compiler
describe Default, "autonum" do
subject{
compiler.call(expr)
}
let(:expr){
autonum(an_operand(leaf), :foo)
}
it_should_behave_like "a traceable compiled"
it 'is an Autonum cog' do
subject.should be_a... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-compiler/default/test_project.rb | Ruby | mit | 49 | master | 1,868 | require 'compiler_helper'
module Alf
class Compiler
describe Default, "project" do
subject{
compiler.call(expr)
}
shared_examples_for "a compacted compilation result" do
it_should_behave_like "a traceable compiled"
it 'has a Compact cog' do
subject.should be... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-compiler/default/test_sort.rb | Ruby | mit | 49 | master | 1,957 | require 'compiler_helper'
module Alf
class Compiler
describe Default, "sort" do
subject{
compiler.call(expr)
}
let(:ordering){
Ordering.new([[:a, :asc]])
}
shared_examples_for "the expected Sort" do
it_should_behave_like "a traceable compiled"
it{ ... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-compiler/default/test_summarize.rb | Ruby | mit | 49 | master | 2,082 | require 'compiler_helper'
module Alf
class Compiler
describe Default, "summarize" do
subject{
compiler.call(expr)
}
let(:by){
AttrList[:a]
}
let(:summarization){
Summarization[{ max: Aggregator.max{ qty } }]
}
let(:expr){
summarize(an_o... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-compiler/default/test_restrict.rb | Ruby | mit | 49 | master | 628 | require 'compiler_helper'
module Alf
class Compiler
describe Default, "restrict" do
subject{
compiler.call(expr)
}
let(:expr){
restrict(an_operand(leaf), predicate)
}
let(:predicate){
Predicate.native(->{ true })
}
it_should_behave_like "a trac... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-compiler/shared/compiled_examples.rb | Ruby | mit | 49 | master | 2,654 | shared_examples_for 'a compiled' do
it { should be_a(Alf::Compiler::Cog) }
it 'should return self on to_cog' do
subject.to_cog.should be(subject)
end
end
shared_examples_for 'a traceable compiled' do
it_should_behave_like "a compiled"
def has_tracking!(compiled)
compiled.expr.should_not be_nil
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-adapter-memory/test_adapter_instance.rb | Ruby | mit | 49 | master | 372 | require 'spec_helper'
module Alf
class Adapter
describe Memory, "an instance" do
let(:adapter){ Memory.new('memory://') }
let(:readable_cogs){
[ "suppliers", "parts" ]
}
it_should_behave_like "an adapter"
it_should_behave_like "an adapter with readable cogs"
end # des... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-adapter-memory/test_adapter_class.rb | Ruby | mit | 49 | master | 295 | require 'spec_helper'
module Alf
class Adapter
describe Memory do
let(:adapter_class){ Memory }
let(:recognized_conn_specs) do
[ 'memory://' ]
end
it_should_behave_like "an adapter class"
end # describe Memory
end # class Adapter
end # module Alf |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-adapter-memory/connection/test_insert.rb | Ruby | mit | 49 | master | 390 | require 'spec_helper'
module Alf
class Adapter
class Memory
describe Connection, "insert" do
let(:adapter){ Memory.new('memory://') }
it 'works' do
adapter.connect do |conn|
conn.insert(:suppliers, [{foo: "bar"}])
end
end
end # describe Connec... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-adapter-memory/connection/test_update.rb | Ruby | mit | 49 | master | 389 | require 'spec_helper'
module Alf
class Adapter
class Memory
describe Connection, "update" do
let(:adapter){ Memory.new('memory://') }
it 'works' do
adapter.connect do |conn|
conn.update(:suppliers, {id: 1}, true)
end
end
end # describe Connect... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-adapter-memory/connection/test_delete.rb | Ruby | mit | 49 | master | 380 | require 'spec_helper'
module Alf
class Adapter
class Memory
describe Connection, "delete" do
let(:adapter){ Memory.new('memory://') }
it 'works' do
adapter.connect do |conn|
conn.delete(:suppliers, true)
end
end
end # describe Connection
e... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-predicate/test_predicate.rb | Ruby | mit | 49 | master | 2,744 | require 'spec_helper'
shared_examples_for "a predicate" do
let(:x){ 12 }
let(:y){ 13 }
it 'provides a proc for easy evaluation' do
got = subject.to_proc.call(Tuple(x: 12, y: 13))
[ TrueClass, FalseClass ].should include(got.class)
end
it 'can be negated easily' do
(!subject).should be_a(Alf::P... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-predicate/grammar/test_match.rb | Ruby | mit | 49 | master | 2,468 | require 'spec_helper'
module Alf
class Predicate
describe Grammar, 'match?' do
context "tautology" do
subject{ Grammar[:tautology] }
it 'matches a tautology' do
subject.should be_match([:tautology, true])
end
it 'does no match a wrong one' do
subject.sho... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-predicate/grammar/test_sexpr.rb | Ruby | mit | 49 | master | 2,007 | require 'spec_helper'
module Alf
class Predicate
describe Grammar, "sexpr" do
subject{ Grammar.sexpr(expr) }
let(:contradiction){
[:contradiction, false]
}
let(:identifier){
[:identifier, :name]
}
before do
subject.should be_a(Sexpr)
end
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-predicate/nodes/and/test_and_split.rb | Ruby | mit | 49 | master | 1,719 | require 'spec_helper'
module Alf
class Predicate
describe And, "and_split" do
let(:tautology){ Factory.tautology }
subject{ predicate.and_split(list) }
context 'when attributes on one side' do
let(:predicate){ Factory.eq(:x, 2) & Factory.eq(:y, 3) }
context 'when fully cover... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-predicate/nodes/nadic_bool/test_free_variables.rb | Ruby | mit | 49 | master | 323 | require 'spec_helper'
module Alf
class Predicate
describe NadicBool, "free_variables" do
subject{ expr.free_variables }
context "on a complex attribute comparison" do
let(:expr){ Factory.comp(:neq, :x => :y, :z => 2) }
it{ should eq(AttrList[:x, :y, :z]) }
end
end
end
e... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-predicate/nodes/dyadic_comp/test_and_split.rb | Ruby | mit | 49 | master | 1,045 | require 'spec_helper'
module Alf
class Predicate
describe DyadicComp, "and_split" do
let(:predicate){ Factory.eq(:id, 2) }
let(:tautology){ Factory.tautology }
subject{ predicate.and_split(list) }
context 'when included' do
let(:list){ AttrList[:id, :name] }
it{ should... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-predicate/nodes/qualified_identifier/test_name.rb | Ruby | mit | 49 | master | 229 | require 'spec_helper'
module Alf
class Predicate
describe QualifiedIdentifier, "name" do
let(:expr){ Factory.qualified_identifier(:t, :id) }
subject{ expr.name }
it{ should eq(:id) }
end
end
end |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-predicate/nodes/qualified_identifier/test_and_split.rb | Ruby | mit | 49 | master | 543 | require 'spec_helper'
module Alf
class Predicate
describe QualifiedIdentifier, "and_split" do
let(:predicate){ Factory.qualified_identifier(:t, :id) }
let(:tautology){ Factory.tautology }
subject{ predicate.and_split(list) }
context 'when included' do
let(:list){ AttrList[:id... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.