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 | thechangelog/nightly | https://github.com/thechangelog/nightly | spec/buffer_spec.rb | Ruby | mit | 229 | master | 1,175 | require_relative "../lib/buffer"
RSpec.describe Buffer do
let(:buffer) { Buffer.new "8675309", ["Go", "CSS"] }
let(:repo1) { double language: "JavaScript", english?: true }
let(:repo2) { double language: "Go", english?: true }
let(:repo3) { double language: "CSS", english?: true }
let(:repo4) { double langua... |
github | thechangelog/nightly | https://github.com/thechangelog/nightly | spec/repo_spec.rb | Ruby | mit | 229 | master | 5,576 | require_relative "../lib/repo"
RSpec.describe Repo do
let(:repo) { Repo.new owner: {} }
describe "#blocked?" do
it "is true when repo id is blocked" do
repo.id = repo.send(:blocked_github_repo_ids).sample
expect(repo).to be_blocked
end
it "is true when repo owner id is in the blocked" do
... |
github | thechangelog/nightly | https://github.com/thechangelog/nightly | spec/core_ext/integer_spec.rb | Ruby | mit | 229 | master | 473 | require_relative "../../lib/core_ext/integer"
RSpec.describe "String extensions" do
describe "#comma_separated" do
it "converts to comma separated string" do
expect(0.comma_separated).to eq "0"
expect(23.comma_separated).to eq "23"
expect(134.comma_separated).to eq "134"
expect(1234.comma... |
github | thechangelog/nightly | https://github.com/thechangelog/nightly | spec/core_ext/string_spec.rb | Ruby | mit | 229 | master | 2,601 | require_relative "../../lib/core_ext/string"
RSpec.describe "String extensions" do
describe "#emojify" do
it "takes :emoji: and turns them in to img tags pointing at emoji images" do
string = "I :heart: this let's :shipit:!"
expect(string.emojify).to eq "I ❤️ this let's <img alt='shipit' src='/images... |
github | pawurb/activerecord-analyze | https://github.com/pawurb/activerecord-analyze | activerecord-analyze.gemspec | Ruby | mit | 228 | main | 971 | # -*- encoding: utf-8 -*-
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "activerecord-analyze/version"
Gem::Specification.new do |gem|
gem.name = "activerecord-analyze"
gem.version = ActiveRecordAnalyze::VERSION
gem.authors = ["pawurb"]
gem.email = [... |
github | pawurb/activerecord-analyze | https://github.com/pawurb/activerecord-analyze | lib/activerecord-analyze.rb | Ruby | mit | 228 | main | 2,143 | # frozen_string_literal: true
require "activerecord-analyze/main"
module ActiveRecordAnalyze
def self.analyze_sql(raw_sql, opts = {})
if opts[:full_debug] == true
opts = {
format: :pretty_json,
verbose: true,
costs: true,
buffers: true,
timing: true,
summary... |
github | pawurb/activerecord-analyze | https://github.com/pawurb/activerecord-analyze | lib/activerecord-analyze/main.rb | Ruby | mit | 228 | main | 1,948 | module ActiveRecord
module ConnectionAdapters
module PostgreSQL
module DatabaseStatements
def analyze(arel, binds = [], opts = {})
opts_sql = ActiveRecordAnalyze.build_prefix(opts)
sql = "EXPLAIN #{opts_sql} #{to_sql(arel, binds)}"
PostgreSQL::ExplainPrettyPrinter.new.... |
github | pawurb/activerecord-analyze | https://github.com/pawurb/activerecord-analyze | spec/analyze_sql_spec.rb | Ruby | mit | 228 | main | 1,755 | # frozen_string_literal: true
require "spec_helper"
describe "ActiveRecord analyze" do
let(:raw_sql) do
"SELECT * FROM users WHERE email = 'email@example.com'"
end
let(:result) do
ActiveRecordAnalyze.analyze_sql(raw_sql, opts)
end
describe "default opts" do
let(:opts) do
{}
end
... |
github | pawurb/activerecord-analyze | https://github.com/pawurb/activerecord-analyze | spec/spec_helper.rb | Ruby | mit | 228 | main | 596 | # frozen_string_literal: true
require "rubygems"
require "active_record/railtie"
require "bundler/setup"
require "migrations/create_users_migration.rb"
require_relative "../lib/activerecord-analyze"
ENV["DATABASE_URL"] ||= "postgresql://postgres:secret@localhost:5432/activerecord-analyze-test"
RSpec.configure do |co... |
github | pawurb/activerecord-analyze | https://github.com/pawurb/activerecord-analyze | spec/main_spec.rb | Ruby | mit | 228 | main | 1,579 | # frozen_string_literal: true
require "spec_helper"
require "migrations/create_users_migration.rb"
class User < ActiveRecord::Base; end
describe "ActiveRecord analyze" do
describe "default opts" do
it "works" do
expect do
User.all.analyze
end.not_to raise_error
end
end
EXPECTED_KEY... |
github | markbates/coffeebeans | https://github.com/markbates/coffeebeans | coffeebeans.gemspec | Ruby | mit | 228 | master | 1,141 | # -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{coffeebeans}
s.version = "1.0.1.20110527114144"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = [%q{markbates}]
s.date = %q{2011-05-27}
s.description = %q{coffeebeans was... |
github | markbates/coffeebeans | https://github.com/markbates/coffeebeans | Rakefile | Ruby | mit | 228 | master | 702 | require 'rubygems'
# Set up gems listed in the Gemfile.
gemfile = File.expand_path('../Gemfile', __FILE__)
begin
ENV['BUNDLE_GEMFILE'] = gemfile
require 'bundler'
Bundler.setup
rescue Bundler::GemNotFound => e
STDERR.puts e.message
STDERR.puts "Try running `bundle install`."
exit!
end if File.exist?(gemfil... |
github | markbates/coffeebeans | https://github.com/markbates/coffeebeans | Gemfile | Ruby | mit | 228 | master | 205 | source 'http://rubygems.org'
gem 'rake'
gem 'rails'
gem "rspec-rails", "2.6.0"
gem 'gemstub', ">= 2.0.0"
gem 'coffee-script'
gem 'sqlite3'
gem 'capybara', :git => 'git://github.com/jnicklas/capybara.git' |
github | markbates/coffeebeans | https://github.com/markbates/coffeebeans | spec/spec_helper.rb | Ruby | mit | 228 | master | 695 | ENV["RAILS_ENV"] = "test"
require File.expand_path("../dummy/config/environment.rb", __FILE__)
require 'rubygems'
require 'rspec/rails'
ActionMailer::Base.delivery_method = :test
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.default_url_options[:host] = "test.com"
Rails.backtrace_cleaner.remove_s... |
github | markbates/coffeebeans | https://github.com/markbates/coffeebeans | spec/request/coffee_script_spec.rb | Ruby | mit | 228 | master | 800 | require 'spec_helper'
feature "CoffeeScript" do
scenario "should render a .js.coffee file." do
visit drinks_url(:format => 'js')
page.should have_content('(function() { alert("i like coffee!"); }).call(this);')
end
scenario "should render a block with helper tags" do
visit drinks_url
... |
github | markbates/coffeebeans | https://github.com/markbates/coffeebeans | spec/dummy/Gemfile | Ruby | mit | 228 | master | 781 | source 'http://rubygems.org'
gem 'rails', '3.0.7'
gem 'coffeebeans', :path => '~/gemdev/coffeebeans'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger (ruby-debug for... |
github | markbates/coffeebeans | https://github.com/markbates/coffeebeans | spec/dummy/config/routes.rb | Ruby | mit | 228 | master | 1,852 | Dummy::Application.routes.draw do
match '/drinks(.:format)', :to => 'drinks#index', :as => :drinks
# The priority is based upon order of creation:
# first created -> highest priority.
# Sample of regular route:
# match 'products/:id' => 'catalog#view'
# Keep in mind you can assign values other than :cont... |
github | markbates/coffeebeans | https://github.com/markbates/coffeebeans | spec/dummy/config/application.rb | Ruby | mit | 228 | master | 2,091 | require File.expand_path('../boot', __FILE__)
# Pick the frameworks you want:
# require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "rails/test_unit/railtie"
# If you have a Gemfile, require the gems listed there, including any ... |
github | markbates/coffeebeans | https://github.com/markbates/coffeebeans | spec/dummy/config/initializers/secret_token.rb | Ruby | mit | 228 | master | 496 | # Be sure to restart your server when you modify this file.
# Your secret key for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attac... |
github | markbates/coffeebeans | https://github.com/markbates/coffeebeans | lib/coffeebeans.rb | Ruby | mit | 228 | master | 785 | require 'coffee-script'
module CoffeeBeans
module Handlers
module CoffeeScript
def self.erb_handler
@@erb_handler ||= ActionView::Template.registered_template_handler(:erb)
end
def self.call(template)
compiled_source = erb_handler.call(template)
"::CoffeeScript.compile(... |
github | jsuchal/garelic | https://github.com/jsuchal/garelic | garelic.gemspec | Ruby | mit | 228 | master | 662 | # -*- encoding: utf-8 -*-
require File.expand_path('../lib/garelic/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Jan Suchal"]
gem.email = ["johno@jsmf.net"]
gem.description = %q{Use Google Analytics for Rails App Performance Monitoring}
gem.summary = %q{}
gem.homep... |
github | jsuchal/garelic | https://github.com/jsuchal/garelic | lib/garelic.rb | Ruby | mit | 228 | master | 4,318 | require "garelic/version"
require "garelic/middleware"
class Garelic
Timing = '<!-- /* GARELIC DATA */ -->'.html_safe
@@deployed_version_slot = 5
cattr_accessor :deployed_version, :deployed_version_slot, instance_accessor: false
def self.monitoring(profile_id)
buffer = <<-HTML
<script type="text/j... |
github | jsuchal/garelic | https://github.com/jsuchal/garelic | lib/garelic/middleware.rb | Ruby | mit | 228 | master | 533 | class Garelic::Middleware
def initialize(app)
@app = app
Garelic::Metrics.reset!
end
def call(env)
status, headers, response = @app.call(env)
if headers["Content-Type"] =~ /text\/html|application\/xhtml\+xml/ \
and response.respond_to?(:body) \
and response.body.respond_to?(:gsub... |
github | bokmann/sentient_user | https://github.com/bokmann/sentient_user | sentient_user.gemspec | Ruby | mit | 227 | master | 1,078 | # -*- encoding: utf-8 -*-
require File.expand_path('../lib/sentient_user/version.rb', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["bokmann"]
gem.email = ["dbock@javaguy.org"]
gem.description = %q{lets the User model in most authentication frameworks know who is the current user}
ge... |
github | bokmann/sentient_user | https://github.com/bokmann/sentient_user | Rakefile | Ruby | mit | 227 | master | 313 | require 'rubygems'
require 'rake'
require "bundler/gem_tasks"
require 'rake/testtask'
Rake::TestTask.new(:test) do |test|
test.libs << 'lib' << 'test'
test.pattern = 'test/**/test_*.rb'
test.verbose = true
end
task :default => :test
require File.expand_path('../lib/sentient_user/version.rb', __FILE__) |
github | bokmann/sentient_user | https://github.com/bokmann/sentient_user | lib/sentient_user.rb | Ruby | mit | 227 | master | 963 | module SentientUser
def self.included(base)
base.class_eval {
def self.current
Thread.current[:user]
end
def self.current=(o)
raise(ArgumentError,
"Expected an object of class '#{self}', got #{o.inspect}") unless (o.is_a?(self) || o.nil?)
Thread.current[:u... |
github | bokmann/sentient_user | https://github.com/bokmann/sentient_user | test/test_sentient_user.rb | Ruby | mit | 227 | master | 1,364 | require 'helper'
class TestTruth < Minitest::Should::TestCase
should "allow making the 'person' class sentient" do
p = Person.new
p.make_current
assert_equal Person.current, p
end
should "allow making the 'user' class sentient" do
u = User.new
u.make_current
assert_equal User.current, u
... |
github | bokmann/sentient_user | https://github.com/bokmann/sentient_user | test/helper.rb | Ruby | mit | 227 | master | 1,062 | require 'rubygems'
#require 'test/unit'
require "minitest/autorun"
require "minitest/should"
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'sentient_user'
#class Test::Unit::TestCase
#end
class Person
include SentientUser
end
class User
inc... |
github | pzol/monadic | https://github.com/pzol/monadic | Rakefile | Ruby | mit | 227 | master | 255 | #!/usr/bin/env rake
require "bundler/gem_tasks"
require 'rspec/core/rake_task'
desc "Run all specs"
RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = FileList['spec/**/*_spec.rb']
t.rspec_opts = %w[--format doc --color]
end
task :default => :spec |
github | pzol/monadic | https://github.com/pzol/monadic | Guardfile | Ruby | mit | 227 | master | 425 | # More info at https://github.com/guard/guard#readme
guard 'bundler' do
watch('Gemfile')
# Uncomment next line if Gemfile contain `gemspec' command
# watch(/^.+\.gemspec/)
end
guard 'rspec', :version => 2 do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/monadic/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
... |
github | pzol/monadic | https://github.com/pzol/monadic | monadic.gemspec | Ruby | mit | 227 | master | 1,056 | # -*- encoding: utf-8 -*-
require File.expand_path('../lib/monadic/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Piotr Zolnierek"]
gem.email = ["pz@anixe.pl"]
gem.description = %q{brings some functional goodness to ruby by giving you some monads}
gem.summary = %q{see... |
github | pzol/monadic | https://github.com/pzol/monadic | examples/validation.rb | Ruby | mit | 227 | master | 914 | require 'monadic'
class AgeTooLowError < ArgumentError; end
class AgeTooHighError < ArgumentError; end
valid_age = ->(age_expr) {
age = age_expr.to_i
case
when age <= 0; Failure(AgeTooLowError.new(age_expr))
when age > 130; Failure(AgeTooHighError.new(age_expr))
else Success(age)
end
}
valid_name = ->(... |
github | pzol/monadic | https://github.com/pzol/monadic | examples/validation_module.rb | Ruby | mit | 227 | master | 1,119 | require 'monadic'
Person = Struct.new(:name, :age)
module PersonValidation
class AgeTooLowError < ArgumentError; end
class AgeTooHighError < ArgumentError; end
def self.validate(params)
Validation() do
extend PersonValidation
check { valid_age(params[:age]) }
check { valid_name(params[... |
github | pzol/monadic | https://github.com/pzol/monadic | lib/monadic/monad.rb | Ruby | mit | 227 | master | 1,563 | module Monadic
module Monad
def initialize(value)
@value = join(value)
end
# Allows priviledged access to the inner value of the Monad from within the block
def bind(proc=nil, &block)
(proc || block).call(@value)
end
# If the passed value is monad already, get the value to avoid... |
github | pzol/monadic | https://github.com/pzol/monadic | lib/monadic/maybe.rb | Ruby | mit | 227 | master | 2,611 | module Monadic
class Maybe
include Monadic::Monad
def self.unit(value)
return Nothing if value.nil? || (value.respond_to?(:empty?) && value.empty?)
return Just.new(value)
end
# Initialize is private, because it always would return an instance of Maybe, but Just or Nothing
# are requi... |
github | pzol/monadic | https://github.com/pzol/monadic | lib/monadic/either.rb | Ruby | mit | 227 | master | 3,579 | module Monadic
# @abstract Chains function calls and stops executing if one of them fails.
class Either
include Monadic::Monad
def self.chain(initial=nil, &block)
Either::Chain.new(&block).call(initial)
end
def self.unit(value)
return value if value.is_a? Either
return Nothing ... |
github | pzol/monadic | https://github.com/pzol/monadic | lib/monadic/errors.rb | Ruby | mit | 227 | master | 263 | module Monadic
# thrown by Option#fetch if it has no value and no default was provided
class NoValueError < StandardError; end
# thrown when a Success or Failure was expected, but anything else was returned
class NotEitherError < StandardError; end
end |
github | pzol/monadic | https://github.com/pzol/monadic | lib/monadic/validation.rb | Ruby | mit | 227 | master | 1,328 | module Monadic
# Wraps the construction of the Validation class
def Validation(&block)
Validation.new.call(&block)
end
# Conducts several function calls which do checks, of which each must return Success or Failure
# and returns a list of all failures.
# Validation is not a monad, but an deemed an app... |
github | pzol/monadic | https://github.com/pzol/monadic | lib/monadic/try.rb | Ruby | mit | 227 | master | 517 | module Monadic
## Wrap a block or a predicate to always return Success or Failure.
## It will catch StandardError and return as a Failure.
def Try(arg = nil, &block)
begin
predicate = arg.is_a?(Proc) ? arg.call : arg
return Either(block.call) if block_given? && predicate.nil?
return Either(p... |
github | pzol/monadic | https://github.com/pzol/monadic | spec/try_spec.rb | Ruby | mit | 227 | master | 1,430 | require 'spec_helper'
describe 'Monadic::Try' do
it 'catches exceptions' do
Try { Date.parse('2012-02-30') }.should be_a Failure
end
it 'returns Failure when the value is nil or false' do
Try { nil }.should be_a Failure
Try { false }.should be_a Failure
end
it 'returns Failure for an empty coll... |
github | pzol/monadic | https://github.com/pzol/monadic | spec/either_spec.rb | Ruby | mit | 227 | master | 7,251 | require 'spec_helper'
describe Monadic::Either do
it 'Either cannot be created using #new, use #unit instead' do
expect { Either.new(1) }.to raise_error NoMethodError
end
it 'Success.new and Success.unit and Success() return the same' do
Success(1).should == Success.unit(1)
Success.new(1).should == ... |
github | pzol/monadic | https://github.com/pzol/monadic | spec/monad_spec.rb | Ruby | mit | 227 | master | 1,317 | require 'spec_helper'
describe Monadic::Monad do
class Identity
include Monadic::Monad
def self.unit(value)
new(value)
end
end
it_behaves_like 'a Monad' do
let(:monad) { Identity }
end
it '#to_s shows the monad name and its value' do
Identity.unit(1).to_s.should == 'Identity(1)'... |
github | pzol/monadic | https://github.com/pzol/monadic | spec/validation_spec.rb | Ruby | mit | 227 | master | 2,341 | require 'spec_helper'
describe Monadic::Validation do
Person = Struct.new(:age, :gender, :sobriety, :name)
it 'a projection of Success and Failure' do
def validate(person)
check_age = ->(age_expr) {
age = age_expr.to_i
case
when age <= 0; Failure('Age must be > 0')
when... |
github | pzol/monadic | https://github.com/pzol/monadic | spec/maybe_spec.rb | Ruby | mit | 227 | master | 4,844 | require 'spec_helper'
describe Monadic::Maybe do
it_behaves_like 'a Monad' do
let(:monad) { Maybe }
end
it 'Maybe cannot be created using #new, use #unit instead' do
expect { Maybe.new(1) }.to raise_error NoMethodError
end
it 'nil as value always returns Nothing()' do
Maybe(nil).a.b.c.should ... |
github | pzol/monadic | https://github.com/pzol/monadic | spec/monad_axioms.rb | Ruby | mit | 227 | master | 826 | require 'spec_helper'
shared_examples 'a Monad' do
describe 'axioms' do
it '1st monadic law: left-identity' do
f = ->(value) { monad.unit(value + 1) }
monad::unit(1).bind do |value|
f.(value)
end.should == f.(1)
end
it '2nd monadic law: right-identy - unit and bind do not chang... |
github | pzol/monadic | https://github.com/pzol/monadic | spec/spec_helper.rb | Ruby | mit | 227 | master | 204 | require 'bundler/setup'
Bundler.require(:test)
$LOAD_PATH << File.expand_path('../../lib', __FILE__)
require File.expand_path('../../lib/monadic', __FILE__)
require 'monad_axioms'
require 'jruby_fixes' |
github | pzol/monadic | https://github.com/pzol/monadic | spec/nothing_spec.rb | Ruby | mit | 227 | master | 1,475 | require 'spec_helper'
describe Monadic::Nothing do
it_behaves_like 'a Monad' do
let(:monad) { Nothing }
end
it '===' do
(Maybe(nil) === Nothing).should be_true
end
it 'Nothing stays Nothing' do
Maybe(nil).fetch.should == Nothing
Maybe(nil)._.should == Nothing
Maybe(... |
github | pzol/monadic | https://github.com/pzol/monadic | spec/examples/applicative_spec.rb | Ruby | mit | 227 | master | 1,330 | require 'spec_helper'
# Is a transformation C[A -> B] -> C[A] -> C[B]
module Applicative
# @param [Proc, lambda] proc
# @return [Functor] functor
def apply(value)
return value.class.unit(@value.call(value.fetch))
end
alias :<< :apply
end
class Monadic::Just
include Applicative
end
class Monadic::Ei... |
github | pzol/monadic | https://github.com/pzol/monadic | spec/examples/hotel_booking_spec.rb | Ruby | mit | 227 | master | 3,488 | require 'spec_helper'
require 'active_support/time'
describe 'Hotel Booking Example' do
module HotelBookingRequestParams
extend self
def hotel_code(params)
param = params['hotel_code']
Try(param =~ /^[A-Z]{3}[A-Z0-9]{4}$/) { param }.or "hotel_code must be of pattern XXX0001, got '#{param}'"
... |
github | pzol/monadic | https://github.com/pzol/monadic | spec/examples/builder_spec.rb | Ruby | mit | 227 | master | 1,798 | require 'spec_helper'
class BSONTestConverter
class InvalidBSONString < StandardError; end
def self.from_string(s)
raise InvalidBSONString unless s =~ /^[0-9a-z]{24}$/
return self.new(s)
end
def initialize(s)
@bson = s
end
def to_s
@bson
end
def ==(other)
return 0 unless other.is... |
github | pzol/monadic | https://github.com/pzol/monadic | spec/core_ext/object_spec.rb | Ruby | mit | 227 | master | 248 | require 'spec_helper'
require 'monadic/core_ext/object'
describe 'pseudo Elvis operator _?' do
it 'works' do
nil._?.should == Nothing
"foo"._?.should == 'foo'
{}._?.a.b.should == Nothing
{}._?[:foo] == Nothing
end
end |
github | aki77/activestorage-validator | https://github.com/aki77/activestorage-validator | Gemfile | Ruby | mit | 227 | master | 329 | source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
# Specify your gem's dependencies in activestorage-validator.gemspec
gemspec
local_gemfile = "Gemfile.local"
if File.exist?(local_gemfile)
eval_gemfile(local_gemfile) # rubocop:disable Security/Eval
else
gem 'sqli... |
github | aki77/activestorage-validator | https://github.com/aki77/activestorage-validator | activestorage-validator.gemspec | Ruby | mit | 227 | master | 1,344 | lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "activestorage/validator/version"
Gem::Specification.new do |spec|
spec.name = "activestorage-validator"
spec.version = ActiveStorage::Validator::VERSION
spec.authors = ["aki"]
spec.e... |
github | aki77/activestorage-validator | https://github.com/aki77/activestorage-validator | spec/spec_helper.rb | Ruby | mit | 227 | master | 806 | require "bundler/setup"
require "active_storage/engine"
Bundler.require :default, :development
require "support/blob_helper"
Combustion.initialize! :active_record, :active_job do
if ActiveRecord::VERSION::MAJOR < 6 && config.active_record.sqlite3.respond_to?(:represent_boolean_as_integer)
config.active_record.sq... |
github | aki77/activestorage-validator | https://github.com/aki77/activestorage-validator | spec/support/blob_helper.rb | Ruby | mit | 227 | master | 883 | module BlobHelper
def create_file_blob(filename:, content_type: "image/jpeg", metadata: nil)
if Rails::VERSION::MAJOR < 6 || (Rails::VERSION::MAJOR == 6 && Rails::VERSION::MINOR == 0)
ActiveStorage::Blob.create_after_upload! io: file_fixture(filename).open, filename: filename, content_type: content_type, m... |
github | aki77/activestorage-validator | https://github.com/aki77/activestorage-validator | spec/internal/db/schema.rb | Ruby | mit | 227 | master | 1,255 | # frozen_string_literal: true
ActiveRecord::Schema.define do
create_table :users do |t|
t.timestamps null: false
end
create_table :active_storage_blobs do |t|
t.string :key, null: false
t.string :filename, null: false
t.string :content_type
t.text :metadata
t.bigint ... |
github | aki77/activestorage-validator | https://github.com/aki77/activestorage-validator | spec/activestorage/validator/blob_spec.rb | Ruby | mit | 227 | master | 5,398 | RSpec.describe ActiveRecord::Validations::BlobValidator do
after { User.clear_validators! }
describe 'presence: true' do
context 'has_one_attached' do
before do
User.validates :file, presence: true
end
it { expect(User.new.valid?).to eq false }
it { expect(User.new(file: create... |
github | aki77/activestorage-validator | https://github.com/aki77/activestorage-validator | lib/activestorage/validator.rb | Ruby | mit | 227 | master | 228 | require 'activestorage/validator/version'
ActiveSupport.on_load(:active_record) do
require 'activestorage/validator/blob'
end
I18n.load_path += Dir[File.expand_path(File.join(__dir__, '../../config/locales', '*.yml')).to_s] |
github | aki77/activestorage-validator | https://github.com/aki77/activestorage-validator | lib/activestorage/validator/blob.rb | Ruby | mit | 227 | master | 1,616 | module ActiveRecord
module Validations
class BlobValidator < ::ActiveModel::EachValidator
def validate_each(record, attribute, values) # rubocop:disable Metrics/AbcSize
return unless values.attached?
Array(values).each do |value|
if options[:size_range].present?
if opt... |
github | amatsuda/still_life | https://github.com/amatsuda/still_life | Rakefile | Ruby | mit | 227 | master | 311 | # frozen_string_literal: true
require "bundler/gem_tasks"
require "rake/testtask"
Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList['test/**/*_test.rb'] - FileList['test/dummy_app/test/**/*_test.rb']
t.warning = true
t.verbose = true
end
task default: :test |
github | amatsuda/still_life | https://github.com/amatsuda/still_life | still_life.gemspec | Ruby | mit | 227 | master | 1,217 | lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "still_life/version"
Gem::Specification.new do |spec|
spec.name = "still_life"
spec.version = StillLife::VERSION
spec.authors = ["Akira Matsuda"]
spec.email = ["ronnie@dio.jp"... |
github | amatsuda/still_life | https://github.com/amatsuda/still_life | lib/still_life.rb | Ruby | mit | 227 | master | 708 | # frozen_string_literal: true
require_relative 'still_life/version'
require_relative 'still_life/action_dispatch_extension'
require_relative 'still_life/capybara_extension'
require_relative 'still_life/railtie'
module StillLife
def self.draw(html)
location = caller.detect {|c| c =~ /^#{Rails.root}/}.remove(Rail... |
github | amatsuda/still_life | https://github.com/amatsuda/still_life | lib/still_life/action_dispatch_extension.rb | Ruby | mit | 227 | master | 911 | # frozen_string_literal: true
module StillLife
module ActionDispatchExtension
def get(*, **)
super.tap do
StillLife.draw(response.body) unless response.get_header('Content-Transfer-Encoding') == 'binary'
end
end
def post(*, **)
super.tap do
StillLife.draw(response.body)... |
github | amatsuda/still_life | https://github.com/amatsuda/still_life | lib/still_life/railtie.rb | Ruby | mit | 227 | master | 1,156 | # frozen_string_literal: true
require 'rails'
module StillLife
class Railtie < Rails::Railtie
initializer 'still_life' do
if ENV['STILL_LIFE'] || ENV['STILLLIFE']
ActiveSupport.on_load :action_dispatch_integration_test do
ActionDispatch::Integration::Session.prepend StillLife::ActionDisp... |
github | amatsuda/still_life | https://github.com/amatsuda/still_life | lib/still_life/capybara_extension.rb | Ruby | mit | 227 | master | 1,453 | # frozen_string_literal: true
module StillLife
module CapybaraExtension
module ElementExtension
def click(*)
return super if Thread.current[:_still_life_inside_modal]
body_was = session.body
super.tap do
3.times do
if session.body.present? && (session.body != ... |
github | amatsuda/still_life | https://github.com/amatsuda/still_life | test/still_life_test.rb | Ruby | mit | 227 | master | 4,739 | require "test_helper"
class StillLifeTest < Test::Unit::TestCase
STILL_LIFE_ENV_VAR = 'test'
def test_executing_tests_in_the_dummy_app
Dir.chdir "#{__dir__}/dummy_app" do
FileUtils.rm_rf 'tmp/html/'
Bundler.with_unbundled_env do
case ENV['TEST_FRAMEWORK']
when 'test-unit'
... |
github | amatsuda/still_life | https://github.com/amatsuda/still_life | test/test_helper.rb | Ruby | mit | 227 | master | 346 | # frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
require 'rails'
require "still_life"
require 'test/unit'
Test::Unit::TestCase.class_eval do
def assert_html_dumped(path)
assert File.exist?(f = "#{__dir__}/dummy_app/tmp/html/#{path}.html") && File.read(f).present?, "#{f} ... |
github | amatsuda/still_life | https://github.com/amatsuda/still_life | test/dummy_app/Gemfile | Ruby | mit | 227 | master | 469 | source 'https://rubygems.org'
gem 'rails', '~> 6.0.0'
gem 'sqlite3'
gem 'puma'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
group :development, :test do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :test do
gem 'capybara', '>= 2.15'
g... |
github | amatsuda/still_life | https://github.com/amatsuda/still_life | test/dummy_app/spec/rails_helper.rb | Ruby | mit | 227 | master | 3,300 | # 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 | amatsuda/still_life | https://github.com/amatsuda/still_life | test/dummy_app/spec/controllers/users_controller_spec.rb | Ruby | mit | 227 | master | 4,865 | require 'rails_helper'
# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to specify the controller code that
# was generated by Rails when you ran the scaffold generator.
#
# It assumes that the implementation code is generated by the rails scaffold... |
github | amatsuda/still_life | https://github.com/amatsuda/still_life | test/dummy_app/spec/requests/users_spec.rb | Ruby | mit | 227 | master | 227 | require 'rails_helper'
RSpec.describe "Users", type: :request do
describe "GET /users" do
it "works! (now write some real specs)" do
get users_path
expect(response).to have_http_status(200)
end
end
end |
github | amatsuda/still_life | https://github.com/amatsuda/still_life | test/dummy_app/spec/system/users_spec.rb | Ruby | mit | 227 | master | 938 | require 'rails_helper'
RSpec.describe "Users CRUD", type: :system do
fixtures :users
before do
@user = users(:one)
end
scenario "visiting the index" do
visit users_path
expect(page).to have_selector "h1", text: "Users"
end
scenario "creating a User" do
visit users_path
click_on "New ... |
github | amatsuda/still_life | https://github.com/amatsuda/still_life | test/dummy_app/db/schema.rb | Ruby | mit | 227 | master | 943 | # This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# dat... |
github | amatsuda/still_life | https://github.com/amatsuda/still_life | test/dummy_app/test/test_helper.rb | Ruby | mit | 227 | master | 384 | ENV['RAILS_ENV'] ||= 'test'
require_relative '../config/environment'
case ENV['TEST_FRAMEWORK']
when 'test-unit'
require 'test/unit/rails/test_help'
else
require 'rails/test_help'
end
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all
... |
github | amatsuda/still_life | https://github.com/amatsuda/still_life | test/dummy_app/test/system/users_test.rb | Ruby | mit | 227 | master | 880 | require "application_system_test_case"
class UsersTest < ApplicationSystemTestCase
setup do
@user = users(:one)
end
test "visiting the index" do
visit users_url
assert_selector "h1", text: "Users"
end
test "creating a User" do
visit users_url
click_on "New User"
within "form" do
... |
github | amatsuda/still_life | https://github.com/amatsuda/still_life | test/dummy_app/test/controllers/users_controller_test.rb | Ruby | mit | 227 | master | 969 | require 'test_helper'
class UsersControllerTest < ActionDispatch::IntegrationTest
setup do
@user = users(:one)
end
test "should get index" do
get users_url
assert_response :success
end
test "should get new" do
get new_user_url
assert_response :success
end
test "should create user" ... |
github | amatsuda/still_life | https://github.com/amatsuda/still_life | test/dummy_app/test/integration/users_integration_test.rb | Ruby | mit | 227 | master | 209 | require 'test_helper'
class UsersIntegrationTest < ActionDispatch::IntegrationTest
setup do
@user = users(:one)
end
test 'it' do
get "/users/#{@user.id}"
assert_response :success
end
end |
github | amatsuda/still_life | https://github.com/amatsuda/still_life | test/dummy_app/app/controllers/users_controller.rb | Ruby | mit | 227 | master | 1,772 | class UsersController < ApplicationController
before_action :set_user, only: [:show, :edit, :update, :destroy]
# GET /users
# GET /users.json
def index
@users = User.all
end
# GET /users/1
# GET /users/1.json
def show
end
# GET /users/new
def new
@user = User.new
end
# GET /users/1... |
github | amatsuda/still_life | https://github.com/amatsuda/still_life | test/dummy_app/config/application.rb | Ruby | mit | 227 | master | 1,005 | require_relative 'boot'
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
# require "active_storage/engine"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
# require "action_cable... |
github | amatsuda/still_life | https://github.com/amatsuda/still_life | test/dummy_app/config/environments/production.rb | Ruby | mit | 227 | master | 3,561 | Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web serve... |
github | amatsuda/still_life | https://github.com/amatsuda/still_life | test/dummy_app/config/environments/development.rb | Ruby | mit | 227 | master | 2,048 | Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web serv... |
github | amatsuda/still_life | https://github.com/amatsuda/still_life | test/dummy_app/config/environments/test.rb | Ruby | mit | 227 | master | 1,759 | Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suit... |
github | mirah/pindah | https://github.com/mirah/pindah | pindah.gemspec | Ruby | apache-2.0 | 227 | master | 779 | # -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{pindah}
s.version = "0.1.3"
s.date = Time.now.strftime("%Y-%m-%d")
s.authors = [%q{Phil Hagelberg, Brendan Ribera, Adam Parrott}]
s.email = [%q{technomancy@gmail.com, brendan.ribera@gmail.com, parrott.adam@gmail.com}]
s.summary = %q{A too... |
github | mirah/pindah | https://github.com/mirah/pindah | lib/pindah.rb | Ruby | apache-2.0 | 227 | master | 5,789 | require "rake"
require "fileutils"
require "tempfile"
require "pp"
require "erb"
require "pathname"
begin
require 'ant'
rescue LoadError
abort 'This Rakefile requires JRuby. Please use jruby -S rake.'
end
require "mirah"
module Pindah
class << self
include Rake::DSL
end
VERSION = '0.1.3'
def self.i... |
github | mirah/pindah | https://github.com/mirah/pindah | lib/pindah_cli.rb | Ruby | apache-2.0 | 227 | master | 2,549 | require 'fileutils'
require 'erb'
module PindahCLI
DEFAULT_TARGET_VERSION = '2.3.3'
def self.create(package, location=nil, activity_name=nil)
segments = package.split('.')
location ||= segments.last
src_dir = File.join(location, 'src', *segments)
mkdir location, File.join('src', *segments)
m... |
github | mirah/pindah | https://github.com/mirah/pindah | test/pindah_cli_test.rb | Ruby | apache-2.0 | 227 | master | 2,848 | require 'test/unit'
require 'tmpdir'
require 'fileutils'
require 'rubygems'
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'pindah_cli'))
class PindahCLITest < Test::Unit::TestCase
PWD = File.expand_path(File.dirname(__FILE__))
def fixture(name)
File.read(File.join(PWD, 'fixtures', na... |
github | mirah/pindah | https://github.com/mirah/pindah | test/pindah_build_test.rb | Ruby | apache-2.0 | 227 | master | 1,051 | require 'test/unit'
require 'find'
require 'rubygems'
require 'fileutils'
require File.expand_path(File.join(File.dirname(__FILE__), '..',
'lib', 'pindah'))
def Pindah.ant
@ant
end
class PindahBuildTest < Test::Unit::TestCase
def setup
@garrett_path = File.expand_path(File.j... |
github | capistrano/laravel | https://github.com/capistrano/laravel | capistrano-laravel.gemspec | Ruby | mit | 226 | master | 1,308 | # frozen_string_literal: true
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'capistrano/laravel/version'
Gem::Specification.new do |spec|
spec.name = 'capistrano-laravel'
spec.version = Capistrano::Laravel::VERSION
spec.authors = ['Pe... |
github | capistrano/laravel | https://github.com/capistrano/laravel | Rakefile | Ruby | mit | 226 | master | 232 | # frozen_string_literal: true
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
task default: %i[spec rubocop]
RSpec::Core::RakeTask.new(:spec)
desc 'Run RuboCop checks'
RuboCop::RakeTask.new |
github | capistrano/laravel | https://github.com/capistrano/laravel | lib/capistrano/tasks/laravel.rake | Ruby | mit | 226 | master | 7,760 | # frozen_string_literal: true
# rubocop:disable Style/MixinUsage
include Comparable
# rubocop:enable Style/MixinUsage
# rubocop:disable Metrics/BlockLength
namespace :load do
task :defaults do
# Which roles to consider as laravel roles
set :laravel_roles, :all
# The artisan flags to include on artisan ... |
github | capistrano/laravel | https://github.com/capistrano/laravel | spec/spec_helper.rb | Ruby | mit | 226 | master | 359 | # frozen_string_literal: true
require 'bundler/setup'
require 'capistrano/all'
require 'capistrano/framework'
require 'capistrano/laravel'
RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = '.rspec_status'
config.expect_with :rspec d... |
github | orta/chairs | https://github.com/orta/chairs | chairs.gemspec | Ruby | mit | 226 | master | 805 | # -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "chairs/version"
Gem::Specification.new do |s|
s.name = "chairs"
s.version = Chairs::VERSION
s.authors = ["orta"]
s.email = ["orta.therox@gmail.com"]
s.homepage = "http://github.com/orta/muscialchairs"
s.... |
github | orta/chairs | https://github.com/orta/chairs | lib/musician.rb | Ruby | mit | 226 | master | 8,661 | require "rubygems"
require File.join(File.dirname(__FILE__), 'pow')
require File.join(File.dirname(__FILE__), 'simctl_parser')
require File.join(File.dirname(__FILE__), 'install_parser')
require "chairs/version"
# this command comes in handy for dev
# rm *.gem; gem uninstall chairs -ax;gem build *.gemspec; gem instal... |
github | orta/chairs | https://github.com/orta/chairs | lib/simctl_parser.rb | Ruby | mit | 226 | master | 715 | class SimctlParser
def get_devices
output = `xcrun simctl list`.strip
output = output.split("== Devices ==").last
os = ""
output.lines.map do |line|
if line.strip.start_with?( "--")
os = line.gsub("-","").strip
end
if line.strip.length != 0 && line.strip.start_with?( "... |
github | orta/chairs | https://github.com/orta/chairs | lib/install_parser.rb | Ruby | mit | 226 | master | 1,607 | class App
attr_accessor :bundle_id, :name, :app_path, :bundle_path, :modified_date, :exists
def to_s
"<App #{bundle_id} - #{name} > - #{app_path}"
end
end
class InstallParser
def parse ( log_path )
apps = {}
File.read(log_path).lines.each do |line|
if line.include? "MIInstallableBundl... |
github | orta/chairs | https://github.com/orta/chairs | lib/pow/file.rb | Ruby | mit | 226 | master | 1,533 | module Pow
# Pow object representing a file. Inherits from Pow::Base
class File < Base
def initialize(path, mode="r+", &block) #:nodoc:
super
open(mode, &block) if block_given?
end
def open(mode="r", &block) #:nodoc:
Kernel.open(path.to_s, mode, &block)
end
def crea... |
github | orta/chairs | https://github.com/orta/chairs | lib/pow/directory.rb | Ruby | mit | 226 | master | 2,694 | module Pow
# Pow object representing a directory. Inherits from Pow::Base
class Directory < Base
include Enumerable
def initialize(path, mode=nil, &block) #:nodoc:
super
open(&block) if block_given?
end
def open(mode=nil, &block) #:nodoc:
raise PowError, "'#{path}' does not e... |
github | orta/chairs | https://github.com/orta/chairs | lib/pow/pow.rb | Ruby | mit | 226 | master | 4,655 | class PowError < StandardError; end
# Path based in current working directory
def Pow(*args, &block)
Pow::Base.open(*args, &block)
end
# Path based in the current file's directory
def Pow!(*args, &block)
file_path = ::File.dirname(caller[0])
Pow(file_path, *args, &block)
end
module Pow
class Base
attr_ac... |
github | grosser/i18n_data | https://github.com/grosser/i18n_data | Rakefile | Ruby | mit | 226 | master | 2,375 | # frozen_string_literal: true
require 'bundler/setup'
require 'bundler/gem_tasks'
require 'bump/tasks'
require 'yaml'
$LOAD_PATH << "lib"
require 'i18n_data'
task default: [:spec, :rubocop]
desc "Run tests"
task :spec do
sh "rspec --warnings spec/"
end
desc "Rubocop"
task :rubocop do
sh "rubocop --parallel"
end... |
github | grosser/i18n_data | https://github.com/grosser/i18n_data | i18n_data.gemspec | Ruby | mit | 226 | master | 544 | # frozen_string_literal: true
name = "i18n_data"
require "./lib/#{name}/version"
Gem::Specification.new name, I18nData::VERSION do |s|
s.summary = "country/language names and 2-letter-code pairs, in 85 languages"
s.authors = ["Michael Grosser"]
s.email = "michael@grosser.it"
s.homepage = "https://github.com/gr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.