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-types/test_attr_list.rb | Ruby | mit | 49 | master | 280 | require 'spec_helper'
module Alf
describe AttrList do
def AttrList.exemplars
[
[],
[:a],
[:a, :b]
].map{|arg| AttrList.coerce(arg) }
end
let(:type){ AttrList }
it_should_behave_like 'A valid type implementation'
end
end |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/attr_list/test_coerce.rb | Ruby | mit | 49 | master | 1,445 | require 'spec_helper'
module Alf
describe AttrList, "coerce" do
subject{ AttrList.coerce(arg) }
let(:expected){ AttrList.new [:a, :b] }
describe "with an AttrList" do
let(:arg){ AttrList.new [:a, :b] }
it{ should be(arg) }
end
describe "with a list of Symbols" do
let(:arg){ ... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/attr_list/test_project_tuple.rb | Ruby | mit | 49 | master | 876 | require 'spec_helper'
module Alf
describe AttrList, "project_tuple" do
let(:key){ AttrList.new [:a, :b] }
let(:tuple){ {:a => 1, :b => 2, :c => 3} }
describe "when used without allbut" do
subject{ key.project_tuple(tuple) }
it{ should eq({:a => 1, :b => 2}) }
end
describe "when use... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/attr_list/test_intersect.rb | Ruby | mit | 49 | master | 708 | require 'spec_helper'
module Alf
describe AttrList, 'intersect?' do
subject{ left.intersect?(right) }
context 'when equal' do
let(:left){ AttrList[:id, :name] }
let(:right){ AttrList[:name, :id] }
it{ should be_true }
end
context 'when not equal but intersect' do
let(:left)... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/attr_list/test_sameset.rb | Ruby | mit | 49 | master | 691 | require 'spec_helper'
module Alf
describe AttrList, 'sameset?' do
subject{ left.sameset?(right) }
context 'when equal' do
let(:left){ AttrList[:id, :name] }
let(:right){ AttrList[:name, :id] }
it{ should be_true }
end
context 'when not equal' do
let(:left){ AttrList[:id] }
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/attr_list/test_set_compare.rb | Ruby | mit | 49 | master | 1,055 | require 'spec_helper'
module Alf
describe AttrList, 'set_compare' do
subject{ left.set_compare(right) }
let(:left){ AttrList[:id, :name] }
context 'when equal' do
let(:right){ AttrList[:name, :id] }
it{ should eq(0) }
end
context 'when a superset' do
let(:right){ AttrList[:n... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/attr_list/test_or.rb | Ruby | mit | 49 | master | 384 | require 'spec_helper'
module Alf
describe AttrList, "|" do
let(:list){ AttrList.new [:id, :name] }
context 'disjoint lists' do
subject{ list | [:status] }
it{ should eq(AttrList[:id, :name, :status]) }
end
context 'non disjoint lists' do
subject{ list | [:id, :status] }
it... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/attr_list/test_allbut.rb | Ruby | mit | 49 | master | 519 | require 'spec_helper'
module Alf
describe AttrList, "project" do
let(:list){ AttrList.new [:id, :name, :status] }
subject{ list.allbut(subset) }
context 'on a proper subset' do
let(:subset){ [:id, :name] }
it{ should eq(AttrList[:status]) }
end
context 'on an empty subset' do
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/attr_list/test_subset.rb | Ruby | mit | 49 | master | 1,196 | require 'spec_helper'
module Alf
describe AttrList, 'subset?' do
context 'when equal' do
let(:left){ AttrList[:id, :name] }
let(:right){ AttrList[:name, :id] }
it 'returns true if non proper' do
left.subset?(right).should be_true
end
it 'returns false if proper' do
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/attr_list/test_ampersand.rb | Ruby | mit | 49 | master | 349 | require 'spec_helper'
module Alf
describe AttrList, "&" do
let(:list){ AttrList.new [:id, :name] }
context 'disjoint lists' do
subject{ list & [:status] }
it{ should eq(AttrList[]) }
end
context 'non disjoint lists' do
subject{ list & [:id, :status] }
it{ should eq(AttrLis... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/attr_list/test_to_a.rb | Ruby | mit | 49 | master | 253 | require 'spec_helper'
module Alf
describe AttrList, 'to_a' do
it 'returns an array of symbols' do
AttrList[:a, :b].to_a.should eq([:a, :b])
end
it 'works on empty list' do
AttrList[].to_a.should eq([])
end
end
end |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/attr_list/test_project.rb | Ruby | mit | 49 | master | 1,015 | require 'spec_helper'
module Alf
describe AttrList, "project" do
let(:list){ AttrList.new [:id, :name, :status] }
context '--no-allbut' do
subject{ list.project(subset) }
context 'on a proper subset' do
let(:subset){ [:id, :name] }
it { should eq(AttrList[:id, :name]) }
e... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/attr_list/test_include.rb | Ruby | mit | 49 | master | 366 | require 'spec_helper'
module Alf
describe AttrList, 'include?' do
let(:list){ AttrList[:id, :name] }
subject{ list.include?(attribute) }
context 'when included' do
let(:attribute){ :id }
it{ should be_true }
end
context 'when not included' do
let(:attribute){ :notthatone }
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/attr_list/test_superset.rb | Ruby | mit | 49 | master | 1,217 | require 'spec_helper'
module Alf
describe AttrList, 'superset?' do
context 'when equal' do
let(:left){ AttrList[:id, :name] }
let(:right){ AttrList[:name, :id] }
it 'returns true if non proper' do
left.superset?(right).should be_true
end
it 'returns false if proper' do
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/attr_list/test_to_ordering.rb | Ruby | mit | 49 | master | 468 | require 'spec_helper'
module Alf
describe AttrList, "to_ordering" do
let(:attrs){ [:a, :b] }
describe "without direction" do
subject{ AttrList.coerce(attrs).to_ordering }
it{ should eq(Ordering.new [[:a, :asc], [:b, :asc]])}
end
describe "with a direction" do
subject{ AttrList.coe... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/attr_list/test_split_tuple.rb | Ruby | mit | 49 | master | 954 | require 'spec_helper'
module Alf
describe AttrList, "split_tuple" do
let(:key){ AttrList.new [:a, :b] }
let(:tuple){ {:a => 1, :b => 2, :c => 3} }
describe "when used without allbut" do
subject{ key.split_tuple(tuple) }
it{ should eq([{:a => 1, :b => 2}, {:c => 3}]) }
end
describe ... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/attr_list/test_hash_and_eql.rb | Ruby | mit | 49 | master | 954 | require 'spec_helper'
module Alf
describe AttrList, "hash and ==" do
subject{ left == right }
after do
left.hash.should eq(right.hash) if subject
end
context "when the same empty lists" do
let(:left){ AttrList[] }
let(:right){ AttrList[] }
it{ should be_true }
end
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/attr_list/test_difference.rb | Ruby | mit | 49 | master | 345 | require 'spec_helper'
module Alf
describe AttrList, "-" do
let(:list){ AttrList.new [:id, :name] }
context 'disjoint lists' do
subject{ list - [:status] }
it{ should eq(list) }
end
context 'non disjoint lists' do
subject{ list - [:id, :status] }
it{ should eq(AttrList[:nam... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/tuple_expression/test_to_ruby_literal.rb | Ruby | mit | 49 | master | 318 | require 'spec_helper'
module Alf
describe TupleExpression, 'to_ruby_literal' do
it 'should raise a NotImplementedError if no source code' do
expr = TupleExpression[lambda{status > 10}]
lambda{ expr.to_ruby_literal }.should raise_error(NotImplementedError)
end
end # TupleExpression
end # Alf |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/tuple_expression/test_infer_type.rb | Ruby | mit | 49 | master | 233 | require 'spec_helper'
module Alf
describe TupleExpression, 'infer_type' do
let(:expr){ TupleExpression.new(->(t){}, "", String) }
subject{ expr.infer_type }
it{ should be(String) }
end # TupleExpression
end # Alf |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/tuple_expression/test_coerce.rb | Ruby | mit | 49 | master | 803 | require 'spec_helper'
module Alf
describe TupleExpression, "coerce" do
let(:scope) {
Support::TupleScope.new(:status => 10)
}
subject{ TupleExpression.coerce(arg) }
describe "with nil" do
let(:arg){ nil }
specify{ lambda{ subject }.should raise_error(ArgumentError) }
end
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/tuple_expression/test_evaluate.rb | Ruby | mit | 49 | master | 731 | require 'spec_helper'
module Alf
describe TupleExpression, 'evaluate' do
subject{ exp.evaluate(scope) }
let(:tuple){ Tuple(name: "Jones") }
let(:scope){ Support::TupleScope.new(tuple) }
context 'when the proc is of arity 0' do
let(:exp){ TupleExpression[->(){ name.upcase }] }
it{ shou... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/keys/test_any.rb | Ruby | mit | 49 | master | 265 | require 'spec_helper'
module Alf
describe Keys, "any?" do
subject{ keys.any?{|k| (k & [:name]).empty? } }
let(:keys) {
Keys[ [:a], [:name], [:last, :name] ]
}
let(:expected) {
Keys[ [:a] ]
}
it{ should be_true }
end
end |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/keys/test_select.rb | Ruby | mit | 49 | master | 1,171 | require 'spec_helper'
module Alf
describe Keys, "select" do
context 'when checking for intersection' do
subject{ keys.select{|k| (k & [:name]).empty? } }
let(:keys) {
Keys[ [:a], [:name], [:last, :name] ]
}
let(:expected) {
Keys[ [:a] ]
}
it{ should eq(expec... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/keys/test_empty.rb | Ruby | mit | 49 | master | 319 | require 'spec_helper'
module Alf
describe Keys, "empty?" do
subject{ keys.empty? }
context 'on empty Keys' do
let(:keys){ Keys.new [] }
it{ should be_true }
end
context 'on non empty Keys' do
let(:keys){ Keys.new [ AttrList[:a] ] }
it{ should be_false }
end
end
end |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/keys/test_rename.rb | Ruby | mit | 49 | master | 415 | require 'spec_helper'
module Alf
describe Keys, "rename" do
subject{ keys.rename(:name => :nome) }
context 'on empty Keys' do
let(:keys){ Keys[] }
it{ should eq(Keys[]) }
end
context 'on non empty Keys' do
let(:keys) { Keys[ [:a], [:name], [:last, :name] ] }
let(:expecte... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/keys/test_first.rb | Ruby | mit | 49 | master | 245 | require 'spec_helper'
module Alf
describe Keys, "first" do
subject{ keys.first }
let(:keys) {
Keys[ [:a], [:name], [:last, :name] ]
}
let(:expected) {
AttrList[:a]
}
it{ should eq(expected) }
end
end |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/keys/test_coerce.rb | Ruby | mit | 49 | master | 1,353 | require 'spec_helper'
module Alf
describe Keys, ".coerce" do
subject{ Keys.coerce(arg) }
let(:expected){ Keys.new [ AttrList[:id], AttrList[:name] ] }
context 'on a Keys' do
let(:arg){ expected }
it{ should be(arg) }
end
context 'on an Array of AttrList coercables' do
let(:a... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/keys/test_map.rb | Ruby | mit | 49 | master | 263 | require 'spec_helper'
module Alf
describe Keys, "map" do
subject{ keys.map{|k| k | [:foo] } }
let(:keys) {
Keys[ [:a], [:name] ]
}
let(:expected) {
Keys[ [:a, :foo], [:name, :foo] ]
}
it{ should eq(expected) }
end
end |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/keys/test_all.rb | Ruby | mit | 49 | master | 266 | require 'spec_helper'
module Alf
describe Keys, "all?" do
subject{ keys.all?{|k| (k & [:name]).empty? } }
let(:keys) {
Keys[ [:a], [:name], [:last, :name] ]
}
let(:expected) {
Keys[ [:a] ]
}
it{ should be_false }
end
end |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/keys/test_plus.rb | Ruby | mit | 49 | master | 488 | require 'spec_helper'
module Alf
describe Keys, "+" do
subject{ left + right }
context 'when disjoint' do
let(:left) { Keys[ [:a] ] }
let(:right){ Keys[ [:b] ] }
let(:expected){ Keys[ [:a], [:b] ] }
it{ should eq(expected) }
end
context 'when not disjoint' do
let(:le... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/keys/test_reject.rb | Ruby | mit | 49 | master | 293 | require 'spec_helper'
module Alf
describe Keys, "reject" do
subject{ keys.reject{|k| (k & [:name]).empty? } }
let(:keys) {
Keys[ [:a], [:name], [:last, :name] ]
}
let(:expected) {
Keys[ [:name], [:last, :name] ]
}
it{ should eq(expected) }
end
end |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/keys/test_if_empty.rb | Ruby | mit | 49 | master | 753 | require 'spec_helper'
module Alf
describe Keys, "if_empty" do
context 'with an arg' do
subject{ keys.if_empty([ [:foo] ]) }
context 'when empty' do
let(:keys){ Keys[] }
let(:expected){ Keys[ [:foo] ] }
it{ should eq(expected) }
end
context 'when not empty' do
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/keys/test_ampersand.rb | Ruby | mit | 49 | master | 477 | require 'spec_helper'
module Alf
describe Keys, "&" do
subject{ left & right }
context 'when disjoint' do
let(:left) { Keys[ [:a] ] }
let(:right){ Keys[ [:b] ] }
let(:expected){ Keys[ ] }
it{ should eq(expected) }
end
context 'when not disjoint' do
let(:left) { Keys[... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/keys/test_project.rb | Ruby | mit | 49 | master | 517 | require 'spec_helper'
module Alf
describe Keys, "project" do
let(:keys){
Keys[ [:id], [:id, :name], [:status] ]
}
let(:attrs){
[:id]
}
subject{ keys.project(attrs, allbut) }
context '--no-allbut' do
let(:allbut) { false }
let(:expected){ Keys[ [:id], [] ] }
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/keys/test_hash_and_equal.rb | Ruby | mit | 49 | master | 700 | require 'spec_helper'
module Alf
describe Keys, "hash and ==" do
subject{ left == right }
after do
(left.hash == right.hash).should be_true if subject
end
context 'on empty Keys' do
let(:left) { Keys.new [] }
let(:right){ Keys.new [] }
it{ should be_true }
end
cont... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/size/test_triple_equal.rb | Ruby | mit | 49 | master | 516 | require 'spec_helper'
module Alf
module Types
describe Size, "===" do
it 'should recognize 0' do
(Size === 0).should be_true
end
it 'should recognize any positive integer' do
(Size === 10).should be_true
end
it 'should not recognize negative integers' do
(S... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/size/test_coerce.rb | Ruby | mit | 49 | master | 509 | require 'spec_helper'
module Alf
module Types
describe Size, "coerce" do
it 'should coerce strings correctly' do
Size.coerce("0").should eq(0)
Size.coerce("10").should eq(10)
end
it 'should raise TypeError on negative integers' do
lambda{ Size.coerce("-1") }.should rais... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/heading/test_cardinality.rb | Ruby | mit | 49 | master | 454 | require 'spec_helper'
module Alf
describe Heading, "cardinality" do
subject{ heading.cardinality }
after do
subject.should eq(heading.count)
subject.should eq(heading.size)
end
context 'on an empty heading' do
let(:heading){ Heading.new({}) }
it{ should eq(0) }
end
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/heading/test_merge.rb | Ruby | mit | 49 | master | 644 | module Alf
describe Heading, "merge" do
subject{ left.merge(right) }
context 'with disjoint headings' do
let(:left) { Heading[:name => String] }
let(:right){ Heading[:city => String] }
it "computes the union" do
subject.should eq(Heading[:name => String, :city => String])
en... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/heading/test_triple_equal.rb | Ruby | mit | 49 | master | 861 | require 'spec_helper'
module Alf
describe Heading, "===" do
let(:h){ Heading[name: String, status: Integer] }
subject{ h===tuple }
context 'on a conforming Hash' do
let(:tuple){ {name: "Smith", status: 20} }
it{ should be_true }
end
context 'on a conforming Tuple' do
let(:tu... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/heading/test_to_h.rb | Ruby | mit | 49 | master | 418 | require 'spec_helper'
module Alf
describe Heading, "to_h" do
subject{ heading.to_h }
after do
subject.should eq(heading.to_hash)
end
context 'on an empty heading' do
let(:heading){ Heading.new({}) }
it{ should eq({}) }
end
context 'on a non-empty heading' do
let(:h... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/heading/test_comparison.rb | Ruby | mit | 49 | master | 2,281 | require 'spec_helper'
module Alf
describe Heading, "<=>" do
let(:heading){ Heading.new(name: String, status: Integer, active: Boolean) }
subject{ heading <=> other }
context 'with itself' do
let(:other){ heading }
before{ heading.should eq(other) }
it{ should eq(0) }
end
co... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/heading/test_project.rb | Ruby | mit | 49 | master | 404 | require 'spec_helper'
module Alf
describe Heading, "project" do
let(:heading){ Heading[:id => Integer, :name => String] }
context 'without allbut' do
subject{ heading.project([:id]) }
it { should eq(Heading[:id => Integer]) }
end
context 'with allbut' do
subject{ heading.project(... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/heading/test_intersection.rb | Ruby | mit | 49 | master | 760 | require 'spec_helper'
module Alf
describe Heading, "intersection" do
subject{ left & right }
context 'with disjoint headings' do
let(:left) { Heading[:name => String] }
let(:right){ Heading[:city => String] }
it{ should eq(Heading[{}]) }
end
context 'with non disjoint headings' d... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/heading/test_coerce.rb | Ruby | mit | 49 | master | 1,445 | require 'spec_helper'
module Alf
module Types
describe Heading, "coerce" do
let(:heading){ Heading.new(name: String, status: Integer) }
subject{ heading.coerce(arg) }
context 'when applied to a Hash' do
let(:arg){ {name: "Smith", status: "20"} }
it{ should be_a(Hash) }
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/heading/test_union.rb | Ruby | mit | 49 | master | 983 | require 'spec_helper'
module Alf
describe Heading, "union" do
let(:h_name){ Heading[:name => String] }
let(:h_city){ Heading[:city => String] }
it "should work on empty headings" do
Heading::EMPTY.union(Heading::EMPTY).should eq(Heading::EMPTY)
end
it "should work with disjoint headings" ... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/heading/test_split.rb | Ruby | mit | 49 | master | 438 | require 'spec_helper'
module Alf
describe Heading, "split" do
let(:heading){ Heading[id: Integer, name: String] }
context 'without allbut' do
subject{ heading.split([:id]) }
it { should eq([Heading[id: Integer], Heading[name: String]]) }
end
context 'without allbut' do
subject{ h... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/heading/test_allbut.rb | Ruby | mit | 49 | master | 216 | require 'spec_helper'
module Alf
describe Heading, "allbut" do
let(:heading){ Heading[id: Integer, name: String] }
subject{ heading.allbut([:id]) }
it { should eq(Heading[name: String]) }
end
end |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/heading/class/test_coerce.rb | Ruby | mit | 49 | master | 799 | require 'spec_helper'
module Alf
describe Heading, "coerce" do
subject{ Heading.coerce(arg) }
context 'with a Heading' do
let(:arg){ Heading.new :foo => String }
it{ should be(arg) }
end
context 'with a Hash' do
let(:arg){ {:foo => String} }
it{ should eq(Heading.new :foo ... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/heading/class/test_infer.rb | Ruby | mit | 49 | master | 486 | require 'spec_helper'
module Alf
describe Heading, "infer" do
subject{ Heading.infer(arg) }
context 'with a Heading' do
let(:arg){ Heading.new foo: String }
it{ should be(arg) }
end
context 'with a Hash' do
let(:arg){ {:foo => 20} }
it{ should eq(Heading.new foo: Fixnum) }... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/summarization/test_coerce.rb | Ruby | mit | 49 | master | 891 | require 'spec_helper'
module Alf
describe Summarization, "coerce" do
subject{ Summarization.coerce(arg) }
describe "from a Summarization" do
let(:arg){ Summarization.new(:s => Aggregator.sum{ qty }) }
it{ should eq(arg) }
end
describe "from a Hash" do
let(:arg){ { :s => Aggregator... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/summarization/test_least.rb | Ruby | mit | 49 | master | 290 | require 'spec_helper'
module Alf
describe Summarization, "least" do
it 'should invoke least on each aggregator' do
sum = Summarization.coerce(["s", Aggregator.avg{ qty }, "m", Aggregator.max{ size }])
sum.least.should eq({:s => [0.0, 0.0], :m => nil})
end
end
end |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/summarization/test_summarize.rb | Ruby | mit | 49 | master | 375 | require 'spec_helper'
module Alf
describe Summarization, "summarize" do
it 'should summarize as expected' do
rel = [
{:qty => 10, :size => 12},
{:qty => 5, :size => 5}
]
sum = Summarization.coerce(["s", Aggregator.avg{ qty }, "m", Aggregator.max{ size }])
sum.summarize(re... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/selector/test_select.rb | Ruby | mit | 49 | master | 799 | require 'spec_helper'
module Alf
describe Selector, "select" do
subject{ selector.select(tuple) }
let(:tuple){ {name: "foo", city: {name: "bar"}} }
context 'on name' do
let(:selector){ Selector.coerce("name") }
it{ should eq("foo") }
end
context 'on city' do
let(:selector){ ... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/selector/test_to_ruby_literal.rb | Ruby | mit | 49 | master | 408 | require 'spec_helper'
module Alf
describe Selector, "to_ruby_literal" do
subject{ selector.to_ruby_literal }
context 'on a single' do
let(:selector){ Selector.coerce(:name) }
it { should eq('Alf::Selector[:name]') }
end
context 'on a composite' do
let(:selector){ Selector.coerce(... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/selector/test_to_lispy.rb | Ruby | mit | 49 | master | 364 | require 'spec_helper'
module Alf
describe Selector, "to_lispy" do
subject{ selector.to_lispy }
context 'on a single' do
let(:selector){ Selector.coerce(:name) }
it { should eq(':name') }
end
context 'on a composite' do
let(:selector){ Selector.coerce([:a, :name]) }
it { sh... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/selector/test_to_a.rb | Ruby | mit | 49 | master | 354 | require 'spec_helper'
module Alf
describe Selector, "to_a" do
subject{ selector.to_a }
context 'on a single' do
let(:selector){ Selector.coerce(:name) }
it { should eq([:name]) }
end
context 'on a composite' do
let(:selector){ Selector.coerce([:a, :name]) }
it { should eq(... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/selector/test_dive.rb | Ruby | mit | 49 | master | 651 | require 'spec_helper'
module Alf
describe Selector, "dive" do
subject{ selector.dive(:a) }
context 'on a single, not the same' do
let(:selector){ Selector.coerce(:name) }
it { should be_nil }
end
context 'on a single, same' do
let(:selector){ Selector.coerce(:a) }
it { sho... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/selector/test_coerce.rb | Ruby | mit | 49 | master | 658 | require 'spec_helper'
module Alf
describe Selector, ".coerce" do
subject{ Selector.coerce(arg) }
before do
subject.should be_a(Selector)
end
context 'on a Symbol' do
let(:arg){ :name }
it { should eq(Selector.new(:name)) }
end
context 'on a single string' do
let(:a... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/selector/test_simple_q.rb | Ruby | mit | 49 | master | 349 | require 'spec_helper'
module Alf
describe Selector, "simple?" do
subject{ selector.simple? }
context 'on a single' do
let(:selector){ Selector.coerce(:name) }
it { should be_true }
end
context 'on a composite' do
let(:selector){ Selector.coerce([:a, :name]) }
it { should b... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/selector/test_composite_q.rb | Ruby | mit | 49 | master | 355 | require 'spec_helper'
module Alf
describe Selector, "composite?" do
subject{ selector.composite? }
context 'on a single' do
let(:selector){ Selector.coerce(:name) }
it { should be_false }
end
context 'on a composite' do
let(:selector){ Selector.coerce([:a, :name]) }
it { s... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/ordering/test_total.rb | Ruby | mit | 49 | master | 1,531 | require 'spec_helper'
module Alf
describe Ordering, "total" do
subject{ ordering.total(keys) }
context 'when the ordering already covers a key' do
let(:ordering){ Ordering[[:city, :name]] }
let(:keys) { Keys[[:name]] }
it{ should eq(ordering) }
end
context 'when the ordering... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/ordering/test_to_attr_list.rb | Ruby | mit | 49 | master | 604 | require 'spec_helper'
module Alf
describe Ordering, "to_attr_list" do
subject{ ordering.to_attr_list }
context 'on an empty ordering' do
let(:ordering){ Ordering::EMPTY }
it{ should eq(AttrList::EMPTY) }
end
context 'on an ordering with single names' do
let(:ordering){ Ordering.n... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/ordering/test_dive.rb | Ruby | mit | 49 | master | 789 | require 'spec_helper'
module Alf
describe Ordering, 'dive' do
subject{ ordering.dive(:b) }
context 'when the ordering has :b' do
let(:ordering){
Ordering.new([[:a, :asc], [[:b, :x], :asc], [[:b, :y], :asc]])
}
let(:expected){
Ordering.new([[:x, :asc], [:y, :asc]])
}
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/ordering/test_coerce.rb | Ruby | mit | 49 | master | 2,193 | require 'spec_helper'
module Alf
describe Ordering, "coerce" do
context 'with single attribute names' do
let(:expected){ Ordering.new([[:a, :asc], [:b, :asc]]) }
it "should work with an Ordering" do
key = Ordering.coerce [:a, :b]
key.should eq(expected)
end
it "should w... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/ordering/test_merge.rb | Ruby | mit | 49 | master | 1,507 | require 'spec_helper'
module Alf
describe Ordering, "merge" do
subject{ Ordering.coerce(left) + right }
let(:expected){ Ordering.new([[:a, :asc], [:b, :desc]]) }
describe "with another Ordering" do
let(:left){ [:a] }
let(:right){ Ordering.new([[:b, :desc]]) }
it{ should eq(expected) ... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/ordering/test_compare.rb | Ruby | mit | 49 | master | 1,309 | require 'spec_helper'
module Alf
describe Ordering, "compare" do
it "should work on a singleton ordering" do
key = Ordering.coerce [:a]
key.compare({:a => 1}, {:a => 2}).should == -1
key.compare({:a => 1}, {:a => 1}).should == 0
key.compare({:a => 2}, {:a => 1}).should == 1
end
i... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/ordering/test_lte.rb | Ruby | mit | 49 | master | 915 | require 'spec_helper'
module Alf
describe Ordering, "<=" do
subject{ o1 <= o2 }
context 'when empty' do
let(:o1){ Ordering::EMPTY }
let(:o2){ Ordering.new([]) }
it{ should be_true }
end
context 'when equal' do
let(:o1){ Ordering.new([[:a, :asc], [:b, :desc]]) }
let(:... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/ordering/test_sorter.rb | Ruby | mit | 49 | master | 1,460 | require 'spec_helper'
module Alf
describe Ordering, "sorter" do
subject{ ordering.sorter }
context 'on an ordering with single names' do
let(:ordering){ Ordering.coerce([[:a, :desc]]) }
let(:tuples){
[{a: 2},
{a: 7},
{a: 1}]
}
let(:expected){
[{a: ... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/ordering/test_selectors.rb | Ruby | mit | 49 | master | 609 | require 'spec_helper'
module Alf
describe Ordering, "selectors" do
subject{ ordering.selectors }
context 'with single attribute names' do
let(:ordering){ Ordering.new([[:a, :asc], [:b, :asc]]) }
it "works as expected" do
subject.should eq([Alf::Selector[:a], Alf::Selector[:b]])
en... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/ordering/test_reverse.rb | Ruby | mit | 49 | master | 902 | require 'spec_helper'
module Alf
describe Ordering, "reverse" do
subject{
ordering.reverse
}
context 'on an empty ordering' do
let(:ordering){ Ordering.new([]) }
it{ should eq(ordering) }
end
context 'on a singleton asc ordering' do
let(:ordering){ Ordering.new([[... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/ordering/test_hash_get.rb | Ruby | mit | 49 | master | 531 | require 'spec_helper'
module Alf
describe Ordering, "[]" do
let(:ordering){ Ordering.new([[:a, :asc], [:b, :desc], [[:c, :d], :asc]]) }
it 'return the direction when an attribute' do
ordering[:a].should eq(:asc)
ordering[:b].should eq(:desc)
ordering[Selector[:a]].should eq(:asc)
ord... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/selection/test_select.rb | Ruby | mit | 49 | master | 892 | require 'spec_helper'
module Alf
describe Selection, "select" do
subject{ selection.select(tuple) }
let(:tuple){ {name: "foo", city: {name: "bar"}} }
context 'on a selection of [name]' do
let(:selection){ Selection.coerce("name") }
it{ should eq("foo") }
end
context 'on a selectio... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/selection/test_coerce.rb | Ruby | mit | 49 | master | 1,154 | require 'spec_helper'
module Alf
describe Selection, ".coerce" do
subject{ Selection.coerce(arg) }
before do
subject.should be_a(Selection)
end
context 'with a Symbol' do
let(:arg){ :name }
let(:expected){
Selection.new(:name)
}
it{ should eq(expected) }
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/renaming/test_coerce.rb | Ruby | mit | 49 | master | 589 | require 'spec_helper'
module Alf
describe Renaming, "coerce" do
subject{ Renaming.coerce(arg) }
let(:expected){ Renaming.new(:old1 => :new1, :old2 => :new2) }
describe "from a Renaming" do
let(:arg){ Renaming.new(:old1 => :new1, :old2 => :new2) }
it{ should eq(expected) }
end
descri... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/renaming/test_rename_attr_list.rb | Ruby | mit | 49 | master | 508 | require 'spec_helper'
module Alf
describe Renaming, "rename_attr_list" do
let(:renaming){ Renaming[:old => :new, :foo => :bar] }
let(:expected){ AttrList[:bar, :new, :name] }
subject{ renaming.rename_attr_list(attr_list) }
context 'on an attribute list' do
let(:attr_list){ AttrList[:foo, :ol... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/renaming/test_invert.rb | Ruby | mit | 49 | master | 259 | require 'spec_helper'
module Alf
describe Renaming, "invert" do
let(:renaming){ Renaming[:old => :new, :foo => :bar] }
let(:expected){ Renaming[:new => :old, :bar => :foo] }
subject{ renaming.invert }
it{ should eq(expected) }
end
end |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/renaming/test_to_attr_list.rb | Ruby | mit | 49 | master | 255 | require 'spec_helper'
module Alf
describe Renaming, "to_attr_list" do
let(:renaming){ Renaming[:old => :new, :foo => :bar] }
subject{ renaming.to_attr_list }
let(:expected){ AttrList[:old, :foo] }
it{ should eq(expected) }
end
end |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/renaming/test_complete.rb | Ruby | mit | 49 | master | 302 | require 'spec_helper'
module Alf
describe Renaming, "complete" do
let(:renaming){ Renaming[:old => :new, :foo => :bar] }
subject{ renaming.complete(AttrList[:old, :blah]) }
let(:expected){ Renaming[:old => :new, :foo => :bar, :blah => :blah] }
it{ should eq(expected) }
end
end |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/renaming/test_rename_tuple.rb | Ruby | mit | 49 | master | 330 | require 'spec_helper'
module Alf
describe Renaming, "rename_tuple" do
let(:r){ Renaming.coerce(["old", "new"]) }
it 'should rename correctly' do
tuple = {:old => :a, :other => :b}
expected = {:new => :a, :other => :b}
r.rename_tuple(tuple).should eq(expected)
end
end # Renaming
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/attr_name/test_triple_equal.rb | Ruby | mit | 49 | master | 593 | require 'spec_helper'
module Alf
describe AttrName, "===" do
it "should allow normal names" do
(AttrName === :city).should be_true
end
it "should allow underscores" do
(AttrName === :my_city).should be_true
end
it "should allow numbers" do
(AttrName === :city2).should be_true
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/attr_name/test_coerce.rb | Ruby | mit | 49 | master | 428 | require 'spec_helper'
module Alf
describe AttrName, "coerce" do
it 'should work on valid attribute names' do
AttrName.coerce("city").should eq(:city)
AttrName.coerce(:big?).should eq(:big?)
end
it 'should raise ArgumentError otherwise' do
lambda{ AttrName.coerce("!123") }.should raise... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/tuple_computation/test_to_attr_list.rb | Ruby | mit | 49 | master | 388 | require 'spec_helper'
module Alf
describe TupleComputation, "to_attr_list" do
it 'should return the correct list of attribute names' do
list = TupleComputation[
:big? => lambda{ status > 20 },
:who => lambda{ "#{first} #{last}" }
].to_attr_list
list.should be_a(AttrList)
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/tuple_computation/test_coerce.rb | Ruby | mit | 49 | master | 1,026 | require 'spec_helper'
module Alf
describe TupleComputation, "coerce" do
subject{ TupleComputation.coerce(arg).evaluate(scope) }
let(:scope) {
Support::TupleScope.new(status: 10, who: "alf")
}
describe "from a TupleComputation" do
let(:arg){ TupleComputation.new hello: TupleExpression.co... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/tuple_computation/test_project.rb | Ruby | mit | 49 | master | 1,114 | require 'spec_helper'
module Alf
describe TupleComputation, "project" do
big = TupleExpression.coerce(->(t){ t.status > 10 })
who = TupleExpression.coerce(->(t){ t.name })
let(:comp){
TupleComputation[big?: big, who: who]
}
subject{ comp.project(list, allbut) }
context 'when not allbu... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/tuple_computation/test_to_heading.rb | Ruby | mit | 49 | master | 667 | require 'spec_helper'
module Alf
describe TupleComputation, 'to_heading' do
let(:computation){
TupleComputation[
:big? => lambda{ status > 20 },
:who => lambda{ "#{first} #{last}" },
:sub => Relation::DUM
]
}
subject{ computation.to_heading }
context 'with prop... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/tuple_computation/test_empty.rb | Ruby | mit | 49 | master | 377 | require 'spec_helper'
module Alf
describe TupleComputation, "empty?" do
subject{ comp.empty? }
context 'when not empty' do
let(:comp){
TupleComputation[big?: ->{}, who: ->{}]
}
it{ should be_false }
end
context 'when empty' do
let(:comp){
TupleComputation[{}... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-types/type_check/test_triple_equal.rb | Ruby | mit | 49 | master | 1,885 | require 'spec_helper'
module Alf
module Types
describe TypeCheck, '===' do
let(:heading){ Heading.new(name: String, status: Integer) }
let(:tuple) { {name: 'Smith', status: 20} }
let(:missing){ { status: 20} }
let(:extra) { {name: 'Smith', status: 20, foo: "bar"} }
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-lang/test_predicates.rb | Ruby | mit | 49 | master | 331 | require 'spec_helper'
module Alf
module Lang
describe Predicates do
include Predicates
it "eq should factor a predicate" do
eq(:x, 12).should be_a(Alf::Predicate)
end
it "between should factor a predicate" do
between(:x, 2, 3).should be_a(Alf::Predicate)
end
en... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-lang/object_oriented/test_to_array.rb | Ruby | mit | 49 | master | 1,183 | require 'spec_helper'
module Alf
module Lang
describe ObjectOriented, 'to_array' do
include ObjectOriented.new(supplier_names_relation)
let(:ordering){ Ordering.coerce([[:name, :desc]]) }
context 'with a block' do
it 'yields the block with a ToArray' do
seen = nil
t... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-lang/object_oriented/test_rendering_methods.rb | Ruby | mit | 49 | master | 938 | require 'spec_helper'
module Alf
module Lang
describe ObjectOriented do
include ObjectOriented.new(supplier_names_relation)
Renderer.each do |name,_,clazz|
describe "#to_#{name}" do
subject{ :"to_#{name}" }
it 'should exist' do
meths = ObjectOriented.instance_... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-lang/object_oriented/test_to_rash.rb | Ruby | mit | 49 | master | 759 | require 'spec_helper'
module Alf
module Lang
describe ObjectOriented, 'to_rash' do
include ObjectOriented.new(supplier_names_relation)
subject{
to_rash(options).each_line.map do |line|
::Kernel.eval(line)
end
}
before do
subject.should be_a(Array)
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-lang/object_oriented/test_tuple_extract.rb | Ruby | mit | 49 | master | 1,180 | require 'spec_helper'
module Alf
module Lang
describe ObjectOriented, 'tuple_extract' do
def subject(&bl)
rel.extend(ObjectOriented.new(rel))
rel.tuple_extract(&bl)
end
context 'on a singleton' do
let(:rel) { [{name: "Jones"}] }
let(:expected){ Tuple(name: "... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-lang/parser/lispy/test_connection_bang.rb | Ruby | mit | 49 | master | 595 | require 'spec_helper'
module Alf
module Lang
module Parser
describe Lispy, 'connection!' do
context 'when bound' do
let(:lispy){ Lispy.new([], 12) }
it 'allows obtaining its connection' do
lispy.connection!.should eq(12)
end
end
context 'w... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-lang/parser/lispy/test_to_s.rb | Ruby | mit | 49 | master | 227 | require 'spec_helper'
module Alf
module Lang
module Parser
describe Lispy, 'to_s' do
let(:lispy){ Lispy.new }
subject{ lispy.to_s }
it{ should eq("Lispy()") }
end
end
end
end |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-lang/parser/lispy/test_parse.rb | Ruby | mit | 49 | master | 973 | require 'spec_helper'
module Alf
module Lang
module Parser
describe Lispy do
context 'when unbound' do
let(:lispy){ Lispy.new }
it 'allows parsing predicate expressions' do
p = lispy.parse{ eq(:x, 1) & neq(:y, 2) }
p.should be_a(Alf::Predicate)
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-lang/parser/safer/test_parse.rb | Ruby | mit | 49 | master | 2,044 | require 'spec_helper'
module Alf
module Lang
module Parser
describe Safer, "test_parse" do
let(:viewpoint) do
Module.new{
def suppliers
Algebra::Operand::Named.new(:suppliers)
end
}
end
let(:parser){ Safer.new([viewpoint]) }... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-lang/functional/test_tuple.rb | Ruby | mit | 49 | master | 393 | require 'spec_helper'
module Alf
module Lang
describe "Tuple(...) literal" do
include Functional
subject{ Tuple(h) }
describe 'on an empty tuple' do
let(:h){ {} }
it{ should eq(Tuple::EMPTY) }
end
describe 'on an valid tuple' do
let(:h){ {:name => "Alf"} }
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | spec/unit/alf-lang/functional/test_relation.rb | Ruby | mit | 49 | master | 488 | require 'spec_helper'
module Alf
module Lang
describe "Relation(...) literal" do
include Functional
describe 'on a single tuple' do
subject{ Relation(name: "Jones") }
it{ should eq(Alf::Relation.coerce([{name: "Jones"}])) }
end
describe 'on an array of tuples' do
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.