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
ckruse/CFPropertyList
https://github.com/ckruse/CFPropertyList
lib/cfpropertylist/rbCFTypes.rb
Ruby
mit
213
master
7,993
# -*- coding: utf-8 -*- # # CFTypes, e.g. CFString, CFInteger # needed to create unambiguous plists # # Author:: Christian Kruse (mailto:cjk@wwwtech.de) # Copyright:: Copyright (c) 2009 # License:: MIT License require 'base64' module CFPropertyList ## # Blob is intended to distinguish between a Ruby String i...
github
ckruse/CFPropertyList
https://github.com/ckruse/CFPropertyList
lib/cfpropertylist/rbCFPropertyList.rb
Ruby
mit
213
master
13,635
# -*- coding: utf-8 -*- require 'kconv' require 'date' require 'time' # # CFPropertyList implementation # # class to read, manipulate and write both XML and binary property list # files (plist(5)) as defined by Apple. Have a look at CFPropertyList::List # for more documentation. # # == Example # require 'cfproperty...
github
ckruse/CFPropertyList
https://github.com/ckruse/CFPropertyList
test/test_autodetection.rb
Ruby
mit
213
master
1,320
require 'minitest/autorun' require 'rubygems' require 'cfpropertylist' require 'reference' class TestUid < Minitest::Test include Reference def test_auto_detect_plain plist = CFPropertyList::List.new(:file => "test/reference/string_ascii_short.plain.plist") assert_equal "data", CFPropertyList.native_typ...
github
ckruse/CFPropertyList
https://github.com/ckruse/CFPropertyList
test/test_stringio.rb
Ruby
mit
213
master
332
require 'minitest/autorun' require 'rubygems' require 'cfpropertylist' require 'reference' class TestStringio < Minitest::Test include Reference def test_read_stringio plist = CFPropertyList::List.new(data: raw_binary('array')) assert_equal parsed_binary('array'), CFPropertyList.native_types(plist.value...
github
ckruse/CFPropertyList
https://github.com/ckruse/CFPropertyList
test/test_string.rb
Ruby
mit
213
master
5,631
require 'minitest/autorun' require 'rubygems' require 'cfpropertylist' require 'reference' class TestString < Minitest::Test include Reference def test_read_string_ascii_short assert_equal 'data', parsed_xml('string_ascii_short') assert_equal 'data', parsed_binary('string_ascii_short') end def test...
github
ckruse/CFPropertyList
https://github.com/ckruse/CFPropertyList
test/test_integer.rb
Ruby
mit
213
master
2,904
require 'minitest/autorun' require 'rubygems' #gem 'libxml-ruby' require 'cfpropertylist' require 'reference' class TestInteger < Minitest::Test include Reference def test_read_1_byte assert_equal 1, parsed_xml('int_1_byte') assert_equal 1, parsed_binary('int_1_byte') end def test_read_2_bytes ...
github
ckruse/CFPropertyList
https://github.com/ckruse/CFPropertyList
test/test_invalid_xml.rb
Ruby
mit
213
master
1,607
# -*- coding: utf-8 -*- require 'minitest/autorun' require 'rubygems' require 'cfpropertylist' class TestInvalidXML < Minitest::Test def test_invalid_xml_with_libxml require 'cfpropertylist/rbLibXMLParser' orig_parsers = CFPropertyList::List.parsers CFPropertyList::List.parsers = [CFPropertyList::Binary...
github
ckruse/CFPropertyList
https://github.com/ckruse/CFPropertyList
test/reference.rb
Ruby
mit
213
master
990
module Reference def raw_xml(filename) data = File.new("test/reference/#{filename}.xml").read data.force_encoding('UTF-8') if data.respond_to?(:force_encoding) data end def parsed_xml(filename) plist = CFPropertyList::List.new(:data => raw_xml(filename)) CFPropertyList.native_types(plist.valu...
github
ckruse/CFPropertyList
https://github.com/ckruse/CFPropertyList
test/test_array.rb
Ruby
mit
213
master
1,723
require 'minitest/autorun' require 'rubygems' require 'cfpropertylist' require 'reference' class TestArray < Minitest::Test include Reference def test_read_array assert_equal [ "object" ], parsed_xml('array') assert_equal [ "object" ], parsed_binary('array') end def test_write_array plist = CFP...
github
ckruse/CFPropertyList
https://github.com/ckruse/CFPropertyList
test/test_boolean.rb
Ruby
mit
213
master
1,056
require 'minitest/autorun' require 'rubygems' require 'cfpropertylist' require 'reference' class TestBoolean < Minitest::Test include Reference def test_read_true assert_equal true, parsed_xml('boolean_true') assert_equal true, parsed_binary('boolean_true') end def test_read_false assert_equal ...
github
ckruse/CFPropertyList
https://github.com/ckruse/CFPropertyList
test/test_plain.rb
Ruby
mit
213
master
5,973
require 'minitest/autorun' require 'rubygems' require 'cfpropertylist' require 'reference' class TestPlain < Minitest::Test include Reference def test_string_ascii_short assert_equal "data", parsed_plain("string_ascii_short") end def test_string_ascii_long assert_equal "datadatadatadatadatadatadata...
github
ckruse/CFPropertyList
https://github.com/ckruse/CFPropertyList
test/test_real.rb
Ruby
mit
213
master
739
require 'minitest/autorun' require 'rubygems' #gem 'libxml-ruby' require 'cfpropertylist' require 'reference' class TestReal < Minitest::Test include Reference def test_read_float assert_equal 1.5, parsed_xml('real_float') assert_equal 1.5, parsed_binary('real_float') end def test_read_double a...
github
ckruse/CFPropertyList
https://github.com/ckruse/CFPropertyList
test/test_object_ref_size4.rb
Ruby
mit
213
master
521
require 'minitest/autorun' require 'rubygems' require 'cfpropertylist' require 'reference' class TestObjectRefSize4 < Minitest::Test include Reference def test_very_big_dict dict = parsed_binary('very_big_binary_dict') 50000.times do |i| assert dict.has_key?('key' + i.to_s) assert_equal i.to...
github
ckruse/CFPropertyList
https://github.com/ckruse/CFPropertyList
test/test_dictionary.rb
Ruby
mit
213
master
2,993
require 'minitest/autorun' require 'rubygems' #gem 'libxml-ruby' require 'cfpropertylist' require 'reference' class TestDictionary < Minitest::Test include Reference def test_read_dictionary assert_equal({ "key" => "value" }, parsed_xml('dictionary')) assert_equal({ "key" => "value" }, parsed_binary('di...
github
ckruse/CFPropertyList
https://github.com/ckruse/CFPropertyList
test/test_array3.rb
Ruby
mit
213
master
244
require 'minitest/autorun' require 'rubygems' #gem 'libxml-ruby' require 'cfpropertylist' require 'reference' class TestArray < Minitest::Test include Reference def test_read_array3 assert_equal [ ], parsed_xml('array3') end end
github
ckruse/CFPropertyList
https://github.com/ckruse/CFPropertyList
test/test_uid.rb
Ruby
mit
213
master
2,853
require 'minitest/autorun' require 'rubygems' require 'cfpropertylist' require 'reference' class TestUid < Minitest::Test include Reference def test_parse_binary assert_equal 4129, parsed_binary('uid') end def test_parse_xml_rexml orig_parsers = CFPropertyList::List.parsers require 'cfpropertyl...
github
ckruse/CFPropertyList
https://github.com/ckruse/CFPropertyList
test/test_array2.rb
Ruby
mit
213
master
225
require 'minitest/autorun' require 'rubygems' require 'cfpropertylist' require 'reference' class TestArray < Minitest::Test include Reference def test_read_array2 assert_equal [ ], parsed_xml('array2') end end
github
ckruse/CFPropertyList
https://github.com/ckruse/CFPropertyList
test/test_data.rb
Ruby
mit
213
master
2,294
require 'minitest/autorun' require 'rubygems' require 'cfpropertylist' require 'reference' require 'stringio' class TestData < Minitest::Test include Reference def test_read_data_short assert_equal 'data', parsed_xml('data_short') assert_equal 'data', parsed_binary('data_short') end def test_read_...
github
ckruse/CFPropertyList
https://github.com/ckruse/CFPropertyList
test/test_long_strings.rb
Ruby
mit
213
master
3,251
require 'minitest/autorun' require 'rubygems' require 'cfpropertylist' require 'reference' class TestLongStrings < Minitest::Test include Reference def test_very_long_string_with_libxml orig_parsers = CFPropertyList::List.parsers require 'cfpropertylist/rbLibXMLParser' CFPropertyList::List.parsers = ...
github
ckruse/CFPropertyList
https://github.com/ckruse/CFPropertyList
test/test_binary.rb
Ruby
mit
213
master
2,328
# -*- coding: ascii-8bit -*- require 'minitest/autorun' require 'rubygems' require 'cfpropertylist' require 'reference' class TestBinary < Minitest::Test def test_pack_it_with_size assert_equal "\xFF", CFPropertyList::Binary.pack_it_with_size(1, 0xFF) assert_equal "\xFF\xFF", CFPropertyList::Binary.pack_i...
github
ckruse/CFPropertyList
https://github.com/ckruse/CFPropertyList
test/test_offsets.rb
Ruby
mit
213
master
2,445
require 'minitest/autorun' require 'rubygems' require 'cfpropertylist' require 'reference' class TestOffsets < Minitest::Test include Reference def test_read_offsets_1_byte array = parsed_xml('offsets_1_byte') assert_equal 20, array.size 0.upto(19) do |i| assert_equal i.to_s, array[i] end ...
github
ckruse/CFPropertyList
https://github.com/ckruse/CFPropertyList
test/test_formatted.rb
Ruby
mit
213
master
3,027
require 'minitest/autorun' require 'rubygems' require 'cfpropertylist' class TestFormatted < Minitest::Test def test_formatted_with_libxml orig_parsers = CFPropertyList::List.parsers require 'cfpropertylist/rbLibXMLParser' CFPropertyList::List.parsers = [CFPropertyList::Binary, CFPropertyList::LibXMLPars...
github
ckruse/CFPropertyList
https://github.com/ckruse/CFPropertyList
test/test_date.rb
Ruby
mit
213
master
1,880
require 'minitest/autorun' require 'rubygems' require 'cfpropertylist' require 'reference' class TestDate < Minitest::Test include Reference def test_read_date_epoch assert_equal Time.at(0), parsed_xml('date_epoch') assert_equal Time.at(0), parsed_binary('date_epoch') end def test_read_date_1900 ...
github
ckruse/CFPropertyList
https://github.com/ckruse/CFPropertyList
test/performance/enumerator.rb
Ruby
mit
213
master
510
#require 'test/unit' require 'rubygems' require 'benchmark' require './lib/cfpropertylist' n = 1000000 array = ['object'] * n enum = ['object'].cycle(n) Benchmark.bm do |x| x.report('array') { plist = CFPropertyList::List.new plist.value = CFPropertyList.guess(array) plist.to_str(CFPropertyList::List::...
github
tiagopog/jsonapi-utils
https://github.com/tiagopog/jsonapi-utils
jsonapi-utils.gemspec
Ruby
mit
213
master
1,581
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'jsonapi/utils/version' Gem::Specification.new do |spec| spec.name = 'jsonapi-utils' spec.version = JSONAPI::Utils::VERSION spec.authors = ['Tiago Guedes', 'Douglas Andr...
github
tiagopog/jsonapi-utils
https://github.com/tiagopog/jsonapi-utils
lib/jsonapi/utils.rb
Ruby
mit
213
master
554
require 'jsonapi-resources' require 'jsonapi/utils/version' require 'jsonapi/utils/exceptions' require 'jsonapi/utils/request' require 'jsonapi/utils/response' require 'jsonapi/utils/support/filter/custom' JSONAPI::Resource.extend JSONAPI::Utils::Support::Filter::Custom module JSONAPI module Utils def self.incl...
github
tiagopog/jsonapi-utils
https://github.com/tiagopog/jsonapi-utils
lib/jsonapi/utils/request.rb
Ruby
mit
213
master
2,643
module JSONAPI::Utils module Request # Setup and check request before action gets actually evaluated. # # @api public def jsonapi_request_handling setup_request check_request rescue JSONAPI::Exceptions::InvalidResource, JSONAPI::Exceptions::InvalidField, JSONAPI::...
github
tiagopog/jsonapi-utils
https://github.com/tiagopog/jsonapi-utils
lib/jsonapi/utils/response.rb
Ruby
mit
213
master
264
require 'jsonapi/utils/response/formatters' require 'jsonapi/utils/response/renders' require 'jsonapi/utils/response/support' module JSONAPI module Utils module Response include Renders include Formatters include Support end end end
github
tiagopog/jsonapi-utils
https://github.com/tiagopog/jsonapi-utils
lib/jsonapi/utils/response/renders.rb
Ruby
mit
213
master
3,996
module JSONAPI module Utils module Response module Renders # Helper method to render JSON API-compliant responses. # # @param json [ActiveRecord::Base, ActiveRecord::Relation, Hash, Array<Hash>] # Object to be serialized into JSON # e.g.: User.first, User.all, { d...
github
tiagopog/jsonapi-utils
https://github.com/tiagopog/jsonapi-utils
lib/jsonapi/utils/response/formatters.rb
Ruby
mit
213
master
13,556
module JSONAPI module Utils module Response module Formatters # Helper method to format ActiveRecord or Hash objects into JSON API-compliant ones. # # @note The return of this method represents what will actually be displayed in the response body. # @note It can also be calle...
github
tiagopog/jsonapi-utils
https://github.com/tiagopog/jsonapi-utils
lib/jsonapi/utils/response/support.rb
Ruby
mit
213
master
655
require 'jsonapi/utils/support/error' require 'jsonapi/utils/support/filter/default' require 'jsonapi/utils/support/pagination' require 'jsonapi/utils/support/sort' module JSONAPI module Utils module Response module Support include ::JSONAPI::Utils::Support::Error include ::JSONAPI::Utils::...
github
tiagopog/jsonapi-utils
https://github.com/tiagopog/jsonapi-utils
lib/jsonapi/utils/exceptions/active_record.rb
Ruby
mit
213
master
6,366
module JSONAPI module Utils module Exceptions class ActiveRecord < ::JSONAPI::Exceptions::Error attr_reader :object, :resource, :relationships, :relationship_names, :foreign_keys # Construct an error decorator over ActiveRecord objects. # # @param object [ActiveRecord::Base]...
github
tiagopog/jsonapi-utils
https://github.com/tiagopog/jsonapi-utils
lib/jsonapi/utils/exceptions/internal_server_error.rb
Ruby
mit
213
master
663
module JSONAPI module Utils module Exceptions class InternalServerError < ::JSONAPI::Exceptions::Error # HTTP status code # # @return [String] # # @api public def code '500' end # Decorate errors for 500 responses. # ...
github
tiagopog/jsonapi-utils
https://github.com/tiagopog/jsonapi-utils
lib/jsonapi/utils/support/sort.rb
Ruby
mit
213
master
1,611
module JSONAPI::Utils::Support module Sort # Apply sort on result set (ascending by default). # e.g.: User.order(:first_name) # # @param records [ActiveRecord::Relation, Array] collection of records # e.g.: User.all or [{ id: 1, name: 'Tiago' }, { id: 2, name: 'Doug' }] # # @return [Ac...
github
tiagopog/jsonapi-utils
https://github.com/tiagopog/jsonapi-utils
lib/jsonapi/utils/support/pagination.rb
Ruby
mit
213
master
8,324
module JSONAPI module Utils module Support module Pagination RecordCountError = Class.new(ArgumentError) # Check whether pagination links should be included. # # @api public # @return [Boolean] def include_pagination_links? JSONAPI.configuration.def...
github
tiagopog/jsonapi-utils
https://github.com/tiagopog/jsonapi-utils
lib/jsonapi/utils/support/error.rb
Ruby
mit
213
master
588
module JSONAPI module Utils module Support module Error MEMBERS = %i(title detail id code source links status meta).freeze module_function def sanitize(errors) Array(errors).map do |error| MEMBERS.reduce({}) do |sum, key| value = error.try(key) |...
github
tiagopog/jsonapi-utils
https://github.com/tiagopog/jsonapi-utils
lib/jsonapi/utils/support/filter/default.rb
Ruby
mit
213
master
1,871
module JSONAPI::Utils::Support::Filter module Default # Apply default equality filters. # e.g.: User.where(name: 'Foobar') # # @param records [ActiveRecord::Relation, Array] collection of records # e.g.: User.all or [{ id: 1, name: 'Tiago' }, { id: 2, name: 'Doug' }] # # @param options...
github
tiagopog/jsonapi-utils
https://github.com/tiagopog/jsonapi-utils
lib/jsonapi/utils/support/filter/custom.rb
Ruby
mit
213
master
398
module JSONAPI::Utils::Support::Filter module Custom def _custom_filters @_allowed_custom_filters || [] end def custom_filters(*attrs) attrs.each { |attr| custom_filter(attr) } end def custom_filter(attr) attr = attr.to_sym @_allowed_filters[attr] = {} @_allowed_cus...
github
tiagopog/jsonapi-utils
https://github.com/tiagopog/jsonapi-utils
spec/spec_helper.rb
Ruby
mit
213
master
360
require 'smart_rspec' require 'factory_bot' require 'support/helpers' RSpec.configure do |config| config.include Helpers::ResponseParser config.include FactoryBot::Syntax::Methods config.define_derived_metadata do |meta| meta[:aggregate_failures] = true end config.mock_with :rspec do |mocks| mocks....
github
tiagopog/jsonapi-utils
https://github.com/tiagopog/jsonapi-utils
spec/rails_helper.rb
Ruby
mit
213
master
631
require 'spec_helper' require 'rails/all' require 'rails/test_help' require 'rspec/rails' require 'jsonapi-resources' require 'jsonapi/utils' require 'support/models' require 'support/factories' require 'support/resources' require 'support/controllers' require 'support/paginators' require 'support/shared/jsonapi_er...
github
tiagopog/jsonapi-utils
https://github.com/tiagopog/jsonapi-utils
spec/test_app.rb
Ruby
mit
213
master
2,001
## # General configs ## JSONAPI.configure do |config| config.json_key_format = :underscored_key config.allow_include = true config.allow_sort = true config.allow_filter = true config.default_page_size = 10 config.maximum_page_size = 10 config.default_paginator = :paged config.top_level_links_include_...
github
tiagopog/jsonapi-utils
https://github.com/tiagopog/jsonapi-utils
spec/support/paginators.rb
Ruby
mit
213
master
269
class CustomOffsetPaginator < OffsetPaginator def pagination_range(page_params) offset = page_params['offset'].to_i.nonzero? || 0 limit = page_params['limit'].to_i.nonzero? || JSONAPI.configuration.default_page_size offset..offset + limit - 1 end end
github
tiagopog/jsonapi-utils
https://github.com/tiagopog/jsonapi-utils
spec/support/controllers.rb
Ruby
mit
213
master
4,263
require 'support/exceptions' class BaseController < ActionController::Base include JSONAPI::Utils protect_from_forgery with: :null_session rescue_from ActiveRecord::RecordNotFound, with: :jsonapi_render_not_found end class PostsController < BaseController before_action :load_user, only: %i(index get_related_r...
github
tiagopog/jsonapi-utils
https://github.com/tiagopog/jsonapi-utils
spec/support/helpers.rb
Ruby
mit
213
master
408
require 'json' module Helpers module ResponseParser def json @json ||= JSON.parse(response.body) end def errors @errors ||= json['errors'] end def error @error ||= errors.first end def data @data ||= json['data'] end def collection @collection ||=...
github
tiagopog/jsonapi-utils
https://github.com/tiagopog/jsonapi-utils
spec/support/exceptions.rb
Ruby
mit
213
master
369
module Exceptions class MyCustomError < ::JSONAPI::Exceptions::Error attr_accessor :object def initialize(object) @object = object end def errors [JSONAPI::Error.new( code: '125', status: :unprocessable_entity, id: 'my_custom_validation_error', title: 'My ...
github
tiagopog/jsonapi-utils
https://github.com/tiagopog/jsonapi-utils
spec/support/resources.rb
Ruby
mit
213
master
771
class CategoryResource < JSONAPI::Resource attribute :title has_many :posts end class PostResource < JSONAPI::Resource attributes :title, :content_type, :body has_one :author has_one :category end class AuthorResource < JSONAPI::Resource model_name 'Person' has_many :posts end module V2 class PostRes...
github
tiagopog/jsonapi-utils
https://github.com/tiagopog/jsonapi-utils
spec/support/models.rb
Ruby
mit
213
master
1,635
require 'active_record' ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:') # Tables ActiveRecord::Schema.define do create_table :users do |t| t.string :first_name t.string :last_name t.boolean :admin t.timestamps null: false end create_table :profiles, force:...
github
tiagopog/jsonapi-utils
https://github.com/tiagopog/jsonapi-utils
spec/support/factories.rb
Ruby
mit
213
master
1,077
require 'factory_bot' require_relative './models' # require 'byebug'; byebug FactoryBot.define do factory :user, class: User do sequence(:id) { |n| n } sequence(:first_name) { |n| "User##{n}" } sequence(:last_name) { |n| "Lastname##{n}" } after(:create) { |user| create(:profile, user: user) } ...
github
tiagopog/jsonapi-utils
https://github.com/tiagopog/jsonapi-utils
spec/support/shared/jsonapi_request.rb
Ruby
mit
213
master
224
shared_context 'JSON API headers' do let(:headers) do { 'Accept' => 'application/vnd.api+json', 'Content-Type' => 'application/vnd.api+json' } end before(:each) { request.headers.merge!(headers) } end
github
tiagopog/jsonapi-utils
https://github.com/tiagopog/jsonapi-utils
spec/support/shared/jsonapi_errors.rb
Ruby
mit
213
master
6,226
shared_examples_for 'JSON API invalid request' do context 'when request is invalid' do context 'with "include"' do context 'when resource does not exist' do it 'renders a 400 response' do get :index, params: { include: :foobar } expect(response).to have_http_status :bad_request ...
github
tiagopog/jsonapi-utils
https://github.com/tiagopog/jsonapi-utils
spec/features/record_count_spec.rb
Ruby
mit
213
master
2,624
require 'rails_helper' ## # Configs ## # Resource class RecordCountTestResource < JSONAPI::Resource; end # Controller class RecordCountTestController < BaseController def explicit_count jsonapi_render json: User.all, options: { count: 42, resource: UserResource } end def array_count jsonapi_render jso...
github
tiagopog/jsonapi-utils
https://github.com/tiagopog/jsonapi-utils
spec/features/page_count_spec.rb
Ruby
mit
213
master
2,147
require 'rails_helper' ## # Configs ## # Resource class PageCountTestResource < JSONAPI::Resource; end # Controller class PageCountTestController < BaseController def index jsonapi_render json: User.all, options: { resource: UserResource } end end # Routes def TestApp.draw_page_count_test_routes JSONAPI.c...
github
tiagopog/jsonapi-utils
https://github.com/tiagopog/jsonapi-utils
spec/controllers/users_controller_spec.rb
Ruby
mit
213
master
19,285
require 'rails_helper' describe UsersController, type: :controller do include_context 'JSON API headers' before(:all) do @user = FactoryBot.create_list(:user, 3, :with_posts).first end before(:each) do JSONAPI.configuration.json_key_format = :underscored_key end let(:user) { @user } l...
github
tiagopog/jsonapi-utils
https://github.com/tiagopog/jsonapi-utils
spec/controllers/profile_controller_spec.rb
Ruby
mit
213
master
1,257
require 'rails_helper' describe ProfileController, type: :controller do include_context 'JSON API headers' let(:relationships) { ProfileResource._relationships.keys.map(&:to_s) } let(:fields) { ProfileResource.fields.reject { |e| e == :id }.map(&:to_s) - relationships } let(:attributes) { { nickname: '...
github
tiagopog/jsonapi-utils
https://github.com/tiagopog/jsonapi-utils
spec/controllers/posts_controller_spec.rb
Ruby
mit
213
master
16,432
require 'rails_helper' describe PostsController, type: :controller do include_context 'JSON API headers' before(:all) do @post = FactoryBot.create_list(:post, 3).first end before(:each) do JSONAPI.configuration.json_key_format = :underscored_key end let(:relationships) { PostResource._relationsh...
github
tiagopog/jsonapi-utils
https://github.com/tiagopog/jsonapi-utils
spec/jsonapi/utils/support/pagination_spec.rb
Ruby
mit
213
master
4,719
require 'rails_helper' describe JSONAPI::Utils::Support::Pagination do subject do OpenStruct.new(params: {}).extend(JSONAPI::Utils::Support::Pagination) end before(:all) do FactoryBot.create_list(:user, 2) end let(:options) { {} } ## # Public API ## describe '#record_count_for' do con...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
Gemfile
Ruby
mit
213
master
310
# frozen_string_literal: true source "https://rubygems.org" # Specify your gem's dependencies in action-cable-testing.gemspec gemspec gem "rails", "~> 6.0" gem "pry-byebug" local_gemfile = "Gemfile.local" if File.exist?(local_gemfile) eval(File.read(local_gemfile)) # rubocop:disable Security/Eval end
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
action-cable-testing.gemspec
Ruby
mit
213
master
1,311
# frozen_string_literal: true lib = File.expand_path("../lib", __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "action_cable/testing/version" Gem::Specification.new do |spec| spec.name = "action-cable-testing" spec.version = ActionCable::Testing::VERSION spec.authors ...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
Rakefile
Ruby
mit
213
master
392
# frozen_string_literal: true require "bundler/gem_tasks" require "rspec/core/rake_task" require "rubocop/rake_task" require "rake/testtask" require "cucumber/rake/task" Rake::TestTask.new do |t| t.test_files = FileList["test/**/*_test.rb"] end RuboCop::RakeTask.new RSpec::Core::RakeTask.new(:spec) Cucumber::Rake:...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
lib/generators/test_unit/channel/channel_generator.rb
Ruby
mit
213
master
445
# frozen_string_literal: true require "rails/generators/test_unit" module TestUnit # :nodoc: module Generators # :nodoc: class ChannelGenerator < Base # :nodoc: source_root File.expand_path("../templates", __FILE__) check_class_collision suffix: "ChannelTest" def create_test_file tem...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
lib/generators/rspec/channel/channel_generator.rb
Ruby
mit
213
master
372
# frozen_string_literal: true require "generators/rspec" module Rspec module Generators # @private class ChannelGenerator < Base source_root File.expand_path("../templates", __FILE__) def create_channel_spec template "channel_spec.rb.erb", File.join("spec/channels", class_path, "#{file_...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
lib/rspec/rails/example/channel_example_group.rb
Ruby
mit
213
master
1,811
# frozen_string_literal: true require "rspec/rails/matchers/action_cable/have_streams" module RSpec module Rails # @api public # Container module for channel spec functionality. It is only available if # ActionCable has been loaded before it. module ChannelExampleGroup # This blank module is o...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
lib/rspec/rails/shared_contexts/action_cable.rb
Ruby
mit
213
master
1,037
# frozen_string_literal: true # Generate contexts to use specific Action Cable adapter: # - "action_cable:async" (action_cable: :async) # - "action_cable:inline" (action_cable: :inline) # - "action_cable:test" (action_cable: :test) %w[async inline test].each do |adapter| RSpec.shared_context "action_cable:#{adapter}...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
lib/rspec/rails/matchers/action_cable.rb
Ruby
mit
213
master
2,283
# rubocop: disable Style/FrozenStringLiteralComment require "rspec/rails/matchers/action_cable/have_broadcasted_to" module RSpec module Rails module Matchers # Namespace for various implementations of ActionCable features # # @api private module ActionCable end # @api public...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb
Ruby
mit
213
master
4,819
# rubocop: disable Style/FrozenStringLiteralComment require "action_cable/testing/rails_six" using ActionCable::Testing::Rails6 module RSpec module Rails module Matchers module ActionCable # rubocop: disable Metrics/ClassLength # @private class HaveBroadcastedTo < RSpec::Matchers::...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
lib/rspec/rails/matchers/action_cable/have_streams.rb
Ruby
mit
213
master
1,768
# rubocop: disable Style/FrozenStringLiteralComment module RSpec module Rails module Matchers module ActionCable # @api private # Provides the implementation for `have_stream`, `have_stream_for`, and `have_stream_from`. # Not intended to be instantiated directly. class HaveS...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
lib/action_cable/testing.rb
Ruby
mit
213
master
629
# frozen_string_literal: true require "action_cable/testing/version" require "action_cable" require "action_cable/testing/rails_six" # These has been merged into Rails 6 unless ActionCable::VERSION::MAJOR >= 6 require "action_cable/testing/test_helper" require "action_cable/testing/test_case" require "action_...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
lib/action_cable/testing/test_helper.rb
Ruby
mit
213
master
5,344
# frozen_string_literal: true require "action_cable/testing/rails_six" using ActionCable::Testing::Rails6 module ActionCable # Provides helper methods for testing Action Cable broadcasting module TestHelper CHANNEL_NOT_FOUND = ArgumentError.new("Broadcasting channel can't be infered. Please, specify it with `...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
lib/action_cable/testing/test_case.rb
Ruby
mit
213
master
240
# frozen_string_literal: true require "active_support/test_case" module ActionCable class TestCase < ActiveSupport::TestCase include ActionCable::TestHelper ActiveSupport.run_load_hooks(:action_cable_test_case, self) end end
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
lib/action_cable/testing/rails_six.rb
Ruby
mit
213
master
943
# frozen_string_literal: true module ActionCable module Testing # Enables Rails 6 compatible API via Refinements. # # Use this to write Rails 6 compatible tests (not every Rails 6 API # could be backported). # # Usage: # # my_test.rb # require "test_helper" # # using Act...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
lib/action_cable/testing/rspec.rb
Ruby
mit
213
master
1,081
# frozen_string_literal: true require "action-cable-testing" require "rspec/rails" if RSpec::Rails::FeatureCheck.respond_to?(:has_action_cable_testing?) warn <<~MSG You're using RSpec with Action Cable support. You can remove `require "action_cable/testing/rspec"` from your RSpec setup. NOTE: if you u...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
lib/action_cable/testing/channel/test_case.rb
Ruby
mit
213
master
9,984
# frozen_string_literal: true require "active_support" require "active_support/test_case" require "active_support/core_ext/hash/indifferent_access" require "json" require "action_cable/testing/rails_six" using ActionCable::Testing::Rails6 module ActionCable module Channel class NonInferrableChannelError < ::St...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
lib/action_cable/testing/connection/test_case.rb
Ruby
mit
213
master
8,088
# frozen_string_literal: true require "active_support" require "active_support/test_case" require "active_support/core_ext/hash/indifferent_access" require "action_dispatch" require "action_dispatch/http/headers" require "action_dispatch/testing/test_request" module ActionCable module Connection class NonInferr...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
lib/action_cable/subscription_adapter/test.rb
Ruby
mit
213
master
1,011
# frozen_string_literal: true require "action_cable/subscription_adapter/async" module ActionCable module SubscriptionAdapter # == Test adapter for Action Cable # # The test adapter should be used only in testing. Along with # <tt>ActionCable::TestHelper</tt> it makes a great tool to test your Rails...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
spec/spec_helper.rb
Ruby
mit
213
master
1,005
# frozen_string_literal: true $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__) begin require "pry-byebug" rescue LoadError end require "action_controller/railtie" require "action_view/railtie" require "action_cable" require "action_cable/testing/rspec" require "ammeter/init" # Require all the stubs an...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
spec/generators/rspec_spec.rb
Ruby
mit
213
master
590
# frozen_string_literal: true require "spec_helper" require "generators/rspec/channel/channel_generator" describe Rspec::Generators::ChannelGenerator, type: :generator do destination File.expand_path("../../../tmp", __FILE__) let(:args) { ["chat"] } before do prepare_destination run_generator(args) ...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
spec/generators/test_unit_spec.rb
Ruby
mit
213
master
556
# frozen_string_literal: true require "spec_helper" require "generators/test_unit/channel/channel_generator" describe TestUnit::Generators::ChannelGenerator, type: :generator do destination File.expand_path("../../../tmp", __FILE__) let(:args) { ["chat"] } before do prepare_destination run_generator(a...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
spec/dummy/app/channels/chat_channel.rb
Ruby
mit
213
master
472
class ChatChannel < ApplicationCable::Channel periodically every: 5.seconds do transmit action: :now, time: Time.now end def subscribed reject unless user_id.present? @room_id = params[:room_id] stream_from "chat_#{@room_id}" if @room_id.present? end def speak(data) ActionCable.server....
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
spec/dummy/app/channels/application_cable/connection.rb
Ruby
mit
213
master
559
module ApplicationCable class Connection < ActionCable::Connection::Base identified_by :user_id def connect self.user_id = verify_user end def disconnect $stdout.puts "User #{user_id} disconnected" end private def verify_user user_id = request.params[:user_id] || ...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
spec/dummy/spec/rails_helper.rb
Ruby
mit
213
master
2,154
# This file is copied to spec/ when you run 'rails generate rspec:install' require 'spec_helper' ENV['RAILS_ENV'] ||= 'test' require File.expand_path('../../config/environment', __FILE__) # Prevent database truncation if the environment is production abort("The Rails environment is running in production mode!") if Rail...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
spec/dummy/config/application.rb
Ruby
mit
213
master
768
require_relative "boot" require "action_controller/railtie" require "action_cable/engine" require "global_id" GlobalID.app = "dummy" module Dummy class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into f...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
spec/rspec/rails/channel_example_group_spec.rb
Ruby
mit
213
master
244
require "spec_helper" module RSpec::Rails describe ChannelExampleGroup do if defined?(ActionCable) it_behaves_like "an rspec-rails example group mixin", :channel, './spec/channels/', '.\\spec\\channels\\' end end end
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
spec/rspec/rails/matchers/action_cable/have_broadcasted_to_spec.rb
Ruby
mit
213
master
6,497
require "spec_helper" require "rspec/rails/feature_check" if RSpec::Rails::FeatureCheck.has_action_cable_testing? require "rspec/rails/matchers/action_cable" end RSpec.describe "have_broadcasted_to matchers", :skip => !RSpec::Rails::FeatureCheck.has_action_cable_testing? do let(:channel) do Class.new(ActionCa...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
spec/rspec/rails/matchers/action_cable/have_stream_spec.rb
Ruby
mit
213
master
4,984
require "spec_helper" require "rspec/rails/feature_check" module FakeChannelHelper extend ActiveSupport::Concern module ClassMethods # @private def channel_class Class.new(ActionCable::Channel::Base) do def subscribed stream_from "chat_#{params[:id]}" if params[:id] strea...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
spec/support/shared_examples.rb
Ruby
mit
213
master
3,319
# Copied from rspec-rails require 'pathname' shared_examples_for "an rspec-rails example group mixin" do |type, *paths| let(:mixin) { described_class } def define_group_in(path, group_definition) path = Pathname(path) $_new_group = nil begin file = path + "whatever_spec.rb" Dir.mktmpdir(...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
spec/support/helpers.rb
Ruby
mit
213
master
558
# Copied from rspec-rails module Helpers include RSpec::Rails::FeatureCheck def with_isolated_config original_config = RSpec.configuration RSpec.configuration = RSpec::Core::Configuration.new RSpec::Rails.initialize_configuration(RSpec.configuration) if defined?(ActionCable) RSpec.configure...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
spec/support/deprecated_api.rb
Ruby
mit
213
master
240
DeprecatedApi = Module.new do def self.enabled? ActionCable::VERSION::MAJOR < 6 && ( Gem::Version.new(ActionCable::Testing::VERSION) < Gem::Version.new("1.0") || raise("Deprecated API should be removed") ) end end
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
test/test_helper.rb
Ruby
mit
213
master
618
# frozen_string_literal: true $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__) begin require "pry-byebug" rescue LoadError end require "action_cable" require "action-cable-testing" require "active_support/testing/autorun" # Require all the stubs and models Dir[File.expand_path("stubs/*.rb", __dir__)].e...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
test/syntax_test.rb
Ruby
mit
213
master
503
# frozen_string_literal: true require_relative "test_helper" using ActionCable::Testing::Rails6 class BroadcastChannel < ActionCable::Channel::Base end class TransmissionsTest < ActionCable::TestCase def test_broadcasting_for_name skip unless ActionCable::Testing::Rails6::SUPPORTED user = User.new(42) ...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
test/test_helper_test.rb
Ruby
mit
213
master
4,624
# frozen_string_literal: true require_relative "test_helper" class BroadcastChannel < ActionCable::Channel::Base end class TransmissionsTest < ActionCable::TestCase using ActionCable::Testing::Rails6 def test_assert_broadcasts assert_nothing_raised do assert_broadcasts("test", 1) do ActionCabl...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
test/channel/test_case_test.rb
Ruby
mit
213
master
4,904
# frozen_string_literal: true require_relative "../test_helper" class TestTestChannel < ActionCable::Channel::Base end class CrazyNameChannelTest < ActionCable::Channel::TestCase tests TestTestChannel def test_set_channel_class_manual assert_equal TestTestChannel, self.class.channel_class end end class C...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
test/connection/test_case_test.rb
Ruby
mit
213
master
3,256
# frozen_string_literal: true require_relative "../test_helper" class SimpleConnection < ActionCable::Connection::Base identified_by :user_id class << self attr_accessor :disconnected_user_id end def connect self.user_id = request.params[:user_id] || cookies[:user_id] end def disconnect sel...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
test/stubs/test_adapter.rb
Ruby
mit
213
master
247
# frozen_string_literal: true class SuccessAdapter < ActionCable::SubscriptionAdapter::Base def broadcast(channel, payload) end def subscribe(channel, callback, success_callback = nil) end def unsubscribe(channel, callback) end end
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
test/stubs/user.rb
Ruby
mit
213
master
224
# frozen_string_literal: true class User attr_reader :name def initialize(name) @name = name end def to_global_id GlobalID.new("User##{name}") end def to_gid_param to_global_id.to_param end end
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
test/stubs/test_server.rb
Ruby
mit
213
master
814
# frozen_string_literal: true require "ostruct" class TestServer include ActionCable::Server::Connections include ActionCable::Server::Broadcasting attr_reader :logger, :config, :mutex def initialize(subscription_adapter: SuccessAdapter) @logger = ActiveSupport::TaggedLogging.new ActiveSupport::Logger.n...
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
features/support/env.rb
Ruby
mit
213
master
306
require "aruba/cucumber" require "fileutils" Before do @aruba_timeout_seconds = 30 end Before do example_app_dir = "spec/dummy" aruba_dir = "tmp/aruba" # Remove the previous aruba workspace. FileUtils.rm_rf(aruba_dir) if File.exist?(aruba_dir) FileUtils.cp_r(example_app_dir, aruba_dir) end
github
palkan/action-cable-testing
https://github.com/palkan/action-cable-testing
features/step_definitions/additional_cli_steps.rb
Ruby
mit
213
master
678
begin require "action_controller/railtie" require "action_view/railtie" require "action_cable" rescue LoadError # rubocop:disable Lint/HandleExceptions end require "rails/version" require "action_cable/testing/rspec" Then /^the example(s)? should( all)? pass$/ do |_, _| step %q{the output should contain "0 fa...
github
Shopify/rotoscope
https://github.com/Shopify/rotoscope
Rakefile
Ruby
mit
213
main
1,260
# frozen_string_literal: true # ========================================================== # Packaging # ========================================================== GEMSPEC = Gem::Specification.load("rotoscope.gemspec") require "bundler/gem_tasks" require "rubygems/package_task" Gem::PackageTask.new(GEMSPEC) do |pkg|...
github
Shopify/rotoscope
https://github.com/Shopify/rotoscope
rotoscope.gemspec
Ruby
mit
213
main
958
# frozen_string_literal: true lib = File.expand_path("../lib", __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "rotoscope/version" Gem::Specification.new do |s| s.name = "rotoscope" s.version = Rotoscope::VERSION s.authors = ["Jahfer Husain", "Dylan Thacker-Smith"] s....
github
Shopify/rotoscope
https://github.com/Shopify/rotoscope
ext/rotoscope/extconf.rb
Ruby
mit
213
main
297
# frozen_string_literal: true require "mkmf" $CFLAGS << " -std=c99" $CFLAGS << " -Wall" $CFLAGS << " -Wno-declaration-after-statement" unless ["0", "", nil].include?(ENV["ROTOSCOPE_COMPILE_ERROR"]) $CFLAGS << " -Werror" end $defs << "-D_POSIX_SOURCE" create_makefile("rotoscope/rotoscope")