text stringlengths 10 2.61M |
|---|
module StrokeDB
# Lazy loads items from array applying procs on each read and write.
#
# Example:
#
# @ary[i] = 10
#
# applies "unmap proc" to new item value.
#
# @ary.at(i)
#
# applies "map proc" to value just have been read.
#
# StrokeDB uses this class to "follow" links to other documents
... |
# only load configured metrics
MetricFu.metrics.each { |task| import "#{File.dirname(__FILE__)}/#{task}.rake" }
namespace :metrics do
if MetricFu::RAILS
desc "Generate coverage, cyclomatic complexity, flog, flay, railroad, reek, roodi, stats and churn reports"
task :all => MetricFu.metrics
task :set_te... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :encounter do
title "MyString"
content "MyText"
cover_image "MyString"
published_at "2017-10-08 15:14:50"
deleted_at "2017-10-08 15:14:50"
creator_id 1
end
end
|
require_relative "test_helper"
class ContainerTest < Minitest::Test
include CreateCerts
private
def setup
Celluloid.boot
end
def certs_dir
File.join("test", "support", "certs")
end
def teardown
@client.close if defined?(@client)
@server.stop if defined?(@server)
Celluloid.shutdown
... |
module SimpleJsonapi::Node::RelationshipData
# Represents a relationship's +data+ object.
#
# @abstract
# @!attribute [r] relationship_definition
# @return [Definition::Relationship]
# @!attribute [r] add_to_included
# @return [Boolean]
class Base < SimpleJsonapi::Node::Base
attr_reader :relatio... |
# frozen_string_literal: true
require 'rails/generators/base'
module Graphql
module Generators
module Core
def self.included(base)
base.send(
:class_option,
:directory,
type: :string,
default: "app/graphql",
desc: "Directory where generated files sh... |
require 'chemistry/element'
Chemistry::Element.define "Nickel" do
symbol "Ni"
atomic_number 28
atomic_weight 58.6934
melting_point '1726K'
end
|
class Bootcamp
def initialize(name,slogan, student_capacity)
@name = name
@slogan = slogan
@student_capacity = student_capacity
@teachers = []
@students = []
@grades = Hash.new {|h,k| h[k] = []}
end
def name
@name
end
def slogan
@slogan
end
def teach... |
require 'yaml'
MESSAGES = YAML.load_file('mortgage_calculator_messages.yml')
def prompt(message)
puts "#{message}\n"
end
def clear
system('clear') || system('cls')
end
def retrieve_amount
loop do
prompt(MESSAGES['loan_amount'])
amount = gets.chomp
if amount.empty? || amount.to_f <= 0
prompt(M... |
class Project < ApplicationRecord
validates :name, presence: true
validates :description, presence: true
validates :contact_email, presence: true
before_create :normalize_name
enum status: %w(in_progress completed)
has_many :payments
def normalize_name
self.name = self.name.downcase
end
def ch... |
require 'rails_helper'
RSpec.feature "Access Form Submission Page", js: true do
before do
stub_et_api
stub_presigned_url_api_for_s3
end
scenario "user will be able to read text" do
given_i_am(:company01)
answer_all_questions
confirmation_of_supplied_details_page.submit_form
expect(form... |
class ApplicationController < ActionController::Base
before_action :authenticate_user!
helper_method :get_base_url
def get_base_url
@base_url2 = "https://s3.eu-west-3.amazonaws.com/lasthome/uploads"
end
end
|
class Auto::TestcaseCategory < ActiveRecord::Base
acts_as_tree
validates_presence_of :title
belongs_to :project
has_many :testcases, :foreign_key => "category_id", :class_name => "Auto::Testcase"
has_many :scripts, :class_name => "Auto::TestcaseScript", :foreign_key => "category_id"
def self.find_root_by_projec... |
class ApiController < ApplicationController
def movies
@movies = Movie.order('updated_at desc').limit(10)
render json: @movies
end
end
|
# 教程网址:http://www.runoob.com/redis/redis-tutorial.html
# 操作redis,Redis不仅仅支持简单的key-value类型的数据,同时还提供list,set,zset,hash等数据结构的存储。
# value可以是 字符串(String), 哈希(Hash), 列表(list), 集合(sets) 和 有序集合(sorted sets)等类型
class Common::RedisClient
def initialize(*args)
@redis ||= Redis.new(:host => "price-redis", :port => 6379)
en... |
require "env_http_proxy/version"
require 'net/http'
require 'uri'
module Net
class << HTTP
alias_method :org_new, :new
def new address, port = 80, proxy_addr = nil, proxy_port = nil, proxy_user=nil, proxy_pass=nil
if ENV['http_proxy'].nil?
org_new(address, port, proxy_addr, proxy_port, proxy_us... |
# Budget is a meta class that is used to calculate summary data
# for all the deliverables on a project. Think of it akin to:
# has_many :deliverables
# belongs_to :project
#
class Budget
attr_reader :project
def initialize(project_id)
@project = Project.find(project_id)
end
# Gets the next due da... |
require "net/scp"
module AejisBackup
module Store
class Scp < Abstract
def initialize
config_accessor :server, :path, :user, :password
end
def store!(file)
say("Copying backup to #{server} starts", :green)
# Make shure what directory exists
Net::SSH.start(serve... |
class Alert < ApplicationRecord
belongs_to :user
belongs_to :challenge
ALERT_TYPES = [
'challenged',
'won',
'lost',
'declined'
]
validates :alert_type, inclusion: { in: ALERT_TYPES }, presence: true
scope :unread, -> { where(is_read: false) }
def display_text
case alert_type
wh... |
require './lib/coco'
require 'fileutils'
RSpec.configure do |config|
config.before(:suite) do
FileUtils.rm('.coco.yml', :force => true)
end
config.after(:suite) do
create_config(:exclude => ['lib'])
end
end
include Coco
COVERAGE_100 = {'the/filename/100' => [nil, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9]}
COVER... |
class BrandsController < ApplicationController
def new
@brand = Brand.new
end
def index
@brand = Brand.new
@brands = Brand.all
end
def create
@brand = Brand.new(brand_params)
@brand.save
redirect_to (brands_path)
end
def edit
@brand = Brand.find(params[:id])
@brands = Brand.a... |
class MemoriesController < ApplicationController
def index
@memories = Memory.all.page(params[:page])
end
def new
@memory = Memory.new
end
def show
@memory = Memory.find(params[:id])
respond_to do |format|
format.html
format.json { render :json => { id: @memory.id, memorydate: @m... |
#require 'mini_magick'
# Image processing engine using MiniMagick (see https://rubyforge.org/projects/mini-magick/)
class IQ::Processor::Adapters::MiniMagick < IQ::Processor::Adapters::Base
# @@content_types = {:jpg=> 'image/jpeg', :jpeg => 'image/jpeg', :gif => 'image/gif', :png => 'image/png'}
#
# def content_type... |
class StatesController < ApplicationController
def index
@states = State.find(:all)
respond_to do |format|
format.xml { render :xml => @states.to_xml(:include => [:cities]) }
end
end
end
|
class User < ActiveRecord::Base
self.table_name = 'users'
has_many :last_posts
has_many :admin_messages
has_many :subscriptions
def typ
super || 0
end
def banned?
ban
end
def verificated?
verificated
end
def authenticated?
persisted?
end
def registered?
authentic... |
class RoomLocationsController < ApplicationController
before_filter :find_house, :only => :index
def index
@rooms = @house.room_locations.all(:order => :id_room)
if @rooms.size==1
redirect_to :controller => "payers", :action => "find_payer_by_address", :room_id => @rooms[0].id
end
end
priv... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :earthquake do
source { (?a..?z).to_a.sample(2).join }
eqid { [?0..?9, ?a..?z].map(&:to_a).flatten.sample(8+rand(8)).join }
version { ((rand*(10**0.25)) ** 4).floor } # low-weighted random 0..10
date_t... |
class OrderInfo < ApplicationRecord
belongs_to :order
validates :order, presence: true
end
|
class Worker
attr_reader :id, :price_per_shift
def initialize(attributes = {})
@id = attributes[:id]
@first_name = attributes[:first_name]
@price_per_shift = attributes[:price_per_shift]
end
end
|
class EARMMS::MembershipAdminAlertsController < EARMMS::MembershipAdminController
get '/' do
next halt 404 unless logged_in?
next halt 404 unless has_role? 'admin:access'
@alerts = {
:dismiss_action => '/admin/alerts',
:alerts => EARMMS::Alert.non_actioned_grouped_for_section(:membership)
... |
# Source: https://launchschool.com/exercises/7ec184cd
class Person
attr_accessor :name
end
person1 = Person.new
person1.name = 'Jessica'
puts person1.name
|
class QueryService
def self.query(tasks:, search_input:)
tasks.select { |task| task.title =~ Regexp.new(search_input) }
end
end
|
class PostsController < ApplicationController
before_action :set_post, only: [:show, :edit, :update, :destroy]
# GET /posts
def index
posts_with_username = Post.order(created_at: :desc).with_user
render_for_react(
props: {
posts: posts_with_username,
}
)
end
# GET /@:username... |
#!/usr/bin/env ruby
# file: omah.rb
# title: Offline Mail Helper
require 'zip'
require 'nokorexi'
require 'dynarex-daily'
require 'novowels'
module Library
def fetch_file(filename)
lib = File.dirname(__FILE__)
File.read File.join(lib,'..','stylesheet',filename)
end
end
class Omah
include Library
... |
# frozen_string_literal: true
require 'json'
require 'net/http'
require 'active_support/core_ext/hash'
class ElTiempo
BASE_URL = 'http://api.tiempo.com/index.php?api_lang=es'
LOCATIONS_PARAM = 'division='
LOCATION_PARAM = 'localidad='
AFFILIATE_PARAM = 'affiliate_id='
def self.calc(options = [], affiliate_... |
#--
# Ruby Whois
#
# An intelligent pure Ruby WHOIS client and parser.
#
# Copyright (c) 2009-2013 Simone Carletti <weppos@weppos.net>
#++
require 'whois/record/scanners/base'
module Whois
class Record
module Scanners
# Scanner for the whois.gandi.net record.
class WhoisGandiNet < Base
s... |
class ActivitiesController < ApplicationController
before_action :authorize_user, except: [:destroy, :show]
def show
@trips = Trip.where(user_id: current_user)
@activity = Activity.find(params[:id])
@map = @activity.address.split.join("+")
if !@activity.reference.nil?
@place = Place.get_info(... |
class VehicleBuilder
attr_reader :vehicle
def build_frame
raise 'You must implement this method in a descendant class.'
end
def build_engine
raise 'You must implement this method in a descendant class.'
end
def build_wheels
raise 'You must implement this method in a descendant class.'
end
... |
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'bundler/setup'
require 'vedeu'
TESTCASE = 'dsl_app_031'
class DSLApp
Vedeu.bind(:_initialize_) do
Vedeu.trigger(:_refresh_)
sleep 0.25
Vedeu.trigger(:_clear_view_content_)
end
Vedeu.configure do
debug!
height 10
log Dir.tmpdi... |
module RunPal
class FilterPostsByGender < UseCase
def run(inputs)
inputs[:user_id] = inputs[:user_id] ? inputs[:user_id].to_i : nil
inputs[:gender_pref] = inputs[:gender_pref] ? inputs[:gender_pref].to_i : nil
inputs[:radius] = inputs[:radius] ? inputs[:radius].to_i : nil
inputs[:user_lon... |
require 'rubygems'
require 'selenium-webdriver'
require 'down'
require 'fileutils'
SUBREDDIT="EarthPorn"
DATADIR='./downloads'
SCROLL_LENGTH = 10
OPTIONS = Selenium::WebDriver::Chrome::Options.new(
args: ['--headless', '--disable-gpu', 'window-size=1280x800', 'user-data-dir='+DATADIR]
)
def testPreviewString(myStri... |
require 'active_support'
namespace :event_manager do
task :create_musical_style_preferences => :environment do
musical_style_preferences = ['Top 40/Modern',
'Club/House',
'Rap (Radio Hip-Hop)',
'Big Band/Swing',
... |
class CreateAnswers < ActiveRecord::Migration
def change
create_table :answers do |t|
t.text :answer_body, null:false
t.boolean :is_correct, null: false
t.references :question, null: false
t.timestamps null:false
end
end
end
|
require "vworkapp_ruby"
describe VW::Worker do
before(:all) do
VW::Worker.base_uri 'https://api.staging.vworkapp.com/api/2.0'
VW.api_key = "AtuogECLCV2R7uT-fkPg"
end
context "Without a known worker" do
describe "#Create" do
it "Assigns the new worker an id" do
@worker = VW::Wor... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_action :authenticate_user!
before_action :authenticate_ip_addreess
def authenticate_active_admin_user!
... |
name 'torque'
maintainer 'David Brown'
maintainer_email 'dmlb2000@gmail.com'
license 'All rights reserved'
description 'Installs/Configures torque'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.1'
issues_url 'https://github.com/dmlb2000/torque-cookbook/issues'
source_url 'https:/... |
module CDI
module V1
class SendToPusherWorker
include Sidekiq::Worker
sidekiq_options :retry => 5, queue: :system_notifications
sidekiq_retry_in { |count| count * 60 }
def perform(channel_name, event, options=nil)
data = {}
user = User.select(:id, :username, :first_name... |
class StaticPagesController < ApplicationController
def root
render :root
end
end
|
# David Lin
# O(n) complexity
# Using dynamic programming, bottom-up method
# @param {Integer} n
# @return {Integer}
def nth_ugly_number(n)
return "n must be no more than 1690" if n > 1690
cached,p1,p2,p3 = [1],0,0,0
loop do
next_ugly_number = [cached[p1]*2,cached[p2]*3,cached[p3]*5].min
case next_ugly_... |
class RemoveColumnUser < ActiveRecord::Migration
def change
remove_column :users, :comform_password, :string
remove_column :users, :password, :string
end
end |
describe AttachmentMailer, :email do
include MailerSpecHelper
describe "#new_attachment_notification" do
let(:mail) { AttachmentMailer.new_attachment_notification(requester, proposal, attachment) }
it_behaves_like "a proposal email"
it "includes the name of the user who added the attachment" do
... |
name 'lnav'
maintainer 'Jean-Francois Theroux'
maintainer_email 'me@failshell.io'
license 'Apache 2.0'
description 'Installs/Configures lnav'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.0'
|
# Copyright 2013, Dell
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
... |
# frozen_string_literal: false
require_relative "utils"
if defined?(OpenSSL::TestUtils)
class OpenSSL::TestSSLSession < OpenSSL::SSLTestCase
def test_session_equals
session = OpenSSL::SSL::Session.new <<-SESSION
-----BEGIN SSL SESSION PARAMETERS-----
MIIDFgIBAQICAwEEAgA5BCCY3pW6iTkPoD5SENuztz/gZjhvey6XnHbsxd22k... |
require 'rails_helper'
RSpec.describe HomeController, type: :controller do
render_views
include BasicAuthHelper
describe 'get #index' do
before { get :index }
it { is_expected.to respond_with(:success) }
it { is_expected.to render_template(:index) }
end
describe 'get #secret' do
def do_re... |
module Core::Cells
class Template < Base
def template_name
@options[:template_name]
end
end
end
|
require "minitest/autorun"
require "pry-byebug"
require_relative "../core_ext/attr_history"
class Dummy
extend AttrHistory
attr_historized(:value)
def initialize(value=nil)
self.value = value if value
end
def update(value)
self.value = value
end
end
class AttrHistoryTest < Minitest::Test
def ... |
# Simple Role Syntax
# ==================
# Supports bulk-adding hosts to roles, the primary server in each group
# is considered to be the first unless any hosts have the primary
# property set. Don't declare `role :all`, it's a meta role.
role :web, %w{teddy@10.110.126.29}
|
require 'minitest/autorun'
require_relative 'test_helper'
require_relative 'fake_sftp'
include FileMover
class SftpTest < MiniTest::Unit::TestCase
include TestHelper
def test_sftp_sink
Net::SSH.reset
host = 'localhost'
user = 'user'
password = 'password'
remote_dir = '.'
si... |
class Course < ApplicationRecord
validates_uniqueness_of :name, scope: :tees
validates_presence_of :name, :tees
end
|
#!/usr/bin/env ruby
require 'plist'
require 'fileutils'
require 'optparse'
require 'colorize'
require 'yaml'
require 'terminal-table'
################################################################################
#
# This script works by building the SPMTest project once without including an
# SDK framework, then i... |
module Asaas
class Customer < Model
transform_keys(&:to_sym)
attribute :id, Types::Coercible::String.optional.default(nil)
attribute :name, Types::Coercible::String
attribute :cpfCnpj, Types::Coercible::String
attribute :email, Types::Coercible::String.optional.default(nil)
attribute :pho... |
# Author:: Nathaniel Talbott.
# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
# License:: Ruby license.
require 'runit/testresult'
require 'runit/testsuite'
require 'runit/assert'
require 'runit/error'
require 'test/unit/testcase'
module RUNIT
class TestCase < Test::Unit::TestCase
... |
require "google/cloud/pubsub"
module Hoze
class Configuration
attr_accessor :channel, :key, :auto_ack, :connector, :max_tries
def initialize prefix = nil
@connector = ConnectorConfiguration.new prefix
@prefix = prefix
end
def channel
env_config('CHANNEL') || @channel
end
... |
class OSM
def endpoint(address)
"#{ENV['OSM_ENDPOINT']}?q=#{address}&format=json&addressdetails=1"
end
def has_no_results?(response)
response.empty?
end
def parse_response(response)
response.map do |result|
{
latitude: result["lat"].to_f,
longitude: result["lon"].to_f,
... |
$:.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version:
require "momentum_cms/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "momentum_cms"
s.version = MomentumCms::VERSION
s.authors = ['Emerson', 'Bill']
s.email = ['e... |
# frozen_string_literal: true
require_relative "./descriptors"
require_relative "./targets"
module Homebrew
class SourceLocator
def descriptor
@descriptor ||= find_descriptor
end
def initialize(target_name, target_path)
@target_name = target_name
@target_path = target_path
end
... |
Rails.application.routes.draw do
root 'recipes#index'
resources :recipes
end
|
require 'spec_helper'
describe "items/edit.html.erb" do
before(:each) do
@item = assign(:item, stub_model(Item,
:text => "MyString",
:done => false,
:order => 1
))
end
it "renders the edit item form" do
render
# Run the generator again with the --webrat flag if you want to use... |
class UsersController < ApplicationController
def create
@user = User.new(user_params)
@user.save
session[:user_id] = @user.id
redirect_to @user
end
def new
@user = User.new
end
def show
if current_user != nil && current_user.id.to_s == params[:id].to_s
@user = User.find(param... |
class Entrant < ApplicationRecord
has_many :event
has_many :company
belongs_to :user
end
|
class Gallery < ActiveRecord::Base
has_many :gallery_collections
has_many :pictures, :through => :gallery_collections, :source => :link
end
|
class Neighborhood < ActiveRecord::Base
belongs_to :city
has_many :listings
has_many :reservations, through: :listings
validates_presence_of :name, :city_id
extend Reservable::ClassMethods
include Reservable::InstanceMethods
def neighborhood_openings(start_date, end_date)
openings = Listing.avail... |
require 'rails_helper'
RSpec.feature "guest user visits application root" do
scenario "and can see a search box" do
visit root_path
expect(current_path).to eq(root_path)
expect(page).to have_content("AltFuelFinder")
expect(page).to have_button("Locate")
end
end
|
#!/usr/bin/ruby -w
require File.join(File.dirname(__FILE__), 'lib/gilded_rose')
def item_klass(name, sell_in, quality)
Item.new(name, sell_in, quality)
end
def initialize_item_as(klass, name, sell_in, quality)
item = item_klass(name, sell_in, quality)
klass.new(item.name, item.sell_in, item.quality)
end
puts ... |
class Quiz < ActiveRecord::Base
has_many :questions, dependent: :destroy
has_many :outcomes, dependent: :destroy
validates :title, :description, :img_url, :url_name, presence: true
def max_points
total = 0
questions.each do |q|
total += q.max_points
end
total
end
end
|
# frozen_string_literal: true
class User < ApplicationRecord
has_many :products
has_many :addresses
validates :username, :email, :first_name, :last_name, presence: true
end
|
class Api::BaseController < ::ActionController::API
# class Api::BaseController < ::ActionController::Base
include ActionController::ImplicitRender
include ActionController::Helpers
# 使 ActiveModelSerializer 在 render json hook 生效
# include ActionController::Serialization
# 安装 token authenticatable
include ... |
# 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... |
class MyStack
def initialize
@store = []
end
def pop
@store.pop[:value] unless empty?
end
def push(value)
@store.push({
max: new_max(value),
min: new_min(value),
value: value
})
end
def peek
@store.last
end
def size
@store.length
end
def empty?
@s... |
require_relative 'fund_request'
require_relative 'project'
describe FundRequest do
before do
@fund_request = FundRequest.new("VC-Friendly Startup Projects")
@initial_fund = 1000
target_fund = @initial_fund * 20
@project = Project.new("XYZ", @initial_fund, target_fund)
@fund_request.add_project... |
class ItemsController < ApplicationController
before_action :find_item, only: [:show, :edit, :update, :destroy]
def index
#displays all items owned by a single user
@items = @current_user.items
@categories = Category.all
end
def show
end
def new
@item = Item.ne... |
#TEDDIT: Strings - Student's File
# Teddit is a Ruby text based news aggregator. Think Reddit in your terminal.
# This exercise will be used throughout the ruby portion of this course.
# We will incrementally build a news aggregator (next week using API's)
# We will create a more dynamic Teddit, and pull the latest ne... |
# == Schema Information
#
# Table name: categories
#
# id :integer not null, primary key
# name :string
# ancestry :string
# created_at :datetime not null
# updated_at :datetime not null
# slug :string
# icon :string
# position :integer
#
class Category < ... |
class FriendJobsController < ApplicationController
respond_to :json
def index
@friendJobs = FriendJob.all
end
def new
@friendJob = FriendJob.new
end
def create
@friendJob = FriendJob.new(friend_job_params)
@friendJob.friend_id = current_friend.id
@friendJob.save
@friendJ... |
module Rubinius
class CompilerNG
class LocalVariable
attr_reader :slot
def initialize(slot)
@slot = slot
end
end
class LocalReference
attr_reader :slot
def initialize(var)
@slot = var.slot
end
def get_bytecode(g)
g.push_local @slot
... |
require 'sinatra'
require 'sinatra/activerecord'
require 'haml'
require 'rest-client'
require 'xmlsimple'
require 'data_mapper'
set :database, 'sqlite3:///shortened_urls.db'
set :database, 'sqlite3:///visits.db'
before '/' do
set_country
end
class ShortenedUrl < ActiveRecord::Base
# Validates whether the value ... |
require_relative '../config'
class AddTimestamps < ActiveRecord::Migration
def change
add_column :students, :created_at, :datetime
add_column :students, :updated_at, :datetime
add_column :teachers, :created_at, :datetime
add_column :teachers, :updated_at, :datetime
add_column :relationships, :cre... |
class GamesController < ApplicationController
skip_before_action :authenticate_user!, only: :index
def index
if params[:query].present?
@games = Game.where("name ILIKE ?", "%#{params[:query]}%")
else
@games = Game.all
end
end
def new
@game = Game.new
end
def create
@game =... |
class RemoveAvatarFromListing < ActiveRecord::Migration[5.0]
def change
remove_column :listings, :avatar
end
end
|
class DropConcerts < ActiveRecord::Migration
def change
drop_table :concerts
end
end
|
#Run through our class from yesterday, orient everyone, talk about the behaviour that we have going on right now
# Self keyword slide -
# - add
puts self
# in class, run file
# demo that it is the class, vs self when you're in the instance it's the instance
# Remember that this is always the IMPLIED SELF
# make a... |
require 'rails_helper'
RSpec.describe User, type: :model do
context 'fields' do
it { is_expected.to have_field(:name).of_type(String) }
it { is_expected.to have_field(:email).of_type(String) }
it { is_expected.to have_field(:encrypted_password).of_type(String) }
it { is_expected.to have_field(:role_... |
class CreateBiddingPeriods < ActiveRecord::Migration
def self.up
create_table :bidding_periods do |t|
t.date :start_dt
t.date :end_dt
t.integer :item_id
t.integer :num_periods
t.integer :status
t.integer :bidding_cap
t.timestamps
end
end
def self.down
drop_t... |
class FontLateef < Formula
head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/lateef"
desc "Lateef"
homepage "https://fonts.google.com/specimen/Lateef"
def install
(share/"fonts").install "Lateef-Bold.ttf"
(share/"fonts").install "Lateef-Extr... |
require 'rails_helper'
RSpec.feature 'Routing', type: :feature do
it 'User is routed to correct page' do
sign_up
expect(find('h1')).to have_content 'Welcome to the chatroom'
end
scenario 'Only signed in users can access dashboard' do
expect { visit '/admin' }.to raise_error ActionController::Routing... |
require 'rails_helper'
RSpec.describe RobotsController, type: :controller do
# let!(:user) {User.create!(username: 'test', email: 'test@gmail.com', password: 'password')}
before :each do
user = create(:user)
session_login(user)
end
let!(:user) {User.create(username: 'test', email: 'test@gmail.com', p... |
require "fog/core/model"
module Fog
module Compute
class Brkt
class ComputingCell < Fog::Model
# @!group Attributes
identity :id
attribute :name
attribute :description
attribute :provider
attribute :gateway_ip
attribute :provider_options, :aliases =>... |
module Gui
class FrameOptionsWidget
ACTIVE_COLOR = ::Gosu::Color::GREEN
DISABLED_COLOR = ::Gosu::Color::GRAY
def initialize options = {}
@visible = options.has_key?(:visible) ? options[:visible] : false
@objects = {}
end
def clean o = @objects
@objects.each { |n, o|
if o.is_a? Array
deep_destroy o
... |
class Product < ActiveRecord::Base
monetize :price_cents
has_many :orders
end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.