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
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/integration/database_test.rb
Ruby
mit
5,086
master
5,657
# frozen_string_literal: true require_relative "../adapters/spec_helper" describe Sequel::Database do before do @db = DB end it "should provide disconnect functionality" do @db.disconnect @db.pool.size.must_equal 0 @db.test_connection @db.pool.size.must_equal 1 end it "should provide di...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/integration/associations_test.rb
Ruby
mit
5,086
master
135,479
# frozen_string_literal: true require_relative "../adapters/spec_helper" one_to_one_eager_limit_strategies = Module.new do extend Minitest::Spec::DSL it "eager loading one_to_one associations should work correctly" do Artist.one_to_one :first_album, {:clone=>:first_album}.merge(@els) if @els Artist.one_to...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/integration/model_test.rb
Ruby
mit
5,086
master
6,098
# frozen_string_literal: true require_relative "../adapters/spec_helper" describe "Sequel::Model basic support" do before do @db = DB @db.create_table!(:items, :engine=>:InnoDB) do primary_key :id String :name end class ::Item < Sequel::Model(@db) end end after do @db.drop_ta...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/integration/schema_test.rb
Ruby
mit
5,086
master
43,003
# frozen_string_literal: true require_relative "../adapters/spec_helper" describe "Database schema parser" do after do DB.drop_table?(:items) end describe "with identifier mangling" do before do @iom = DB.identifier_output_method @iim = DB.identifier_input_method @qi = DB.quote_identif...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/integration/timezone_test.rb
Ruby
mit
5,086
master
2,923
# frozen_string_literal: true require_relative "../adapters/spec_helper" describe "Sequel timezone support" do def _test_timezone(timezone=Sequel.application_timezone) Sequel.datetime_class = Time # Tests should cover both DST and non-DST times. [Time.now, Time.local(2010,1,1,12), Time.local(2010,6,1,12)...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/integration/type_test.rb
Ruby
mit
5,086
master
4,659
# frozen_string_literal: true require_relative "../adapters/spec_helper" describe "Supported types" do def create_items_table_with_column(name, type, opts={}) DB.create_table!(:items){column name, type, opts} DB[:items] end after(:all) do DB.drop_table?(:items) end it "should support casting co...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/integration/prepared_statement_test.rb
Ruby
mit
5,086
master
23,089
# frozen_string_literal: true require_relative "../adapters/spec_helper" describe "Prepared Statements and Bound Arguments" do before do @db = DB @db.create_table!(:items) do primary_key :id integer :numb end @c = Class.new(Sequel::Model(:items)) @ds = @db[:items] @ds.insert(:numb...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/integration/eager_loader_test.rb
Ruby
mit
5,086
master
24,671
# frozen_string_literal: true require_relative "../adapters/spec_helper" describe "Eagerly loading a tree structure" do before(:all) do DB.instance_variable_get(:@schemas).clear DB.create_table!(:nodes) do primary_key :id foreign_key :parent_id, :nodes end class ::Node < Sequel::Model ...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/integration/migrator_test.rb
Ruby
mit
5,086
master
14,462
# frozen_string_literal: true require_relative "../adapters/spec_helper" Sequel.extension :migration describe Sequel::Migrator do before do @db = DB @m = Sequel::Migrator end after do @db.drop_table?(:schema_info, :schema_migrations, :sm1111, :sm1122, :sm2222, :sm2233, :sm3333, :sm11111, :sm22222, :a...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/integration/dataset_test.rb
Ruby
mit
5,086
master
106,057
# frozen_string_literal: true require_relative "../adapters/spec_helper" describe "Simple Dataset operations" do before do @db = DB @db.create_table!(:items) do primary_key :id Integer :number end @ds = @db[:items] @ds.insert(:number=>10) @ds = @ds.async if async? end after do...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/adapters/sqlite_spec.rb
Ruby
mit
5,086
master
47,047
# frozen_string_literal: true SEQUEL_ADAPTER_TEST = :sqlite require_relative 'spec_helper' describe "An SQLite database" do before do @db = DB end after do @db.drop_table?(:fk) @db.use_timestamp_timezones = false Sequel.datetime_class = Time end it "should unescape escaped paths in URI for ...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/adapters/mysql_spec.rb
Ruby
mit
5,086
master
42,053
# frozen_string_literal: true SEQUEL_ADAPTER_TEST = :mysql require_relative 'spec_helper' describe "MySQL", '#create_table' do before do @db = DB @db.test_connection end after do @db.drop_table?(:dolls) end it "should create a temporary table" do @db.disconnect @db.create_table(:tmp_dol...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/adapters/mssql_spec.rb
Ruby
mit
5,086
master
33,044
# frozen_string_literal: true SEQUEL_ADAPTER_TEST = :mssql require_relative 'spec_helper' describe "A MSSQL database" do before do @db = DB end it "should be able to read fractional part of timestamp" do rs = @db["select getutcdate() as full_date, cast(round(datepart(millisecond, getutcdate()), 0) as i...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/adapters/oracle_spec.rb
Ruby
mit
5,086
master
15,115
# frozen_string_literal: true SEQUEL_ADAPTER_TEST = :oracle require_relative 'spec_helper' unless DB.opts[:autosequence] warn "Running oracle adapter specs without :autosequence Database option results in many errors, use the :autosequence Database option when testing" end describe "An Oracle database" do before...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/adapters/spec_helper.rb
Ruby
mit
5,086
master
3,569
# frozen_string_literal: true if ENV['COVERAGE'] require_relative "../sequel_coverage" SimpleCov.sequel_coverage(:group=>%r{lib/sequel/adapters}) end $:.unshift(File.join(File.dirname(File.expand_path(__FILE__)), "../../lib/")) require_relative "../../lib/sequel" begin require_relative "../spec_config" unless d...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/adapters/sqlanywhere_spec.rb
Ruby
mit
5,086
master
2,966
# frozen_string_literal: true SEQUEL_ADAPTER_TEST = :sqlanywhere require_relative 'spec_helper' describe "convert_smallint_to_bool" do before do @db = DB @ds = @db[:booltest] end after do @db.convert_smallint_to_bool = true end describe "Database#convert_smallint_to_bool" do before do ...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/adapters/db2_spec.rb
Ruby
mit
5,086
master
4,914
# frozen_string_literal: true SEQUEL_ADAPTER_TEST = :db2 require_relative 'spec_helper' if DB.table_exists?(:test) DB.drop_table(:test) end describe Sequel::Database do before do @db = DB @db.create_table(:test){String :a} @ds = @db[:test] end after do @db.drop_table(:test) end it "sh...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/model/class_dataset_methods_spec.rb
Ruby
mit
5,086
master
9,093
# frozen_string_literal: true require_relative "spec_helper" describe Sequel::Model, "class dataset methods" do before do @db = Sequel.mock @c = Class.new(Sequel::Model(@db[:items].with_extend{def supports_cte?(*) true end}.with_fetch(:id=>1).with_autoid(1).with_numrows(0))) @d = @c.dataset @db.sqls...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/model/spec_helper.rb
Ruby
mit
5,086
master
1,527
# frozen_string_literal: true $:.unshift(File.join(File.dirname(File.expand_path(__FILE__)), "../../lib/")) require_relative "../../lib/sequel" Sequel::Deprecation.backtrace_filter = lambda{|line, lineno| lineno < 4 || line =~ /_spec\.rb/} ENV['MT_NO_PLUGINS'] = '1' # Work around stupid autoloading of plugins gem 'mi...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/model/association_reflection_spec.rb
Ruby
mit
5,086
master
40,701
# frozen_string_literal: true require_relative "spec_helper" describe Sequel::Model::Associations::AssociationReflection, "#associated_class" do before do @c = Class.new(Sequel::Model(:foo)) class ::ParParent < Sequel::Model; end end after do Object.send(:remove_const, :ParParent) end it "should...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/model/eager_loading_spec.rb
Ruby
mit
5,086
master
207,281
# frozen_string_literal: true require_relative "spec_helper" describe Sequel::Model, "#eager" do before do class ::EagerAlbum < Sequel::Model(:albums) columns :id, :band_id many_to_one :band, :class=>'EagerBand', :key=>:band_id one_to_many :tracks, :class=>'EagerTrack', :key=>:album_id ma...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/model/dataset_methods_spec.rb
Ruby
mit
5,086
master
6,500
# frozen_string_literal: true require_relative "spec_helper" describe Sequel::Model::DatasetMethods, "#destroy" do before do @c = Class.new(Sequel::Model(:items)) do self::Destroyed = [] def destroy model::Destroyed << self end end @d = @c.dataset @d = @d.with_fetch([{:id=>...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/model/record_spec.rb
Ruby
mit
5,086
master
65,718
# frozen_string_literal: true require_relative "spec_helper" describe "Model#values" do before do @c = Class.new(Sequel::Model(:items)) end it "should return the hash of model values" do hash = {:x=>1} @c.load(hash).values.must_be_same_as(hash) end it "should be aliased as to_hash" do hash ...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/model/base_spec.rb
Ruby
mit
5,086
master
31,776
# frozen_string_literal: true require_relative "spec_helper" describe "Model attribute setters" do before do @c = Class.new(Sequel::Model(:items)) do columns :id, :x, :y, :"x y" end @o = @c.new DB.reset end it "refresh should return self" do @o = @c[1] def @o._refresh(*) [] end ...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/model/plugins_spec.rb
Ruby
mit
5,086
master
15,689
# frozen_string_literal: true require_relative "spec_helper" describe Sequel::Model, ".plugin" do before do module Sequel::Plugins module Timestamped module InstanceMethods def get_stamp(*args); @values[:stamp] end def abc; 123; end end module ClassMetho...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/model/hooks_spec.rb
Ruby
mit
5,086
master
11,712
# frozen_string_literal: true require_relative "spec_helper" describe "Model#before_create && Model#after_create" do before do @c = Class.new(Sequel::Model(:items)) do columns :x set_primary_key :x unrestrict_primary_key def after_create DB << "BLAH after" end end...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/model/exceptions_spec.rb
Ruby
mit
5,086
master
744
# frozen_string_literal: true require_relative "spec_helper" describe Sequel::MassAssignmentRestriction, "#create" do it "should set model attr" do model_cls = Class.new model = model_cls.new err = Sequel::MassAssignmentRestriction.create("method foo doesn't exist", model, "foo") err.message.must_i...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/model/model_spec.rb
Ruby
mit
5,086
master
31,986
# frozen_string_literal: true require_relative "spec_helper" describe "Sequel::Model()" do before do @db = Sequel::Model.db end it "should return a model with a temporary name" do m = Sequel::Model(:blah) m.name.must_equal "Sequel::_Model(:blah)" m.send(:dataset_methods_module).name.must_equal "...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/model/validations_spec.rb
Ruby
mit
5,086
master
6,660
# frozen_string_literal: true require_relative "spec_helper" describe Sequel::Model::Errors do before do @errors = Sequel::Model::Errors.new end it "should be clearable using #clear" do @errors.add(:a, 'b') @errors.must_equal(:a=>['b']) @errors.clear @errors.must_equal({}) end it "s...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/model/inflector_spec.rb
Ruby
mit
5,086
master
3,262
# frozen_string_literal: true require_relative "spec_helper" describe Sequel::Inflections do before do @plurals, @singulars, @uncountables = Sequel.inflections.plurals.dup, Sequel.inflections.singulars.dup, Sequel.inflections.uncountables.dup end after do Sequel.inflections.plurals.replace(@plurals) ...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/core/spec_helper.rb
Ruby
mit
5,086
master
897
# frozen_string_literal: true if ENV['COVERAGE'] require_relative "../sequel_coverage" SimpleCov.sequel_coverage(:filter=>%r{lib/sequel/(\w+\.rb|(dataset|database|model|connection_pool)/\w+\.rb|adapters/mock\.rb)\z}) end $:.unshift(File.join(File.dirname(File.expand_path(__FILE__)), "../../lib/")) require_relative...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/core/schema_generator_spec.rb
Ruby
mit
5,086
master
9,724
# frozen_string_literal: true require_relative "spec_helper" describe Sequel::Schema::CreateTableGenerator do before do @generator = Sequel::Schema::CreateTableGenerator.new(Sequel.mock) do string(:title).must_be_nil column(:body, :text).must_be_nil foreign_key(:parent_id).must_be_nil pri...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/core/object_graph_spec.rb
Ruby
mit
5,086
master
27,932
# frozen_string_literal: true require_relative "spec_helper" describe Sequel::Dataset do before do @db = Sequel.mock(:columns=>proc do |sql| case sql when /points/ [:id, :x, :y] when /lines|foo/ [:id, :x, :y, :graph_id] else [:id, :name, :x, :y, :lines_x] end...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/core/mock_adapter_spec.rb
Ruby
mit
5,086
master
49,358
# frozen_string_literal: true require_relative "spec_helper" describe "Sequel Mock Adapter" do it "should have an adapter method" do db = Sequel.mock db.must_be_kind_of(Sequel::Mock::Database) db.adapter_scheme.must_equal :mock end it "should support registering mock adapter type" do begin ...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/core/version_spec.rb
Ruby
mit
5,086
master
461
# frozen_string_literal: true require_relative "spec_helper" describe "Sequel.version" do it "should be in the form X.Y.Z with all being numbers" do Sequel.version.must_match(/\A\d+\.\d+\.\d+\z/) end it "MAJOR/MINOR/TINY/VERSION_NUMBER should be integers" do Sequel::MAJOR.must_be_kind_of(Integer) Se...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/core/database_spec.rb
Ruby
mit
5,086
master
138,806
# frozen_string_literal: true require_relative "spec_helper" describe "A new Database" do before do @db = Sequel::Database.new(1 => 2, :logger => 3) end it "should not allow dup/clone" do proc{@db.dup}.must_raise NoMethodError proc{@db.clone}.must_raise NoMethodError end it "should receive op...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/core/connection_pool_spec.rb
Ruby
mit
5,086
master
53,733
# frozen_string_literal: true require_relative "spec_helper" require_relative '../../lib/sequel/connection_pool/sharded_threaded' connection_pool_defaults = {:pool_class=>:threaded, :pool_timeout=>5, :max_connections=>4} st_connection_pool_defaults = connection_pool_defaults.merge(:pool_class=>:single, :single_threade...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/core/expression_filters_spec.rb
Ruby
mit
5,086
master
67,136
# frozen_string_literal: true require_relative "spec_helper" describe "Blockless Ruby Filters" do before do db = Sequel.mock @d = db[:items].with_extend do def l(*args, &block) literal(filter_expr(*args, &block)) end def lit(*args) literal(*args) end end end ...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/core/placeholder_literalizer_spec.rb
Ruby
mit
5,086
master
7,372
# frozen_string_literal: true require_relative "spec_helper" describe "Dataset::PlaceholderLiteralizer" do before do @c = Sequel::Dataset::PlaceholderLiteralizer @db = Sequel.mock @ds = @db[:items] @h = {:id=>1} @ds.db.fetch = @h end it "should handle calls with no placeholders" do loa...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/core/schema_spec.rb
Ruby
mit
5,086
master
96,922
# frozen_string_literal: true require_relative "spec_helper" [nil, :postgres].each do |database_type| describe "DB#{"(#{database_type})" if database_type}" do before do if database_type == :postgres @db = Sequel.mock(:host=>"postgres") @db.extension :identifier_mangling @db.quote_id...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
spec/core/deprecated_spec.rb
Ruby
mit
5,086
master
1,915
# frozen_string_literal: true require_relative "spec_helper" describe "Sequel::Deprecated" do before do @d = Sequel::Deprecation @prev_prefix = @d.prefix @prev_output = @d.output @prev_backtrace_filter = @d.backtrace_filter @output = [] def @output.puts(s) self << s end @d.prefi...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
fast_jsonapi.gemspec
Ruby
apache-2.0
5,038
master
1,796
lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "fast_jsonapi/version" Gem::Specification.new do |gem| gem.name = "fast_jsonapi" gem.version = FastJsonapi::VERSION gem.required_ruby_version = '>= 2.0.0' if gem.respond_to? :required_ruby_version= gem.requ...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
spec/spec_helper.rb
Ruby
apache-2.0
5,038
master
785
require 'active_record' require 'fast_jsonapi' require 'rspec-benchmark' require 'byebug' require 'active_model_serializers' require 'oj' require 'jsonapi/serializable' require 'jsonapi-serializers' Dir[File.dirname(__FILE__) + '/shared/contexts/*.rb'].each {|file| require file } Dir[File.dirname(__FILE__) + '/shared/...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
spec/shared/contexts/movie_context.rb
Ruby
apache-2.0
5,038
master
10,737
RSpec.shared_context 'movie class' do # Movie, Actor Classes and serializers before(:context) do # models class Movie attr_accessor :id, :name, :release_year, :director, :actor_ids, :owner_id, ...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
spec/shared/contexts/js_context.rb
Ruby
apache-2.0
5,038
master
2,412
RSpec.shared_context 'jsonapi-serializers movie class' do before(:context) do # models class JSMovie attr_accessor :id, :name, :release_year, :actors, :owner, :movie_type end class JSActor attr_accessor :id, :name, :email end class JSUser attr_accessor :id, :name end ...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
spec/shared/contexts/jsonapi_group_context.rb
Ruby
apache-2.0
5,038
master
2,851
RSpec.shared_context 'jsonapi group class' do # Person, Group Classes and serializers before(:context) do # models class JSONAPIPerson attr_accessor :id, :first_name, :last_name end class JSONAPIGroup attr_accessor :id, :name, :groupees # Let's assume groupees can be Person or Group ob...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
spec/shared/contexts/ams_group_context.rb
Ruby
apache-2.0
5,038
master
2,241
RSpec.shared_context 'ams group class' do before(:context) do # models class AMSPerson < ActiveModelSerializers::Model attr_accessor :id, :first_name, :last_name end class AMSGroup < ActiveModelSerializers::Model attr_accessor :id, :name, :groupees end # serializers class AMS...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
spec/shared/contexts/js_group_context.rb
Ruby
apache-2.0
5,038
master
2,678
RSpec.shared_context 'jsonapi-serializers group class' do # Person, Group Classes and serializers before(:context) do # models class JSPerson attr_accessor :id, :first_name, :last_name end class JSGroup attr_accessor :id, :name, :groupees # Let's assume groupees can be Person or Group ...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
spec/shared/contexts/group_context.rb
Ruby
apache-2.0
5,038
master
2,168
RSpec.shared_context 'group class' do # Person, Group Classes and serializers before(:context) do # models class Person attr_accessor :id, :first_name, :last_name end class Group attr_accessor :id, :name, :groupees # Let's assume groupees can be Person or Group objects end # s...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
spec/shared/contexts/jsonapi_context.rb
Ruby
apache-2.0
5,038
master
2,683
RSpec.shared_context 'jsonapi movie class' do before(:context) do # models class JSONAPIMovie attr_accessor :id, :name, :release_year, :actors, :owner, :movie_type end class JSONAPIActor attr_accessor :id, :name, :email end class JSONAPIUser attr_accessor :id, :name end...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
spec/shared/contexts/ams_context.rb
Ruby
apache-2.0
5,038
master
3,688
RSpec.shared_context 'ams movie class' do before(:context) do # models class AMSModel < ActiveModelSerializers::Model derive_attributes_from_names_and_fix_accessors end class AMSMovieType < AMSModel attributes :id, :name, :movies end class AMSMovie < AMSModel attributes :id,...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
spec/shared/examples/object_serializer_class_methods_examples.rb
Ruby
apache-2.0
5,038
master
900
RSpec.shared_examples 'returning correct relationship hash' do |serializer, id_method_name, record_type| it 'returns correct relationship hash' do expect(relationship).to be_instance_of(FastJsonapi::Relationship) # expect(relationship.keys).to all(be_instance_of(Symbol)) expect(relationship.serializer).to...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
spec/lib/object_serializer_spec.rb
Ruby
apache-2.0
5,038
master
19,263
require 'spec_helper' describe FastJsonapi::ObjectSerializer do include_context 'movie class' include_context 'group class' context 'when testing instance methods of object serializer' do it 'returns correct hash when serializable_hash is called' do options = {} options[:meta] = { total: 2 } ...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
spec/lib/object_serializer_fields_spec.rb
Ruby
apache-2.0
5,038
master
1,717
require 'spec_helper' describe FastJsonapi::ObjectSerializer do include_context 'movie class' let(:fields) do { movie: %i[name actors advertising_campaign], actor: %i[name agency] } end it 'only returns specified fields' do hash = MovieSerializer.new(movie, fields: fields).serializabl...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
spec/lib/object_serializer_attribute_param_spec.rb
Ruby
apache-2.0
5,038
master
3,870
require 'spec_helper' describe FastJsonapi::ObjectSerializer do include_context 'movie class' context "params option" do let(:hash) { serializer.serializable_hash } before(:context) do class Movie def viewed?(user) user.viewed.include?(id) end end class MovieS...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
spec/lib/object_serializer_inheritance_spec.rb
Ruby
apache-2.0
5,038
master
4,292
require 'spec_helper' describe FastJsonapi::ObjectSerializer do after(:all) do classes_to_remove = %i[ User UserSerializer Country CountrySerializer Employee EmployeeSerializer Photo PhotoSerializer EmployeeAccount ] classes_to_remove.each do |klass_...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
spec/lib/object_serializer_caching_spec.rb
Ruby
apache-2.0
5,038
master
2,750
require 'spec_helper' describe FastJsonapi::ObjectSerializer do include_context 'movie class' context 'when caching has_many' do before(:each) do rails = OpenStruct.new rails.cache = ActiveSupport::Cache::MemoryStore.new stub_const('Rails', rails) end it 'returns correct hash when s...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
spec/lib/object_serializer_class_methods_spec.rb
Ruby
apache-2.0
5,038
master
15,673
require 'spec_helper' describe FastJsonapi::ObjectSerializer do include_context 'movie class' describe '#has_many' do subject(:relationship) { serializer.relationships_to_serialize[:roles] } before do serializer.has_many *children end after do serializer.relationships_to_serialize =...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
spec/lib/object_serializer_polymorphic_spec.rb
Ruby
apache-2.0
5,038
master
1,246
require 'spec_helper' describe FastJsonapi::ObjectSerializer do class List attr_accessor :id, :name, :items end class ChecklistItem attr_accessor :id, :name end class Car attr_accessor :id, :model, :year end class ListSerializer include FastJsonapi::ObjectSerializer set_type :list ...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
spec/lib/object_serializer_relationship_param_spec.rb
Ruby
apache-2.0
5,038
master
2,094
require 'spec_helper' describe FastJsonapi::ObjectSerializer do include_context 'movie class' context "params option" do let(:hash) { serializer.serializable_hash } before(:context) do class MovieSerializer has_many :agencies do |movie, params| movie.actors.map(&:agency) if params...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
spec/lib/object_serializer_struct_spec.rb
Ruby
apache-2.0
5,038
master
1,664
require 'spec_helper' describe FastJsonapi::ObjectSerializer do include_context 'movie class' context 'when testing object serializer with ruby struct' do it 'returns correct hash when serializable_hash is called' do options = {} options[:meta] = { total: 2 } options[:links] = { self: 'self'...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
spec/lib/object_serializer_relationship_links_spec.rb
Ruby
apache-2.0
5,038
master
2,344
require 'spec_helper' describe FastJsonapi::ObjectSerializer do include_context 'movie class' context "params option" do let(:hash) { serializer.serializable_hash } context "generating links for a serializer relationship" do let(:params) { { } } let(:options_with_params) { { params: params }...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
spec/lib/object_serializer_performance_spec.rb
Ruby
apache-2.0
5,038
master
8,531
require 'spec_helper' describe FastJsonapi::ObjectSerializer, performance: true do include_context 'movie class' include_context 'ams movie class' include_context 'jsonapi movie class' include_context 'jsonapi-serializers movie class' include_context 'group class' include_context 'ams group class' inclu...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
spec/lib/serialization_core_spec.rb
Ruby
apache-2.0
5,038
master
3,177
require 'spec_helper' describe FastJsonapi::ObjectSerializer do include_context "movie class" include_context 'group class' context 'when testing class methods of serialization core' do it 'returns correct hash when id_hash is called' do inputs = [{id: 23, record_type: :movie}, {id: 'x', record_type: ...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
spec/lib/extensions/active_record_spec.rb
Ruby
apache-2.0
5,038
master
3,520
require 'spec_helper' require 'active_record' require 'sqlite3' describe 'active record' do # Setup DB before(:all) do @db_file = "test.db" # Open a database db = SQLite3::Database.new @db_file # Create tables db.execute_batch <<-SQL create table suppliers ( name varchar(30), ...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
spec/lib/instrumentation/as_notifications_negative_spec.rb
Ruby
apache-2.0
5,038
master
1,355
require 'spec_helper' describe FastJsonapi::ObjectSerializer do include_context 'movie class' context 'instrument' do before(:each) do options = {} options[:meta] = { total: 2 } options[:include] = [:actors] @serializer = MovieSerializer.new([movie, movie], options) end cont...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
spec/lib/instrumentation/as_notifications_spec.rb
Ruby
apache-2.0
5,038
master
2,259
require 'spec_helper' describe FastJsonapi::ObjectSerializer do include_context 'movie class' context 'instrument' do before(:all) do require 'fast_jsonapi/instrumentation' end after(:all) do [ :serialized_json, :serializable_hash ].each do |m| alias_command = "alias_method :#{m}...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
spec/lib/instrumentation/skylight/normalizers_require_spec.rb
Ruby
apache-2.0
5,038
master
376
require 'spec_helper' describe FastJsonapi::ObjectSerializer do context 'instrument' do context 'skylight' do # skip for normal runs because this could alter some # other test by insterting the instrumentation xit 'make sure requiring skylight normalizers works' do require 'fast_jsonap...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
spec/lib/multi_to_json/result_spec.rb
Ruby
apache-2.0
5,038
master
415
require 'spec_helper' module FastJsonapi module MultiToJson describe Result do it 'supports chaining of rescues' do expect do Result.new(LoadError) do require '1' end.rescue do require '2' end.rescue do require '3' end.resc...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
lib/fast_jsonapi.rb
Ruby
apache-2.0
5,038
master
227
# frozen_string_literal: true module FastJsonapi require 'fast_jsonapi/object_serializer' if defined?(::Rails) require 'fast_jsonapi/railtie' elsif defined?(::ActiveRecord) require 'extensions/has_one' end end
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
lib/extensions/has_one.rb
Ruby
apache-2.0
5,038
master
755
# frozen_string_literal: true ::ActiveRecord::Associations::Builder::HasOne.class_eval do # Based on # https://github.com/rails/rails/blob/master/activerecord/lib/active_record/associations/builder/collection_association.rb#L50 # https://github.com/rails/rails/blob/master/activerecord/lib/active_record/associati...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
lib/generators/serializer/serializer_generator.rb
Ruby
apache-2.0
5,038
master
491
# frozen_string_literal: true require 'rails/generators/base' class SerializerGenerator < Rails::Generators::NamedBase source_root File.expand_path('templates', __dir__) argument :attributes, type: :array, default: [], banner: 'field field' def create_serializer_file template 'serializer.rb.tt', File.join...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
lib/fast_jsonapi/relationship.rb
Ruby
apache-2.0
5,038
master
3,812
module FastJsonapi class Relationship attr_reader :key, :name, :id_method_name, :record_type, :object_method_name, :object_block, :serializer, :relationship_type, :cached, :polymorphic, :conditional_proc, :transform_method, :links, :lazy_load_data def initialize( key:, name:, id_method_name...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
lib/fast_jsonapi/link.rb
Ruby
apache-2.0
5,038
master
420
module FastJsonapi class Link attr_reader :key, :method def initialize(key:, method:) @key = key @method = method end def serialize(record, serialization_params, output_hash) output_hash[key] = if method.is_a?(Proc) method.arity == 1 ? method.call(record) : method.call(reco...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
lib/fast_jsonapi/attribute.rb
Ruby
apache-2.0
5,038
master
773
module FastJsonapi class Attribute attr_reader :key, :method, :conditional_proc def initialize(key:, method:, options: {}) @key = key @method = method @conditional_proc = options[:if] end def serialize(record, serialization_params, output_hash) if include_attribute?(record, s...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
lib/fast_jsonapi/multi_to_json.rb
Ruby
apache-2.0
5,038
master
2,731
# frozen_string_literal: true require 'logger' # Usage: # class Movie # def to_json(payload) # FastJsonapi::MultiToJson.to_json(payload) # end # end module FastJsonapi module MultiToJson # Result object pattern is from https://johnnunemaker.com/resilience-in-ruby/ # e.g. https://github.com...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
lib/fast_jsonapi/object_serializer.rb
Ruby
apache-2.0
5,038
master
11,201
# frozen_string_literal: true require 'active_support/time' require 'active_support/json' require 'active_support/concern' require 'active_support/inflector' require 'active_support/core_ext/numeric/time' require 'fast_jsonapi/attribute' require 'fast_jsonapi/relationship' require 'fast_jsonapi/link' require 'fast_jso...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
lib/fast_jsonapi/serialization_core.rb
Ruby
apache-2.0
5,038
master
6,481
# frozen_string_literal: true require 'active_support/concern' require 'fast_jsonapi/multi_to_json' module FastJsonapi MandatoryField = Class.new(StandardError) module SerializationCore extend ActiveSupport::Concern included do class << self attr_accessor :attributes_to_serialize, ...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
lib/fast_jsonapi/railtie.rb
Ruby
apache-2.0
5,038
master
230
# frozen_string_literal: true require 'rails/railtie' class Railtie < Rails::Railtie initializer 'fast_jsonapi.active_record' do ActiveSupport.on_load :active_record do require 'extensions/has_one' end end end
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
lib/fast_jsonapi/instrumentation/serializable_hash.rb
Ruby
apache-2.0
5,038
master
380
require 'active_support/notifications' module FastJsonapi module ObjectSerializer alias_method :serializable_hash_without_instrumentation, :serializable_hash def serializable_hash ActiveSupport::Notifications.instrument(SERIALIZABLE_HASH_NOTIFICATION, { name: self.class.name }) do serializabl...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
lib/fast_jsonapi/instrumentation/serialized_json.rb
Ruby
apache-2.0
5,038
master
370
require 'active_support/notifications' module FastJsonapi module ObjectSerializer alias_method :serialized_json_without_instrumentation, :serialized_json def serialized_json ActiveSupport::Notifications.instrument(SERIALIZED_JSON_NOTIFICATION, { name: self.class.name }) do serialized_json_wit...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
lib/fast_jsonapi/instrumentation/skylight/normalizers/serializable_hash.rb
Ruby
apache-2.0
5,038
master
597
require 'fast_jsonapi/instrumentation/skylight/normalizers/base' require 'fast_jsonapi/instrumentation/serializable_hash' module FastJsonapi module Instrumentation module Skylight module Normalizers class SerializableHash < SKYLIGHT_NORMALIZER_BASE_CLASS register FastJsonapi::ObjectSeria...
github
Netflix/fast_jsonapi
https://github.com/Netflix/fast_jsonapi
lib/fast_jsonapi/instrumentation/skylight/normalizers/serialized_json.rb
Ruby
apache-2.0
5,038
master
591
require 'fast_jsonapi/instrumentation/skylight/normalizers/base' require 'fast_jsonapi/instrumentation/serializable_hash' module FastJsonapi module Instrumentation module Skylight module Normalizers class SerializedJson < SKYLIGHT_NORMALIZER_BASE_CLASS register FastJsonapi::ObjectSeriali...
github
mbleigh/acts-as-taggable-on
https://github.com/mbleigh/acts-as-taggable-on
Guardfile
Ruby
mit
4,996
master
208
# frozen_string_literal: true guard :rspec, cmd: 'bin/rspec' do watch(%r{^spec/.+_spec\.rb}) watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" } watch('spec/spec_helper.rb') { "spec" } end
github
mbleigh/acts-as-taggable-on
https://github.com/mbleigh/acts-as-taggable-on
Appraisals
Ruby
mit
4,996
master
554
# frozen_string_literal: true appraise 'activerecord-7.1' do gem 'activerecord', '~> 7.1.0' gem 'pg' gem 'sqlite3', '~> 1.4' gem 'mysql2', '~> 0.5' end appraise 'activerecord-7.2' do gem 'activerecord', '~> 7.2.0' gem 'pg' gem 'sqlite3', '~> 2.2' gem 'mysql2', '~> 0.5' end appraise 'activerecord-8.0'...
github
mbleigh/acts-as-taggable-on
https://github.com/mbleigh/acts-as-taggable-on
Rakefile
Ruby
mit
4,996
master
472
require 'rubygems' require 'bundler/setup' import "./lib/tasks/tags_collate_utf8.rake" desc 'Default: run specs' task default: :spec desc 'Copy sample spec database.yml over if not exists' task :copy_db_config do cp 'spec/internal/config/database.yml.sample', 'spec/internal/config/database.yml' end task spec: [:c...
github
mbleigh/acts-as-taggable-on
https://github.com/mbleigh/acts-as-taggable-on
Gemfile
Ruby
mit
4,996
master
311
source 'https://rubygems.org' gemspec # Dev libs gem 'appraisal' gem 'barrier' gem 'byebug', platforms: [:mri] gem 'database_cleaner' gem 'rake' gem 'rspec' gem 'rspec-rails' gem 'rspec-its' # Fallback to sqlite3 in dev/local environment gem 'sqlite3' # Dev tools / linter gem 'guard-rspec', require: false
github
mbleigh/acts-as-taggable-on
https://github.com/mbleigh/acts-as-taggable-on
acts-as-taggable-on.gemspec
Ruby
mit
4,996
master
1,169
require_relative 'lib/acts-as-taggable-on/version' Gem::Specification.new do |gem| gem.name = 'acts-as-taggable-on' gem.version = ActsAsTaggableOn::VERSION gem.authors = ['Michael Bleigh', 'Joost Baaij'] gem.email = %w(michael@intridea.com joost@spacebabies.nl) gem.description ...
github
mbleigh/acts-as-taggable-on
https://github.com/mbleigh/acts-as-taggable-on
spec/spec_helper.rb
Ruby
mit
4,996
master
1,099
begin require 'byebug' rescue LoadError end $LOAD_PATH << '.' unless $LOAD_PATH.include?('.') $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__)) require 'logger' require File.expand_path('../../lib/acts-as-taggable-on', __FILE__) I18n.enforce_available_locales = true require 'rails' require 'rspec/its' requ...
github
mbleigh/acts-as-taggable-on
https://github.com/mbleigh/acts-as-taggable-on
spec/internal/db/schema.rb
Ruby
mit
4,996
master
3,264
ActiveRecord::Schema.define version: 0 do create_table ActsAsTaggableOn.tags_table, force: true do |t| t.string :name t.integer :taggings_count, default: 0 t.string :type end add_index ActsAsTaggableOn.tags_table, ['name'], name: 'index_tags_on_name', unique: true create_table ActsAsTaggableOn.tagg...
github
mbleigh/acts-as-taggable-on
https://github.com/mbleigh/acts-as-taggable-on
spec/internal/app/models/taggable_model.rb
Ruby
mit
4,996
master
352
class TaggableModel < ActiveRecord::Base acts_as_taggable acts_as_taggable_on :languages acts_as_taggable_on :skills acts_as_taggable_on :needs, :offerings acts_as_taggable_tenant :tenant_id has_many :untaggable_models attr_reader :tag_list_submethod_called def tag_list=(v) @tag_list_submethod_ca...
github
mbleigh/acts-as-taggable-on
https://github.com/mbleigh/acts-as-taggable-on
spec/internal/app/models/cached_model_with_array.rb
Ruby
mit
4,996
master
256
if using_postgresql? class CachedModelWithArray < ActiveRecord::Base acts_as_taggable end if postgresql_support_json? class TaggableModelWithJson < ActiveRecord::Base acts_as_taggable acts_as_taggable_on :skills end end end
github
mbleigh/acts-as-taggable-on
https://github.com/mbleigh/acts-as-taggable-on
spec/internal/app/models/company.rb
Ruby
mit
4,996
master
359
class Company < ActiveRecord::Base acts_as_taggable_on :locations, :markets has_many :markets, :through => :market_taggings, :source => :tag private def find_or_create_tags_from_list_with_context(tag_list, context) if context.to_sym == :markets Market.find_or_create_all_with_like_by_name(tag_list) ...
github
mbleigh/acts-as-taggable-on
https://github.com/mbleigh/acts-as-taggable-on
spec/internal/app/models/non_standard_id_taggable_model.rb
Ruby
mit
4,996
master
239
class NonStandardIdTaggableModel < ActiveRecord::Base self.primary_key = :an_id acts_as_taggable acts_as_taggable_on :languages acts_as_taggable_on :skills acts_as_taggable_on :needs, :offerings has_many :untaggable_models end
github
mbleigh/acts-as-taggable-on
https://github.com/mbleigh/acts-as-taggable-on
spec/support/database.rb
Ruby
mit
4,996
master
1,686
# frozen_string_literal: true # set adapter to use, default is sqlite3 # to use an alternative adapter run => rake spec DB='postgresql' db_name = ENV['DB'] || 'sqlite3' database_yml = File.expand_path('../internal/config/database.yml', __dir__) unless File.exist?(database_yml) raise "Please create #{database_yml} f...
github
mbleigh/acts-as-taggable-on
https://github.com/mbleigh/acts-as-taggable-on
spec/support/0-helpers.rb
Ruby
mit
4,996
master
653
def using_sqlite? ActsAsTaggableOn::Utils.connection && ActsAsTaggableOn::Utils.connection.adapter_name == 'SQLite' end def supports_concurrency? !using_sqlite? end def using_postgresql? ActsAsTaggableOn::Utils.using_postgresql? end def postgresql_version if using_postgresql? ActsAsTaggableOn::Utils.conn...
github
mbleigh/acts-as-taggable-on
https://github.com/mbleigh/acts-as-taggable-on
spec/acts_as_taggable_on/tagging_spec.rb
Ruby
mit
4,996
master
5,887
require 'spec_helper' RSpec.describe ActsAsTaggableOn::Tagging do before(:each) do @tagging = ActsAsTaggableOn::Tagging.new end it 'should not be valid with a invalid tag' do @tagging.taggable = TaggableModel.create(name: 'Bob Jones') @tagging.tag = ActsAsTaggableOn::Tag.new(name: '') @tagging.c...
github
mbleigh/acts-as-taggable-on
https://github.com/mbleigh/acts-as-taggable-on
spec/acts_as_taggable_on/taggable_spec.rb
Ruby
mit
4,996
master
33,802
require 'spec_helper' RSpec.describe 'Taggable To Preserve Order' do before(:each) do @taggable = OrderedTaggableModel.new(name: 'Bob Jones') end it 'should have tag associations' do [:tags, :colours].each do |type| expect(@taggable.respond_to?(type)).to be_truthy expect(@taggable.respond_t...
github
mbleigh/acts-as-taggable-on
https://github.com/mbleigh/acts-as-taggable-on
spec/acts_as_taggable_on/tagger_spec.rb
Ruby
mit
4,996
master
5,275
require 'spec_helper' RSpec.describe 'Tagger' do before(:each) do @user = User.create @taggable = TaggableModel.create(name: 'Bob Jones') end it 'should have taggings' do @user.tag(@taggable, with: 'ruby,scheme', on: :tags) expect(@user.owned_taggings.size).to eq(2) end it 'should have tags...
github
mbleigh/acts-as-taggable-on
https://github.com/mbleigh/acts-as-taggable-on
spec/acts_as_taggable_on/caching_spec.rb
Ruby
mit
4,996
master
4,101
require 'spec_helper' RSpec.describe 'Acts As Taggable On' do describe 'Caching' do before(:each) do @taggable = CachedModel.new(name: 'Bob Jones') @another_taggable = OtherCachedModel.new(name: 'John Smith') end it 'should add saving of tag lists and cached tag lists to the instance' do ...