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
aasm/aasm
https://github.com/aasm/aasm
spec/unit/transition_spec.rb
Ruby
mit
5,199
master
13,108
require 'spec_helper' describe 'transitions' do it 'should raise an exception when whiny' do process = ProcessWithNewDsl.new expect { process.stop! }.to raise_error do |err| expect(err.class).to eql(AASM::InvalidTransition) expect(err.message).to eql("Event 'stop' cannot transition from 'sleepin...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/state_spec.rb
Ruby
mit
5,199
master
2,867
require 'spec_helper' describe AASM::Core::State do let(:state_machine) { AASM::StateMachine.new(:name) } before(:each) do @name = :astate @options = { :crazy_custom_key => 'key' } end def new_state(options={}) AASM::Core::State.new(@name, Conversation, state_machine, @options.merge(options)) ...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/rspec_matcher_spec.rb
Ruby
mit
5,199
master
3,324
require 'spec_helper' describe 'state machine' do let(:simple) { SimpleExample.new } let(:multiple) { SimpleMultipleExample.new } describe 'transition_from' do it "works for simple state machines" do expect(simple).to transition_from(:initialised).to(:filled_out).on_event(:fill_out) expect(simpl...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/override_warning_spec.rb
Ruby
mit
5,199
master
1,930
require 'spec_helper' describe 'warns when overrides a method' do before do AASM::Configuration.hide_warnings = false end after do AASM::Configuration.hide_warnings = true end module Clumsy def self.included base base.send :include, AASM base.aasm do state :valid ev...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/namespaced_multiple_example_spec.rb
Ruby
mit
5,199
master
2,994
require 'spec_helper' describe 'state machine' do let(:namespaced) { NamespacedMultipleExample.new } it 'starts with an initial state' do expect(namespaced.aasm(:status).current_state).to eq(:unapproved) expect(namespaced).to respond_to(:unapproved?) expect(namespaced).to be_unapproved expect(nam...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/subclassing_spec.rb
Ruby
mit
5,199
master
1,449
require 'spec_helper' describe 'subclassing' do it 'should have the parent states' do SuperClass.aasm.states.each do |state| expect(SubClassWithMoreStates.aasm.states).to include(state) end expect(SubClass.aasm.states).to eq(SuperClass.aasm.states) end it 'should not add the child states to t...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/guard_with_params_multiple_spec.rb
Ruby
mit
5,199
master
277
require 'spec_helper' describe "guards with params" do let(:guard) { GuardWithParamsMultiple.new } let(:user) {GuardParamsClass.new} it "list permitted states" do expect(guard.aasm(:left).states({:permitted => true}, user).map(&:name)).to eql [:reviewed] end end
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/localizer_spec.rb
Ruby
mit
5,199
master
3,461
require 'spec_helper' if defined?(ActiveRecord) require 'models/active_record/localizer_test_model' load_schema describe AASM::Localizer, "new style" do before(:all) do I18n.load_path << 'spec/localizer_test_model_new_style.yml' I18n.reload! end after(:all) do I18n.load_path.delet...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/initial_state_spec.rb
Ruby
mit
5,199
master
475
require 'spec_helper' describe 'initial states' do it 'should use the first state defined if no initial state is given' do expect(NoInitialState.new.aasm.current_state).to eq(:read) end it 'should determine initial state from the Proc results' do expect(InitialStateProc.new(InitialStateProc::RICH - 1).a...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/subclassing_multiple_spec.rb
Ruby
mit
5,199
master
3,076
require 'spec_helper' describe 'subclassing with multiple state machines' do it 'should have the parent states' do SuperClassMultiple.aasm(:left).states.each do |state| expect(SubClassWithMoreStatesMultiple.aasm(:left).states).to include(state) end expect(SubClassMultiple.aasm(:left).states).to eq...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/reloading_spec.rb
Ruby
mit
5,199
master
314
require 'spec_helper' describe 'when redefining states' do let(:definer) { DoubleDefiner.new } it "allows extending states" do expect(definer).to receive(:do_enter) definer.finish end it "allows extending events" do expect(definer).to receive(:do_on_transition) definer.finish end end
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/class_with_keyword_arguments_spec.rb
Ruby
mit
5,199
master
1,154
require 'spec_helper' describe ClassWithKeywordArguments do let(:state_machine) { ClassWithKeywordArguments.new } let(:resource) { double('resource', value: 1) } context 'when using optional keyword arguments' do it 'changes state successfully to closed_temporarily' do expect(state_machine.close_tempo...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/initial_state_multiple_spec.rb
Ruby
mit
5,199
master
581
require 'spec_helper' describe 'initial states' do it 'should use the first state defined if no initial state is given' do expect(NoInitialStateMultiple.new.aasm(:left).current_state).to eq(:read) end it 'should determine initial state from the Proc results' do balance = InitialStateProcMultiple::RICH -...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/basic_two_state_machines_example_spec.rb
Ruby
mit
5,199
master
291
require 'spec_helper' describe 'on initialization' do let(:example) { BasicTwoStateMachinesExample.new } it 'should be in the initial state' do expect(example.aasm(:search).current_state).to eql :initialised expect(example.aasm(:sync).current_state).to eql :unsynced end end
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/new_dsl_spec.rb
Ruby
mit
5,199
master
342
require 'spec_helper' describe "the new dsl" do let(:process) {ProcessWithNewDsl.new} it 'should not conflict with other event or state methods' do expect {ProcessWithNewDsl.state}.to raise_error(RuntimeError, "wrong state method") expect {ProcessWithNewDsl.event}.to raise_error(RuntimeError, "wrong even...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/guard_arguments_check_spec.rb
Ruby
mit
5,199
master
220
require 'spec_helper' describe "nil as first argument" do let(:guard) { GuardArgumentsCheck.new } it 'does not raise errors' do expect { guard.mark_as_reviewed(nil, 'second arg') }.not_to raise_error end end
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/event_naming_spec.rb
Ruby
mit
5,199
master
487
require 'spec_helper' describe "event naming" do let(:state_machine) { StateMachineWithFailedEvent.new } it "allows an event of failed without blowing the stack aka stack level too deep" do state_machine.failed expect { state_machine.failed }.to raise_error(AASM::InvalidTransition) end it "allows sen...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/guard_spec.rb
Ruby
mit
5,199
master
2,835
require 'spec_helper' describe "per-transition guards" do let(:guardian) { Guardian.new } it "allows the transition if the guard succeeds" do expect { guardian.use_one_guard_that_succeeds! }.to_not raise_error expect(guardian).to be_beta end it "stops the transition if the guard fails" do expect ...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/event_spec.rb
Ruby
mit
5,199
master
12,628
require 'spec_helper' describe 'adding an event' do let(:state_machine) { AASM::StateMachine.new(:name) } let(:event) do AASM::Core::Event.new(:close_order, state_machine, {:success => :success_callback}) do before :before_callback after :after_callback transitions :to => :closed, :from => [:...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/event_multiple_spec.rb
Ruby
mit
5,199
master
2,045
require 'spec_helper' describe 'current event' do let(:pe) {ParametrisedEventMultiple.new} it 'if no event has been triggered' do expect(pe.aasm(:left).current_event).to be_nil end it 'if a event has been triggered' do pe.wakeup expect(pe.aasm(:left).current_event).to eql :wakeup end it 'if ...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/event_with_keyword_arguments_spec.rb
Ruby
mit
5,199
master
975
require 'spec_helper' describe EventWithKeywordArguments do let(:example) { EventWithKeywordArguments.new } context 'when using required keyword arguments' do it 'works with required keyword argument' do expect(example.close(key: 1)).to be_truthy end it 'works when required keyword argument is ...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/memory_leak_spec.rb
Ruby
mit
5,199
master
1,874
# require 'spec_helper' # describe "state machines" do # def number_of_objects(klass) # ObjectSpace.each_object(klass) {} # end # def machines # AASM::StateMachineStore.instance_variable_get("@stores") # end # it "should be created without memory leak" do # machines_count = machines.size # ...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/persistence/mongoid_persistence_spec.rb
Ruby
mit
5,199
master
5,476
require 'spec_helper' if defined?(Mongoid::Document) describe 'mongoid' do Dir[File.dirname(__FILE__) + "/../../models/mongoid/*.rb"].sort.each do |f| require File.expand_path(f) end before(:all) do # if you want to see the statements while running the spec enable the following line #...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/persistence/active_record_persistence_spec.rb
Ruby
mit
5,199
master
31,074
require 'spec_helper' if defined?(ActiveRecord) Dir[File.dirname(__FILE__) + "/../../models/active_record/*.rb"].sort.each do |f| require File.expand_path(f) end load_schema # if you want to see the statements while running the spec enable the following line # require 'logger' # ActiveRecord::Base.l...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/persistence/mongoid_persistence_multiple_spec.rb
Ruby
mit
5,199
master
6,518
require 'spec_helper' if defined?(Mongoid::Document) describe 'mongoid' do Dir[File.dirname(__FILE__) + "/../../models/mongoid/*.rb"].sort.each do |f| require File.expand_path(f) end before(:all) do # if you want to see the statements while running the spec enable the following line #...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/persistence/redis_persistence_spec.rb
Ruby
mit
5,199
master
1,584
require 'spec_helper' if defined?(Redis::Objects) describe 'redis' do Dir[File.dirname(__FILE__) + "/../../models/redis/*.rb"].sort.each do |f| require File.expand_path(f) end before(:all) do @model = RedisSimple end describe "instance methods" do let(:model) {@model.new} ...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/persistence/dynamoid_persistence_spec.rb
Ruby
mit
5,199
master
2,453
require 'spec_helper' if defined?(Dynamoid) describe 'dynamoid' do Dir[File.dirname(__FILE__) + "/../../models/dynamoid/*.rb"].sort.each do |f| require File.expand_path(f) end before(:all) do @model = DynamoidSimple end describe "instance methods" do let(:model) {@model.new} ...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/persistence/sequel_persistence_spec.rb
Ruby
mit
5,199
master
13,789
require 'spec_helper' if defined?(Sequel) describe 'sequel' do Dir[File.dirname(__FILE__) + "/../../models/sequel/*.rb"].sort.each do |f| require File.expand_path(f) end before(:all) do @model = Sequel::Simple end describe "instance methods" do let(:model) {@model.new} ...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/persistence/sequel_persistence_multiple_spec.rb
Ruby
mit
5,199
master
4,851
require 'spec_helper' if defined?(Sequel) describe 'sequel' do Dir[File.dirname(__FILE__) + "/../../models/sequel/*.rb"].sort.each do |f| require File.expand_path(f) end before(:all) do @model = Sequel::Multiple end describe "instance methods" do let(:model) {@model.new} ...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/persistence/no_brainer_persistence_multiple_spec.rb
Ruby
mit
5,199
master
6,627
require 'spec_helper' if defined?(NoBrainer::Document) describe 'nobrainer' do Dir[File.dirname(__FILE__) + '/../../models/nobrainer/*.rb'].sort.each do |f| require File.expand_path(f) end before(:all) do # if you want to see the statements while running the spec enable the # following...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/persistence/no_brainer_persistence_spec.rb
Ruby
mit
5,199
master
5,165
require 'spec_helper' if defined?(NoBrainer::Document) describe 'nobrainer' do Dir[File.dirname(__FILE__) + '/../../models/nobrainer/*.rb'].sort.each do |f| require File.expand_path(f) end before(:all) do # if you want to see the statements while running the spec enable the # following...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/persistence/redis_persistence_multiple_spec.rb
Ruby
mit
5,199
master
2,739
require 'spec_helper' if defined?(Redis) describe 'redis' do Dir[File.dirname(__FILE__) + "/../../models/redis/*.rb"].sort.each do |f| require File.expand_path(f) end before(:all) do @model = RedisMultiple end describe "instance methods" do let(:model) {@model.new} it ...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/persistence/active_record_persistence_multiple_spec.rb
Ruby
mit
5,199
master
21,915
require 'spec_helper' if defined?(ActiveRecord) Dir[File.dirname(__FILE__) + "/../../models/active_record/*.rb"].sort.each do |f| require File.expand_path(f) end load_schema # if you want to see the statements while running the spec enable the following line # require 'logger' # ActiveRecord::Base.l...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/persistence/dynamoid_persistence_multiple_spec.rb
Ruby
mit
5,199
master
4,247
require 'spec_helper' if defined?(Dynamoid) describe 'dynamoid' do Dir[File.dirname(__FILE__) + "/../../models/dynamoid/*.rb"].sort.each do |f| require File.expand_path(f) end before(:all) do @model = DynamoidMultiple end describe "instance methods" do let(:model) {@model.new...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/invokers/base_invoker_spec.rb
Ruby
mit
5,199
master
1,776
require 'spec_helper' describe AASM::Core::Invokers::BaseInvoker do let(:target) { double } let(:record) { double } let(:args) { [] } subject { described_class.new(target, record, args) } describe '#may_invoke?' do it 'then raises NoMethodError' do expect { subject.may_invoke? }.to raise_error(No...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/invokers/class_invoker_spec.rb
Ruby
mit
5,199
master
4,182
require 'spec_helper' describe AASM::Core::Invokers::ClassInvoker do let(:target) { Class.new { def call; end } } let(:record) { double } let(:args) { [] } subject { described_class.new(target, record, args) } describe '#may_invoke?' do context 'when subject is a Class and responds to #call' do i...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/invokers/literal_invoker_spec.rb
Ruby
mit
5,199
master
2,941
require 'spec_helper' describe AASM::Core::Invokers::LiteralInvoker do let(:target) { nil } let(:record) { double } let(:args) { [] } subject { described_class.new(target, record, args) } describe '#may_invoke?' do context 'when subject is a Symbol' do let(:target) { :i_am_symbol } it 'the...
github
aasm/aasm
https://github.com/aasm/aasm
spec/unit/invokers/proc_invoker_spec.rb
Ruby
mit
5,199
master
3,824
require 'spec_helper' describe AASM::Core::Invokers::ProcInvoker do let(:target) { Proc.new {} } let(:record) { double } let(:args) { [] } subject { described_class.new(target, record, args) } describe '#may_invoke?' do context 'when subject is a Proc' do it 'then returns "true"' do expec...
github
rails-api/rails-api
https://github.com/rails-api/rails-api
Rakefile
Ruby
mit
5,135
master
227
require "bundler/gem_tasks" require 'rake/testtask' Rake::TestTask.new(:test) do |t| t.libs << 'lib' t.libs << 'test' t.pattern = 'test/**/*_test.rb' t.warning = true t.verbose = false end task :default => [:test]
github
rails-api/rails-api
https://github.com/rails-api/rails-api
rails-api.gemspec
Ruby
mit
5,135
master
1,232
# -*- encoding: utf-8 -*- $:.push File.expand_path('../lib', __FILE__) require 'rails-api/version' Gem::Specification.new do |gem| gem.name = "rails-api" gem.version = Rails::API::VERSION gem.platform = Gem::Platform::RUBY gem.summary = %q{Rails for API only Applications} gem.descri...
github
rails-api/rails-api
https://github.com/rails-api/rails-api
lib/rails-api.rb
Ruby
mit
5,135
master
225
require 'rails/version' require 'rails-api/version' require 'rails-api/action_controller/api' require 'rails-api/application' module Rails module API def self.rails3? Rails::VERSION::MAJOR == 3 end end end
github
rails-api/rails-api
https://github.com/rails-api/rails-api
lib/generators/rails/api_resource_route/api_resource_route_generator.rb
Ruby
mit
5,135
master
570
require 'rails/generators/rails/resource_route/resource_route_generator' module Rails module Generators class ApiResourceRouteGenerator < ResourceRouteGenerator def add_resource_route return if options[:actions].present? route_config = regular_class_path.collect{ |namespace| "namespace :#{...
github
rails-api/rails-api
https://github.com/rails-api/rails-api
lib/rails-api/public_exceptions.rb
Ruby
mit
5,135
master
1,476
module Rails module API class PublicExceptions attr_accessor :public_path def initialize(public_path) @public_path = public_path end def call(env) exception = env["action_dispatch.exception"] status = env["PATH_INFO"][1..-1] request = ActionD...
github
rails-api/rails-api
https://github.com/rails-api/rails-api
lib/rails-api/application.rb
Ruby
mit
5,135
master
3,679
require 'rails/application' require 'rails-api/public_exceptions' require 'rails-api/application/default_rails_four_middleware_stack' module Rails class Application < Engine alias_method :rails_default_middleware_stack, :default_middleware_stack def default_middleware_stack if Rails::API.rails3? ...
github
rails-api/rails-api
https://github.com/rails-api/rails-api
lib/rails-api/application/default_rails_four_middleware_stack.rb
Ruby
mit
5,135
master
3,769
module Rails class Application class DefaultRailsFourMiddlewareStack attr_reader :config, :paths, :app def initialize(app, config, paths) @app = app @config = config @paths = paths end def build_stack ActionDispatch::MiddlewareStack.new.tap do |middleware|...
github
rails-api/rails-api
https://github.com/rails-api/rails-api
lib/rails-api/generators/rails/app/app_generator.rb
Ruby
mit
5,135
master
255
require 'rails/generators' require 'rails/generators/rails/app/app_generator' Rails::Generators::AppGenerator.source_paths.unshift( File.expand_path('../../../../templates/rails/app', __FILE__) ) class Rails::AppBuilder undef tmp undef vendor end
github
rails-api/rails-api
https://github.com/rails-api/rails-api
lib/rails-api/templates/rails/scaffold_controller/controller.rb
Ruby
mit
5,135
master
1,901
<% module_namespacing do -%> class <%= controller_class_name %>Controller < ApplicationController before_action <%= ":set_#{singular_table_name}" %>, only: [:show, :update, :destroy] # GET <%= route_url %> # GET <%= route_url %>.json def index @<%= plural_table_name %> = <%= orm_class.all(class_name) %> ...
github
rails-api/rails-api
https://github.com/rails-api/rails-api
lib/rails-api/templates/rails/app/Gemfile
Ruby
mit
5,135
master
988
source 'https://rubygems.org' <%- if rails_gemfile_entry.is_a? String -%> <%= rails_gemfile_entry %> <%- else -%> <%- rails_gemfile_entry.each do |entry| -%> <%- if entry.respond_to?(:name) %> gem '<%= entry.name -%>', '<%= entry.version -%>' <%- end -%> <%- end -%> <%- end -%> gem 'rails-api' <%- if database_gemfil...
github
rails-api/rails-api
https://github.com/rails-api/rails-api
lib/rails-api/templates/test_unit/scaffold/functional_test.rb
Ruby
mit
5,135
master
1,112
require 'test_helper' <% module_namespacing do -%> class <%= controller_class_name %>ControllerTest < ActionController::TestCase setup do @<%= singular_table_name %> = <%= table_name %>(:one) end test "should get index" do get :index assert_response :success assert_not_nil assigns(:<%= table_nam...
github
rails-api/rails-api
https://github.com/rails-api/rails-api
lib/rails-api/action_controller/api.rb
Ruby
mit
5,135
master
5,842
require 'action_view' require 'action_controller' require 'action_controller/log_subscriber' module ActionController # API Controller is a lightweight version of <tt>ActionController::Base</tt>, # created for applications that don't require all functionality that a complete # \Rails controller provides, allowing...
github
rails-api/rails-api
https://github.com/rails-api/rails-api
test/test_helper.rb
Ruby
mit
5,135
master
1,180
# Configure Rails Environment ENV["RAILS_ENV"] = "test" require 'bundler/setup' require 'rails' require 'rails/test_help' require 'rails-api' def rails3? Rails::API.rails3? end class ActiveSupport::TestCase def self.app @@app ||= Class.new(Rails::Application) do def self.name 'TestApp' en...
github
rails-api/rails-api
https://github.com/rails-api/rails-api
test/api_controller/url_for_test.rb
Ruby
mit
5,135
master
374
require 'test_helper' class UrlForApiController < ActionController::API def one; end def two; end end class UrlForApiTest < ActionController::TestCase tests UrlForApiController def setup super @request.host = 'www.example.com' end def test_url_for get :one assert_equal "http://www.exampl...
github
rails-api/rails-api
https://github.com/rails-api/rails-api
test/api_controller/renderers_test.rb
Ruby
mit
5,135
master
1,734
require 'test_helper' require 'active_support/core_ext/hash/conversions' class Model def to_json(options = {}) { :a => 'b' }.to_json(options) end def to_xml(options = {}) { :a => 'b' }.to_xml(options) end end class RenderersApiController < ActionController::API use ActionDispatch::ShowExceptions, R...
github
rails-api/rails-api
https://github.com/rails-api/rails-api
test/api_controller/redirect_to_test.rb
Ruby
mit
5,135
master
382
require 'test_helper' class RedirectToApiController < ActionController::API def one redirect_to :action => "two" end def two; end end class RedirectToApiTest < ActionController::TestCase tests RedirectToApiController def test_redirect_to get :one assert_response :redirect assert_equal "htt...
github
rails-api/rails-api
https://github.com/rails-api/rails-api
test/api_controller/action_methods_test.rb
Ruby
mit
5,135
master
722
require 'test_helper' class ActionMethodsApiController < ActionController::API def one; end def two; end # Rails 5 does not have method hide_action if Rails::VERSION::MAJOR < 5 hide_action :two end end class ActionMethodsApiTest < ActionController::TestCase tests ActionMethodsApiController def test...
github
rails-api/rails-api
https://github.com/rails-api/rails-api
test/api_controller/conditional_get_test.rb
Ruby
mit
5,135
master
1,457
require 'test_helper' require 'active_support/core_ext/integer/time' require 'active_support/core_ext/numeric/time' class ConditionalGetApiController < ActionController::API before_filter :handle_last_modified_and_etags, :only => :two def one if stale?(:last_modified => Time.now.utc.beginning_of_day, :etag =>...
github
rails-api/rails-api
https://github.com/rails-api/rails-api
test/api_controller/force_ssl_test.rb
Ruby
mit
5,135
master
368
require 'test_helper' class ForceSSLApiController < ActionController::API force_ssl def one; end def two head :ok end end class ForceSSLApiTest < ActionController::TestCase tests ForceSSLApiController def test_redirects_to_https get :two assert_response 301 assert_equal "https://test.hos...
github
rails-api/rails-api
https://github.com/rails-api/rails-api
test/api_controller/data_streaming_test.rb
Ruby
mit
5,135
master
629
require 'test_helper' module TestApiFileUtils def file_name() File.basename(__FILE__) end def file_path() File.expand_path(__FILE__) end def file_data() @data ||= File.open(file_path, 'rb') { |f| f.read } end end class DataStreamingApiController < ActionController::API include TestApiFileUtils def one; end...
github
rails-api/rails-api
https://github.com/rails-api/rails-api
test/generators/resource_generator_test.rb
Ruby
mit
5,135
master
490
require 'generators/generators_test_helper' require 'rails/generators/rails/resource/resource_generator' class ResourceGeneratorTest < Rails::Generators::TestCase include GeneratorsTestHelper arguments %w(account) setup :copy_routes def test_resource_routes_are_added run_generator assert_file "confi...
github
rails-api/rails-api
https://github.com/rails-api/rails-api
test/generators/scaffold_generator_test.rb
Ruby
mit
5,135
master
4,554
require 'generators/generators_test_helper' require 'rails/generators/rails/scaffold/scaffold_generator' class ScaffoldGeneratorTest < Rails::Generators::TestCase include GeneratorsTestHelper arguments %w(product_line title:string product:belongs_to user:references) setup :copy_routes def test_scaffold_on_in...
github
rails-api/rails-api
https://github.com/rails-api/rails-api
test/generators/app_generator_test.rb
Ruby
mit
5,135
master
1,492
require 'generators/generators_test_helper' require 'rails-api/generators/rails/app/app_generator' class AppGeneratorTest < Rails::Generators::TestCase include GeneratorsTestHelper arguments [destination_root] def test_skeleton_is_created run_generator default_files.each { |path| assert_file path } ...
github
rails-api/rails-api
https://github.com/rails-api/rails-api
test/generators/generators_test_helper.rb
Ruby
mit
5,135
master
828
require 'test_helper' require 'rails/generators' module GeneratorsTestHelper def self.included(base) base.class_eval do destination File.expand_path("../../tmp", __FILE__) setup :prepare_destination teardown :remove_destination begin base.tests Rails::Generators.const_get(base...
github
rails-api/rails-api
https://github.com/rails-api/rails-api
test/api_application/api_application_test.rb
Ruby
mit
5,135
master
1,896
require 'test_helper' require 'action_controller/railtie' require 'rack/test' class OmgController < ActionController::API def index render :text => "OMG" end def unauthorized render :text => "get out", :status => :unauthorized end end class ApiApplicationTest < ActiveSupport::TestCase include ::Rac...
github
athityakumar/colorls
https://github.com/athityakumar/colorls
colorls.gemspec
Ruby
mit
5,112
main
3,408
# frozen_string_literal: true lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'colorls/version' POST_INSTALL_MESSAGE = %( ******************************************************************* Changes introduced in colorls Sort by dirs : -sd flag has bee...
github
athityakumar/colorls
https://github.com/athityakumar/colorls
Rakefile
Ruby
mit
5,112
main
1,203
# frozen_string_literal: true require 'bundler/setup' require 'rubygems/tasks' Gem::Tasks.new require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) do |t| t.rspec_opts = '--warnings' end require 'rubocop/rake_task' RuboCop::RakeTask.new desc 'Build the manual' file 'man/colorls.1' => ['man/colorls.1.ron...
github
athityakumar/colorls
https://github.com/athityakumar/colorls
lib/colorls.rb
Ruby
mit
5,112
main
483
# frozen_string_literal: true require 'yaml' require 'etc' require 'English' require 'filesize' require 'io/console' require 'io/console/size' require 'rainbow/ext/string' require 'clocale' require 'unicode/display_width' require 'addressable/uri' require_relative 'colorls/core' require_relative 'colorls/fileinfo' re...
github
athityakumar/colorls
https://github.com/athityakumar/colorls
lib/colorls/git.rb
Ruby
mit
5,112
main
2,226
# frozen_string_literal: true require 'pathname' require 'set' module ColorLS module Git EMPTY_SET = Set.new.freeze private_constant :EMPTY_SET def self.status(repo_path) prefix, success = git_prefix(repo_path) return unless success prefix_path = Pathname.new(prefix) git_stat...
github
athityakumar/colorls
https://github.com/athityakumar/colorls
lib/colorls/fileinfo.rb
Ruby
mit
5,112
main
2,654
# frozen_string_literal: true require 'forwardable' module ColorLS class FileInfo extend Forwardable @@users = {} # rubocop:disable Style/ClassVars @@groups = {} # rubocop:disable Style/ClassVars attr_reader :stats, :name, :path, :parent def initialize(name:, parent...
github
athityakumar/colorls
https://github.com/athityakumar/colorls
lib/colorls/layout.rb
Ruby
mit
5,112
main
2,010
# frozen_string_literal: true module ColorLS class Layout def initialize(contents, widths, line_size) @max_widths = widths @contents = contents @screen_width = line_size end def each_line return if @contents.empty? get_chunks(chunk_size).each { |line| yield(line.compact, @...
github
athityakumar/colorls
https://github.com/athityakumar/colorls
lib/colorls/core.rb
Ruby
mit
5,112
main
14,967
# frozen_string_literal: true module ColorLS # on Windows (were the special 'nul' device exists) we need to use UTF-8 @file_encoding = File.exist?('nul') ? Encoding::UTF_8 : Encoding::ASCII_8BIT def self.file_encoding @file_encoding end def self.terminal_width console = IO.console width = IO.c...
github
athityakumar/colorls
https://github.com/athityakumar/colorls
lib/colorls/flags.rb
Ruby
mit
5,112
main
10,638
# frozen_string_literal: true require 'optparse' require 'colorls/version' module ColorLS class Flags def initialize(*args) @args = args @light_colors = false @opts = default_opts @report_mode = false @exit_status_code = 0 parse_options return unless @opts[:mode] == ...
github
athityakumar/colorls
https://github.com/athityakumar/colorls
lib/colorls/yaml.rb
Ruby
mit
5,112
main
736
# frozen_string_literal: true module ColorLS class Yaml def initialize(filename) @filepath = File.join(File.dirname(__FILE__),"../yaml/#{filename}") @user_config_filepath = File.join(Dir.home, ".config/colorls/#{filename}") end def load(aliase: false) yaml = read_file(@filepath) ...
github
athityakumar/colorls
https://github.com/athityakumar/colorls
spec/spec_helper.rb
Ruby
mit
5,112
main
783
# frozen_string_literal: true require 'simplecov' SimpleCov.start do add_filter '/spec/' end if ENV['CI'] == 'never' # FIXME: migrate to new Codecov uploader / action require 'codecov' SimpleCov.formatter = SimpleCov::Formatter::Codecov end require 'bundler/setup' require 'colorls' Dir["#{File.dirname(__FILE...
github
athityakumar/colorls
https://github.com/athityakumar/colorls
spec/color_ls/monkey_spec.rb
Ruby
mit
5,112
main
395
# frozen_string_literal: true require 'colorls/monkeys' RSpec.describe String do # rubocop:disable RSpec/FilePath describe '#uniq' do it 'removes all duplicate characters' do expect('abca'.uniq).to be == 'abc' end end describe String, '#colorize' do it 'colors a string with red' do expe...
github
athityakumar/colorls
https://github.com/athityakumar/colorls
spec/color_ls/core_spec.rb
Ruby
mit
5,112
main
2,408
# frozen_string_literal: false require 'spec_helper' RSpec.describe ColorLS::Core do subject { described_class.new(colors: Hash.new('black')) } context 'ls' do it 'works with Unicode characters' do camera = 'Cámara'.force_encoding(ColorLS.file_encoding) imagenes = 'Imágenes'.force_encoding(ColorL...
github
athityakumar/colorls
https://github.com/athityakumar/colorls
spec/color_ls/layout_spec.rb
Ruby
mit
5,112
main
3,012
# frozen_string_literal: true require 'spec_helper' # rubocop:todo RSpec/MultipleDescribes RSpec.describe(ColorLS::HorizontalLayout, '#each_line') do subject { described_class.new(array, array.map(&:length), width) } context 'when empty' do let(:array) { [] } let(:width) { 10 } it 'does nothing' do...
github
athityakumar/colorls
https://github.com/athityakumar/colorls
spec/color_ls/yaml_spec.rb
Ruby
mit
5,112
main
508
# frozen_string_literal: true require 'spec_helper' RSpec.describe ColorLS::Yaml do filenames = { file_aliases: :value, folder_aliases: :value, folders: :key, files: :key }.freeze let(:base_directory) { 'lib/yaml' } filenames.each do |filename, sort_type| describe filename do let(:...
github
athityakumar/colorls
https://github.com/athityakumar/colorls
spec/color_ls/flags_spec.rb
Ruby
mit
5,112
main
14,773
# frozen_string_literal: true require 'spec_helper' FIXTURES = 'spec/fixtures' RSpec.describe ColorLS::Flags do subject do described_class.new(*args).process rescue SystemExit => e raise "colorls exited with #{e.status}" unless e.success? end let(:a_txt_file_info) do instance_double( Color...
github
athityakumar/colorls
https://github.com/athityakumar/colorls
spec/color_ls/git_spec.rb
Ruby
mit
5,112
main
1,664
# frozen_string_literal: false require 'spec_helper' RSpec.describe ColorLS::Git do before(:all) do # rubocop:todo RSpec/BeforeAfterAll `echo` # initialize $CHILD_STATUS expect($CHILD_STATUS).to be_success # rubocop:todo RSpec/ExpectInHook end context 'with file in repository root' do it 'returns `...
github
athityakumar/colorls
https://github.com/athityakumar/colorls
spec/support/yaml_sort_checker.rb
Ruby
mit
5,112
main
1,131
# frozen_string_literal: true require 'yaml' require 'open3' # workaround https://github.com/samg/diffy#119 require 'diffy' # Check Yaml if Alphabetically sorted class YamlSortChecker class NotSortedError < StandardError; end def initialize(filename) @yaml = YAML.load_file(filename) end def sorted?(type...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
sequel.gemspec
Ruby
mit
5,086
master
1,489
require File.expand_path("../lib/sequel/version", __FILE__) SEQUEL_GEMSPEC = Gem::Specification.new do |s| s.name = 'sequel' s.version = Sequel.version s.platform = Gem::Platform::RUBY s.extra_rdoc_files = ["MIT-LICENSE"] s.rdoc_options += ["--quiet", "--line-numbers", "--inline-source", '--title', 'Sequel: T...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
Rakefile
Ruby
mit
5,086
master
6,510
require "rake" require "rake/clean" NAME = 'sequel' VERS = lambda do require File.expand_path("../lib/sequel/version", __FILE__) Sequel.version end CLEAN.include ["sequel-*.gem", "rdoc", "coverage", "www/public/*.html", "www/public/rdoc*", "spec/bin-sequel-*"] # Gem Packaging desc "Build sequel gem" task :packag...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
www/make_www.rb
Ruby
mit
5,086
master
491
#!/usr/bin/env ruby require 'erb' $: << File.join(File.dirname(__FILE__), '..','lib', 'sequel') require 'version' Dir.chdir(File.dirname(__FILE__)) erb = ERB.new(File.read('layout.html.erb')) Dir['pages/*.html.erb'].each do |page| public_loc = "#{page.gsub(/\Apages\//, 'public/').sub('.erb', '')}" content = content...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
lib/sequel/ast_transformer.rb
Ruby
mit
5,086
master
4,316
# frozen-string-literal: true module Sequel # The +ASTTransformer+ class is designed to handle the abstract syntax trees # that Sequel uses internally and produce modified copies of them. By itself # it only produces a straight copy. It's designed to be subclassed and have # subclasses returned modified copi...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
lib/sequel/timezones.rb
Ruby
mit
5,086
master
10,065
# frozen-string-literal: true module Sequel @application_timezone = nil @database_timezone = nil @typecast_timezone = nil @local_offsets = {} # Backwards compatible alias Timezones = SequelMethods Deprecation.deprecate_constant(self, :Timezones) # Sequel doesn't pay much attention to timezones by d...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
lib/sequel/deprecated.rb
Ruby
mit
5,086
master
3,024
# frozen-string-literal: true module Sequel # This module makes it easy to print deprecation warnings with optional backtraces to a given stream. # There are a two accessors you can use to change how/where the deprecation methods are printed # and whether/how backtraces should be included: # # Sequel::Depr...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
lib/sequel/connection_pool.rb
Ruby
mit
5,086
master
6,735
# frozen-string-literal: true # The base connection pool class, which all other connection pools are based # on. This class is not instantiated directly, but subclasses should at # the very least implement the following API: # # initialize(Database, Hash) :: Initialize using the passed Sequel::Database # ...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
lib/sequel/dataset.rb
Ruby
mit
5,086
master
2,232
# frozen-string-literal: true module Sequel # A dataset represents an SQL query. Datasets # can be used to select, insert, update and delete records. # # Query results are always retrieved on demand, so a dataset can be kept # around and reused indefinitely (datasets never cache results): # # my_posts...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
lib/sequel/model.rb
Ruby
mit
5,086
master
3,090
# frozen-string-literal: true require_relative 'core' module Sequel # <tt>Sequel::Model</tt> is an object relational mapper built on top of Sequel core. Each # model class is backed by a dataset instance, and many dataset methods can be # called directly on the class. Model datasets return rows as model insta...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
lib/sequel/database.rb
Ruby
mit
5,086
master
1,395
# frozen-string-literal: true module Sequel # Hash of adapters that have been used. The key is the adapter scheme # symbol, and the value is the Database subclass. ADAPTER_MAP = {} # Hash of shared adapters that have been registered. The key is the # adapter scheme symbol, and the value is the Sequel m...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
lib/sequel/core.rb
Ruby
mit
5,086
master
17,292
# frozen-string-literal: true %w'bigdecimal date set thread time uri'.each{|f| require f} # Top level module for Sequel # # There are some module methods that are added via metaprogramming, one for # each supported adapter. For example: # # DB = Sequel.sqlite # Memory database # DB = Sequel.sqlite('blog.db') # ...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
lib/sequel/sql.rb
Ruby
mit
5,086
master
76,248
# frozen-string-literal: true module Sequel # The <tt>Sequel::BasicObject</tt> class is just like the # default +BasicObject+ class, except that missing constants are resolved in # +Object+. This allows the virtual row support to work with classes # without prefixing them with ::, such as: # # DB[:bonds...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
lib/sequel/exceptions.rb
Ruby
mit
5,086
master
4,083
# frozen-string-literal: true module Sequel # The default exception class for exceptions raised by Sequel. # All exception classes defined by Sequel are descendants of this class. class Error < ::StandardError # If this exception wraps an underlying exception, the underlying # exception is held here. ...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
lib/sequel/version.rb
Ruby
mit
5,086
master
742
# frozen-string-literal: true module Sequel # The major version of Sequel. Only bumped for major changes. MAJOR = 5 # The minor version of Sequel. Bumped for every non-patch level # release, generally around once a month. MINOR = 103 # The tiny version of Sequel. Usually 0, only bumped for bugfix # ...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
lib/sequel/adapters/ado.rb
Ruby
mit
5,086
master
9,108
# frozen-string-literal: true require 'win32ole' module Sequel # The ADO adapter provides connectivity to ADO databases in Windows. module ADO # ADO constants (DataTypeEnum) # Source: https://msdn.microsoft.com/en-us/library/ms675318(v=vs.85).aspx AdBigInt = 20 AdBinary = 128 ...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
lib/sequel/adapters/amalgalite.rb
Ruby
mit
5,086
master
5,938
# frozen-string-literal: true require 'amalgalite' require_relative 'shared/sqlite' module Sequel module Amalgalite # Type conversion map class for Sequel's use of Amalgamite class SequelTypeMap < ::Amalgalite::TypeMaps::DefaultMap methods_handling_sql_types.delete('string') methods_handling_sql...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
lib/sequel/adapters/mysql2.rb
Ruby
mit
5,086
master
10,060
# frozen-string-literal: true require 'mysql2' require_relative 'utils/mysql_mysql2' module Sequel module Mysql2 NativePreparedStatements = if ::Mysql2::VERSION >= '0.4' true else require_relative 'utils/mysql_prepared_statements' false end class Database < Sequel::Database ...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
lib/sequel/adapters/ibmdb.rb
Ruby
mit
5,086
master
13,106
# frozen-string-literal: true require 'ibm_db' require_relative 'shared/db2' module Sequel module IBMDB tt = Class.new do Sequel.set_temp_name(self){"Sequel::IBMDB::_TypeTranslator"} def boolean(s) !s.to_i.zero? end def int(s) s.to_i end end.new # Hash holding type translation method...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
lib/sequel/adapters/mock.rb
Ruby
mit
5,086
master
11,351
# frozen-string-literal: true require_relative 'utils/unmodified_identifiers' module Sequel module Mock class Connection # Sequel::Mock::Database object that created this connection attr_reader :db # Shard this connection operates on, when using Sequel's # sharding support (always :defa...
github
jeremyevans/sequel
https://github.com/jeremyevans/sequel
lib/sequel/adapters/mysql.rb
Ruby
mit
5,086
master
13,848
# frozen-string-literal: true require 'mysql' raise(LoadError, "require 'mysql' did not define Mysql::CLIENT_MULTI_RESULTS!, so it not supported. Please install the mysql or ruby-mysql gem.\n") unless defined?(Mysql::CLIENT_MULTI_RESULTS) require_relative 'utils/mysql_mysql2' require_relative 'utils/mysql_prepared_st...