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
milkcocoa/grape-jbuilder
https://github.com/milkcocoa/grape-jbuilder
lib/grape/jbuilder/renderer.rb
Ruby
mit
49
master
673
module Grape module Jbuilder class Renderer def initialize(view_path, template) @view_path, @template = view_path, template end def render(scope, locals = {}) unless view_path raise "Use Rack::Config to set 'api.tilt.root' in config.ru" end engine = ::...
github
reddavis/Naive-Bayes
https://github.com/reddavis/Naive-Bayes
Rakefile
Ruby
mit
49
master
1,344
require 'rubygems' require 'rake' begin require 'jeweler' Jeweler::Tasks.new do |gem| gem.name = "naive_bayes" gem.summary = %Q{Simple straight forward Naive Bayes classifier implementation} gem.description = %Q{Simple straight forward Naive Bayes classifier implementation} gem.email = "reddavis@gm...
github
reddavis/Naive-Bayes
https://github.com/reddavis/Naive-Bayes
naive_bayes.gemspec
Ruby
mit
49
master
1,604
# Generated by jeweler # DO NOT EDIT THIS FILE DIRECTLY # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command # -*- encoding: utf-8 -*- Gem::Specification.new do |s| s.name = %q{naive_bayes} s.version = "0.0.3" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :requir...
github
reddavis/Naive-Bayes
https://github.com/reddavis/Naive-Bayes
spec/naive_bayes_spec.rb
Ruby
mit
49
master
1,827
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe "NaiveBayes" do describe "Classification" do before do @classifier = create_and_train_classifier end it "should classify as spam with a score of 0.5" do a = @classifier.classify('bad', 'word') a[0].shou...
github
reddavis/Naive-Bayes
https://github.com/reddavis/Naive-Bayes
spec/spec_helper.rb
Ruby
mit
49
master
213
$LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'naive_bayes' require 'spec' require 'spec/autorun' Spec::Runner.configure do |config| end
github
reddavis/Naive-Bayes
https://github.com/reddavis/Naive-Bayes
lib/naive_bayes.rb
Ruby
mit
49
master
2,468
# Bayes Theorem # P(A|B) = P(B|A) * P(A) / P(B) # Terminology # An ITEM is made up of FEATURES # An ITEM belongs to a CLASS # Bayes With Our Terminology # P(Class | Item) = P(Item | Class) * P(Class) / P(Item) # However, when classifying, P(Item) is the same across all calcualtions # So we don't bother to calculate ...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
alf-core.gemspec
Ruby
mit
49
master
1,403
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__) require "alf/core/version" $version = Alf::Core::Version.to_s Gem::Specification.new do |s| s.name = "alf-core" s.version = $version s.summary = "Relational Algebra at your fingertips" s.description = "Alf brings the relational algebra both in Shell and i...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
Rakefile
Ruby
mit
49
master
209
# We run tests by default task :default => :test # # Install all tasks found in tasks folder # # See .rake files there for complete documentation. # Dir["tasks/*.rake"].each do |taskfile| load taskfile end
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
Gemfile
Ruby
mit
49
master
304
source 'http://rubygems.org' group :runtime do gem "myrrha", "~> 3.0" gem "domain", "~> 1.0" gem "path", ">= 1.3", "< 3.0" gem "sexpr", "~> 0.6.0" end group :test do gem "rake", "~> 10.1" gem "rspec", "~> 2.14" end group :extra do gem "highline", "~> 1.6" gem "ruby_cop", "~> 1.0" end
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/optimizer_helper.rb
Ruby
mit
49
master
514
require 'spec_helper' require 'unit/alf-optimizer/shared/a_pass_through_expression_for_restrict' require 'unit/alf-optimizer/shared/a_split_able_expression_for_restrict' require 'unit/alf-optimizer/shared/an_unoptimizable_expression_for_restrict' require 'unit/alf-optimizer/shared/an_optimizable_expression_for_restric...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/update_helper.rb
Ruby
mit
49
master
1,758
require 'spec_helper' class UpdateContext def initialize @requests = [] end attr_reader :requests def heading(name) case name when :suppliers then Alf::Heading[:sid => Integer, :name => String] when :parts then Alf::Heading[:pid => Integer, :color => String] end end def insert(n...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/spec_helper.rb
Ruby
mit
49
master
1,412
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) require "rspec" require 'alf-core' require 'alf/lang/parser/safer' require 'shared/an_operator_class' require 'shared/a_valid_type_implementation' require 'shared/a_value' require 'shared/a_scope' require 'shared/a_cog' (Path.dir/"unit").glob("**/shared_exampl...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/compiler_helper.rb
Ruby
mit
49
master
382
require 'spec_helper' require_relative 'unit/alf-compiler/shared/compiled_examples' module CompilerHelper def compiler @compiler ||= Alf::Compiler::Default.new end def leaf @leaf ||= Alf::Engine::Leaf.new([{a: 2}, {a: 1}], Alf::Algebra::Operand::Named.new(:leaf)) end end RSpec.configure do |c| c...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/regression/restrict/test_restrict_with_keywords.rb
Ruby
mit
49
master
446
require 'spec_helper' module Alf describe "(restrict xxx, :keyword => ...)" do it "should support using a keyword on Relation" do rel = Relation(when: "now") rel.restrict(when: "now").should eq(rel) end it "should support using a keyword on Lispy" do Alf.examples.query do (rest...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/regression/project/test_project_with_stop.rb
Ruby
mit
49
master
315
require 'spec_helper' module Alf describe "project(...)" do subject{ Alf.examples.query do project(matching(supplies, restrict(suppliers, city: "Paris")), [:pid]) end } it "should not raise an error" do ->{ subject }.should_not raise_error end end end
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/regression/relation/test_relation_allbut_all.rb
Ruby
mit
49
master
262
require 'spec_helper' require 'date' module Alf describe Relation, "allbut" do describe "when all attributes are projected away" do subject{ Relation(sid: "P1").allbut([:sid]) } it{ should eql(Relation::DEE) } end end end
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/regression/relation/test_relation_with_date.rb
Ruby
mit
49
master
228
require 'spec_helper' require 'date' module Alf describe Relation do describe "when attributes on Date domain" do subject{ Relation(date: Date.today) } it_should_behave_like "A value" end end end
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/regression/relation/test_coerce.rb
Ruby
mit
49
master
477
require 'spec_helper' module Alf describe Relation, ".coerce bugs" do let(:arg){ [Tuple(sid: "S5", suppliers: Relation([]))] } context 'on Relation' do subject{ Relation.coerce(arg) } it 'works' do subject.should be_a(Relation) end end context 'on Relation[...]' do ...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/regression/relation/test_restrict.rb
Ruby
mit
49
master
409
require 'spec_helper' module Alf describe Relation, ".restrict bugs" do let(:arg){ Relation([ { sid: "S1", supplies: Relation(pid: ["P1", "P2"]) }, { sid: "S5", supplies: Relation([]) } ]) } context 'on Relation' do subject{ arg.restrict(sid: 'S5') } it 'does not...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/regression/heading/test_heading_with_date.rb
Ruby
mit
49
master
224
require 'spec_helper' require 'date' module Alf describe Heading do describe "when attributes on Foo domain" do subject{ Heading[{:date => Date}] } it_should_behave_like "A value" end end end
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-io/test_renderer.rb
Ruby
mit
49
master
845
require 'spec_helper' module Alf describe Renderer do subject{ Renderer } let(:input){ [{:a => 1}] } it { should respond_to(:rash) } it { should respond_to(:text) } it { should respond_to(:csv) } it { should respond_to(:yaml) } describe 'renderer' do subject{ Renderer.renderer(:...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-io/test_reader.rb
Ruby
mit
49
master
769
require 'spec_helper' module Alf describe Reader do subject{ Reader } it { should respond_to(:rash) } describe "rash on a real IO" do subject{ Reader.rash($stdin) } it{ should be_a(Reader::Rash) } end describe "reader" do specify "when associated" do r = Reader.reader...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-io/support/test_proc_io.rb
Ruby
mit
49
master
393
require 'spec_helper' module Alf module Support describe CSVUtils::ProcIO do include CSVUtils it 'works as expected' do @seen = nil proc_io = CSVUtils::ProcIO.new{|str| @seen = str} with_csv(proc_io, row_sep: "\n") do |csv| csv << ["Smith", 20, "London"] end ...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-io/reader/test_ruby.rb
Ruby
mit
49
master
406
require 'spec_helper' module Alf describe Reader::Ruby do it_should_behave_like "a Reader class" let(:file){ File.expand_path('../input.ruby', __FILE__) } let(:reader){ Reader::Ruby.new(file) } let(:expected){ [ {:id => 1}, {:id => 2} ] } it "...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-io/reader/test_json.rb
Ruby
mit
49
master
641
require 'spec_helper' require 'json' module Alf describe Reader::JSON do it_should_behave_like "a Reader class" let(:str) { ::JSON.dump(input) } let(:io) { StringIO.new(str) } let(:reader){ Reader::JSON.new(io) } subject{ reader.to_a } describe "when called on a JSON Array" do ...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-io/reader/test_initialize.rb
Ruby
mit
49
master
1,747
require 'spec_helper' module Alf describe "Reader#initialize" do subject{ Reader.new(*args) } let(:input){ nil } let(:options){ nil } let(:args){ [input, options].compact } before do subject.should be_a(Reader) end after do subject.input.should eq(input) end conte...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-io/reader/test_yaml.rb
Ruby
mit
49
master
631
require 'spec_helper' require 'json' module Alf describe Reader::YAML do it_should_behave_like "a Reader class" let(:str) { input.to_yaml } let(:io) { StringIO.new(str) } let(:reader){ Reader::YAML.new(io) } subject{ reader.to_a } describe "when called on a Array" do le...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-io/reader/test_rash.rb
Ruby
mit
49
master
718
require 'spec_helper' module Alf describe Reader::Rash do it_should_behave_like "a Reader class" let(:lines){ [{:id => 1},{:id => 2}] } let(:str) { lines.collect{|s| s.inspect}.join("\n") } let(:io) { StringIO.new(str) } describe "when called on a StringIO" do let...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-io/reader/test_csv.rb
Ruby
mit
49
master
1,604
require 'spec_helper' module Alf class Reader describe CSV do it_should_behave_like "a Reader class" describe "without options" do let(:input){ StringIO.new << "size\n10\n20\n" } let(:expected){ [{:size => "10"}, {:size => "20"}] } subject{ ...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-io/reader/class/test_by_mime_type.rb
Ruby
mit
49
master
661
require 'spec_helper' module Alf describe Reader, ".by_mime_type" do let(:io){ StringIO.new("") } context 'when mime type is unrecognized' do subject{ Reader.by_mime_type("no/suchone", io) } it 'should raise an error' do lambda{ subject }.should raise_err...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-io/renderer/test_json.rb
Ruby
mit
49
master
902
require 'spec_helper' module Alf class Renderer describe JSON do context 'the class' do subject{ JSON } it_should_behave_like "a Renderer class" end context "an instance on a Relation" do subject{ JSON.new(input).execute("") } let(:input){ Relation(id: [1, 2])...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-io/renderer/test_html.rb
Ruby
mit
49
master
1,316
require 'spec_helper' module Alf class Renderer describe Html do context 'the class' do subject{ Html } it_should_behave_like "a Renderer class" end describe "execute on a Relation" do subject{ Html.new(input).execute("") } let(:input){ Relation(id: [1, 2]) } ...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-io/renderer/test_text.rb
Ruby
mit
49
master
1,076
require 'spec_helper' module Alf class Renderer describe Text do context 'the class' do subject{ Text } it_should_behave_like "a Renderer class" end describe "execute on a Relation" do subject{ Text.new(input).execute("") } let(:input){ Relation(id: [1, 2]) } ...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-io/renderer/test_csv.rb
Ruby
mit
49
master
1,533
require 'spec_helper' module Alf class Renderer describe CSV do context 'the class' do subject{ CSV } it_should_behave_like "a Renderer class" end context 'an instance on multiple tuples' do let(:input){ [{:id => 1, :name => "Smith"}, {:id => 2, :name => "Jon...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-io/renderer/test_rash.rb
Ruby
mit
49
master
752
require 'spec_helper' module Alf class Renderer describe Rash do context 'the class' do subject{ Rash } it_should_behave_like "a Renderer class" end context 'an instance' do subject{ Rash.new(input).execute("") } context "when a Relation" do let(:inp...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-io/renderer/test_initialize.rb
Ruby
mit
49
master
977
require 'spec_helper' module Alf describe "Renderer#initialize" do subject{ Renderer.new(*args) } describe "with full args" do let(:args){[ [], {:opts => true} ]} specify { subject.input.should eq([]) subject.options.should eq(:opts => true) } end describe "on a su...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-io/renderer/test_yaml.rb
Ruby
mit
49
master
1,218
require 'spec_helper' module Alf class Renderer describe YAML do describe 'the class itself' do subject{ YAML } it_should_behave_like "a Renderer class" end subject{ YAML.new(input).execute('') } describe "execute" do let(:input){ Relation(id: [1, 2]) } ...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-io/renderer/class/test_by_mime_type.rb
Ruby
mit
49
master
723
require 'spec_helper' module Alf describe Renderer, ".by_mime_type" do context 'when mime type is unrecognized' do subject{ Renderer.by_mime_type("no/suchone", [{id: "csv", name: "CSV"}]) } it 'should raise an error' do lambda{ subject }.should raise_error(Uns...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-io/renderer/text/test_cell.rb
Ruby
mit
49
master
1,209
require 'spec_helper' module Alf class Renderer::Text describe Cell do let(:f){ Cell.new } specify "text_rendering" do Cell.new(100).text_rendering.should == "100" Cell.new(:hello).text_rendering.should == ":hello" Cell.new("hello").text_rendering.should == "hello" ...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-io/renderer/text/test_table.rb
Ruby
mit
49
master
1,052
require 'spec_helper' module Alf class Renderer::Text describe Table do let(:columns){ [ :method, :total ] } let(:table){ Table.new(records, columns) } describe "on an empty table" do let(:records){ [ ] } specify "to_s" do table.to_s.should == "+---------+-----...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-io/renderer/text/test_row.rb
Ruby
mit
49
master
658
require 'spec_helper' module Alf class Renderer::Text describe Row do let(:row){ Row.new(values) } describe "when single values are used only" do let(:values){ [ 10/3.0, true ] } specify "rendering_lines" do row.rendering_lines.should == ["| 3.333 | true |"] ...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-io/shared_examples/a_renderer_class.rb
Ruby
mit
49
master
545
shared_examples_for "a Renderer class" do it 'should be a subclass of Renderer' do subject.ancestors.should include(Alf::Renderer) end it "has a default mime type" do subject.should respond_to(:mime_type) end describe "an instance" do let(:renderer){ subject.new([{id: 1}]) } it 'renders an...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-io/shared_examples/a_reader_class.rb
Ruby
mit
49
master
444
shared_examples_for "a Reader class" do it 'should be a subclass of Reader' do described_class.ancestors.should include(Alf::Reader) end it "has a default mime type" do described_class.should respond_to(:mime_type) end describe "an instance" do let(:reader){ described_class.new(StringIO.new("")...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-adapter-fs/folder/test_adapter_class.rb
Ruby
mit
49
master
481
require 'spec_helper' module Alf class Adapter describe Folder do let(:adapter_class){ Folder } let(:recognized_conn_specs) do [ File.dirname(__FILE__), Path.dir ] end it_should_behave_like "an adapter class" describe "recognizes?" do it 'is not be too permissive...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-adapter-fs/folder/test_adapter_instance.rb
Ruby
mit
49
master
389
require 'spec_helper' module Alf class Adapter describe Folder, "an instance" do let(:adapter){ Folder.new(Path.dir/"fixtures") } let(:readable_cogs){ [ "suppliers.rash", "suppliers" ] } it_should_behave_like "an adapter" it_should_behave_like "an adapter with readable cog...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-database/options/test_new.rb
Ruby
mit
49
master
1,719
require 'spec_helper' module Alf class Database describe Options, "install_options_from_hash" do let(:viewpoint){ Module.new{ include Viewpoint } } subject{ Options.new(h) } context 'when valid, coercable options with viewpoint' do let(:h){ {schema_cache: "false", viewpoint: viewpoint...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-database/options/test_parser.rb
Ruby
mit
49
master
403
require 'spec_helper' module Alf class Database describe Options, "parser" do subject{ opts.parser } let(:opts){ Options.new } context 'by default' do it { should be(Lang::Parser::Lispy) } end context 'when explicitely set' do before{ opts.parser = Lang::Parser::...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-database/options/test_merge.rb
Ruby
mit
49
master
511
require 'spec_helper' module Alf class Database describe Options, "merge" do let(:opts){ Options.new(schema_cache: true) } subject{ opts.merge(schema_cache: false) } it{ should be_a(Options) } it 'is not the original' do subject.should_not be(opts) end it 'merges t...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-database/options/test_schema_cache.rb
Ruby
mit
49
master
529
require 'spec_helper' module Alf class Database describe Options, "schema_cache?" do subject{ opts.schema_cache? } let(:opts){ Options.new } context 'by default' do it { should eq(true) } end context 'when explicitely set' do before{ opts.schema_cache = false } ...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-database/options/test_viewpoint.rb
Ruby
mit
49
master
437
require 'spec_helper' module Alf class Database describe Options, "viewpoint" do subject{ opts.viewpoint } let(:opts){ Options.new } context 'by default' do it { should be(Viewpoint::NATIVE) } end context 'when explicitely set' do let(:mod){ Module.new{ include A...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-database/options/test_freeze.rb
Ruby
mit
49
master
384
require 'spec_helper' module Alf class Database describe Options, "freeze" do let(:opts){ Options.new(schema_cache: true) } subject{ opts.freeze } it{ should be(opts) } it 'should prevent further modifications' do lambda{ subject.schema_cache = false }.should ...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-database/database/test_default_options.rb
Ruby
mit
49
master
310
require 'spec_helper' module Alf describe Database, 'default_options' do subject{ Database.new(Path.dir) } it_should_behave_like "a facade on database options" it 'should allow default options to be consulted' do subject.default_options.should be_a(Database::Options) end end end
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-database/database/test_connect.rb
Ruby
mit
49
master
951
require 'spec_helper' module Alf describe Database, 'connect' do context 'without a block' do subject{ Database.connect(Path.dir) } it{ should be_a(Database::Connection) } it 'should not be closed' do subject.should_not be_closed end end context 'with a block' do ...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-database/database/test_connection.rb
Ruby
mit
49
master
403
require 'spec_helper' module Alf describe Database, 'connection' do let(:db){ Database.new(Path.dir) } subject{ db.connection } after do subject.close end it{ should be_a(Database::Connection) } it 'sets a copy of the original options' do subject.options.should be_a(Database::...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-database/database/test_new.rb
Ruby
mit
49
master
1,165
require 'spec_helper' module Alf describe Database, '.new' do let(:adapter){ Adapter.new(nil) } after do subject.adapter.should be_a(Adapter) end context 'on a single adapter' do subject{ Database.new(adapter) } it 'uses the specified adapter' do subject.adapter.should be...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-database/connection/test_query.rb
Ruby
mit
49
master
418
require 'spec_helper' module Alf class Database describe Connection, "query" do let(:conn){ sap_conn } context 'with a leaf operand' do subject{ conn.query{ suppliers } } it{ should be_a(Relation) } end context 'with a complex expression' do subject{ conn.query{...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-database/connection/test_migrate.rb
Ruby
mit
49
master
457
require 'spec_helper' module Alf class Database describe Connection, "migrate" do let(:conn){ Connection.new(self){|opts| @original_opts = opts; self } } subject{ conn.migrate! } def migrate!(opts) @seen_opts = opts end before do @seen_opts = nil ...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-database/connection/test_lock.rb
Ruby
mit
49
master
364
require 'spec_helper' module Alf class Database describe Connection, "lock" do let(:conn){ sap_conn } context 'with a Symbol' do subject{ conn.lock(:suppliers, :exclusive){ @seen = true } } it 'delegates to the underlying connection' do subject @seen.should be_tr...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-database/connection/test_reconnect.rb
Ruby
mit
49
master
874
require 'spec_helper' module Alf class Database describe Connection, "reconnect" do let(:connection_handler){ ->(opts){ self } } let(:conn){ Connection.new(self, &connection_handler) } subject{ conn.reconnect(opts) } def close @closed = true end before do c...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-database/connection/test_options.rb
Ruby
mit
49
master
311
require 'spec_helper' module Alf class Database describe Connection, "options" do subject{ sap_conn } it_should_behave_like "a facade on database options" it 'should allow options to be consulted' do subject.options.should be_a(Database::Options) end end end end
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-database/connection/test_tuple_extract.rb
Ruby
mit
49
master
877
require 'spec_helper' module Alf class Database describe Connection, "tuple_extract" do let(:conn){ sap_conn } context 'when more than one tuple' do subject{ conn.tuple_extract{ suppliers } } it 'raises a NoSuchTupleError' do lambda{ subject }.should ...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-database/connection/test_fact.rb
Ruby
mit
49
master
1,108
require 'spec_helper' module Alf class Database describe Connection, "fact!" do let(:conn){ sap_conn } context 'when more than one tuple' do subject{ conn.fact!{ suppliers } } it 'raises a FactAssertionError' do lambda{ subject }.should raise_error(Fa...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-database/connection/test_parse.rb
Ruby
mit
49
master
1,483
require 'spec_helper' module Alf class Database describe Connection, "parse" do let(:conn){ sap_conn } shared_examples_for 'a named operand on suppliers' do it{ should be_a(Algebra::Operand::Named) } it 'has the expected name' do subject.name.should eq(:suppliers) ...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-database/connection/test_deny.rb
Ruby
mit
49
master
779
require 'spec_helper' module Alf class Database describe Connection, "deny!" do let(:conn){ sap_conn } context 'with the result is not empty' do subject{ conn.deny!{ suppliers } } it 'raises a AssertionError' do lambda{ subject }.should raise_error(Fa...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-database/connection/test_relvar.rb
Ruby
mit
49
master
753
require 'spec_helper' module Alf class Database describe Connection, "relvar" do let(:conn){ sap_conn } context 'with a leaf operand' do subject{ conn.relvar{ suppliers } } it{ should be_a(Relvar::Base) } it 'has the expected name' do subject.expr.name.should eq(:...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-database/connection/test_new.rb
Ruby
mit
49
master
395
require 'spec_helper' module Alf class Database describe Connection, "new" do let(:connection_handler){ ->(opts){ "a connection" } } subject{ Connection.new(self, &connection_handler) } it 'should open the physical connection right away' do subject.should_not be_closed subject...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-database/connection/test_close.rb
Ruby
mit
49
master
510
require 'spec_helper' module Alf class Database describe Connection, "close" do let(:connection_handler){ ->(opts){ self } } let(:conn){ Connection.new(self, &connection_handler) } subject{ conn.close } def close @seen = true end it 'should close the physical conne...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-database/connection/test_assert.rb
Ruby
mit
49
master
808
require 'spec_helper' module Alf class Database describe Connection, "assert!" do let(:conn){ sap_conn } context 'with the result is not empty' do subject{ conn.assert!{ suppliers } } it{ should be_true } end context 'with the result is empty' do subject{ conn.a...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-relation/tuple/test_to_attr_list.rb
Ruby
mit
49
master
222
require 'spec_helper' module Alf describe Tuple, "to_attr_list" do subject{ tuple.to_attr_list } let(:tuple){ Tuple.coerce(name: "Smith", status: 12) } it{ should eq(AttrList[:name, :status]) } end end
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-relation/tuple/test_remap.rb
Ruby
mit
49
master
245
require 'spec_helper' module Alf module Types describe Tuple, "remap" do let(:tuple){ Tuple(id: 10, name: "Alf") } subject{ tuple.remap{|k,v| v.to_s.length} } it { should eq(Tuple(id: 2, name: 3)) } end end end
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-relation/tuple/test_triple_equal.rb
Ruby
mit
49
master
808
require 'spec_helper' module Alf describe Tuple, "===" do subject{ type === tuple } context 'when applied to a most specific tuple than declared' do let(:type){ Tuple[price: Float] } let(:tuple){ type.new(price: 12.0) } it{ should be_true } end contex...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-relation/tuple/test_attribute_accessors.rb
Ruby
mit
49
master
869
require 'spec_helper' module Alf module Types describe Tuple, "attribute accessors" do context 'when no conflict' do let(:tuple){ Tuple(:id => 1, :name => "Alf") } it 'has expected accessors' do tuple.id.should eq(1) tuple.name.should eq("Alf") end it '...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-relation/tuple/test_hash.rb
Ruby
mit
49
master
563
require 'spec_helper' module Alf describe Tuple, 'hash' do let(:tuple){ Tuple[id: Integer].new(id: 12) } subject{ tuple.hash == other.hash } context 'on purely equal tuple' do let(:other){ Tuple[id: Integer].new(id: 12) } it{ should be_true } end context 'on equal tuple but a subt...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-relation/tuple/test_project.rb
Ruby
mit
49
master
362
require 'spec_helper' module Alf module Types describe Tuple, "project" do let(:tuple){ Tuple(:id => 1, :name => "Alf") } subject{ tuple.project([:name]) } it { should eq(Tuple(:name => "Alf")) } it 'does not create nil for missing entries' do tuple.project([:none]).should eq(T...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-relation/tuple/test_merge.rb
Ruby
mit
49
master
500
require 'spec_helper' module Alf module Types describe Tuple, "merge" do let(:tuple){ Tuple(id: 10, name: "Smith") } subject{ tuple.merge(other) } context 'without name clash' do let(:other){ Tuple(status: 30) } it{ should eq(Tuple(id: 10, name: "Smith", status: 30)) } ...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-relation/tuple/test_rename.rb
Ruby
mit
49
master
269
require 'spec_helper' module Alf module Types describe Tuple, "rename" do let(:tuple){ Tuple(:id => 1, :name => "Alf") } subject{ tuple.rename(:name => :first_name) } it { should eq(Tuple(:id => 1, :first_name => "Alf")) } end end end
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-relation/tuple/test_extend.rb
Ruby
mit
49
master
648
require 'spec_helper' module Alf module Types describe Tuple, "extend" do let(:tuple){ Tuple(id: 1, name: "Alf") } context 'without name clash' do subject{ tuple.extend(up: lambda{ name.upcase }) } it { should eq(Tuple(id: 1, name: "Alf", up: "ALF")) } end ...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-relation/tuple/test_allbut.rb
Ruby
mit
49
master
233
require 'spec_helper' module Alf module Types describe Tuple, "allbut" do let(:tuple){ Tuple(:id => 1, :name => "Alf") } subject{ tuple.allbut([:name]) } it { should eq(Tuple(:id => 1)) } end end end
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-relation/tuple/test_split.rb
Ruby
mit
49
master
524
require 'spec_helper' module Alf describe Tuple, "split" do let(:tuple){ Tuple(a: 1, b: 2, c: 3) } subject{ tuple.split(list) } context 'with the whole list' do let(:list){ [:a, :b, :c] } it{ should eq([ tuple, Tuple::EMPTY ]) } end context 'with a sublist' do let(:list){ [...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-relation/tuple/test_equality.rb
Ruby
mit
49
master
557
require 'spec_helper' module Alf describe Tuple, 'equality' do let(:tuple){ Tuple[id: Integer].new(id: 12) } subject{ tuple == other } context 'on purely equal tuple' do let(:other){ Tuple[id: Integer].new(id: 12) } it{ should be_true } end context 'on equal tuple but a subtype' d...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-relation/tuple/test_heading.rb
Ruby
mit
49
master
452
require 'spec_helper' module Alf describe Tuple, "heading" do subject{ tuple.heading } describe 'on a tuple factored through an explicit type' do let(:tuple){ Tuple[status: Integer].new(status: 12) } it{ should eq(Heading.new(status: Integer)) } end describe 'on a tuple factored throug...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-relation/tuple/class/test_type.rb
Ruby
mit
49
master
581
require 'spec_helper' module Alf describe Tuple, '.type' do let(:heading){ {name: String, status: Integer} } subject{ Tuple.type(heading) } it 'returns a subclass' do subject.should be_a(Class) subject.superclass.should be(Alf::Tuple) end it 'coerces the heading' do subject.he...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-relation/tuple/class/test_coerce.rb
Ruby
mit
49
master
569
require 'spec_helper' module Alf module Types describe Tuple, '.coerce' do subject{ Tuple.coerce(arg) } let(:expected){ Tuple[name: String].new(:name => "bla") } context 'on self' do let(:arg){ expected } it { should be(expected) } end context 'on a Tuple' do ...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-relation/tuple/factored-types/test_comparisons.rb
Ruby
mit
49
master
1,622
require 'spec_helper' module Alf describe Tuple, '<=>' do let(:type) { Tuple[name: String, status: Integer] } let(:supertype){ Tuple[name: String, status: Numeric] } let(:subtype) { Tuple[name: String, status: Fixnum] } subject{ type <=> other } context 'on something else' do let(:o...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-relation/tuple/factored-types/test_rename.rb
Ruby
mit
49
master
242
require 'spec_helper' module Alf describe Tuple, 'rename' do let(:type){ Tuple[name: String, status: Integer] } subject{ type.rename(name: :first_name) } it{ should eq(Tuple[first_name: String, status: Integer]) } end end
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-relation/tuple/factored-types/test_equality.rb
Ruby
mit
49
master
510
require 'spec_helper' module Alf describe Tuple, '.==' do let(:type){ Tuple[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){ Tuple[name: String, s...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-relation/tuple/factored-types/test_triple_equal.rb
Ruby
mit
49
master
1,425
require 'spec_helper' module Alf describe Tuple, '===' do let(:type){ Tuple[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.coerce(nam...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-relation/tuple/factored-types/test_allbut.rb
Ruby
mit
49
master
744
require 'spec_helper' module Alf describe Tuple, '.allbut' do let(:type){ Tuple[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/tuple/factored-types/test_split.rb
Ruby
mit
49
master
670
require 'spec_helper' module Alf describe Tuple, 'split' do let(:type){ Tuple[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([ Tuple[{}], ty...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-relation/tuple/factored-types/test_to_ruby_literal.rb
Ruby
mit
49
master
393
require 'spec_helper' module Alf describe Tuple, 'to_ruby_literal' do let(:type){ Tuple[name: String, status: Integer] } subject{ type.to_ruby_literal } it 'should be human friendly' do subject.should eq("Alf::Tuple[{:name => String, :status => Integer}]") end it 'should allow eval round...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-relation/tuple/factored-types/test_coerce.rb
Ruby
mit
49
master
2,448
require 'spec_helper' module Alf describe Tuple, '.coerce' do let(:type) { Tuple[name: String, status: Integer] } subject{ type.coerce(tuple) } context 'on single attributes' do let(:tuple){ {'name' => "Jones", 'status' => "20"} } it 'coerces the attributes' do subject.should eq(T...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-relation/tuple/factored-types/test_project.rb
Ruby
mit
49
master
754
require 'spec_helper' module Alf describe Tuple, '.project' do let(:type){ Tuple[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(Tuple::E...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-relation/relation/test_relops.rb
Ruby
mit
49
master
2,296
require 'spec_helper' module Alf describe Relation do let(:rel1){ Alf::Relation(sid: ['S1', 'S2', 'S3']) } let(:rel2){ Alf::Relation(sid: ['S5', 'S2']) } it 'should have all relational operators installed' do Algebra::Operator.each do |op| rel1.should respond_to(op.rubycase_name) ...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-relation/relation/test_hash.rb
Ruby
mit
49
master
599
require 'spec_helper' module Alf describe Relation, 'hash' do let(:tuple){ Relation[id: Integer].coerce(id: 12) } subject{ tuple.hash == other.hash } context 'on purely equal relation' do let(:other){ Relation[id: Integer].coerce(id: 12) } it{ should be_true } end context 'on equa...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-relation/relation/test_keys.rb
Ruby
mit
49
master
271
require 'spec_helper' module Alf describe "Relation#keys" do let(:rel){ Relation([ {:max => 2, :name => "Jones"}, {:max => 7.3, :name => "Jones"}, ]) } subject{ rel.keys } it{ should eq(Keys[[:max, :name]]) } end end
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-relation/relation/test_aggregation.rb
Ruby
mit
49
master
618
require 'spec_helper' module Alf describe Relation, "aggregation methods" do let(:rel){ Alf::Relation(qty: [1, 2, 3, 4]) } it "avg" do rel.avg{ qty }.should eq(2.5) end it "collect", :ruby19 => true do rel.collect{ qty }.should eq([1, 2, 3, 4]) end it "concat", :ruby19 => true ...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-relation/relation/test_sugar.rb
Ruby
mit
49
master
905
require 'spec_helper' module Alf describe Relation, '[]' do let(:rel){ Alf::Relation(sid: 'S1', sname: "Jones", city: "London") } context 'as a selection' do subject{ rel[:pid => :sid] } let(:expected){ Alf::Relation(pid: 'S1') } it{ should eq(expected) } end context 'as a selec...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-relation/relation/test_inspect.rb
Ruby
mit
49
master
347
require 'spec_helper' module Alf describe Relation do let(:rel){Relation.coerce([ {:sid => 'S1'}, {:sid => 'S2'}, {:sid => 'S3'} ])} describe "inspect" do it "should allows the litteral round-trip" do Kernel.eval(rel.inspect).should == rel end en...
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-relation/relation/test_to_relation.rb
Ruby
mit
49
master
257
require 'spec_helper' module Alf describe "Relation#to_relation" do let(:rel){ Relation(:sid => ['S1', 'S2', 'S3']) } subject{ rel.to_relation } it 'should return self' do subject.object_id.should eq(rel.object_id) end end end
github
alf-tool/alf-core
https://github.com/alf-tool/alf-core
spec/unit/alf-relation/relation/test_to_hash.rb
Ruby
mit
49
master
1,103
require 'spec_helper' module Alf describe "Relation#to_hash" do let(:rel){ Alf::Relation([ {sid: 'S1', name: 'Jones', city: 'London', status: 20}, {sid: 'S2', name: 'Blake', city: 'London', status: 20}, ]) } specify "with :sid => :name" do rel.to_hash(:sid => :name).sho...