text stringlengths 10 2.61M |
|---|
module Synchronisable
module Helper
# Provides logging helper methods.
# Class or module that includes this one
# should implement `logger` method.
#
# @api private
module Logging
protected
%i(verbose colorize).each do |name|
define_method("#{name}_logging?".to_sym) do
... |
class AddUserIdToForums < ActiveRecord::Migration
def change
add_column :forums, :user_id, :integer
add_index :forums, :user_id
end
end
|
require 'rails_helper'
describe "user sees a list of ideas" do
scenario "user has multiple ideas on a page" do
user = create(:user)
idea1 = Idea.create!(name: "idea1", description: "read", user: user, category: build(:category))
idea2 = Idea.create!(name: "idea2", description: "learn", user: user, catego... |
class User < ActiveRecord::Base
has_secure_password
before_create :create_remember_token
has_many :gadgets, dependent: :destroy
def User.new_remember_token
SecureRandom.urlsafe_base64
end
private
def create_remember_token
self.remember_token = User.new_remember_token
end
end
|
class CreateCourses < ActiveRecord::Migration
def change
create_table :courses do |t|
t.string :name, :limit => 120, :null => false
t.integer :price, :null => false
t.string :image, :limit => 120, :null => false
t.integer :category_id, :null => false
t.timestamps
end
end
end
|
class SessionsController < ApplicationController
layout 'login'
def new
if session[:user_id]
redirect_to home_url
end
end
def create
user = AdminUser.find_by_username(params[:username])
if user && user.authenticate(params[:password])
session[:user_id] = user.id
redirect_t... |
class CreateCoursedLearningTracks < ActiveRecord::Migration
def change
create_table :coursed_learning_tracks do |t|
t.references :user, index: true
t.references :learning_track, index: true
t.string :status
t.datetime :status_changed_at
t.timestamps null: false
end
add_index... |
Sequel.migration do
up do
@log.info { "Running migration #{__FILE__}" }
# rename the old column
rename_column :utxo, :tx_hash, :tx_hash_tmp
# create our new column (but without constraints/indexes yet)
add_column :utxo, :tx_hash, (adapter_scheme == :postgres ? :bytea : :blob)
# copy over ... |
require 'redcarpet'
require 'pygments.rb'
module Soffes
module Blog
class MarkdownRenderer < Redcarpet::Render::HTML
def block_code(code, language)
if language
Pygments.highlight(code, lexer: language.to_sym)
else
"<pre>#{code}</pre>"
end
end
end
end
... |
class Board
attr_accessor :cells
def initialize
@cells = [" "]*9
end
def reset!
@cells = [" "]*9
end
def display
puts ""
puts " #{self.cells[0]} | #{self.cells[1]} | #{self.cells[2]} "
puts "-----------"
puts " #{self.cells[3]} | #{self.cells[4]} | #{self.cells[5]} "
puts "-----------"
puts " #... |
class ConstituentsController < ApplicationController
before_action :set_constituent, only: [:show, :edit, :update, :destroy]
# GET /constituents
# GET /constituents.json
def index
@constituents = Constituent.all
end
# GET /constituents/1
# GET /constituents/1.json
def show
end
# GET /constitu... |
require "#{Rails.root}/lib/Vip_Token/default.rb"
require "#{Rails.root}/lib/Vip_Token/defaultMappingRegistry.rb"
require 'soap/rpc/driver'
class VipSoapInterface < ::SOAP::RPC::Driver
DefaultEndpointUrl = "http://t1.se-demo2.com"
Methods = [
[ "",
"getServerTime",
[ ["in", "GetServerTime... |
class CartItemsController < ApplicationController
skip_before_action :authenticate_user!, only: [:new, :create]
before_action :set_cart, only: [:create, :destroy]
before_action :set_cart_item,only: [:show, :edit, :update, :destroy,:decrement]
def create
dish = Dish.find(params[:dish_id])
@cart_item = ... |
require_relative "../test_helper"
class TestFullApplication < Minitest::Test
attr_reader :full_application, :env, :file, :controller,
:new_view, :show_view, :folder
def setup
@env = {
"REQUEST_METHOD" => "GET",
"PATH_INFO" => "/users/new",
"RACK_INPUT" => ""
}
set_up_ful... |
class AddStatusToPosts < ActiveRecord::Migration[5.0]
def change
add_column :posts, :status, :integer, default: 0
add_column :posts, :offerrequest, :integer, default: 0
add_column :posts, :posttype, :integer, default: 0
end
end
|
class Account < ActiveRecord::Base
has_many :balances
validate :no_direct_subclass
class << self
attr_accessor :owner_type
end
def self.owned_by(klass)
@owner_type = klass.to_s.classify.constantize
belongs_to :owner, :polymorphic => true
validate :check_owner_type
end
def balance_at(d... |
class Library
attr_reader :books
def initialize
@books = []
end
def add_to_collection(book)
@books << book
end
def include?(work)
titles = @books.map do |book|
book.title
end
titles.include?(work)
end
def card_catalogue
alpha = @books.map do |book|
book.author_l... |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
require 'yaml'
boxes = YAML.load_file(File.join(File.dirname(__FILE__), 'boxes.yml'))
provider = boxes['settings']['provider']
#puts boxes
ENV['VAGRANT_DEFAULT_PROVIDER'] = provider
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.... |
# == Schema Information
#
# Table name: dietary_guidances
#
# id :integer not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
# diet_id :integer
# meal_id :integer
#
class DietaryGuidance < ApplicationRecord
belongs_to :meal
belongs_to... |
class CreateContracts < ActiveRecord::Migration[6.1]
def change
create_table :contracts do |t|
t.references :activity, null: false, foreign_key: true
t.integer :rate_type
t.string :rate
t.timestamps
end
remove_column :activities, :contract_type
end
end
|
class Api::V1::SongsController < ApplicationController
before_action :set_song, only: [:show, :update, :destroy]
# GET /songs
def index
@songs = Song.recent
render json: @songs
end
# GET /songs/1
def show
render json: @song
end
# POST /songs
def create
@song = Song.new(song_params)... |
class Page < ActiveRecord::Base
validates_inclusion_of :position , :in => ['top_menu', 'right_menu']
validates :title, :body, :user_id, presence: true
belongs_to :user
def published?
answer == defined?
answer.nil? ? false : true
end
end
|
class View
def display_all_recipes(recipes)
puts '------------'
recipes.each_with_index do |recipe, index|
puts "#{index + 1}. [#{recipe.rating}/5] #{recipe.name} - #{recipe.description}"
end
puts '------------'
end
def ask_for_name
puts 'What is the name of your recipe?'
print '>... |
require 'rails_helper'
require_relative '../support/devise'
RSpec.describe "/departments", type: :request do
def valid_attributes
{
department: attributes_for(:department)
}
end
def invalid_attributes
{
department: {
name: "",
}
}
end
describe "GET /" do
login_... |
class AddAudioConfigToTestcase < ActiveRecord::Migration[5.0]
def change
add_column :testcases, :audio_config, :string
end
end
|
require 'datamappify/data/criteria/relational/find_multiple'
module Datamappify
module Data
module Criteria
module Sequel
class FindMultiple < Relational::FindMultiple
private
# @return [Array]
def records
query_builder = source_class
secondar... |
# frozen_string_literal: true
class UrlValidator < ActiveModel::EachValidator
RESERVED_OPTIONS = [:schemes, :no_local]
def initialize(options)
options.reverse_merge!(schemes: %w(http https))
options.reverse_merge!(message: 'must be a valid URL')
options.reverse_merge!(user_agent: 'Mozilla/5.0 (Macinto... |
require 'open3'
require 'event_emitter'
require 'json'
require 'colorize'
require 'chronic_duration'
require 'komenda'
require 'indentation'
module PuppetModules
class SpecRunner
class Result
attr_accessor :spec_result_list
def initialize
@spec_result_list = []
end
# @return... |
# coding: utf-8
describe SQLiterate::CommentParser do
def parse(q)
SQLiterate::CommentParser.new.parse q
end
def should_parse(q)
r = parse q
expect(r).not_to be_nil
r
end
def should_reject(q)
expect(parse q).to be_nil
end
it "parses a C comment" do
should_parse "/* a comment */... |
class CreateCorrections < ActiveRecord::Migration[6.0]
def change
create_table :corrections do |t|
t.belongs_to :answer
t.belongs_to :user
t.text :text
t.datetime :accepted_at
t.timestamps
end
end
end
|
=begin
Test de l'administration du portail pour un simple user
Cas : Online - Simple user
=end
require 'spec_helper'
describe "Admin pour un simple utilisateur" do
before(:all) do
TI::set_online
TI::as_simple_user
end
it "vouloir atteindre l'administration redirige vers la boite de login" do
page ... |
class Customer
attr_reader :name
@@customers = []
def initialize(options={})
@name = options[:name]
add_to_customers
end
def self.all
@@customers
end
def self.find_by_name(name)
@@customers.each do |customer|
if customer.name == name
return customer
end
end
end
def purc... |
require 'rails_helper'
describe Image do
let(:image) { create(:image) }
describe "validations" do
subject { image }
it { should be_valid }
it { should belong_to(:media_item) }
it { should have_attached_file(:file) }
it { should validate_attachment_presence(:file) }
it { should validate_at... |
class Artist < ActiveRecord::Base
has_many :follows, dependent: :destroy
end |
class CreateQuestionFlows < ActiveRecord::Migration
def change
create_table :question_flows do |t|
t.string :name_en
t.string :name_es
t.string :report_name
t.text :description_en
t.text :description_es
t.integer :first_question_id
t.string :status
t.text :tsorted_e... |
require 'bcrypt'
class User < ActiveRecord::Base
include BCrypt
has_attached_file :image, styles: { small: "64x64", med: "100x100", large: "200x200" }
validates_attachment :image, content_type: { content_type: ["image/jpg", "image/jpeg", "image/png", "image/gif"]}
validates :email, presence: true
has_many :s... |
module WellFormed
module Validations
def valid?
if !models.all?(&:valid?)
merge_model_errors
false
else
super
end
end
private
def merge_model_errors
models.each do |model|
model.errors.each do |attribute, message|
errors.add(attribute... |
class ChangePdfSizeToBigInt < ActiveRecord::Migration
def change
change_column :documents, :pdf_size, :int8, limit: 8
end
end
|
# frozen_string_literal: true
class RemoveSnippetFromEventsAndSteps < ActiveRecord::Migration[6.0]
def change
remove_column :steps, :snippet, :string
remove_column :location_events, :snippet, :string
end
end
|
class Tweet < ApplicationRecord
include Crud::ByUser
has_many :retweets, inverse_of: 'tweet'
accepts_nested_attributes_for :retweets
before_save :set_status
def gadget_id
"#{self.class.name.underscore}_#{self.id}"
end
def client
@client ||= Twitter::REST::Client.new do |config|
conf... |
class CreateCosts < ActiveRecord::Migration
def change
create_table :costs do |t|
t.float :value
t.references :user, index: true
t.references :benefit, index: true
t.timestamps null: false
end
add_foreign_key :costs, :users
add_foreign_key :costs, :benefits
end
e... |
require 'spec_helper'
RSpec.describe Xencoder::Xbase do
let(:subject) { described_class.new('0123456789abcdef'.chars) }
it { expect(subject.to_x(16)).to eq 16.to_s(16) }
it { expect(subject.to_x(100)).to eq 100.to_s(16) }
it { expect(subject.to_i(16.to_s(16))).to eq 16 }
it { expect(subject.to_i(100.to_s(16... |
require "spec_helper"
describe Amorail::TaskType do
before { mock_api }
describe "validations" do
it { should validate_presence_of(:name) }
end
describe ".attributes" do
subject { described_class.attributes }
it_behaves_like 'entity_class'
specify do
is_expected.to include(
... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe ViewHelper do
describe 'officer flags' do
it 'gets the correct SVG for Lt/C' do
expect(described_class.officer_flag('educational')).to include(
'<svg ',
'<title>LTC</title>',
'<path d="M 0 0 l 384 0 l 0 256 l -384 ... |
describe "server requests" do
machine_type = compute.machine_types.first
image = compute.images.first
let(:server_format) do
{
"id" => String,
"workload" => String,
"name" => String,
"description" => String,
"load_balance... |
require 'minitest/autorun'
require 'minitest/pride'
require './lib/car'
require './lib/owner'
class Test < Minitest::Test
def setup
@owner_1 = Owner.new('Regina George', 'Heiress')
end
def test_it_exists
assert_instance_of Owner, @owner_1
end
def test_it_has_attributes
assert_equal "Regina Geor... |
class AddBeginerFlagToBikes < ActiveRecord::Migration[5.0]
def change
add_column :bikes, :beginer_flag, :boolean ,default: false, null: false
end
end
|
class PotentialBuyersController < ApplicationController
before_action :set_potential_buyer, only: [:show, :edit, :update, :destroy]
# GET /potential_buyers
# GET /potential_buyers.json
def index
if current_user.is_admin
@potential_buyers = PotentialBuyer.all
elsif session[:role] == 'realtor'
... |
require('pg')
class SpaceCowboy
attr_accessor :name, :species, :bounty_value, :danger_level, :last_known_location, :homeworld, :favourite_weapon, :cashed_in, :collected_by
attr_reader :id
def initialize ( options )
@name = options["name"]
@species = options["species"]
@bounty_value = options["bounty_... |
class Api::EventsController < ApplicationController
respond_to :html, :json
# This action handles file uploads.
# I'd prefer to have direct amazon s3 uploads that happen independently.
# Right now, we switched from AJAX post to normal HTML post.
# This ties up our servers and isn't very scalable.
# We got ... |
class CompareValidator < ActiveModel::EachValidator
def validate_each(record, atribute, value)
cmp = record.atribute[options[:compare_to]].to_i
case options[:type]
when :greater_than
record.errors.add(atribute, 'は指定項目より大きくなければなりません。')
unless value > cmp
when :less_than
record.errors.ad... |
require_relative '../lib/hipmost/room_repository'
RSpec.describe Hipmost::RoomRepository do
it "loads room data" do
repo = described_class.new(".")
repo.load(data)
expect(repo.size).to eq(2)
room = repo[206455]
expect(room).to be_a(Hipmost::RoomRepository::Room)
room_by_name = repo.find_by... |
# app/controllers/scenarios_controller.rb
class ScenariosController < ApplicationController
before_action :set_scenario, only: %i[show update destroy]
before_action :require_admin, only: %i[new create edit update delete]
before_action :create_variables_hstore, only: %i[create update]
# GET /scenarios
def ind... |
class FontAlexandria < Formula
head "https://github.com/google/fonts/raw/main/ofl/alexandria/Alexandria%5Bwght%5D.ttf", verified: "github.com/google/fonts/"
desc "Alexandria"
desc "9 weights font family made in matching to the latin type Montserrat"
homepage "https://fonts.google.com/specimen/Alexandria"
def ... |
class Student < ActiveRecord::Base
GRADES = [:Kindergarten, :"1", :"2", :"3", :"4", :"5", :"6", :"7", :"8", :"9", :"10", :"11", :"12",
:"13", :"14", :"15", :"16", :"17", :"18", :"Headstart AM", :"Headstart PM", :Preschool]
STATUSES = [ :empty, :pending, :denied, :completed, :stopped ]
validates_un... |
require_relative "./shared/intcode"
def amplify(phase_settings)
signal = 0
amplifiers = phase_settings.map do |setting|
Computer.new(INTCODE).tap { |cpu| cpu.run(inputs: [setting]) }
end
loop do
amplifiers.each { |amplifier| signal = amplifier.run(inputs: [signal]).last }
break if amplifiers.none?... |
class Admins::OrdersController < ApplicationController
before_action :authenticate_admin!
def index
@orders = Order.page(params[:page]).per(10)
end
def show
@order = Order.find(params[:id])
end
def update
@order = Order.find(params[:id])
if @order.update(order_params)
flash[:notice]... |
require 'rails_helper'
describe 'InvoiceItems API' do
it 'returns index of invoice_items' do
create_list(:invoice_item, 2)
get '/api/v1/invoice_items'
items = JSON.parse(response.body)
expect(response).to be_success
expect(items.count).to eq(2)
end
it 'returns a single invoice_item' do
... |
FactoryGirl.define do
factory :message, :class => PointlessFeedback::Message do
name 'A Developer'
email_address 'developer@pointlesscorp.com'
description 'Site is broke'
topic 'Other'
url 'https://www.viget.com/'
end
end
|
require 'rails_helper'
require 'cancan/matchers'
describe 'User' do
describe 'abilities' do
let(:user) { nil }
subject(:ability) { Ability.new(user) }
context 'when anonymous' do
it { is_expected.to be_able_to(:read, :all) }
it { is_expected.not_to be_able_to(:manage, :all) }
end
co... |
class Devices::LogController < Devices::ApplicationController
before_action :set_device
def index
@log = @device.get_log(params[:since])
end
end
|
require 'spec_helper'
describe Qwyz do
before do
@user = create_test_user("n", "e@q.com", "passpass", "passpass")
@qwyz = create_test_qwyz(@user.id, "n", "q", "d")
@qwyz2 = create_test_qwyz(@user.id, "n", "q", "d")
@qwyz3 = create_test_qwyz(@user.id, "n", "q", "d")
@qitem1 = newitem(@qwyz.id, QwyzItem::STAT... |
describe 'ruby hook methods' do
context "- method related hooks: " do
context "method_missing" do
it "should do method_missing" do
#pending("not done yet")
end
end
context "method_added" do
it "should do be triggered everytime we add a method to a class" do
module TraceMe... |
# frozen_string_literal: true
require 'spec_helper'
require 'bolt_spec/bolt_server'
require 'bolt_spec/conn'
require 'bolt_spec/file_cache'
require 'bolt_server/config'
require 'bolt_server/transport_app'
require 'json'
require 'rack/test'
require 'puppet/environments'
describe "BoltServer::TransportApp" do
include... |
class Answer < ApplicationRecord
enum state: { pending: 0, resolved: 1, escalated: 2 }
belongs_to :doubt
belongs_to :user
scope :pend_answer, -> { where("answers.state = ?", 0) }
scope :res_answer, -> { where("answers.state = ?", 1) }
scope :escal_answer, -> { where("answers.state = ?", 2) }
validates_p... |
require "test_helper"
class TupleTest < MiniTest::Test
def create_vector(x, y, z)
RayTracer::Tuple.vector(x: x, y: y, z: z)
end
def create_point(x, y, z)
RayTracer::Tuple.point(x: x, y: y, z: z)
end
def create_tuple(x, y, z, w)
RayTracer::Tuple.new(x: x, y: y, z: z, w:w )
end
def test_that... |
require 'faker'
FactoryGirl.define do
factory :blog do
association :user, factory: :user, strategy: :build
name { Faker::Internet.user_name }
handle { Faker::Lorem.characters(10) }
description "test description"
guest false
factory :guest_blog do
guest true
end
# factory :blog_with_posts d... |
require "test_helper"
describe UsersController do
it "should get index" do
get users_path
must_respond_with :success
end
it "should get show" do
get user_path(users(:one).id)
must_respond_with :success
end
it "should redirect to all users page if user not found" do
users(:one).destroy
... |
#!/usr/bin/ruby
#
# consolidate/aggregate hits files
# input files are assumed to be sorted by doc,term
#
# format is assumed:
# parameters
# arg 0: input file pattern ( a string in quotes *** linux will expand pattern beforehand otherwise)
# arg 2: output file
# input format: term,doc,bin1,bin2,bin3...bin10,bin20,.... |
require 'spec_helper'
describe Cielo::Bandeira do
before do
@bandeiras = Cielo::Bandeira.all
@params = {
:numero => 123,
:valor => 100,
:"url-retorno" => 'localhost',
:autorizar => 2,
:capturar => true
}
end
it "each should have valid name, installments and debit" do
... |
class ConventionsController < ApplicationController
before_filter :check_user, except: [:index, :show]
before_filter :require_user, except: [:index, :show, :convention_payment]
before_action :find_convention, only: [:show]
def index
@conventions = Convention.all
end
def show
@registered_users = Convention... |
$LOAD_PATH.push File.expand_path("../lib", __FILE__)
require "omniauth-quizlet/version"
Gem::Specification.new do |s|
s.name = "omniauth-quizlet"
s.version = Quizlet::VERSION
s.authors = ["John Koht"]
s.email = ["john@kohactive.com"]
s.homepage = "https://github.com/kohactive/omniauth... |
# frozen_string_literal: true
class EtdIndexer < Hyrax::WorkIndexer
##
# Use the custom indexing service.
#
# This obviates inclusion of both `Hyrax::IndexesBasicMetadata` and
# `Hyrax::IndexesLinkedMetadata`, which both override this method (and
# conflict with one another in the process).
def rdf_servic... |
require 'test_helper'
class MerchantsTest < ActionDispatch::IntegrationTest
def redirect_to_sign_in
assert_redirected_to(controller: "devise/sessions", action: "new")
end
def sign_in!
u = User.create(email: "a#{rand(99999)}@a.a", password: "asdfasdf")
sign_in(u)
end
test "index action" do
... |
class Bet < ApplicationRecord
belongs_to :better, class_name: "User"
belongs_to :bettee, class_name: "User"
belongs_to :winner, class_name: "User", optional: true
belongs_to :loser, class_name: "User", optional: true
has_many :notifications
def self.update_status(button, user, bet)
if button === "Accep... |
require "json"
require "time"
module BoshDeploymentResource
class InCommand
def initialize(bosh, writer=STDOUT)
@writer = writer
@bosh = bosh
end
def run(working_dir, request)
raise "no version specified" unless request["version"]
if bosh.target != ""
deployment_name = r... |
When(/^I want to view all the portfolio items on my project$/) do
on(NavigationPage).goto(:portfolio_items_page)
on(PortfolioItemsPage).wait_for_page
end |
class Admin::UsersController < ApplicationController
def index
@users = User.where(admin: false).page(params[:page]).per(10)
end
def show
@user = User.find(params[:id])
end
def edit
@user = User.find(params[:id])
end
def update
@user = User.find(params[:id])
if @user.update_att... |
class CartSerializer < ActiveModel::Serializer
attributes :id
# ,
# :user_id, :clue_id
# has_one :clue
has_one :user
end
|
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :set_locale
before_action :do_not_show_default_locale_in_url
private
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
def do_not_show_default_locale_in_url
... |
#!/usr/bin/ruby
# parses Emsembl FASTA file with detailed header into a mapping from transcript->gene_symbol
# >ENST00000448914.1 cdna:known chromosome:GRCh38:14:22449113:22449125:1 gene:ENSG00000228985.1 gene_biotype:TR_D_gene transcript_biotype:TR_D_gene gene_symbol:TRDD3 description:T cell receptor delta diversity... |
module Admin
class ProductsController < Fae::BaseController
validates :title, uniqueness: true, presence: true
validates :price, presence: true
private
def build_assets
@item.build_hero_image if @item.hero_image.blank?
end
end
end
|
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# nickname :string not null
# email :string not null
# password_digest :string not null
# session_token :string not null
# created_at :datetime ... |
class ArticleFile < ActiveRecord::Migration[5.1]
def change
add_column :articles, :chartFile, :string
end
end
|
class Task < ApplicationRecord
before_create :set_confirmation_default
before_create :set_done_default
belongs_to :goal, optional: true
validates :title, presence: true, length: { in: 2 .. 100 }
validates :content, presence: true, length: { in: 5 .. 500 }
private
def set_confirmation_default
sel... |
#!/usr/bin/env ruby
def point(s)
m = s.match(/[pva]=<([-0-9]+),([-0-9]+),([-0-9]+)>/)
m[1..3].map{|k| k.to_i}.to_a
end
def part1
t = 10000000
puts STDIN.each_with_index.map {|l, idx|
p, v, a = l.chomp.split(', ').map{|k| point(k)}.to_a
distance = p.zip(v, a).map{|pi, vi, ai| (pi + t*vi... |
# -*- encoding: utf-8 -*-
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "pure-css-rails/version"
Gem::Specification.new do |gem|
gem.name = "pure-css-rails"
gem.version = PureCSS::Rails::VERSION
gem.authors = ["Balazs Kutil"]
gem... |
#!/usr/bin/env ruby
require 'curses'
begin
Curses.init_screen
Curses.start_color# if Curses.has_colors?
Curses.use_default_colors
Curses.nonl
Curses.noecho # don't echo keys entered
Curses.curs_set(0) # invisible cursor
half_height = Curses.lines
half_width = Curses.cols
win = Curses::Window.new... |
require 'rails_helper'
RSpec.describe User, type: :model do
describe 'Validations' do
it 'initial test with four fields' do
@user = User.new(
name:"onetwothree",
email:"123@123",
password_confirmation:'aaaaaaa',
created_at:2.day.ago,
updated_at... |
cache ["v1", @podcast], expires_in: 1.hour do # Podcasts will refresh every hour.
xml.rss('version' => "2.0", 'xmlns:itunes' => "http://www.itunes.com/dtds/podcast-1.0.dtd") do
xml.channel do
xml.title @podcast.title
xml.link @podcast.url || "http://www.scpr.org"
xml.des... |
# encoding: utf-8
require File.join(File.dirname(__FILE__), 'helper')
require 'delayed_job'
Delayed::Worker.delay_jobs = false
NewsletterJob = Struct.new(:text, :emails) do
def perform
end
end
class TestDelayedJobInterposer < TuneMyGcInterposerTestCase
def test_init
TuneMyGc.interposer = TuneMyGc::Interp... |
# frozen_string_literal: true
require_relative '../lib/cell'
require_relative '../lib/universe'
class GameOfLifeTest
def self.test_all
failed_tests = 0
total_tests = 0
private_instance_methods.select { |s| s.to_s.start_with?('test_') }.each do |test|
total_tests += 1
GameOfLifeTest.new.send(... |
require 'open-uri'
require 'nokogiri'
class WikiLang
@@url = "http://omniglot.com/writing/languages.htm"
def initialize
@languages = []
fetch_languages
end
def url
@@url
end
def document
Nokogiri::HTML(open(url))
end
def add_language? text
if text.empty?
false
elsif te... |
require 'rails_helper'
RSpec.describe AccountStatements::List, type: :api do
describe 'Behavior' do
let(:user) { create(:user) }
let(:other_user) { create(:user) }
let!(:record_a) { create(:record, user: user, occurred_at: Time.zone.parse('2020/03/01')) }
let!(:record_b) { create(:record, user: user... |
FactoryBot.define do
factory :school_class do
title { "Computer Science" }
room_number { 5 }
end
end
|
# frozen_string_literal: true
module GeoPattern
module Roles
module NamedGenerator
def name?(other_name)
name == other_name.to_sym
end
def name
Helpers.underscore(Helpers.demodulize(self.class).gsub(/Generator/, "")).to_sym
end
end
end
end
|
Rails.application.routes.draw do
devise_for :users
root to: 'main#index'
# Orders
resources :orders
get 'orders/:id/complete', to: 'orders#complete'
# Stands
resources :stands
# Places
resources :places
# Users
resources :users
# Teams
resources :teams
# Challenges
resources :challe... |
# frozen_string_literal: true
require 'shared/file'
require './lib/log_processor/sorter/base'
require './lib/log_processor/sorter/ascending'
RSpec.describe LogProcessor::Sorter::Ascending do
describe '#call' do
include_context 'temp file data'
it 'returns the asc sorted transformed total counted values' do... |
class Deck < ActiveRecord::Base
has_many :games
has_many :cards
validates :deck_name, presence: true
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.