text stringlengths 10 2.61M |
|---|
require 'stax/aws/emr'
require 'yaml'
module Stax
module Emr
def self.included(thor)
thor.desc(:emr, 'Emr subcommands')
thor.subcommand(:emr, Cmd::Emr)
end
end
module Cmd
class Emr < SubCommand
COLORS = {
RUNNING: :green,
WAITING: :gre... |
require 'rails_helper'
require 'spec_helper'
describe Pokemon do
describe "creation" do
it "should be valid" do
pika = FactoryGirl.build(:pikachu)
expect(pika).to be_valid
end
end
end
|
a = [1,2,3,9,1,4,5,2,3,6,6]
# Eliminar el último elemento
puts 'arreglo original'
p a
a.delete_at(-1)
puts 'elimina ultimo elemento del arreglo'
p a
#Eliminar el primer elemento.
a.delete_at(0)
puts 'elimina el primer elemento'
p a
#Eliminar el elemento que se encuentra en la posición media, si el arreglo tiene... |
require 'helper'
describe Trellohub::Form::Issue do
describe '#valid_attributes' do
it 'returns valid_attributes' do
expect(Trellohub::Form::Issue.valid_attributes).to eq %i(
title
labels
state
assignee
milestone
)
end
end
describe '#accessible_attribu... |
require 'yaml'
class Configuration
attr_accessor :options
attr_accessor :browser
def self.config_path=(path)
@@config_path = path
end
def initialize
raise ConfigurationException, "Missing configuration file" unless File.exists?(@@config_path)
environment = ENV['env']
browser = ENV['browser'... |
require 'pp'
class School
VERSION = 1
def initialize
@grades = {}
end
def add(student, grade)
@grades[grade] ||= []
@grades[grade].push(student).sort!
end
def grade(grade)
@grades[grade] ||= []
@grades[grade].sort
end
def to_h
Hash[@grades.sort]
end
end
|
Warden.test_mode!
RSpec.describe "UserSessions" do
after(:each) do
Warden.test_reset!
end
it "allows a user to register" do
visit new_user_registration_path
fill_in(:'user_name', with: "alicia")
fill_in(:'user_email', with: "alicia@example.com")
fill_in(:'user_password', with: "password")
... |
class CreateReceiveGroupLines < ActiveRecord::Migration[5.0]
def change
create_table :receive_group_lines do |t|
t.integer :job_order_id, index: true
t.integer :receive_group_id, index: true
t.float :cost, precision: 7, scale: 2
t.integer :length
t.integer :width
t.inte... |
json.array!(@stickers) do |sticker|
json.extract! sticker, :id, :name, :image, :quantity
json.url sticker_url(sticker, format: :json)
end
|
require 'spec_helper'
require 'yt/collections/videos'
require 'yt/models/channel'
describe Yt::Collections::Videos do
subject(:collection) { Yt::Collections::Videos.new parent: channel }
let(:channel) { Yt::Channel.new id: 'any-id' }
let(:page) { {items: [], token: 'any-token'} }
describe '#size', :ruby2 do
... |
class AddSuperDataToWfinders < ActiveRecord::Migration[6.0]
def change
add_column :wfinders, :super_data, :text
end
end
|
require 'constants'
require 'types'
# FIXME this class contains massive duplication of code from Registration::EditForm:
class Admin::EditRegistrationForm < Reform::Form
feature Reform::Form::Coercion
property :password, virtual: true
property :password_confirmation, virtual: true
property :current_password, ... |
# frozen_string_literal: true
require "abstract_unit"
require "active_support/core_ext/module/introspection"
module ParentA
module B
module C; end
module FrozenC; end
FrozenC.freeze
end
module FrozenB; end
FrozenB.freeze
end
class IntrospectionTest < ActiveSupport::TestCase
def test_parent_nam... |
require 'ostruct'
require 'disk/modules/miq_dummy_disk'
describe MiqDummyDisk do
DUMMY_DISK_BLOCKS = 1000
DUMMY_DISK_BLOCKSIZE = 4096
context ".new" do
it "should not raise an error with arguments" do
expect do
d_info = OpenStruct.new
d_info.d_size = DUMMY_DISK_BLOCKS... |
class RemoveColumnsFromUsers < ActiveRecord::Migration
def change
change_table :users do |t|
t.remove(:report_card, :skill_level)
end
end
end
|
module Api
module V1
class Main::MainTopicsController < ApplicationController
respond_to :json
resource_description do
name 'Main Topics'
end
api :GET, '/topics', "Show All Topics"
def index
respond_with Topic.all
end
api :GET, '/topics/:id', "Show Topic"
param :topic, Hash ... |
class RoleTypesController < ApplicationController
respond_to :html
def show
@role_type = RoleType.find(params[:id])
unless @role_type.published
not_found
else
respond_with(@role_type)
end
end
end
|
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root to: 'home#index'
get 'search/:role', to: 'home#search', as: 'search'
post 'home', to: 'home#sign_in', as: 'sign_in'
delete '/', to: 'home#sign_out', as: 'sign_out'
get '... |
require 'set'
module Mirrors
# Registers a TracePoint immediately upon load to track points at which
# classes and modules are opened for definition. This is used to track
# correspondence between classes/modules and files, as this information isn't
# available in the ruby runtime without extra accounting.
m... |
class Pet < ApplicationRecord
belongs_to :user
belongs_to :animal
has_many :pet_tag
has_many :tag , :through => :pet_tag
validates :name, presence: true, length: { maximum: 50 }
geocoded_by :address # ActiveRecord
after_validation :geocode # auto-fetc... |
ActiveAdmin.register CrawlTargetUrl do
menu priority: 1, label: "Urlクローラー", parent: "data"
config.batch_actions = true
config.per_page = 100
actions :index
action_item(:index, only: :index) do
link_to("クロールする", admin_urlcrawler_path, class: "table_tools_button")
end
index do
id_column
col... |
module Peanut::VideoThumbnail
extend ActiveSupport::Concern
included do
version :screenshot, {if: :video?} do
process :create_screenshot
# Hack to change the version's file extension
def full_filename(for_file)
super.sub(/\..+$/, '.jpg')
end
end
# Create a screenshot w... |
namespace :db do
desc "Erase database"
task :erase => :environment do
puts "Erasing..."
[Idea, Comment, Endorsement].each(&:delete_all)
end
desc "Erase and fill database"
task :populate => [:environment, :erase] do
require 'populator'
require 'faker'
puts "Populating: enjoy ... |
class AddNeterminalToEvaluationSessions < ActiveRecord::Migration[4.2]
def change
add_column :evaluation_sessions, :neterminal, :boolean
end
end
|
#!/usr/bin/env ruby
# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of... |
def suma(primero,segundo)
puts primero
end
#suma(50,100)
def say (param1)
puts "saludo personalizado ", param1
end
#say "seras cachondo"
def suma (primero, segundo)
primero + segundo #return
end
#puts suma (suma 1,2) , 4
def multiplica
producto=25.0 * 3
cociente= 7.0/4
puts producto, cocien... |
class User < ActiveRecord::Base
has_many :entries, :dependent => :destroy
has_many :tasks, :through => :entries
def task_group_progress group
entries.find_by_task_group( group ).inject(0) { |sum, e| sum += e.completion } / 4 # 4 tasks per group
end
def task_group_level_complete group
task_group_prog... |
class RemoveDistrictFromUser < ActiveRecord::Migration[5.1]
def change
remove_column :users, :district, :string
end
end
|
require 'carrierwave/mongoid'
class Post
include Mongoid::Document
include Mongoid::Timestamps
field :title, type: String
field :content, type: String
field :photo, type: String
mount_uploader :photo, PhotoUploader
has_many :comments, class_name: "PostComment"
accepts_nested_attributes_for :comments
v... |
lib = File.expand_path('../../../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "taobao/top/version"
require 'hashie'
require 'active_support/core_ext'
module Taobao
module TOP
mattr_accessor :sandbox
@@sandbox = false
def self.gateways
domain = self.sandbox? ? "t... |
require 'rails_helper'
describe AuditField do
it { should belong_to :grouping }
it { should have_many :audit_field_values }
it { should validate_presence_of :name }
it { should validate_presence_of :value_type }
it { should validate_presence_of :display_order }
it 'sets its api_name based on name' do
... |
require 'rails_helper'
RSpec.describe 'Profile Photos API' do
let!(:user) { create(:user) }
let!(:member_source_type) { create(:member_source_type)}
let!(:member_type) { create(:member_type) }
let!(:account_status_type) { create(:account_status_type)}
let!(:member) { create(:member, member_source_type_id:mem... |
require 'google/apis/youtube_v3'
require 'google/api_client/client_secrets'
class VideoController < ApplicationController
layout false
def new_service
secrets = Google::APIClient::ClientSecrets.new(
{
"web" =>
{
"access_token" => current_user.token,
"refresh_tok... |
module WSDL
module Reader
class Messages < Hash
def lookup_operations_by_element(type, element_name, port_types)
messages = lookup_messages_by_element(element_name)
messages.map do |message|
port_types.lookup_operations_by_message(type, message)
end.flatten
end
... |
class Types::EventProposalType < Types::BaseObject
include FormResponseAttrsFields
authorize_record
field :id, Integer, null: false
field :title, String, null: true
field :status, String, null: false
field :convention, Types::ConventionType, null: false
field :submitted_at, Types::DateType, null: false
... |
require File.dirname(__FILE__) + "/../spec_helper"
describe ForumController do
include SpecControllerHelper
include FactoryScenario
before :each do
Site.delete_all
factory_scenario :forum_with_topics
controller.stub!(:current_user).and_return @user
Site.stub!(:find).and_return @site
... |
class ChangeNameOfColumn < ActiveRecord::Migration[5.2]
def change
rename_column :rental_lists, :descritption, :description
end
end
|
require 'spec_helper'
# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to specify the controller code that
# was generated by Rails when you ran the scaffold generator.
#
# It assumes that the implementation code is generated by the rails scaffold
... |
class Offices < ActiveRecord::Migration
def self.up
create_table :offices do |t|
t.string :office_name
end
end
def self.down
drop_table :offices
end
end
|
# 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... |
module Regex
class Password
def self.VALID_PASSWORD_REGEX
/^[a-zA-Z0-9]{8,}*$/
end
end
end
|
require 'erb'
module TimeHipster
module Application
class View < Struct.new(:template)
class << self
def resolve(controller, action_name)
path = template_path(controller, action_name)
template = File.exists?(path) ? File.read(path) : 'Ok'
new(template)
end
... |
#
# Cookbook:: graphite
# Recipe:: _web_packages
#
# Copyright:: 2014-2016, Heavy Water Software Inc.
#
# 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/LI... |
class RemoveLatitudeFromAssassins < ActiveRecord::Migration[6.0]
def change
remove_column :assassins, :latitude, :integer
remove_column :assassins, :longitude, :integer
end
end
|
#[5.2]ハッシュ
#ハッシュはキーと値の組み合わせでデータを管理するオブジェクトのことです。他の言語では連想配列やディクショナリ(辞書)、マップと呼ばれたりする場合があります。
#ハッシュを作成する場合は以下のような構文(ハッシュリテラル)を使います。
# EX 空のハッシュを作る
{}
# キーと値の組み合わせを3つ格納するハッシュ
{ キー1 => 値1, キー2 => 値2, キー3 => 値3}
#ハッシュはHashクラスのオブジェクトになっています。
# EX 空のハッシュを作成し、そのクラス名を確認する
puts {}.class
# ==> Hash
# EX 国ごとに通貨の単位を格納... |
require 'spec_helper'
RSpec.describe Engine do
include Rack::Test::Methods
context 'for the current api' do
before do
create :tier, :free
params = {
data: {
name: 'Nerdcast',
episodes: 352,
website: 'jovemnerd.com.br'
}
}
ultra_pod = create... |
class CommentsController < ApplicationController
before_action :logged_in_user, only: [:create, :destroy]
def create
@entry = Entry.find(params[:entry_id])
@comment = @entry.comments.build(comment_params)
@comment.user_id = current_user.id
if current_user.following?(@entry.user) || current_user == @entry.user... |
require_relative "../config/environment.rb"
class MovieController
def initialize(url = "https://editorial.rottentomatoes.com/guide/200-essential-movies-to-watch-now/")
MovieScraper.scraper(url)
end
def run
puts "Welcome To Rotten Tomatoes Best 200 Movies Must Watch".blue
view_menu
... |
class Line
attr_accessor :start_point, :end_point
def initialize start_point, end_point
@start_point = start_point
@end_point = end_point
end
def length
Math.sqrt(
(@start_point[0] - @end_point[0])**2 +
(@start_point[1] - @end_point[1])**2
)
end
def == line
(
@start_... |
class Field < ActiveRecord::Base
belongs_to :user
has_many :installations
has_many :mobilizations
has_many :fertilizations
has_many :treatments
has_many :harvests
validates_presence_of :name, :culture, :date
end
|
class CreateWords < ActiveRecord::Migration
def change
create_table :words do |t|
t.string :entry
t.string :furigana
t.decimal :frequency
t.boolean :is_jlpt
t.integer :jlpt_level
t.timestamps
end
end
end
|
require 'rails_helper'
RSpec.describe Stock, type: :model do
let!(:stock) { described_class.create(symbol: 'MC', company_name: 'Microsoft Corp') }
context 'with validations/stock should fail to save' do
it 'is not valid without symbol' do
stock.symbol = nil
expect(stock).not_to be_valid
end
... |
require "rails_helper"
RSpec.describe BuildConferenceEvent do
describe ".from" do
it "translates a participant-join conference event into a class" do
result = described_class.from(event: "participant-join", sid: "1234", conference_sid: "12345")
expect(result).to be_a(ConferenceEvents::ParticipantJoi... |
class Joke < ApplicationRecord
has_and_belongs_to_many :categories
validates :title, presence: true
end
|
class RegistrationsController < Devise::RegistrationsController
respond_to :json
def create
@consumer = Consumer.new(consumer_params)
if(@consumer.save)
render :json => {
:consumer => @consumer,
:status => :ok
}
else
render :json => {:state => ... |
class Api::V1::RescuesController < ApplicationController
def create
rescue1 = Rescue.new(rescue_params)
rescue1.user = active_user
if rescue1.save
render json: {rescue: rescue1}
end
end
def index
render json: Rescue.all
end
def show
@rescue = Rescue.find(params[:id])
rende... |
class WelcomeController < ApplicationController
def index
p "Welcome to Rails!"
end
end
|
class Season < ApplicationRecord
has_many :teams, :through => :season_teams
has_many :season_teams
has_many :game_dates
has_many :players
end
|
module JanusGateway
class Error < StandardError
# @return [Integer]
attr_reader :code
# @return [String]
attr_reader :info
# @param [Integer] error_code
# @param [String] error_info
def initialize(error_code, error_info)
@code = error_code
@info = error_info
super("<Co... |
class CreateTasks < ActiveRecord::Migration
def change
create_table(:tasks) do |t|
t.string :title
t.text :description
t.date :due_time
t.string :estimated_time
t.integer :priority_id
t.integer :state_id
t.timestamps
end
end
end
|
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :timeoutable, :omniauthable, :registerable
devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable, :invitable, :lockable
rolify
include SearchCop
validates :email, presen... |
# == Schema Information
#
# Table name: comments
#
# id :integer not null, primary key
# commentable_id :integer
# commentable_type :string
# text :text
# response_to_id :integer
# user_id :integer
# created_at :datetime not null
# updated_at :... |
# frozen_string_literal: true
module ActiveSettings
module Validation
module Validate
def validate!
return unless self.class.schema
v_res = self.class.schema.call(to_hash)
return if v_res.success?
raise ActiveSettings::Validation::Error, "ActiveSettings validation failed... |
class Case < ActiveRecord::Base
acts_as_mappable
def self.create_from_socrata!(socrata_attrs)
attrs = {
'remote_id' => socrata_attrs['service_request_id'],
'service' => socrata_attrs['service_name'],
'service_subtype' => socrata_attrs['service_subtype'],
'service_details' => so... |
# == Schema Information
#
# Table name: niveles
#
# id :integer not null, primary key
# nivel :string
#
class Nivel < ApplicationRecord
###################################################
##################Validaciones#####################
#validates :nivel, presence: {message: "Campo obligatorio... |
class Reservation < ApplicationRecord
belongs_to :user
belongs_to :menu
validates :start_scheduled_at, presence: true
validates :end_scheduled_at, presence: true
validate :date_before_start
validate :date_before_finish
def date_before_start
return if start_scheduled_at.blank?
errors.add(:start_... |
class WrapsController < ApplicationController
before_action :set_wrap, only: [:show, :edit, :update, :destroy]
before_action :group_menber?
def index
@pet = Pet.find(params[:pet_id])
@wraps = @pet.wraps.includes(:conditions).all.order(start_time: :desc)
end
def new
@wrap = Wrap.new
@wrap.con... |
class AddReportetoManten < ActiveRecord::Migration
def change
add_column :mantenimientos, :reporte, :string
end
end
|
module Monad
class Maybe
def initialize(value)
@value = value
end
def self.lift(value)
Maybe.new value
end
attr_reader :value
def fmap(proc)
if @value.nil?
self
else
Maybe.new(proc.call(@value))
end
end
def apply(maybe)
if @value.... |
require File.expand_path('../test_helper', __FILE__)
class EncryptorTest < Test::Unit::TestCase
algorithms = %x(openssl list-cipher-commands).split
key = Digest::SHA256.hexdigest(([Time.now.to_s] * rand(3)).join)
iv = Digest::SHA256.hexdigest(([Time.now.to_s] * rand(3)).join)
salt = Time.now.to_i.to_s
origi... |
## -*- Ruby -*-
## XML::DOM
## 1998-2001 by yoshidam
##
require 'xml/dom2/node'
require 'xml/dom2/domexception'
module XML
module DOM
=begin
== Class XML::DOM::EntityReference
=== superclass
Node
=end
class EntityReference<Node
=begin
=== Class Methods
--- EntityReference.new(name, *children)
creates a... |
class CatalogController < ApplicationController
def get
render json: Rails.application.config.catalog
end
end
|
# encoding: UTF-8
require 'rails_helper'
require 'byebug'
describe "User logs in", :type => :feature do
before :each do
#create admin user
if User.find_by_email('evermentors@gmail.com').blank?
ActiveRecord::Base.skip_callbacks = true
havit_admin = User.create name: '에버멘토', email: 'evermentors@gma... |
class Api::V1::Batches::ClosingsController < ApplicationController
def update
batch = find_batch(params[:reference])
orders = batch.orders
orders.update(status: 'closing')
render json: { reference: batch.reference, status: 'closing' }, status: :ok
rescue ActiveRecord::RecordNotFound
render jso... |
class CreateOrderGroups < ActiveRecord::Migration
def self.up
create_table :order_groups do |t|
t.date :name
t.integer :department_id
t.integer :type_id
t.integer :now_level
t.integer :no
t.integer :status_id
t.timestamps
end
end
def self.down
drop_table :ord... |
FactoryGirl.define do
factory :card_product, aliases: [:product] do
sequence(:name) { |n| "Example Card #{n}" }
annual_fee_cents { rand(500_00) + 10_00 }
bank_id { Bank.all.pluck(:id).sample }
image_content_type { 'image/png' }
image_file_name { 'example_card_image.png' }
image_file_size ... |
#!/usr/bin/env jruby
$:.unshift File.expand_path('../../lib', __FILE__)
require 'traject/command_line'
require 'benchmark'
unless ARGV.size >= 2
STDERR.puts "\n Benchmark two (or more) different config files with both 0 and 3 threads against the given marc file\n"
STDERR.puts "\n Usage:"
STDERR.puts " ... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :user do
email {Faker::Internet.email}
password {Faker::Internet.password}
first_name {Faker::Name.first_name}
last_name {Faker::Name.last_name}
end
end
|
class CreateSharePoints < ActiveRecord::Migration
def change
create_table :share_points do |t|
t.integer :friendships_id
t.integer :location_id
t.float :points
t.timestamps
end
end
end
|
require "aethyr/core/actions/commands/command_action"
module Aethyr
module Core
module Actions
module Tell
class TellCommand < Aethyr::Extend::CommandAction
def initialize(actor, **data)
super(actor, **data)
end
def action
event = @data
... |
# Pad an Array
# I worked on this challenge with Eunice Choi
# I spent 3 hours on this challenge.
# Complete each step below according to the challenge directions and
# include it in this file. Also make sure everything that isn't code
# is commented in the file.
# 0. Pseudocode
=begin
What is the input? An array... |
require 'test_helper'
require 'mine'
describe Result do
let(:described_class) { Result }
let(:mine) { Mine.new(1,2,3) }
describe 'initialization' do
it 'sets all properties' do
inst = described_class.new(mine)
inst.mine.must_equal mine
inst.iterations.must_equal 0
inst.explosions.mus... |
class ToppagesController < ApplicationController
def index
if logged_in?
redirect_to user_path(id: current_user.id)
end
end
end |
class CreateSeries < ActiveRecord::Migration[6.0]
def change
create_table :series do |t|
t.string :name
t.string :genre
t.integer :no_of_seasons
t.date :date_of_first_release
t.string :director
t.timestamps
end
end
end
|
class V1::ShippingAddressSerializer < ActiveModel::Serializer
attributes :id, :name, :address_line1, :address_line2, :city, :state, :country, :postal_code
end
|
module TemplateBuilder
class FromApp
attr_reader :app_id, :options
def initialize(app_id, options)
@app_id = app_id
@options = options
end
def create_template(persisted=true)
app = App.find(app_id)
Converters::AppConverter.new(app).to_template.tap do |template|
templ... |
#!/usr/bin/env ruby
require 'typhoeus'
require 'bloomfilter-rb'
require 'nokogiri'
require 'domainatrix'
require 'uri'
class Spider
def initialize(url, options = {})
@start_url = url
@domain = parse_domain(url)
@threads = options[:threads] ? options[:threads] : 200
@max_urls = options[:max_urls] ? opti... |
class Post < ApplicationRecord
before_validation :create_date, on: :create
before_validation :update_date, on: :update
belongs_to :user, inverse_of: :posts
validates_presence_of :title, :body, :user_id, :published_at
private
def create_date
self.updated_at = self.published_at = DateTime.current
end
... |
class Web::FondsController < Web::WebController
layout :set_layout
before_filter :authorize_admins_only, :except => [ :show, :amount_table,
:popup, :contribution_names, :faq ]
# ............................................................................ #
def show
amount_table
@html_title = "Nada... |
class Price
include Virtus.model
include ActiveModel::Model
include ActiveModel::SerializerSupport
attribute :amount, BigDecimal
attribute :currency, String
end
|
require 'statement.rb'
require 'ledger.rb'
require 'date.rb'
describe Statement do
let(:time) {Time.new}
let(:ledger) {Ledger.new}
let(:statement) {ledger.base_statement}
context 'get statement' do
it 'takes deposits and withdrawals and returns statement' do
ledger.deposit(100.00)
ledger.depo... |
#!/usr/bin/env ruby
require 'crfsuite'
# Inherit Crfsuite::Trainer to implement message() function, which receives
# progress messages from a training process.
class Trainer < Crfsuite::Trainer
def message(s)
# Simply output the progress messages to STDOUT.
print s
end
end
def instances(fi)
xseq = Crfs... |
require 'Nokogiri'
class Issue
attr_accessor :project_i, :tracker, :status, :priority, :author_i, :assigned_to, :subject, :start_date, :done_ratio
def initialize(attrs = {})
self.project_i = attrs.xpath("./project/@name").text
self.tracker = attrs.xpath("./tracker/@name").text
self.status = attrs.xpa... |
require File.dirname(__FILE__) + "/../fixtures/classes"
describe :delegate_instantiation, :shared => true do
before(:each) do
@class = @method
end
it "creates a delegate from bound methods" do
@class.new(DelegateTester.method(:bar)).should be_kind_of @class
end
it "creates a delegate from lambdas"... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :task do
goal nil
name "MyString"
due Date.tomorrow
end
end
|
class CreateCompanies < ActiveRecord::Migration
def change
create_table :companies do |t|
t.string :name
t.string :grade
t.decimal :beCutoff
t.decimal :xiiCutoff
t.decimal :xCutoff
t.integer :backsAllowed
t.string :branchesAllowed
t.string :details
t.decimal :... |
module API
module V1
module Entities
class Base < Grape::Entity
format_with(:null) { |v| v.blank? ? "" : v }
format_with(:chinese_date) { |v| v.blank? ? "" : v.strftime('%Y-%m-%d') }
format_with(:chinese_datetime) { |v| v.blank? ? "" : v.strftime('%Y-%m-%d %H:%M:%S') }
format... |
require 'socket'
require_relative 'logdna/client.rb'
require_relative 'logdna/resources.rb'
module Logdna
class Ruby < ::Logger
Logger::TRACE = 5
attr_accessor :level, :app, :env, :meta
@level = nil
@app = nil
@env = nil
@meta = nil
def initialize(key, opts={... |
class Union < ActiveRecord::Base
has_many :tribes
attr_accessible :description, :name
validates :name , presence: true, length: { in: 2..30 }, uniqueness: { case_sensitive: false }
end
|
require File.dirname(__FILE__) + '/../../../spec_helper'
require 'mathn'
ruby_version_is '1.9' do
describe 'Kernel#Rational' do
it 'returns an Integer if denominator divides numerator evenly' do
Rational(42,6).should == 7
Rational(42,6).class.should == Fixnum
Rational(bignum_value,1).should == ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.