text stringlengths 10 2.61M |
|---|
class WorkoutGroup < ApplicationRecord
has_many :user_groups, :dependent => :delete_all
has_many :users, through: :user_groups
has_many :workouts, :dependent => :delete_all
validates :name, presence: true
accepts_nested_attributes_for :user_groups
accepts_nested_attributes_for :workouts, reject_if: :all_b... |
require 'rails_helper'
describe 'Team Parser' do
describe '.parse' do
context 'with valid parameters' do
it 'creates a new team if one does not exist' do
TeamParser.parse(create_pull_request_params)
expect(Team.all.size).to eq(1)
end
it 'finds the team if one does exist' do
... |
class SynchronizeRepositoryWorker
include Sidekiq::Worker
def perform(repository_id)
repository = Repository.find(repository_id)
provider = repository.provider.camelize.constantize
provider::Repositories.synchronize(repository)
repository.save!
SynchronizeIssuesWorker.perform_async(reposito... |
class Post < ActiveRecord::Base
attr_accessible :body, :title, :summary
belongs_to :user
validates :body, :presence => true
validates :title, :presence => true
def to_param
"#{id}-#{title.gsub(/[^a-z0-9]+/i, '-')}"
end
end
|
require 'openssl'
require 'yaml'
require 'hashlib'
require 'deep_merge'
require 'addressable/uri'
require 'httparty'
require 'onering/config'
module Onering
class API
module Actions
class Retry < ::Exception; end
end
module Errors
class Exception < ::Exception; end
class NotConnected <... |
class Content < ActiveRecord::Base
# attr_accessor :color, :text, :font
belongs_to :user
validates_presence_of :color, :title, :font, :user_id
before_create :restrict_user_from_creating_one_more_record
def restrict_user_from_creating_one_more_record
errors.add(:base, "Cannot create one more record, inste... |
require 'sinatra'
require 'open-uri'
require 'openssl'
require 'nokogiri'
require 'nintendo_eshop'
# require 'pry'
# overwrite nintendo_eshop method due to some responses have nil dates
# `self.release_date = Date.parse(result.dig(:releaseDateMask))`
NintendoEshop::Game.class_eval do
def refresh_object(result)
... |
class Changeplayercolumns < ActiveRecord::Migration
def change
change_column :participants, :upgrades, :text, :limit => nil
end
end
|
module MigratorWeb
class Migration
include ActiveModel::Model
attr_accessor :id, :name, :status
def down
ActiveRecord::Migrator.run(:down, self.class.paths, id.to_i)
reload
end
def up
ActiveRecord::Migrator.run(:up, self.class.paths, id.to_i)
reload
end
def redo... |
class Image
def initialize (blur)
@picture = blur
end
def blur
@ones = []
@picture.each_with_index do |row, row_index|
row.each_with_index do |column, column_index|
if column == 1
@ones << [row_index, column_index]
end
end
... |
# -*- coding: utf-8 -*-
module RolesHelper
include ApplicationHelper
def is_admin?(program = current_program)
return false unless session_exists?
return true if current_user && current_user.system_admin?
is_logged_in? && (!session[:act_as_admin].blank? || has_role('Admin', program))
end
def is_... |
class Api::UsersController < ApplicationController
skip_before_action :authenticate_request, only: [:login]
def index
@users = User.all
end
def show
@user = User.find(params[:id])
end
def create
@user = User.create!(user_params)
render status: :created
end
def login
@token = AuthenticateUser.call(... |
#Write another method that returns true if the string passed as an argument is a palindrome, false otherwise.
#This time, however, your method should be case-insensitive, and it should ignore all non-alphanumeric characters.
def real_palindrome?(string)
alphanumeric = ('a'..'z').to_a + ('0'..'9').to_a
palindrome_c... |
namespace :bm do
desc "one class' attributes and small intersection, query benchmarking"
task :one_class_small_intersection => :environment do
require 'benchmark'
include Benchmark
include RakeHelper
def loops
Artist.all.each do |artist|
if artist.commissions.present?
arti... |
# first and last letters of each word in a string swapped
# strings separated by spaces
# input = string
# output = string (swapped first and last letters)
# Capital letters remain as is
# Spaces included in output string
# swap first and last letters around
# sub both letters
def swap(string)
array = string.split
... |
require 'rails_helper'
RSpec.describe PhotoHelper, :type => :helper do
before(:each) do
allow(helper).to receive(:render).and_return("<tag />")
end
context "for two photos" do
it "calls render twice" do
photo = "anyObject"
photos = [photo, photo]
expect(helper).to receive(:render).wit... |
class AddBusVoltageLvToImportanceIndices < ActiveRecord::Migration
def self.up
add_column :importance_indices, :bus_voltage_lv_id, :integer
end
def self.down
remove_column :importance_indices, :bus_voltage_lv_id
end
end
|
class Post < ActiveRecord::Base
validates_presence_of :post
has_attached_file :image, :styles => { :medium => ["590x500>", :jpg]}, :convert_options => { :medium => "-quality 70" }, :message => ""
validates_attachment_content_type :image, :content_type => /\Aimage\/(jpg|jpeg|png|gif)\Z/, :message => "nope"
validates_at... |
require 'socket'
module ML
module Learners
class Learner
SOCKET_PROTOCOL = 0
SOCKET_BUFFSIZE = 1048576
SOCKET_MESSAGES_IN_FLIGHT = 80
LARGE_SOCKET_MESSAGES_IN_FLIGHT = 10
PYTHON_BINARY = %w(python external/ml/mitclasses)
def initialize(model)
@model = model
@n... |
require 'spec_helper'
describe Enocean::Esp3::CommonCommand do
describe "ReadIdBase" do
let(:command) { Enocean::Esp3::ReadIdBase.create }
it "should create a ReadId command" do
command.packet_type.should == 0x05
end
it "should print the packet " do
command.to_s.should_not be_nil
... |
class MoussaillonsController < ApplicationController
def index
@moussaillons = Moussaillon.all
# @number_of_gossips = Gossip.where("moussaillon_id = " + ).count
end
def new
@moussaillon = Moussaillon.new
end
def create
@moussaillon = Moussaillon.new
@moussaillon.username = params_mouss... |
Rails.application.routes.draw do
root to: 'jobs#index'
get 'jobs/next', to: 'jobs#next'
resources :jobs
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
# Serve websocket cable requests in-process
mount ActionCable.server => '/cable'
end
|
class UsersController < ApplicationController
before_action :current_meetup, only: [:show, :directions, :cancel, :update]
def new
@user = User.new
categories = ['Technology','TV','Business','Politics','Travel','Games','Movies','Theatre','Sports','Fashion']
categories.each do |category|
interest ... |
require_relative "../spec_helper"
load_lw_resource("rbenv", "ruby")
describe Chef::Resource::RbenvRuby do
let(:resource) { described_class.new("antruby") }
it "sets the default attribute to definition" do
expect(resource.definition).to eq("antruby")
end
it "attribute definition_file defaults to nil" do
... |
RSpec.describe LaserGem, type: :model do
it "has working factory" do
laser_gem = build :laser_gem
expect(laser_gem.save).to be true
end
it "checks name attribute" do
laser_gem = build :laser_gem, name: ""
expect(laser_gem.save).to be false
end
it "validates low values for length" do
lase... |
class SessionsController < ApplicationController
include SessionsHelper
def index
if logged_in?
redirect_to user_profile_path(current_user.id)
end
end
def create
user = User.find_by(email: params[:email].downcase)
user = Instructor.find_by(email: params[:email].downcase) if !user
if user && user... |
# 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 rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
class Review < ApplicationRecord
validates :rating, presence: true
belongs_to :restaurant
belongs_to :user
end |
require 'spec_helper'
describe Crepe::API, '.mount' do
app do
sub_api = Class.new Crepe::API do
get { 'HI' }
end
mount sub_api
mount -> env { [200, {}, ['OK']] } => '/ping'
namespace :pong do
mount -> env { [200, {}, ['KO']] }
end
end
it 'mounts Rack apps in place' do
... |
class NicknameFan < ActiveRecord::Base
belongs_to :club
validates :club, presence: true
validates :name, presence: true
has_enumeration_for :status, with: CommonStatus, required: true,
create_scopes: true, create_helpers: true
after_initialize :pluralize_name, on: :create
... |
require_relative 'berserk_player'
decribe BerserkPlayer do
before do
@initial_health = 50
@player = BerserkPlayer.new("berserker", @initial_health)
end
it "does not go berserk when w00ted up to 5 times" do 1.upto(5)
{@player.w00t}
@player.berserk?.should be_false
end
it "goes bersek when w00... |
require_relative 'mover'
require_relative 'bomb'
class Player
attr_reader :pos
def initialize(window)
@window = window
@sprite = Gosu::Image.new(window, "images/stickfig.png", false)
@arm = Gosu::Image.new(window, "images/arm.png", false)
@pos = Mover.new
end
def facing xdir, ydir
@x_face ... |
class BookGroupship < ApplicationRecord
belongs_to :book
belongs_to :group
end |
require 'bcrypt'
# The User model
class User < ApplicationRecord
include BCrypt
validates :name, :password_hash, presence: true
validates :admin, inclusion: [true, false]
validates :email, uniqueness: true
validates :email, presence: true,
format: { with: /\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z/... |
require "json"
require "selenium-webdriver"
require "test/unit"
class LogIn < Test::Unit::TestCase
def setup
@driver = Selenium::WebDriver.for :chrome
@base_url = "https://staging.shore.com/merchant/sign_in"
@accept_next_alert = true
@driver.manage.timeouts.implicit_wait = 30
@verification_error... |
class ContactForm < MailForm::Base
attribute :name
attribute :email
attribute :phone
attribute :building
attribute :pets
attribute :smoker
attribute :student
attribute :comments
validates_presence_of :name, :email, :phone
validates_format_of :email, :with => /\A([\w\.%\+\-]+)@([\w\-]+\.)+... |
require ("minitest/autorun")
require_relative("../player")
require_relative("../board")
require_relative("../game")
class TestGame < MiniTest::Test
def setup
positions={
2=>4,
7=>-7,
}
@board=Board.new(9, positions)
@player1=Player.new("Val")
@player2=Player.new("Rick")
@play... |
class ServiceProvider < ApplicationRecord
has_one :booked_service
end
|
Rails.application.routes.draw do
resources :ratings
resources :lessons
resources :reviews
resources :users
resources :sessions
resources :tags
root "new_age#index"
get 'new_age/index', to:"new_age#index"
resources :welcome, only: :index
get '/help', to: "tags#index", as: "help"
# get '/pair', ... |
CAMPUSES = ['Alabaster',
'Auburn',
'Fultondale',
'Gadsden',
'Grandview',
'Grants Mill',
'The Chapel',
'Greystone',
'Huntsville',
'McCalla',
'Mobile',
'Montgomery',
'Online',
... |
module RollbarAPI
class Client
module Connection
def get(path, options = {})
request :get, path, options
end
def post(path, options = {})
request :post, path, options
end
def put(path, options = {})
request :put, path, options
end
def delete(p... |
class MoveIsselectedFromAppointmenttypesToAppointmentTypesUser < ActiveRecord::Migration
def change
remove_column :appointment_types , :is_selected
add_column :appointment_types_users , :is_selected , :boolean
add_column :appointment_types_users , :practi_name , :string
end
end
|
class EventsController < ApplicationController
before_action :set_user, only: [:show]
#respond_to :json
def create
render status: :bad_request, :json => { :msg => "Device ID param not found."} and return unless params[:device_id].present?
@user = User.find_by(:device_id => params[:device_id]) rescue nil
... |
require 'spec_helper'
class ExceptionWithContext < StandardError
def sentry_context
{
foo: "bar"
}
end
end
RSpec.describe Sentry::Client do
let(:configuration) do
Sentry::Configuration.new.tap do |config|
config.dsn = Sentry::TestHelper::DUMMY_DSN
config.transport.transport_class =... |
require 'test_helper'
class Forums::Public::TopicsControllerTest < ActionController::TestCase
setup do
@provider = FactoryBot.create :provider_account
@request.host = @provider.domain
@forum = FactoryBot.create :forum, :account => @provider
@topic = FactoryBot.create :topic, :forum => @forum, :user ... |
class CreateCategories < ActiveRecord::Migration[5.2]
def change
create_table :categories do |t|
t.string :name
t.references :project, foreign_key: {on_delete: :cascade}
t.integer :taskIds, array: true, default: []
t.timestamps
end
end
end
|
class Stock < ActiveRecord::Base
belongs_to :almacen
belongs_to :item
end
|
# encoding: binary
# frozen_string_literal: true
module RbNaCl
module Boxes
class Curve25519XSalsa20Poly1305
# RbNaCl::Box private key. Keep it safe
#
# This class generates and stores NaCL private keys, as well as providing a
# reference to the public key associated with this private key... |
module HasSeason
extend ActiveSupport::Concern
included do
belongs_to :season
end
end
|
#
# Cookbook Name:: vim
# Recipe:: default
#
# Copyright 2015, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
%w{
mercurial
gettext
libncurses5-dev
libacl1-dev
libgpm-dev
}.each do |pc|
package pc do
action :install
end
end
def install_vim(repo, branch, build_dir, prefix)
bash "... |
class Enigma
attr_reader :character_set
def initialize
@character_set = ("a".."z").to_a << " "
end
def key(key_string)
key_array = []
key_sep = key_string.chars
4.times do |index|
key_array << (key_sep[index] + key_sep[index + 1]).to_i
end
key_array
end
def offset(date)
... |
# 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 rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
class AddColumnItemtypeToBillableItem < ActiveRecord::Migration
def change
add_column :billable_items , :item_type , :boolean , :default=> true
add_column :billable_items , :concession_price , :text
end
end
|
require 'rails_helper'
#
# Property's route path is to account
# Tests for creating charges onto a property have been moved to
# charge_create_spec.rb
#
RSpec.describe 'Property#Update', type: :system do
let(:account) { AccountPage.new }
context 'when Agentless' do
before do
log_in
property_create... |
# 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 rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
# Fact: infiniband_hcas
#
# Purpose: Determine list of Infiniband HCAs
#
# Resolution:
# Returns Array of HCA names.
#
require 'facter/util/infiniband'
Facter.add(:infiniband_hcas) do
confine has_infiniband: true
setcode do
hcas = Facter::Util::Infiniband.hcas
if hcas.empty?
nil
else
hca... |
require File.join(File.dirname(__FILE__), '..', "spec_helper")
require "rspec/matchers/dm/has_property"
describe DataMapperMatchers::HasProperty do
it "should pass with the property type" do
Post.should has_property :title, String
end
it "should fail with improper property type" do
lambda {Post.should ha... |
# == Schema Information
#
# Table name: players
#
# id :integer not null, primary key
# session_id :integer not null
# player_number :integer
# name :string(255)
# logged_in :integer
# updated_at :datetime
# chosen_card :integer
#
class Player < ActiveRecord::Base
... |
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = true
# Customize the amount of memory and CPU on the VM:
vb.cpus = 2
vb.memory = "2048"
end
config.vm.provision "shel... |
require 'mysql'
# A few bits to make Mysql easier to use
#
class Mysql
alias :raw_query :query
def query(sql, &block)
begin
if block.nil?
raw_query(sql)
else
raw_query(sql) { |result| block.call(result) }
end
rescue => err
puts err
puts sql
... |
#!/usr/bin/env ruby
# Signal that we're starting Rails for the Log analyser
# Which will mean the plugin init will do the requires
$LOG_ANALYSER = true
# How we signal the analyser to stop when a signal is received
$RUNNING = true
# Flag for File::Tail library
# $DEBUG = true
# Start rails environment; need to fi... |
class CreateProductImages < ActiveRecord::Migration
def up
create_table "product_images" do |t|
t.integer "product_id"
t.integer "image_file_size"
t.string "image_file_name"
t.string "image_content_type"
t.integer "list_order"
t.datetime "created_at"
t.datetime "up... |
class DashboardsController < ApplicationController
def show
@counts = {}
@counts[:companies] = Company.count
end
end
|
require File.join(File.dirname(__FILE__), '..', 'question_1.rb')
describe CharacterFrequency do
context "given an array of charactes" do
let(:input){ ['a', 'a', 'b', 'c', 'b', 'd', 'c', 'c'] }
it "shows frequency of each character" do
expect(CharacterFrequency.new(input).to_hash).to eq({'a' => 2, 'b' ... |
require 'spec_helper'
module OCR
describe AccountReader do
Given(:input_io) { StringIO.new(input) }
Given(:reader) { AccountReader.new(input_io) }
context "with a single scanned number" do
When(:result) { reader.read_account_number }
context "terminated by an end of file" do
Given(... |
FactoryGirl.define do
factory :office, class: Office do
name "Sede Iuvare"
address "Corporativo Nápoles"
latitude "19.3838687"
longitude "-99.1807992"
description "Oficinas Corporativas"
schedule "Lunes a Viernes - 8:00pm"
end
end
|
require 'rails_helper'
RSpec.describe PlaceOrderService do
before :each do
stub_price_limit
stub_place_order
stub_order_info
stub_contract_info
stub_contract_balance
stub_user_current_position
stub_user_history
@trader = Trader.create!(webhook_token: 'oo', email: 'a@b.com', password: ... |
class DissectionsController < ApplicationController
respond_to :html, :js
def index
@dissections = Dissection.all
end
def show
@dissection = Dissection.find(params[:id])
end
def new
@dissection = Dissection.new
end
def edit
@dissection = Dissection.find(params[:id])
end
def crea... |
module Api
module V1
class ProfilController < ApplicationController
before_action :set_profil, only: [:show, :edit, :update, :destroy]
# GET /profils
# GET /profils.json
def index
@profil = Profil.find(params[:user_id])
render json: @profil
end
# POST /profil... |
class User < ActiveRecord::Base
has_secure_password
attr_accessible :login, :password_digest
validates :login, presence: true,
uniqueness: true,
length: { within: 4..32 }
validates :password, presence: true,
length: { within: 5..64 },
... |
class RemoveFileAndFileFileNameFromBooks < ActiveRecord::Migration
def up
remove_column :books, :file
remove_column :books, :file_file_name
end
def down
end
end
|
class OrderDecorator < Draper::Decorator
decorates_association :orderable
delegate_all
def client_info
client.try{|c| c.decorate.admin_link }
end
def orderable_info
if source.orderable
h.link_to source.orderable.class.model_name.underscore.humanize, h.url_for([:admin,source])
end
end
de... |
# run with:
# rails new my_app -m ./lti_starter_app/template.rb
# rails new my_app -m https://raw.githubusercontent.com/atomicjolt/lti_starter_app/master/template.rb
require "fileutils"
require "securerandom"
# repo = "git@github.com:atomicjolt/lti_starter_app.git"
repo = "https://github.com/atomicjolt/lti_starter_ap... |
module Web
class VideosController < Web::BaseController
before_action :authenticate_user!, except: [ :index ]
before_action :correct_user, only: [ :destroy, :update ]
#def edit
#
#end
#
#def show
#
#end
#
#def new
# @video = Video.new
#end
#
#def... |
namespace :riders do
desc 'Destroy all teams and riders, and load new from the riders file'
task :reset => :environment do
Team.destroy_all
update_riders
end
desc 'Only update the riders with new information'
task :update => :environment do
update_riders
end
# Load new teams and riders or up... |
# Author: Jim Noble
# jimnoble@xjjz.co.uk
#
# desserts.rb
#
# A bit of basic object oriented programming
#
require './Dessert'
require './JellyBean'
d1 = Dessert.new("Bread and Butter Pudding", 1000)
d1.name = "Sticky Toffee Pudding"
d1.calories = 10000
puts d1
jb1 = JellyBean.new("Jelly bean", 10, "black licorice")... |
require 'spec_helper'
RSpec.describe Aucklandia::Routes do
let(:client) { Aucklandia::Client.new(ENV['AUCKLANDIA_SECRET']) }
describe '#get_routes' do
context 'successful response' do
it 'returns a collection of bus routes', vcr: true do
expect(client.get_routes).to be_a Array
end
end
... |
# frozen_string_literal: true
require "bundler/gem_tasks"
require "rake/clean"
CLEAN.include("**/*.o", "**/*.so", "**/*.bundle", "pkg", "tmp")
require "rake/extensiontask"
%w[precomputed ref10].each do |provider|
next if provider == "precomputed" && RUBY_PLATFORM !~ /x86_64|x64/
Rake::ExtensionTask.new("x25519_... |
require "spec_helper"
describe "CLI" do
let!(:course_index_array) {[{:name=>"Carlin Weld County Park", :location=>"Palmyra, WI ", :distance=>" 5.8 Miles ", :hole_count=>"18", :course_page, "https://www.dgcoursereview.com/course.php?id=8090"}]}
let!(:course_hash) {{:length=>"5186 ft.", :sse>" 44.5 ", :par>... |
class AddAuthToAppInstanceAndCourse < ActiveRecord::Migration[5.0]
def change
unless column_exists? :authentications, :application_instance_id
add_column :authentications, :application_instance_id, :integer
end
unless column_exists? :authentications, :canvas_course_id
add_column :authenticatio... |
require 'faker'
FactoryGirl.define do
factory :order do
name { Faker::Name.name }
address { Faker::Address.street_address }
city { Faker::Address.city }
county { Faker::Address.state }
postcode { Faker::Address.zip }
email { Faker::Internet.email }
end
end |
require 'test_helper'
class ProductsControllerTest < ActionController::TestCase
setup do
@product = products(:keyword_search1)
@products = [
products(:keyword_search2),
products(:product1)
]
end
test "should show product" do
get :show, id: @product.ean
assert_response :success
... |
require_relative "code"
class Mastermind
def initialize(number)
@secret_code = Code.random(number)
end
def print_matches(code)
exact = code.num_exact_matches(@secret_code)
near = code.num_near_matches(@secret_code)
puts "Exact matches: #{exact}"
puts "Near matc... |
# Their solution
class PokerHand
def initialize(cards)
@cards = []
@rank_count = Hash.new(0)
5.times do
card = cards.draw
@cards << card
@rank_count[card.rank] += 1
end
end
def print
puts @cards
end
def evaluate
if royal_flush? then 'Royal flush'
elsif... |
class PanelProvider < ApplicationRecord
has_many :target_groups, foreign_key: 'panel_provider_id'
has_many :countries, foreign_key: 'panel_provider_id'
has_many :location_groups, foreign_key: 'panel_provider_id'
has_many :users, foreign_key: 'panel_provider_id'
validates :code, presence: true, uniqueness... |
class Child < ApplicationRecord
has_many :vaccines
end
|
class TransactionProcessingWorker
include Sidekiq::Worker
def perform(uuid, params)
from = Account.find(params['from_account_id'])
to = Account.find(params['to_account_id'])
amount = BigDecimal(params['amount'])
transaction = Transaction.new(amount: amount, from_account: from, to_account: to,... |
describe Importers::MenuPageForm do
it 'valid' do
correct_row = FactoryGirl.attributes_for(:menu_page_import_row)
form = described_class.new(correct_row)
expect(form.valid?).to eq(true)
end
context 'invalid' do
it 'id: presence' do
incorrect_row = FactoryGirl.attributes_for(:menu_page_impor... |
class ChangeColumenNameOfComments < ActiveRecord::Migration
def change
rename_column :comments, :parent_id, :commentable_id
rename_column :comments, :parent_type, :commentable_type
end
end
|
class ProductImage < Attachment
mount_uploader :file, ProductImageUploader
validates :file, file_size: { maximum: 4.megabyte },
image_size: { max_width: 2048 }
end
|
class RemovefieldsfromDevices < ActiveRecord::Migration
def change
remove_column :devices, :last_lat
remove_column :devices, :last_lon
remove_column :devices, :last_fix
end
end
|
require './canhelplib'
require 'securerandom'
require 'pry'
module CanhelpPlugin
include Canhelp
def delete_enrollment(token, canvas_url, course_id, enrollment_id, task = "delete")
canvas_delete("#{canvas_url}/api/v1/courses/#{course_id}/enrollments/#{enrollment_id}", token,
{
task: task
})
en... |
require 'lib/Recursive_Open_Struct'
$cfg = Recursive_Open_Struct.new
$cfg.app.name = "fxri - Instant Ruby Enlightenment"
$cfg.delayed_loading = false
$cfg.search_paths = ENV['FXRI_SEARCH_PATH'] if ENV.has_key?('FXRI_SEARCH_PATH')
# uses the first font that is available
$cfg.app.font.name = ["Bitstream V... |
class User
attr_reader :name, :password
def initialize(name:, password:)
@name = name
@password = password
end
def self.create(name:, password:)
if ENV['ENVIRONMENT'] == 'test'
conn = PG.connect(dbname: 'chitter_challenge_test')
else
conn = PG.connect(dbname: 'chitter_challenge')
... |
RSpec.describe Simple::Search do
it "has a version number" do
expect(Simple::Search::VERSION).not_to be nil
end
it "normalizes a string" do
string = "The broken window shatters across the ground!"
expected = "the broken window shatters across the ground"
expect(Simple::Search::normalize(string)).... |
FactoryGirl.define do
factory :organization_address, class: Organization::Address do
country 'Country'
state 'State'
city 'City'
neighborhood 'Neighborhood'
street 'Street'
number '100'
association :organization, strategy: :build
end
end
|
require 'forwardable'
module SubParser
class Subtitle
extend Forwardable
attr_reader :timespan, :text
def_delegator :timespan, :start_time, :start_time
def_delegator :timespan, :end_time, :end_time
def initialize timespan, text
@timespan, @text = timespan, text
end
def to_s
... |
FactoryGirl.define do
factory :review do
skip_create
rating 5
text 'It was great'
restaurant_name 'Pizza Hut'
restaurant_url 'http://pizzahut.com'
date Time.now
user_name 'Mr. Pizza'
end
end |
# coding: utf-8
require "minitest/autorun"
require "mywn"
# Mmem = Meronyms - Member
class TestWnMmem < MiniTest::Test
def setup
@canis = "canis"
end
def test_wn_mmem_class
assert_kind_of Array, @canis.wn_mmem
end
def test_word_match
canis_mmem = [
"canis_familiaris", "wolf", "jackal"
... |
require 'vizier/argument-decorators/base'
require 'orichalcum/completion-response'
module Vizier
#Most common decorator. Tags a argument as omitable. Otherwise, the
#interpreter will return an error to the user if they leave out an
#argument. Optional arguments that aren't provided are set to nil.
class Opt... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.