text stringlengths 10 2.61M |
|---|
# frozen_string_literal: true
require "forwardable"
require "openapi3_parser/node_factory/field"
module Openapi3Parser
module NodeFactory
module Fields
class Reference < NodeFactory::Field
def initialize(context, factory)
context = Context.as_reference(context)
super(context, i... |
require "tdd"
describe Array do
describe "#my_unique" do
let(:array){[1,2,1,3,3]} # array = []
let(:uniq_array){ array.dup } #
it "should remove duplicates from array " do
expect(array.my_uniq).to eq([1,2,3])
end
it "doesn't modify the original array" do
... |
class Video < ActiveRecord::Base
belongs_to :category
has_many :reviews, order: 'created_at DESC', dependent: :destroy
has_many :queue_items, dependent: :destroy
validates_presence_of :title, :description
def self.search_by_title(search_term)
search_term.strip!
search_term.blank? ? [] : \
where(... |
require 'test/unit'
require 'wlang'
require 'wlang/rulesets/ruleset_utils'
# Tests the ruleset utilities.
class WLang::RuleSetUtilsTest < Test::Unit::TestCase
include WLang::RuleSet::Utils
# Tests decoding qdialects
def test_decode_qdialect()
tests = ["wlang", "xhtml", "\nxhtml ", "plain-text", "wlang/pl... |
include_recipe "hpcpack::_get_secrets"
include_recipe "hpcpack::_ps"
bootstrap_dir = node['cyclecloud']['bootstrap']
mod_dir = "#{bootstrap_dir}\\CreateADPDC"
dsc_script = "CreateADPDC.ps1"
modules_dir = "C:\\Program\ Files\\WindowsPowerShell\\Modules"
cookbook_file "#{bootstrap_dir}\\#{dsc_script}.zip" do
source ... |
# 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 Project < ApplicationRecord
include MedusaAutoHtml
include EmailPersonAssociator
email_person_association(:manager)
email_person_association(:owner)
has_many :attachments, as: :attachable, dependent: :destroy
has_many :items, -> {order 'created_at desc'}, dependent: :destroy do
def find_by_inges... |
ActiveAdmin.register Affiliate do
# Filters
filter :title
filter :contact_email
filter :city
filter :state
filter :country
filter :unprocessed
# List
index do
column :id
column :title
column :city
column :state
column :country
actions
end
# Form
form do |f|
... |
# -*- encoding : utf-8 -*-
require 'test_helper'
class PointTest < ActiveSupport::TestCase
test "points should be the same" do
p1 = Point.new(:number => 1,
:latitude => BigDecimal.new("11.23"),
:longitude => BigDecimal.new("45.67"))
p2 = Point.new(:number => 2,
... |
class Player
# 手札の配列を生成
def initialize
@hands = []
end
# 初回に2回デッキからカードを引く
def first_draw_player(deck)
# 生成したdeckからdrawメソッドを用いてカードを一枚引いてくる
card = deck.draw
# 引いたカードを手札に追加する
@hands << card
# 初回は2回なので再度繰り返す
card = deck.draw
@hands << card
puts ""
puts "------------Player手札... |
module Home
class API < Grape::API
format :json
prefix :home
get :welcome do
{ message: 'Hello, world!' }
end
end
end |
class ParksController < ApplicationController
def show
park = Park.find(params["id"])
render json: park
end
end
|
class CartsController < ApplicationController
respond_to :html
# GET /carts
def index
respond_with(@carts = Cart.all)
end
# GET /carts/1
def show
begin
@cart = Cart.find(params[:id])
rescue ActiveRecord::RecordNotFound
logger.error "Нет больше корзины с таким id: #{params[:id]}"
... |
# Copyright © 2011-2019 MUSC Foundation for Research Development~
# All rights reserved.~
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:~
# 1. Redistributions of source code must retain the above copyright notice, this l... |
class PagesController < ApplicationController
def show
@page = ContentBlock.find_by_name(params[:id])
unless @page
authorize! :create, ContentBlock
@page = ContentBlock.create(name: params[:id])
end
end
end
|
class AddAttachmentToComments < ActiveRecord::Migration
def self.up
add_column :comments, :attachment_file_name, :string # Original filename
add_column :comments, :attachment_content_type, :string # Mime type
add_column :comments, :attachment_file_size, :integer # File size in bytes
end
def self.down... |
RSpec.shared_examples_for "a presented collection" do
let(:current_user) { User.new }
let(:params) { { include: "foo,bar", policies: true } }
let(:controller) { Controller.new(current_user, params) }
let(:presenter) { double('presenter') }
before(:each) do
allow(Query).to receive(:records).and_return(rel... |
# -*- ruby -*-
$TESTING_MINIUNIT = true
require 'rubygems'
require 'hoe'
Hoe.plugin :seattlerb
Hoe.spec 'minitest' do
developer 'Ryan Davis', 'ryand-ruby@zenspider.com'
self.rubyforge_name = "bfts"
self.testlib = :minitest
end
def loc dir
system "find #{dir} -name \\*.rb | xargs wc -l | tail -1"
end
desc... |
class AddIsPrivateToTable < ActiveRecord::Migration[5.1]
def change
add_column :tables, :is_private, :boolean
end
end
|
class TranslationLinesController < ApplicationController
before_action :set_translation_line, only: [:show, :edit, :update, :destroy, :previous, :next]
load_and_authorize_resource
# GET /translation_lines
# GET /translation_lines.json
def index
@translation_lines = TranslationLine.all
end
# GET /t... |
class AddSlackServiceIdToSurveys < ActiveRecord::Migration
def change
add_column :surveys, :slack_service_id, :string
add_index :surveys, :slack_service_id
end
end
|
require 'pry'
class Path
attr_accessor :state, :previous, :cost_so_far, :total_cost
def initialize(opt)
@state = opt[:state]
@previous = opt[:previous]
@cost_so_far = opt[:cost_so_far] || 0
@total_cost = opt[:total_cost] || 0
end
end
def a_star_search(paths:,
goal_... |
require 'yaml'
class SubAppGenerator < Rails::Generators::Base
source_root File.expand_path('../templates', __FILE__)
argument :sub_app_name, :type => :string, :default => "application"
def generate_sub_app
empty_directory "app/views/#{file_name}"
empty_directory "public/images/#{file_... |
class Dashboard::RequestsDatatable < Dashboard::ApplicationDatatable
def sortable_columns
@sortable_columns ||= %w(Request.headers Request.params)
end
def searchable_columns
@searchable_columns ||= %w(Request.headers Request.params)
end
private
def data
records.map do |request|
[
... |
require File.dirname(__FILE__) + '/../../spec_helper'
require File.dirname(__FILE__) + '/../../fixtures/enumerator/classes'
require 'enumerator'
describe "Enumerator#each_cons" do
it "iterates the block for each consecutive slice of n elements" do
a = []
EnumSpecs::Numerous.new.each_cons(3) { |e| a << e }
... |
class CreateLocationPrototypes < ActiveRecord::Migration
def change
create_table(:location_prototypes, :id => false) do |t|
t.string :code
t.string :location_type
t.string :area_code
t.string :template
t.string :name
t.string :description
t.string :layout
t.text :op... |
# frozen_string_literal: true
class Task < ApplicationRecord
belongs_to :project
belongs_to :user, optional: true
validates :name, presence: true
end
|
class Cage
attr_accessor :animal
def empty?
@animal == nil
end
end
|
require File.expand_path(File.dirname(__FILE__) + "/my_sears_test_base")
describe "AdminDiscussionThreadsLockTest" do
include MySearsTestBase
before(:all) do
setup_super_user
(1..3).each do|index|
forum = create_community "cat_"+index.to_s
create_topic_with_post(forum,Date.today-100... |
require 'spec_helper'
describe 'nginx::mail', :type => :define do
let (:facts) { debian_facts }
let (:pre_condition) {
'$concat_basedir = "/tmp"
class { "nginx":
mail => true,
vhostdir_available => "/tmp/available",
vhostdir_enabled => "/tmp/enabled",
}'
}
describe 'without param... |
class AddNameToOptiontables < ActiveRecord::Migration[5.2]
def change
add_column :optiontables, :name_opt_zh, :text
add_column :optiontables, :name_opt_en, :text
end
end
|
require 'rails/generators/named_base'
require 'rails/generators/migration'
class MongrationGenerator < Rails::Generators::NamedBase
include Rails::Generators::Migration
source_root File.join(File.dirname(__FILE__), 'mongrations', 'templates')
def self.next_migration_number(dirname)
Time.now.utc.strftime("%Y... |
# frozen_string_literal: true
class UserMailer < ApplicationMailer
include Rails.application.routes.url_helpers
def welcome_email(user)
@user = user
mail(
to: email_with_name(user),
subject: "[Limestone] Welcome!"
)
end
def billing_updated(user)
@user = user
mail(
to: em... |
require 'spec_helper'
describe UsersController, type: :controller do
before (:each) do
@user = FactoryGirl.create(:user)
sign_in @user
end
describe "GET 'index'" do
it "returns a successful response with users" do
expect(User).to receive(:by_activity_date).and_call_original
get :index
... |
require 'open-uri'
require 'pry'
require 'nokogiri'
class Scraper
def self.scrape_index_page(index_url)
scraped_students = []
html = open(index_url)
doc = Nokogiri::HTML(html)
doc.css(".roster-cards-container").each do |card|
card.css(".student-card a").each do |student_info|
... |
require "twilio-ruby"
class SMS
TIME_FORMAT = '%H:%M'
def initialize(config, client: nil)
@client = client || Twilio::REST::Client.new(config[:account_sid], config[:auth_token])
@config = config
end
def deliver
client.messages.create(message_args)
end
private
attr_reader :client, :config... |
class Changeref2ToPractiavail < ActiveRecord::Migration
def change
add_column :businesses , :practi_info_id ,:integer
add_index :businesses , :practi_info_id
end
end
|
class UsersController < ApplicationController
def index
@users = User.search(params[:search][:q])
end
def new
@user = User.new
render "top/login", layout: "login"
end
def create
@user = User.new(user_params)
if @user.save
redirect_to :root, notice: "アカウントを登録しました。"
else
... |
# Write a method that takes a string as argument. The method should return a new, all-caps version of the string, only if the string is longer than 10 characters. Example: change "hello world" to "HELLO WORLD". (Hint: Ruby's String class has a few methods that would be helpful. Check the Ruby Docs!)
def capitalize(wor... |
class OpenJtalk::WaveFileWriter
def initialize(io)
@io = io
end
def write(header, data)
@io.write [ "RIFF",
data.length + 36,
"WAVE",
"fmt ",
16,
header['compression_code'],
header['number_of_channels'],
hea... |
require 'rails_helper'
RSpec.describe RanksController, :type => :controller do
let!(:tv_show) { TvShow.create!(title: SecureRandom.hex) }
before do
user = User.create!(email: 'foo@example.com', password: '12345678')
sign_in :user, user
end
describe "GET #index" do
it "responds successfully with a... |
require 'fluent/parser'
module Fluent
module Mixin
module TypeConverter
include Configurable
include RecordFilterMixin
include Fluent::TextParser::TypeConverter
attr_accessor :types, :types_delimiter, :types_label_delimiter
def configure(conf)
super
end
def f... |
class NdnCxx < Formula
desc "ndn-cxx: NDN C++ library with eXperimental eXtensions"
homepage "http://www.named-data.net/doc/ndn-cxx/"
url "https://github.com/named-data/ndn-cxx/archive/ndn-cxx-0.3.3.tar.gz"
sha256 "9560ca83386c79d8ce542d6e96fede2e6c677881546145ffe8b15a79e3303272"
depends_on "boost"
depends... |
class RenameRecurringEventId < ActiveRecord::Migration
def change
rename_column :events, :recurringEventId, :recurring_event_id
end
end
|
class AddColumnToFevers < ActiveRecord::Migration
def change
add_column :fevers, :range_from, :string
add_column :fevers, :range_to, :string
end
end
|
require 'oystercard'
describe Oystercard do
let (:entry_station) { double :entry_station }
let (:exit_station) { double :exit_station }
let (:oyster) { Oystercard.new }
describe 'new oyster card' do
it 'equals an empty hash' do
expect(oyster.journeys).to eq([])
end
it 'returns balance of 0... |
class AddFavIdToFavoriteUsers < ActiveRecord::Migration
def self.up
add_column :favorite_users, :favorite_id, :integer
end
def self.down
remove_column :favorite_users, :favorite_id
end
end
|
class Octopus
attr_accessor :cute, :weight, :name, :friend
def initialize(name, friend)
@name = name
@friend = friend
end
end
|
module ApipieBindings
class Resource
attr_reader :name
def initialize(name, api)
raise NameError.new("Resource '#{name}' does not exist in the API") unless api.apidoc[:docs][:resources].key?(name)
@name = name
@api = api
end
def call(action, params={}, headers={}, options={})
... |
require 'aws/templates/utils'
module Aws
module Templates
module Utils
module Parametrized
class Constraint
##
# Switch-like variant check
#
# Recursive check implementing switch-based semantics for defining
# checks need to be performed depending o... |
require "contact"
describe "Contacts" do
contact = Contact.new("Ralph Nguyen", "ralph.nguyen@alphasights.com")
it "have correct naming functions" do
expect(contact.first_name).to eq('Ralph')
expect(contact.first_initial).to eq('R')
expect(contact.last_name).to eq('Nguyen')
expect(contact.last_ini... |
class AnswersController < ApplicationController
include Voted
before_action :authenticate_user!
before_action :set_question, only: :create
before_action :set_answer, only: %i[update destroy mark_best]
after_action :publish_answer, only: :create
authorize_resource
def create
@answer = current_user.... |
module Api
module V1
class BracketGroupsController < ApplicationController
before_action :set_bracket_group, only: [:generate, :show, :update, :destroy]
# GET /bracket_groups
# GET /bracket_groups.json
def index
@bracket_groups = BracketGroup.all
end
# GET /bracket_gr... |
# frozen_string_literal: true
require 'tempfile'
copy :setup_history do
before do
if readline?
::Readline::HISTORY.clear
stub_readline
end
shell(:history_file => history_file)
end
after do
tempfile.unlink if @tempfile
end
def tempfile
@tempfile ||= Tempfile.new('rib')
en... |
# User Serializer
class UserSerializer < ActiveModel::Serializer
attributes :full_name,
:display_name,
:email,
:date_of_birth,
:gender,
:facebook_url,
:twitter_url,
:personal_message,
:webpage_url,
:is_banned,
:is_banned_date,
:legal_terms_read,
:privacy_terms_read,
... |
class AddUrlToUsenetThread < ActiveRecord::Migration
def change
add_column :usenet_threads, :url, :string
end
end
|
module Shipwire
class Products::Insert < Products
protected
def product_classification
{ classification: "marketingInsert" }
end
end
end
|
class MapController < ApplicationController
#The resturant form is rendered in the home view due to the modal box being on the homepage
def show
@restaurant = Restaurant.new
@diets = Diet.all
end
end
|
# frozen_string_literal: true
require_relative "lib/email_reply_trimmer"
Gem::Specification.new do |s|
s.name = "email_reply_trimmer"
s.version = EmailReplyTrimmer::VERSION
s.date = Time.now.strftime('%Y-%m-%d')
s.summary = "Library to trim replies from plain text email."
s.description = "EmailReplyTrimmer ... |
require "formula"
class Serve < Formula
homepage "https://github.com/jpillora/serve"
version "1.7.2"
if !OS.linux? && Hardware.is_64_bit?
url "https://github.com/jpillora/serve/releases/download/1.7.2/serve_darwin_amd64.gz"
# md5 "d53e75f2493a7557f086046d66502ed1" MD5 NO WORK, MUST DOWNLOAD WHOLE FILE TO... |
require_relative 'setup'
describe 'model tests' do
before :each do
clean_db
end
it "validates that tags are lowercase, hyphens, and numbers" do
Tag.new(:name => 'abc').should be_valid
Tag.new(:name => 'abc2').should be_valid
Tag.new(:name => 'abc-d').should be_valid
Tag.new(:name => 'ab-bc-c... |
require_relative "Clutch"
require_relative "Cup"
require_relative "Bag"
class Player
def initialize(name)
@name = name
@player_bag = Bag.new
@player_cup = Cup.new
@throw_array = []
@last_report = nil
end
def name()
return @name
end
def store(object)
... |
require 'amqp'
module AMQPConnectionDriver
def connection_driver_initialize
puts "AMQPConnectionDriver is loaded!"
end
def get_connection
new_opts = {
:vhost => ENV["BROKER_VHOST"] || "eventbus",
:host => ENV["BROKER_HOST"] || "localhost",
:port => ENV["BROKER_PORT"] || 5672,
... |
class CreatePladminChecks < ActiveRecord::Migration
def change
create_table :pladmin_checks do |t|
t.references :user, index: true, foreign_key: true
t.integer :pladmin_id
t.string :order_num
t.string :sku
t.string :goods_name
t.string :account
t.integer :pladmin_amount
... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
include SessionsHelper
# ログイン済みのユーザーか確認します。
def logged_in_user
unless logged_in?
flash[:danger] = "ログインしてください。"
redirect_to login_url
end
end
# ログイン済みのユーザーか確認します。
def already_logged_in
... |
require_relative 'gratter_class.rb'
require_relative 'prepare.rb'
base_url = "http://pitchfork.com/reviews/albums/?page=1"
base_xpath = { :links => "//a[@class='album-link']/@href" }
instance = Gratter.new( {:url => base_url, :xpaths => base_xpath} )
data = instance.use
data.prepare_gratter!("http://pitchfork.com", ... |
class RenamePapersColumeName < ActiveRecord::Migration
def change
rename_column :papers,:Title,:title
rename_column :papers,:Abstract,:abstract
rename_column :papers,:Outline,:outline
rename_column :papers,:Status,:status
end
end
|
module Tugboat
class Dockerfile
attr_reader :repository, :image_name
def initialize(path)
load(path)
end
def load(path)
@dockerfile = File.open(path).read
end
# we are hijacking label to get this information
def repository
regex = /(tug.repository=("|')([\w.\/]+))("|'... |
Rails.application.routes.draw do
resources :transactions
resources :permissions
resources :users
namespace :api do
namespace :v1 do
resources :users, only: %i[show index create update]
resources :user_by_uuid, only: [:show]
resources :user_by_email, only: [:show]
resources :user_by_... |
class Category < ApplicationRecord
has_many :user_settings
has_many :category_events
has_many :users, through: :user_settings
has_many :events, through: :category_events
end
|
class Admin::JobReportsController < Admin::BaseController
before_filter :get_years
def index
authorize! :read, :job_reports
end
def registration_totals
authorize! :read, :job_reports
params[:year] ||= 2017
result = JobRegistration.get_stats(params[:year])
@total_registered = result[0]
... |
require 'spec_helper'
describe Regionable, "#load_region" do
let (:issue) { Factory.create(:issue) }
before(:each) do
issue.zip_code = "11111"
end
context "when a region exists for its zipcode" do
before(:each) do
Region.should_receive(:find_by_zip_code).with("11111").and_return(:region)
e... |
require 'httparty'
require 'json'
class CurrentWeather
include HTTParty
base_uri 'api.openweathermap.org/data/2.5'
def retrieve_curent_weather(cityid, api_key)
@curent_weather = JSON.parse(self.class.get("/weather?id=#{cityid}&APPID=#{api_key}").body)
end
def retrieve_coord
@curent_weather['coord']... |
class LineItem < ActiveRecord::Base
belongs_to :product
belongs_to :cart
def total_price
product.price * quantity
end
end
|
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable, :omniauthable,
:recoverable, :rememberable, :trackable, :validatable, :authenticat... |
require 'test_helper'
describe Version do
it 'of a reference' do
license = create(:license)
reference = create(:reference, license: license)
check_version(reference, library_id: reference.library_id)
end
it 'of a Following' do
user = create(:user)
following = user.follow(create(:user))
c... |
class ImportsController < TracksterResources
unloadable
MAX_ONLINE_IMPORT_SIZE = 50_000
def create
path, file_size, options = file_from_params(params[:import])
importer = Contacts::Import.new(current_account, current_user)
if file_size < MAX_ONLINE_IMPORT_SIZE
importer.import(path, options... |
class AddUserIdToSurveys < ActiveRecord::Migration[5.1]
def change
add_reference :surveys, :user, index:true
end
end
|
# frozen_string_literal: true
RSpec.describe SC::Billing::Stripe::PaymentSources::DestroyOperation, :stripe do
subject(:call) do
described_class.new.call(payment_source)
end
let(:stripe_customer) { Stripe::Customer.create }
let(:user) { create(:user, stripe_customer_id: stripe_customer.id) }
let(:stripe... |
require File.dirname(__FILE__) + '/lib/spec_helper.rb'
exit if exclude_test "ideas"
describe "Ideas: " do
before(:all) do
setup
end
after(:all) do
teardown
end
describe "when searching for an idea," do
before(:all) do
@sel.open('/')
@sel.click("link=ideas")
... |
require 'spec_helper'
describe Users::OmniauthCallbacksController do
describe "GET 'twitter'" do
describe "create success" do
before(:each) do
@user = FactoryGirl.create(:user, :twitter_id => '123')
User.stub(:find_or_create_for_twitter_oauth).and_return(@user)
end
it "ret... |
# encoding: UTF-8
class Film
class Horloge
# Pour l'enregistrement de l'horloge
def to_hash
{
horloge: horloge,
time: time,
real_time: real_time,
end_time: end_time,
real_end_time: real_end_time,
duree: duree
}
end
end #/Horloge
e... |
class WinnerState
def initialize(game)
@game = game
end
def handle
output = ""
player = @game.player
output << "You won!! you have scaped with life from the castle!!! "
output << "WELL DONE!!"
output << "Your final score is => #{player.score}\n"
puts output
output
end
end
|
class AddAnnotationCategoryForExternalFeedback < ActiveRecord::Migration[5.0]
def up
AnnotationCategory.create!(title: 'EXTERNE ANMERKUNG', generated_by_system: true)
end
def down
AnnotationCategory.where(title: 'EXTERNE ANMERKUNG').delete_all
end
end
|
FactoryBot.define do
factory :purchase_address do
address = Gimei.address
postal_code { "111-1111" }
prefecture_id { Faker::Number.between(from: 1, to: 48) }
address_line1 { address.city.to_s }
address_line2 { "田中5-5-5" }
bldg_name { "ガーラ渋谷常盤末 303号室" }
... |
class RemoveAgentFromPlans < ActiveRecord::Migration[6.0]
def change
remove_reference :plans, :agent, null: false, foreign_key: true
end
end
|
require 'sequel'
TOKEN_ENV = defined?(RAILS_ENV) ? RAILS_ENV : 'production'
class MiniToken < Struct.new(:db, :token)
TOKEN_SIZE = 6
TOKEN_CHARACTERS = (('A'..'Z').to_a+('a'..'z').to_a+('0'..'9').to_a)
DB_PATH = File.expand_path(File.join(File.dirname(__FILE__), '..', 'db'))
class << self
def output(size ... |
module Admin::ActivitiesHelper
def admin_review_paper_link(activity)
if activity
# (All Papers) - (Current User Reviewed) - (Unreviewed but Withdrawn/Accept/Reject)
unreviewed_papers = activity.unreview_by(current_user).size.to_i
content_tag :li, link_to("Review Papers (#{unreviewed_papers})", a... |
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :print_top_menu
private
def print_top_menu
@title_place = ""
@title_place << print_menu
@title_place << print_current_user
@title_place = @title_place.html_safe
end
def print_menu
render_to_strin... |
# coding: utf-8
require 'rspec'
require './arangodb.rb'
describe ArangoDB do
api = "/_api/simple"
prefix = "api-simple"
context "simple queries:" do
################################################################################
## all query
###################################################################... |
require 'faker'
#Configuration for seed file
NUMBER_OF_USERS = 123
skills = %w(programming plumbing baseball chess gardening algebra hockey baking cooking tennis badminton botany tv\ repair email\ support potty\ training dish\ washing fitness\ Hitman Knitting English spanish french Esperanto Pig\ Latin Persian Arabic... |
class Organization
attr_accessor :name, :children, :parent
@@orgs = 0
@@child_orgs = 0
def initialize(args={})
@children = args.fetch(:children, [])
@parent = args.fetch(:parent, nil)
@name = args.fetch(:name, default_name)
end
def add_child(args={})
children << child = Organization.new(a... |
class Event < ApplicationRecord
validates :title, presence: true
validates :description, presence: true
validates :start_date, presence: true
validates :end_date, presence: true
validates :organisation_id, presence: true, on: [:create]
validate :start_date_cannot_be_greater_than_end_date
belongs_to :organ... |
require 'uri'
class Commit < ActiveRecord::Base
attr_accessible :digest, :timestamp, :url
validates :digest, presence: true
validates :url, format: {with: URI::regexp(%w(http https)), message: 'must be a valid http(s) url'},
allow_nil: true
validates :timestamp, presence: tru... |
require_relative "body"
class Moon < Body
def initialize(name, mass, month, planet)
super(name, mass)
@month = month
@planet = planet
end
end
|
# encoding: utf-8
require "rails_helper"
require Rails.root.join("spec/helpers/user_helper.rb")
describe RestaurantsAPI, :type => :request do
# ============================================================================
context "Add new restaurant" do
before :each do
clear_database
@user = create(... |
Gems: 3rd party plugins/additions for Ruby
Restful web services:
simple web services implemented using HTTP and principles of REST
1. have a base URI
2. Support a data exchange format like XML or JSON
3. SUpport a set of HTTP operations (GET, POST)
HTTParty Gem
Restful web services client
Automatic parsing of ... |
# -*- coding: utf-8 -*-
require_relative 'spec_helper'
describe Codebreaker do
def make_dumb_user_interaction_object
@inter = Codebreaker::UserInteraction.new(double('input sink').as_null_object,
double('output sink').as_null_object)
end
describe 'play_game_i... |
# frozen_string_literal: true
require 'spec_helper'
describe RailwayOperation::Operation do
let(:subject) { described_class.new('Operation sample') }
context '#fails_step' do
it 'allows error classes to be pushed into fails_step declaration' do
subject.fails_step << StandardError
expect(subject.f... |
class CreateBranchesRules < ActiveRecord::Migration
def change
create_table :branches_rules, id: false do |t|
t.references :branch, index: true
t.references :rule, index: true
end
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.