text stringlengths 10 2.61M |
|---|
class Numbers
def initialize(first_number, second_number)
@first_number = first_number.to_i
@second_number = second_number.to_i
end
def sum
@first_number + @second_number
end
def subtraction
@first_number - @second_number
end
def multiplication
@first_number * @second_number
end
... |
require 'net/http'
require 'pp'
class LookupService
def lookup_locations(postcode, radius=1.2)
postcode_data = get_lat_long_for(postcode)
get_bus_stops_within_range(postcode_data[:lat].to_f, postcode_data[:lng].to_f, radius)
end
def get_lat_long_for(postcode)
http = get_http()
path = "/postcode... |
get '/' do
@name = User.find(session[:user_id]).username unless session[:user_id].nil?
@array = ShortenedUrl.where(user_id: session[:user_id]) unless session[:user_id].nil?
erb :index
end
post '/' do
if session[:user_id].nil?
@current = ShortenedUrl.create(url: params[:long_url])
else
user = User.find(session... |
require 'plivo'
class Friend < ApplicationRecord
include Plivo
has_many :friendships
has_many :users, through: :friendships
def self.send_bulk_message(body: nil)
unless body
self.all.each {|f| f.send_message}
else
self.all.each {|f| f.send_message(body)}
end
end
def send_message(b... |
class SlackbotsController < ApplicationController
skip_before_action :verify_authenticity_token
CATEGORY = Struct.new(:name, :path)
CATEGORIES = [
CATEGORY.new("Tシャツ", "tops/tshirt-cutsew/"),
CATEGORY.new("カットソー", "tops/tshirt-cutsew/"),
CATEGORY.new("シャツ", "tops/shirt-blouse/"),
CATEGORY.ne... |
module Hypixel
class Rank
# Returns the highest rank provided in the array.
# Supports both lists of symbols and strings.
#
# Params:
# +ranks+::List of ranks to sort.
# +symbols+::Whether or not the list provided is raw strings or symbols.
def self.top(ranks, symbols)
from_string(ranks.max_by do |r... |
require_relative 'input'
module Mastermind
class Player
include Input
attr_writer :h_num
attr_reader :input
def initialize
@h_num = 0
@msg = Message.new
@code = ["r","g","b","y","c","m"]
end
def is_valid?(incode)
arr = []
for i in incode
arr << i if @code.include?(i)
... |
require 'rails_helper'
describe Address do
describe '#create' do
it "address_firstname,address_lastname,address_kana_firstname,address_kana_lastname, zipcode, prefectures, municipalities, address" do
address = build(:address)
expect(address).to be_valid
end
it "is invalid without a address... |
class AddStatusToTenant < ActiveRecord::Migration[6.1]
def change
add_column :tenants, :status, :string
end
end
|
#here we describe class Product
class Product
def initialize(price, amount)
@price = price
@amount = amount
end
def price
@price
end
def update(params)#each child should define its own method
end
def info#the same
end
def show #this method will return a string to print it later on
"... |
require "fluent/test/log"
require "serverengine"
module DummyLogger
class << self
def logger
dl_opts = {log_level: ServerEngine::DaemonLogger::INFO}
logdev = Fluent::Test::DummyLogDevice.new
logger = ServerEngine::DaemonLogger.new(logdev, dl_opts)
Fluent::Log.new(logger)
end
end
end... |
require 'forwardable'
module PrawnCharts
# PrawnCharts::Graph is the primary class you will use to generate your graphs. A Graph does not
# define a graph type nor does it directly hold any data. Instead, a Graph object can be thought
# of as a canvas on which other graphs are draw. (The actual graphs the... |
class Messenger
attr_reader :record, :model, :attributes
def initialize(params, model)
@model = model
@attributes = attribute_array(params).to_h
if model == "Visit"
url = find_or_create_url
event = find_or_create_event
update_attributes(url, event)
@record = url.visits.new(attr... |
require 'rails_helper'
describe 'user manages images' do
before do
#@user = FactoryGirl.create(:user)
@album = FactoryGirl.create(:album)
end
it 'create a new image' do
user = @album.user
login_as(user, scope: :user)
visit root_path
click_link "Dashboard"
expect(page).to have_content("My Dashboard")
... |
module Service
class MessageCreate < BaseService
step Transaction {
step :permit_params
step :create
}
def create
model = Message.create!(permit_params)
@errors += model.errors.full_messages if model.errors.present?
model
end
def permit_params
params.require(:... |
class AddParticipationDueToUsers < ActiveRecord::Migration
def change
add_column :users, :participation_due, :datetime
end
end
|
require 'rails_helper'
# require 'spec_helper'
RSpec.describe GroupsController, :type => :controller do
# describe GroupsController do
context "when user not logged in" do
describe "GET #index" do
it "redirects to login page" do
get :index
expect(response).to redirect_to new_user_session_p... |
require 'rspec'
require 'spec_helper'
describe 'Misil' do
it 'deberia almacenar vida cuando se instancia el objeto' do
misil = Misil.new 100, 45
expect(misil.vida).to eq 100
end
it 'deberia almacenar masa cuando se instancia el objeto' do
misil = Misil.new 100, 45
expect(misil.masa).to eq 45
... |
class CreateReviews < ActiveRecord::Migration[5.2]
def change
create_table :reviews do |t|
t.integer :user_id, index: true
t.integer :restaurant_id, index: true
t.integer :stars, null: false, limit: 1
t.text :comment
t.text :reply
t.datetime :visited_at
t... |
class RacasController < ApplicationController
before_action :set_raca, only: [:show, :edit, :update, :destroy]
before_action :authenticate_usuario!
# GET /racas
# GET /racas.json
def index
@racas = Raca.all
end
# GET /racas/1
# GET /racas/1.json
def show
end
# GET /racas/new
def new
@... |
require 'test_helper'
require "authlogic/test_case" # include at the top of test_helper.rb
class CommentsControllerTest < ActionController::TestCase
setup do
@recipe = recipes(:one)
@my_comment = comments(:my_comment_about_pasta)
@gf_comment = comments(:girlfriend_comment_about_pasta)
end
setup :act... |
class NoticeMailer < ApplicationMailer
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.notice_mailer.sendmail_tsubuyakie.subject
#
def sendmail_tsubuyakie(tsubuyakie)
@tsubuyakie = tsubuyakie
mail to: "m.umecco@gmail.com",
subject: '【Tsubuy... |
require 'rails_helper'
RSpec.describe Dish, type: :model do
describe "validations" do
it {should validate_presence_of :name}
it {should validate_presence_of :description}
end
describe "relationships" do
it {should belong_to :chef}
it {should have_many :dish_ingredients}
it {should have_many(:... |
class Coach < ActiveRecord::Base
belongs_to :user
has_many :testimonials
has_many :ratings
has_many :chats
has_many :scheduled_calls
after_create :delete_learner # To delete the learner account the coach doesn't need
def delete_learner
@user = User.find(self.user_id)
@user.learner... |
require 'rails_helper'
describe CourseApi::Ping do
describe 'get api/v1/ping' do
before { get('/api/v1/ping') }
it { expect(JSON.parse( response.body )).to eq 'pong' }
end
end |
describe ".are_we_there_yet?" do
it "prints out 'are we there yet?' four times every time the method is called" do
expect(are_we_there_yet?).to eq ("are we there yet?are we there yet?are we there yet?are we there yet?")
end
end
|
class Item < ApplicationRecord
default_scope { order(:item_level => :desc) }
validates :name, presence: true, length: { maximum: 100 }
validates :description, length: { maximum: 256 }
validates :item_level, presence: true, numericality: { only_integer: true }
has_many :auctions
belongs_to :bind, optiona... |
class Camp < ApplicationRecord
# association
belongs_to :admin_user , foreign_key: "user_id"
has_many :ratings, dependent: :destroy
# validation of presence of fields
validates_presence_of :name, :fees, :website, :course
# validation of lengths
validates_length_of :name, in: 3..40
validates_length_of :website... |
class ClientsController < ApplicationController
before_action :set_client, only: [:show, :edit, :update, :destroy]
def import
@client = Client
@import = Mudhead::Importer.new(@client, nil, {})
end
def do_import
@client = Client
@import = Mudhead::Importer.new(@client, params[:file], { before_b... |
class Picture < AbstractModel
has_attached_file :content, :styles => {
:thumbnail => "150",
:large => "800x800>",
:medium => "400x400>"
}, :default_url => "/image/:style/default.gif"
belongs_to :image
validates_attachment_content_type :content, :content_type => /\Aimage\/.*\Z/
validates :content... |
module Ricer::Plug::Params
class JoinedChannelParam < ChannelParam
def default_options; { online: '1', channels: '1', users: '0', connectors: '*', multiple: '0' }; end
end
end
|
describe 'adapter_riak' do
before :all do
require 'riak'
# We don't want Riak warnings in tests
Riak.disable_list_keys_warnings = true
end
moneta_build do
Moneta::Adapters::Riak.new(:bucket => 'adapter_riak')
end
moneta_specs ADAPTER_SPECS.without_increment.without_create
end
|
FactoryBot.define do
factory :retrospective do
id {Faker::Number.between(from: 1, to:50000)}
name { Faker::FunnyName.name }
position { Faker::Number.between }
team { FactoryBot.create(:team) }
end
end
|
require "pry"
class Game
attr_accessor :human_player, :enemies
def initialize(argu)
@human_player = HumanPlayer.new(argu)
@enemies = Array.new
4.times do |player|
player = Player.new("enemy#{player}")
@enemies.push(player)
end
end
d... |
module Fangraphs
module Batters
extend self
extend Download
INDICES = { name: 1, ab: 2, sb: 3, bb: 4, so: 5, slg: 6, obp: 7, woba: 8, wrc: 9, ld: 10, gb: 11, fb: 12 }
DATA = "c,5,21,14,16,38,37,50,54,43,44,45"
SIZE = 13
PARAMS = [
{ version: "L", month: 13, data: DATA, size: SIZE, indice... |
#!/usr/bin/env ruby
# encoding: UTF-8
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'multi_json', require: false
gem 'oj', require: false
gem 'fast_multi_json', path: '.'
end
# Adapted from https://raw.githubusercontent.com/ohler55/oj/39c975a048d89f42062bb542fae98109520b10eb/test/perf... |
require 'active_record'
module Middleman
class ActiveRecordExtension < Extension
option :database_config, 'db/config.yml', 'The location of the YAML database configuration.'
option :database_environment, ENV.fetch('MN_ENV', :development).to_sym, 'The database environment to use.'
def initialize(app, opt... |
module RPX::TestHelper
private
def mock_response(code, body)
OpenStruct.new :code => code, :body => rpx_response(body)
end
def rpx_json(template)
JSON.parse rpx_response(template)
end
def rpx_response(template)
Rails.root.join("test", "fixtures", "rpx", "#{template}.json").read
... |
require 'acfs/request/callbacks'
module Acfs
# Encapsulate all data required to make up a request to the
# underlaying http library.
#
class Request
attr_accessor :body, :format
attr_reader :url, :headers, :params, :data, :method, :operation
include Request::Callbacks
def initialize(url, opti... |
class Parliament < Formula
include Language::Python::Virtualenv
desc "AWS IAM linting library"
homepage "https://github.com/duo-labs/parliament"
url "https://files.pythonhosted.org/packages/5e/9f/84fed753abbd4c77d6ab7243054eed9736a38872f77d31b454a07bfdfab9/parliament-1.4.1.tar.gz"
sha256 "f94ca078a90a56e8d22... |
# frozen_string_literal: true
require "spec_helper"
describe CmeFixListener::TradeCaptureReportRequester do
let(:klass) { described_class }
let(:instance) { klass.new(account) }
let(:account) do
{
"id" => 123,
"name" => "Account1",
"cmeUsername" => "USERNAME_SPEC",
"cmePassword" => "... |
class HomesController < ApplicationController
def top
@posts = Post.all.order('created_at DESC').limit(3)
end
end
|
# Store visits to mongodb.
require "mongo"
require "bson"
class VisitStoreMongo
def initialize(mongo_client)
@client = mongo_client
end
def save(key, visit)
# Don't bother storing null or false values.
hash = visit.to_hash.reject!{|k,v| !v}
# Don't bother with id == "none" either.
if has... |
require 'test_helper'
class HubsControllerTest < ActionDispatch::IntegrationTest
setup do
@hub = hubs(:one)
end
test "should get index" do
get hubs_url
assert_response :success
end
test "should get new" do
get new_hub_url
assert_response :success
end
test "should create hub" do
... |
class VideosController < ApplicationController
before_filter :authenticate_user!, except: [:index, :show]
before_filter :membership_required
# GET /videos
# GET /videos.json
def index
# @videos = Video.page(params[:page]).per_page(3)
@q = Video.search(params[:q])
@videos = @q.result(distinct: true).... |
class Qualification < ActiveRecord::Base
validates :title, presence: true
belong_to :doctor
end
|
# frozen_string_literal: true
require 'yaml'
require 'shellwords'
require 'tempfile'
require 'fileutils'
require 'kubernetes-deploy/common'
require 'kubernetes-deploy/concurrency'
require 'kubernetes-deploy/kubernetes_resource'
%w(
custom_resource
cloudsql
config_map
deployment
ingress
persistent_volume_cl... |
class CardTag < ApplicationRecord
belongs_to :tag
belongs_to :card
end
|
module Enumerated
# Wraps single enumerated definition declared in model.
class Definition
def initialize(model, attribute, declaration)
@model, @attribute, @declaration = model, attribute, declaration
raise ArgumentError, "Declared enumeration must be either Array or Hash." unless declaration.is_... |
require 'euler_helper.rb'
NAME ="Relatively prime"
DESCRIPTION ="Euler's Totient function, φ(n) [sometimes called the phi function], is used to determine the number of numbers less than n which are relatively prime to n. For example, as 1, 2, 4, 5, 7, and 8, are all less than nine and relatively prime to nine, φ(9)=6."... |
class CreateUsers < ActiveRecord::Migration[5.2]
def change
create_table :users do |t|
t.string :name
t.string :provider
t.string :uid
t.string :omniauth_token
t.string :refresh_token
t.integer :expires_at
t.boolean :expires
t.string :name
t.string :nickname
... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
root 'sessoes#new'
get 'login' => 'sessoes#new'
post 'login' => 'sessoes#create'
delete 'logout' => 'sessoes#destroy'
resources :estagiarios, :jornadas
get 'minh... |
resource_group_name = attribute('resource_group_name', default: 'Belfast-Demo-VSTS', description: 'Name of the resource group to interogate')
location = attribute('location', default: 'westeurope')
title 'Belfast Demo Virtual Machine'
control 'Belfast Demo VM' do
impact 1.0
title 'Check the attributes of the ... |
class Coin < ApplicationRecord
has_many :watchlist_coins
has_many :watchlists, through: :watchlist_coins
end
|
class ACMA
extend Conformist
column :name, 11 do |value|
value.match(/[A-Z]+$/)[0].upcase
end
column :callsign, 1
column :latitude, 15
end
class ACMA::Digital < ACMA
column :signal_type do
'digital'
end
end
|
#
# Cookbook Name:: cdap
# Library:: helpers
#
# Copyright © 2016-2017 Cask Data, 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/LICENSE-2.0
#
# Un... |
# -*- encoding : utf-8 -*-
class PagesController < ApplicationController
before_filter :load_group,except: :see_page
before_action :set_page, only: [:show, :edit, :update, :destroy]
before_filter :authenticate_user!, except: [:see_page]
# GET /pages
# GET /pages.json
def index
@pages = @group.pages.al... |
require 'spec_helper'
describe 'organizational units' do
let(:organization_arn) do
output_for(:harness, 'organization_arn')
end
let(:organization) do
organizations_client.describe_organization.organization
end
let(:root) do
organizations_client.list_roots.roots[0]
end
context "builds organ... |
class RemoveQ1FromCheck < ActiveRecord::Migration[5.2]
def change
remove_column :checks, :q1, :text
end
end
|
#
# specifying flor
#
# Tue Jan 24 07:42:13 JST 2017
#
require 'spec_helper'
describe Flor::Waiter do
before :all do
@waiter = Flor::Waiter.allocate
class << @waiter
public :expand_args
end
end
describe '#expand_args' do
it 'expands single points' do
expect(
@waiter.ex... |
module PhotosHelper
def get_image_url(photo)
if photo && photo.image.present?
photo.image.thumb("260x210#").url
# asset_path "no_restaurant.png"
else
asset_path "restaurant_default.png"
end
end
def get_image_cover_url(cover = nil)
if cover && cover.image.present?
cover.i... |
# frozen_string_literal: true
class BooksController < ApplicationController
before_action :authenticate_user!
before_action :set_book, only: %i[show edit destroy update]
before_action :edit_auth, only: %i[edit update destroy]
def index
@book = Book.new
@books = Book.all.includes(:user)
@day_ratio ... |
require 'rails_helper'
RSpec.describe "pet show page", type: :feature do
it "can complete deletion with DELETE and redirect" do
visit "/pets/#{@pet_1.id}"
click_link 'Delete'
expect(current_path).to eq('/pets')
expect(page).not_to have_content(@pet_1.name)
expect(page).not_to have_content(@pet... |
require 'test_helper'
class SpousesControllerTest < ActionDispatch::IntegrationTest
setup do
@spouse = spouses(:one)
end
test "should get index" do
get spouses_url
assert_response :success
end
test "should get new" do
get new_spouse_url
assert_response :success
end
test "should cre... |
module Genetic
class Mutator
def mutate(population, num_generations, fitness_proc)
1.upto(num_generations).each do |generation|
offspring = Population.new(fitness_proc: fitness_proc)
while offspring.count < population.count
parent1 = population.select
parent2 = populat... |
class AddMenuFieldsToPages < ActiveRecord::Migration
def change
add_column :pages, :show_menu, :boolean, :default => false
add_column :pages, :show_in_menu, :boolean, :default => false
end
end
|
class CreateEmoticons < ActiveRecord::Migration
def change
create_table :emoticons do |t|
t.string :name, null: false
t.text :image_data, null: false
t.boolean :active, null: false, default: true
t.timestamps
end
end
end
|
class AddTrialGoalsToModelActivityData < ActiveRecord::Migration
def self.up
add_column "pas_model_activity_modelruns", :trial_number, :integer
add_column "pas_model_activity_modelruns", :trial_goal, :text
end
def self.down
remove_column "pas_model_activity_modelruns", :trial_number
remove_column... |
require File.expand_path File.join(File.dirname(__FILE__), 'spec_helper')
describe SMG::HTTP::Model do
before :all do
@klass = Class.new {
include SMG::Resource
include SMG::HTTP
params "term" => "Portal"
site "http://store.steampowered.com"
}
end
describe "#uri_for" do
it ... |
require "rails_helper"
RSpec.describe MessageStatus do
describe "#delivered?" do
it "is true if the message status is delivered" do
subject = described_class.new("delivered")
result = subject.delivered?
expect(result).to be(true)
end
it "is false if the message status is not delivere... |
require 'rspec'
require 'dessert'
=begin
Instructions: implement all of the pending specs (the `it` statements without blocks)! Be sure to look over the solutions when you're done.
=end
describe Dessert do
let(:cupcake) { Dessert.new("cupcake", 12, chef)}
let(:chef) { double("chef", name: "Gordon") }
describe ... |
class WebhooksController < ApplicationController
skip_before_action :verify_authenticity_token
protect_from_forgery :except => :receive
before_action :check_allowed_ip, only: [:receive]
require 'membership'
include Membership
SECRET_KEY = ENV["PAYSTACK_PRIVATE_KEY"]
def receive
if check_allow... |
MTMD::FamilyCookBook::App.controllers :ingredient do
before do
@logic_class = MTMD::FamilyCookBook::IngredientActions.new(params)
end
get :as_array, :with => '(:q)' do
content_type 'application/json;charset=utf8'
@logic_class.ingredient_options.to_json
end
get :as_array_with_string_values, :wi... |
class ReviewSerializer < ActiveModel::Serializer
attributes :id, :title, :rating, :body, :user_id, :review_date
def review_date
"#{object.created_at.strftime("%B %d, %Y - %I:%M%P")}"
end
belongs_to :user
has_many :votes
end
|
class Recipe < ActiveRecord::Base
belongs_to :category
validates_presence_of :title, :ingredients, :instructions
end
|
require 'spec_helper'
describe 'MorrisChart' do
context 'when countable' do
context 'when monthly interval' do
before do
@chart = Chart.new(
name: 'example_chart',
type: 'countable',
default_interval: 'daily',
)
@stats = [
Stat.new(time: DateT... |
FactoryBot.define do
factory :link do
sequence(:name) { |n| "Link#{n}" }
sequence(:url) { |n| "https://www.testlink#{n}.com" }
linkable { create(:question) }
end
factory :gist, parent: :link do
sequence(:name) { |n| "Gist#{n}" }
sequence(:url) { |n| "https://gist.github.com/name/gist_id_#{n}"... |
def greeting
name = gets "Hey! What is your name: "
puts "Hi #{name}. I am a calculator. \n
I can add, subtract, multiply, and divide.\n"
return name
end
def request_calculation_type
operation_selection = gets "Type 1 to add, 2 to subtract, 3 to multiply, or 4 to divide two numbers: "
... |
module ApplicationHelper
def admin?
current_user && current_user.is_admin
end
end
|
class Coach < ActiveRecord::Base
belongs_to :team
belongs_to :association
end
|
require 'rails_helper'
RSpec.describe "As a visitor " do
describe "When I visit astronauts index page, " do
# (e.g. "Name: Neil Armstrong, Age: 37, Job: Commander")
it "I see a list of astronauts with name, age, and job for each" do
astronaut_1 = Astronaut.create!(name: "Neil Armstrong", age: 37, job: ... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe CollectedCoin, type: :model do
it 'is valid with value and user' do
collected_coin = build(:collected_coin)
expect(collected_coin).to be_valid
end
context 'when validating' do
it { is_expected.to validate_presence_of(:value) }
... |
require 'nokogiri'
require 'open-uri'
require 'json'
require 'yaml'
require 'ostruct'
# Accepts an SVG (xml) file
# Expects a certain schema (Seating Chart generated from Adobe Illustrator)
# Creates an (AR) Section with Stack ID
# Creates (AR) Areas within those sections
module Tix
class ChartParser
SEATABL... |
module RSpec
module Mocks
RSpec.describe MessageExpectation, "has a nice string representation" do
let(:test_double) { double }
example "for a raw message expectation on a test double" do
expect(allow(test_double).to receive(:foo)).to have_string_representation(
"#<RSpec::Mocks::Mes... |
require 'rails_helper'
RSpec.describe Api::V1::ItemsController, type: :controller do
fixtures :items
describe "#index" do
it "serves all items' json" do
get :index, format: :json
expect(response.status).to eq(200)
expect(response.content_type).to eq "application/json"
body = JSON.pars... |
require 'rails_helper'
RSpec.describe Follow, type: :model do
let(:follow) { build :follow }
it '正常系' do
expect(follow.save).to be_truthy
end
it 'followeeの存在性チェック' do
follow.followee = nil
expect(follow.save).to be_falsy
end
it 'followerの存在性チェック' do
follow.follower = nil
expect(fo... |
# frozen_string_literal: true
require 'test_helper'
class UserShowTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# end
def setup
@inactive_user = users(:inactive)
@active_user = users(:archer)
end
test 'should display user when activated' do
get user_path(@active... |
class SubscriptionPlan < ApplicationRecord
has_many :subscription_plan_features
has_many :features, through: :subscription_plan_features
has_many :members
enum duration: [:daily, :weekly, :monthly, :quarterly, :annually]
enum organization_package: [:regular, :corporate, :insurance]
enum status... |
require 'compiler_helper'
module Alf
class Compiler
describe Default, "defaults" do
subject{
compiler.call(expr)
}
shared_examples_for 'the expected Defaults' do
it_should_behave_like "a traceable compiled"
it 'has a Defaults cog' do
expect(subject).to be_ki... |
class TasksController < ApplicationController
def create
@list = List.find(params[:list_id])
@task = @list.tasks.new(task_params)
respond_to do |format|
if @task.save
format.html { redirect_to @list, notice: 'Task was added' }
format.json { render :show, status: :created, location: @list }
format... |
require 'rails-pipeline/redis_forwarder'
require 'rails-pipeline/ironmq_publisher'
# Mix-in the IronMQ publisher into a RedisForwarder to create a
# class that will forward redis messages onto IronMQ
module RailsPipeline
class RedisIronmqForwarder < RedisForwarder
include IronmqPublisher
end
end
|
class ContactMailer < ApplicationMailer
default from: 'teplicy@medalak.ru'
def call_back_mail(contact)
@contact = contact
mail(to: 'teplicy@medalak.ru', subject: 'Обратный звонок')
end
end
|
#! /usr/bin/env ruby -S rspec
require 'spec_helper'
describe "the to_python_type function" do
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
it "should exist" do
Puppet::Parser::Functions.function("to_python_type").should == "function_to_python_type"
end
it "should raise a ParseError if there is ... |
require 'international_trade/currency_converter'
require 'international_trade/rate_hash'
require 'international_trade/transaction_iterator'
require 'international_trade/sales_totaler'
class InternationalTrade
attr_accessor :converter, :transactions
def initialize(arguments)
@converter = CurrencyConverter.n... |
class Bid < ActiveRecord::Base
belongs_to :user
belongs_to :product,counter_cache: true
belongs_to :bidder, :class_name => "User"
# before_save :convert_bid_to_cents
validate :higher_than_current?
validate :higher_than_minimum_bid?
validates :amount, :numericality => true
# def convert_bid_to_cents
... |
require 'rails_helper'
RSpec.describe User, type: :model do
it 'should start with 1000 points' do
new_user = FactoryGirl.create(:user)
expect(new_user.current_points).to eq(1000)
end
end
|
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'yaml'
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
def symbolize_keys(hash)
hash.inject({}){|result, (key, value)|
new_key = case key
when String then key.to_sym
else ... |
class CreateRLinks < ActiveRecord::Migration
def change
create_table :r_links do |t|
t.string :link
t.string :properties
t.timestamps
end
end
end
|
require 'minitest/autorun'
require_relative 'miner'
class Miner_test < Minitest::Test
# UNIT TESTS FOR METHOD increase_rubies(x,y)
# Equivalence classes:
# x and y = 0....infinity -> fake_rubies+=x and rubies+=y
# Tests if ruby counts are increased when both are incremented by the same value
def test_regular_inc... |
require 'socket'
require 'netlink/constants'
require 'netlink/message'
require 'netlink/message_decoder'
require 'netlink/types'
module Netlink
class Socket < ::Socket
SENDTO_SOCKADDR = Netlink::Sockaddr.new.to_binary_s.freeze
attr_reader :netlink_family
def initialize(netlink_family)
super(Netl... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.