text stringlengths 10 2.61M |
|---|
class TravelConferenceDecorator < Draper::Decorator
delegate_all
def travel_team_image_url
h.image_tag model.travel_team_image_url_url
end
end
|
require "rails_helper"
describe Monster do
it "Work valid monster" do
monster = Monster.new(name: "")
monster.valid?
expect(monster.errors[:name]).not_to be_empty
end
end
describe Monster do
it "Work valid monster 2" do
monster = build(:monster)
monster.valid?
expect(monster.errors[:name]... |
require 'set'
class SocialSchedulerController < Sinatra::Application
# diable rack protection while in development
configure :development do
disable :protection
end
configure :production do
disable :protection
end
# store directory paths
set :root, File.expand_path('../../', __FILE__)
set :sc... |
class CreateCharacterBirthrights < ActiveRecord::Migration[5.0]
def change
create_table :character_birthrights do |t|
t.references :character, index: true
t.references :birthright, index: true
t.timestamps null: false
end
add_foreign_key :character_birthrights, :characters
add_forei... |
module CassandraObject
module BelongsTo
extend ActiveSupport::Concern
included do
class_attribute :belongs_to_reflections
self.belongs_to_reflections = {}
end
module ClassMethods
# === Options
# [:class_name]
# Use if the class cannot be inferred from the association
... |
class ComicsController < ApplicationController
before_action :authorize, except: [:index, :show]
def index
end
def show
@comic = Comic.find(params[:comicid])
end
def new
@comic = Comic.new
end
def create
@comic = current_user.comics.new(comic_params)
if @comic.save
redirect_to ... |
require 'active_record'
class Opportunity < ActiveRecord::Base
has_many :signups
has_many :users, through: :signups
#returns whether this group has met its capacity
def isfull?
binding.pry
if self.vol_requests > self.signups.length
binding.pry
return false
end
return true
end
... |
responses = [
"It is certain",
"It is decidedly so",
"Without a doubt",
"Yes, definitely",
"You may rely on it",
"As I see it, yes",
"Most likely",
"Outlook good",
"Yes",
"Signs point to yes",
"Reply hazy try again",
"Ask again later",
"Better not tell you now",
"Cannot predict now",
"Conc... |
module DeviseTokenAuth
class PasswordsController < DeviseTokenAuth::ApplicationController
before_action :set_user_by_token, :only => [:update]
skip_after_action :update_auth_header, :only => [:create, :edit]
# this action is responsible for generating password reset tokens and
# sending emails
de... |
class CreditCard < ActiveRecord::Base
belongs_to :user
belongs_to :profile
has_many :orders, dependent: :destroy
validates :number, :cvv, :expiration_month, :expiration_year, presence: true
validates_numericality_of :expiration_year,
greater_than_or_equal_to: Time.now.year
val... |
# Write another method that returns true if the string passed as an argument is a palindrome,
# false otherwise. This time, however, your method should be case-insensitive, and it should
# ignore all non-alphanumeric characters. If you wish, you may simplify things by calling the
# palindrome? method you wrote in the... |
require 'spec_helper'
describe Content do
let(:srpski) { Language.create(:name => 'srpski') }
let(:english) { Language.create(:name => 'English') }
let(:horror) { Category.create(:name => 'Horror') }
let(:comedy) { Category.create(:name => 'Comedy') }
it 'should be able to count words' do
Content.new(:... |
class SitesController < ApplicationController
require 'open-uri'
require 'fastimage'
require 'nokogiri'
# respond_to :html, :js
def index
# puts "Helloohise0he0h8et40h8eth90erth90et490het490hjerg90hrg90hgr90hgre90hrgh09"
@sites = Site.all
# require pry; binding.pry
# puts "h80se80hsf8g0sef... |
require 'gem_helper'
FooModel.include ApiMonkey::Filterable
describe 'Filterable Concern' do
it 'should provide the filter method' do
expect(FooModel).to respond_to :filter
end
describe '#filter' do
context 'with nil parameter' do
it 'should return a nil set' do
expect(FooModel.filter(nil... |
module HabiticaCli
# Responsible for displaying a "dashboard" of stats
# and tasks for a user as well as caching them
module Commands
def self.status(env)
response = env.api.get('user')
if response.success?
puts status_display(response.body)
display(env, response.body['todos'] + re... |
module Gpx
module Parser
class SaxHandler < Ox::Sax
attr_accessor :rides
def initialize
@current_state = []
@rides = []
end
def start_element(name)
@current_state.push name
case @current_state
when [:gpx, :trk, :trkseg]
@ride = Ride.new
... |
class AddLastingTimeTypeToPictureThreads < ActiveRecord::Migration
def change
add_column :picture_threads, :lasting_time_type, :string, :default => "m"
end
end
|
class FixesLimitOnText < ActiveRecord::Migration
def change
change_column :posts, :content, :text, limit: 100.megabytes
end
end
|
require 'net/http'
require 'json'
module OpenWeather
class Base
private_class_method :new
def self.fetch(options={})
@options = extract_options!(options)
send_request
OpenWeather::WeatherInfo.new(json_data)
end
def self.json_data
@json_data
end
private
def self.send_request
# workaro... |
require File.dirname(__FILE__) + '/../../spec_helper'
describe "/documentos/edit.html.erb" do
include DocumentosHelper
before do
@documento = mock_model(Documento)
@documento.stub!(:tituloMonografia).and_return("MyString")
@documento.stub!(:autorMonografia).and_return("MyString")
@documento.stub... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provider :virtualbox do |vb|
# needed otherwise haskell-src-exts fail to install due to OOM
vb.memory = 2048
# from http://superuser.com/questions/542709/vagrant-s... |
require 'xml/libxml/xmlrpc'
require 'digest'
require 'net/http'
module LiveJournal
class Raw < XML::XMLRPC::Client
def method_missing(*args)
self.call2(*args)
end
def call2(methodName, *args)
call("LJ.XMLRPC." + methodName.to_s, *args)
end
end
class Main
def initialize(param... |
# Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
Devise.setup do |config|
# The secret key used by Devise. Devise uses this key to generate
# random tokens. Changing this key will render invalid all existing
# confirmat... |
module Comm
class Database
include Comm::Resource
def records
fetch_records(:all)
end
private
def fetch_records(m, options = {})
query = options[:conditions] || {}
query[:page] = options[:page] || 1
ary = ProxyArray.new do
data = connection.class.get("#{resource... |
class InstalledClientsController < ApplicationController
before_filter :login_required
# GET /installed_clients
# GET /installed_clients.xml
def index
@title = "List of Installed clients on server"
@installed_clients = InstalledClient.all
respond_to do |format|
format.html # index.html.... |
require 'nokogiri'
class Nifflsploit
class Result
attr_accessor :name, :rank, :authors, :references, :development, :module_options, :targets, :similar_modules
def self.parse(document)
@document = document
@result = Nifflsploit::Result.new
@result.name = @document.xpath("/html/body/div/... |
# frozen_string_literal: true
require 'test_helper'
require 'minitest/mock'
# rubocop:disable Metrics/BlockLength
describe CreateSubscription do
let(:user) { users :user_with_no_subscription }
create_feed1 = ->(url) { [create_feed(url)] }
create_feed2 = lambda { |url|
[create_feed(url, File.join(url, 'rss.... |
class FontMononokiNerdFont < Formula
version "2.3.3"
sha256 "3a52dafaed9afeb2df5b8197ac94e4c560969f174ea6f91a0f7d2a9f4f9f814b"
url "https://github.com/ryanoasis/nerd-fonts/releases/download/v#{version}/Mononoki.zip"
desc "Mononoki Nerd Font (Mononoki)"
desc "Developer targeted fonts with a high number of glyp... |
class MorningActivityResult < ApplicationRecord
belongs_to :user
enum state: %i[not_implemented success failed]
end
|
require 'rails_helper'
RSpec.describe Patient, type: :model do
describe "Relationships" do
it {should (have_many :doctor_patients)}
it {should (have_many :doctors).through(:doctor_patients)}
end
describe "Class Methods" do
it ".patients_order" do
patient_1 = Patient.create!(name: "Katie Bryce"... |
class AddReferenceToTripsTableAndUpdateTripTableName < ActiveRecord::Migration[5.2]
def change
rename_table :trip, :trips
add_reference :trips, :driver, foreign_key: true
add_reference :trips, :passenger, foreign_key: true
end
end
|
# Record reactions against the article
class ReactionsController < ApplicationController
before_action :find_article
def create
@reaction = @article.reactions.new(reaction_params)
@reaction.reaction_type = 'text'
respond_to do |format|
if @reaction.save
format.html { redirect_to article_... |
module Services
class CreateServiceTransaction < ::BaseTransaction
try :find_car, catch: ROM::TupleCountMismatchError
map :create_service
private
def find_car(vin)
CarRepo
.new(rom_env)
.by_vin(vin)
end
def create_service(car, service:)
rom_env
.relations... |
require 'spec_helper'
describe Webmachine::Linking::LinkHeader::Link do
let(:href) { '/dogs' }
let(:attr_pairs) { [['rel', 'up']] }
subject { described_class.new(href, attr_pairs) }
its(:to_s) { should eq '</dogs>; rel="up"' }
end
|
if @agent.agent_regression_checks.exists?
visible = true
status = @agent.regression_checks_global_state
count = @agent.agent_regression_checks.count
running_count = @agent.agent_regression_checks.where(state: [:running, :unknown]).count
success_count = @agent.agent_regression_checks.success.count
failed_co... |
class Request < ApplicationRecord
belongs_to :group
belongs_to :character
belongs_to :spec
end
|
require 'poms/api/drivers/net_http'
require 'poms/api/request'
require 'poms/api/auth'
require 'poms/errors'
module Poms
module Api
# The Client module isolates all HTTP interactions, regardless of the driver
# module to implement the actual operations. Use the Client module to build
# signed requests an... |
#
# CS 430 Spring 2019 P1 (Ruby 1)
#
# Name: Nathan Chan
# Date: 1/11/2019
#
# return an array of all factors of n
def factors(n)
return Array.new(n) { |index| index +=1}.select { |a| n % a == 0}
end
print factors(12)
puts
# return an array of all prime numbers less than or equal to n
def primes(n)... |
require 'spec_helper'
RSpec.describe MarkdownMetrics::Elements::Sentence::Italic do
let(:value) { '*italic* text' }
let(:element) { described_class.new(value: value, start_at: 0) }
describe '.match_element' do
it { expect(described_class.match_element('*', 'i')).to eq(true) }
end
describe '#name' do
... |
class AddSetToCardTemplate < ActiveRecord::Migration
def change
add_column :card_templates, :set, :string
end
end
|
module Schema
module Controls
module DataStructure
def self.example
example = Example.new
example.some_attribute = 'some value'
example
end
def self.ancestors
example.class.ancestors
end
def self.attributes
example.attributes
end
... |
class LineItem < ApplicationRecord
belongs_to :order, optional: true
belongs_to :product, optional: true
belongs_to :cart, counter_cache: true
validates :product_id, uniqueness: {
scope: :cart_id,
message: 'can be added only once in a cart' }, if: :cart_id?
delegate :price, :title, to: :product, all... |
class Api::V1::PropertiesController < ApiController
def index
keys = params.keys.collect { |k| k if k.end_with?("_id")}.compact
if keys
@propertys = JobRequestProperty.where(build_options(keys))
else
@propertys = JobRequestProperty.all
end
respond_to do |format|
format.json { ren... |
Puppet::Type.type(:pe_group).provide(:ruby) do
# Make sure that the faraday package is available.
# Ugh. I hate having to do this but I need the gem to exist
system("puppet resource package faraday ensure='present' provider='puppet_gem'")
Gem.clear_paths
require 'json'
require 'faraday'
##############... |
module PdfTempura
class Document::CharacterField < Document::Field::Base
attr_reader :default_value, :font_name, :font_size, :bold, :italic, :padding,
:alignment, :multi_line, :valign, :leading
alias_method :bold?, :bold
alias_method :italic?, :italic
alias_method :multi_line?, :multi_line
... |
# In this file, we describe the main scene of `lilplateform`. `Ray`
# library provides a base class for describing scenes,
# `Ray::Scene`. There are several hooks that will get called, like
# `setup`, in the begining, then `register` to bind events, and of
# course `render`. In the end, we can clean up images in t... |
require File.dirname(__FILE__) + '/../test_helper'
require 'static_permission_controller'
# Re-raise errors caught by the controller.
class ActiveRbac::StaticPermissionController; def rescue_action(e) raise e end; end
class ActiveRbac::StaticPermissionControllerTest < Test::Unit::TestCase
fixtures :roles, :users, :... |
module Pading
class << self
def configure
yield config
end
def config
@config ||= Config.new
end
end
class Config
attr_accessor :default_per_page, :max_per_page, :page_method_name
def initialize
@default_per_page = 25 # ๆฏ้กต้ป่ฎคๅคๅฐๆฐๆฎ
@max_per_p... |
ActiveAdmin.register Photo do
permit_params :url, :media_id
end
|
# What is the return value of each_with_object in the following code? Why?
['ant', 'bear', 'cat'].each_with_object({}) do |value, hash|
hash[value[0]] = value
end
# { 'a' => 'ant', 'b' => 'bear', 'c' => 'cat' }
# each_with_object will return the initially given {}
# hash is the returning object
# value[0] is the f... |
class AddClientCommentsValidatedToBusinessCases < ActiveRecord::Migration[5.1]
def change
add_column :business_cases, :client_comments_validated, :boolean
end
end
|
# -*- encoding : utf-8 -*-
class Bank
BANKS = {
# 'BNLNGE22' => 'แกแแฅแแ แแแแแแก แแ แแแแฃแแ แแแแแ',
# 'TRESGE22' => 'แกแแฎแแแแฌแแคแ แฎแแแแแ',
'CBASGE22' => 'แแแแแก แแแแแ',
'CNSBGE22' => 'แแแแแ แแแแกแขแแแขแ',
'CRTUGE22' => 'แแแแแ แฅแแ แแฃ',
'DISNGE22' => 'แแแแแแ แแแแแ',
'HSBCGE22' => 'แแแฉ แแก แแ แกแ แแแแแ แกแแฅแ... |
class CreateItems < ActiveRecord::Migration[5.1]
def change
create_table :items do |t|
t.string :item_name
t.string :item_name_kana
t.integer :price
t.string :artist_name
t.string :artist_name_kana
t.string :item_image_id
t.integer :genres
t.date :release_date
... |
class ChangedSurveyAnsSetsAddedAnsCountContestAnsSheetId < ActiveRecord::Migration
def self.up
add_column :survey_ans_sets, :ans_count, :integer
add_column :survey_ans_sets, :contest_ans_sheet_id, :integer
add_index :survey_ans_sets, :contest_ans_sheet_id
end
def self.down
remove_column :survey... |
cookbook_file '/etc/modprobe.d/alsa-base.conf' do
group 'root'
mode '0644'
owner 'root'
end
|
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# name :string(255)
# email :string(255)
# created_at :datetime not null
# updated_at :datetime not null
# encrypted_password ... |
# frozen_string_literal: true
require "rails_helper"
require "employee_importer"
RSpec.describe EmployeeImporter, type: :model do
context "#import" do
it "should throw an error if excel cannot be parsed" do
importer = EmployeeImporter.new(StringIO.new("test"))
expect { importer.call }.to raise_erro... |
# frozen_string_literal: true
module Pragma
module Filter
class Where < Base
attr_reader :condition
def initialize(condition:, **other)
super(**other)
@condition = condition
end
def apply(relation:, value:)
relation.where(condition, value: value)
end
en... |
require 'interfaces'
class WeatherData
include Subject
attr_reader :temperature, :humidity, :pressure
def initialize
#@observers = []
super
end
def notify_observers
@observers.each do |observer|
observer.update(temperature, humidity, pressure)
end
end
def measurements_changed
... |
class Banner < ApplicationRecord
has_attached_file :image, styles: { medium: "1920x683#", thumb: "100x100>" }, default_url: "/galleries/:style/missing.png"
validates_attachment_content_type :image, content_type: /\Aimage\/.*\z/
end
|
class AddNumBackersToRewards < ActiveRecord::Migration
def change
add_column :rewards, :num_backers, :integer, default: 0
end
end
|
module Http
HTTP_OK = 200
HTTP_CREATED = 201
HTTP_MOVED_PERMANENTLY = 301
HTTP_FOUND = 302
HTTP_SEE_OTHER = 303
HTTP_BAD_REQUEST = 400
HTTP_UNAUTHORIZED = 401
HTTP_FORBIDDEN = 403
HTTP_NOT_FOUND = 404
HTTP_INTERNAL_SERVER_ERROR = 500
DEFAULT_TIMEOUT = 3
DEFAULT_OPEN_TIMEOUT = 3
class Cl... |
class Api::V1::InvoicesController < Api::V1::BaseController
before_action :set_invoice, only: [:show, :update, :destroy]
def index
json_response(Invoice.all.order(id: :desc).paginate(page: params[:page], per_page: 20))
end
def show
json_response(@invoice)
end
def create
invoice = Invoice.crea... |
class Manager::Survey::ChoiceSerializer < ActiveModel::Serializer
root false
attributes :id, :order, :content, :commentable
end
|
class Api::UsersController < ApplicationController
#before_action :require_logged_in, only: [:index, :show]
def new
@user = User.new
end
def create
@user = User.new(user_params)
if @user.save
sign_in!(@user)
render '/api/users/show'
else
... |
require_relative('../db/sql_runner')
require("pry")
class Transaction
attr_reader(:date_time, :merchant_id, :tag_id, :amount, :id)
def initialize( options )
@id = options["id"].to_i() if options["id"]
@date_time = options["date_time"]
@merchant_id = options["merchant_id"].to_i
@tag_id = options["... |
class EventsController < InheritedResources::Base
before_filter :authenticate_user!,except: [:index,:show,:buy_ticket_login,:eventsCalendar]
def index
@events = Event.all
end
def new
@event = Event.new
end
def create
t_start = params[:event][:start_time].to_date.to_s + ' ' + params[:start_hou... |
class RenameNameToTitleInMovie < ActiveRecord::Migration
def self.up
rename_column :movies, :name, :title
rename_column :movies, :name_sv, :title_sv
end
def self.down
rename_column :movies, :title, :name
rename_column :movies, :title_sv, :name_sv
end
end
|
require 'rails_helper'
describe "Visiting profiles" do
include TestFactories
before do
@user = authenticated_user
@post = associated_post( user: @user )
@comment = Comment.new( user: @user, body: "A comment to test public profiles." )
allow( @comment ).to receive( :send_favorite_emails )
... |
class Users::PasswordsController < ApplicationController
skip_before_action :authenticate!, only: [:new, :edit, :update]
skip_before_action :validate_headers!, only: [:edit, :update]
before_action :validate_token!, only: [:edit, :update]
# @description serves a password recovery request
# @param email ... |
class AlbumArtist < ApplicationRecord
belongs_to :album
belongs_to :artist
end
|
class Idea < ApplicationRecord
has_many :comments
mount_uploader :picture, PictureUploader
belongs_to :user
end
|
unless ::Hash.method_defined?(:symbolize_keys)
class ::Hash
def symbolize_keys
inject({}) { |hash, (key, value)| hash[key.to_s.to_sym] = value; hash }
end
def symbolize_keys!
replace symbolize_keys
end
end
end |
require 'rspec'
require 'pry'
def balanced_parens?(string_of_parens)
open_parens_so_far = 0
close_parens_so_far = 0
string_of_parens.each_char do |char|
if close_parens_so_far > open_parens_so_far
return false
else
if char == "("
open_parens_so_far += 1
elsif char == ")"
... |
module RunPal
class WalletTransaction < UseCase
def run(inputs)
inputs[:user_id] = inputs[:user_id] ? inputs[:user_id].to_i : nil
user = RunPal.db.get_user(inputs[:user_id])
return failure (:user_does_not_exist) if user.nil?
wallet = RunPal.db.get_wallet_by_userid(inputs[:user_id])
... |
=begin
(Problem):
Build a program that displays when the user will retire and how many years she has to work till retirement.
(Understand the Problem):
โข (Inputs): Integer from user
โข (Outputs): String
โข (Questions):
โข (Rules):
o (Explicit):
Display when the user will retire
Display how many years the... |
require_relative '02_searchable'
require 'active_support/inflector'
# Phase IIIa
class AssocOptions
attr_accessor(
:foreign_key,
:class_name,
:primary_key
)
def model_class
@class_name.constantize
end
def table_name
class_name.constantize.table_name
end
end
class BelongsToOptions < A... |
module Inesita
module Component
include VirtualDOM::DOM
include ComponentHelpers
include ComponentProperties
include ComponentVirtualDomExtension
def render
fail Error, "Implement #render in #{self.class} component"
end
def mount_to(element)
fail Error, "Can't mount #{self.cl... |
module FayeClient
SERVER_PROTOCOL = 'http://'
SERVER_HOST = Config.get(:faye_host)
SERVER_PORT = Config.get(:faye_port)
module_function
def server
"#{SERVER_PROTOCOL}#{SERVER_HOST}:#{SERVER_PORT}/faye"
end
def publish(channel, data)
Faraday.new.post do |req|
req.url server
req.headers['C... |
# For altering existing data |
require File.dirname(__FILE__) + '/../../spec_helper'
describe 'Slicehost.get_backups' do
describe 'success' do
it "should return proper attributes" do
actual = Slicehost[:slices].get_backups.body
actual['backups'].should be_an(Array)
backup = actual['backups'].first
# backup['date'].sho... |
Sequel.migration do
change do
alter_table :uphack_jobs do
add_foreign_key :category_id, :uphack_job_categories
end
end
end
|
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :invite_internal, :class => 'Invite::Internal' do
user
friend
email { friend.email }
status Invite::Internal::STATUS_PENDING
end
end
|
require 'rails_helper'
RSpec.describe BlogsController, :type => :controller do
describe 'GET #index' do
it 'response successfully with an HTTP 200 status code' do
get :index
expect(response).to be_success
expect(response).to have_http_status(200)
end
it 'renders the index template' do
get :index
... |
require_relative 'smart_log_orderer'
module SmartLogParser
class DescendingOrderer < SmartLogOrderer
def order
@data.sort_by{|k, v| -v}
end
def self.direction_text
'descending order'
end
end
end
|
class AddColumnChildBacklogIdToBacklogItems < ActiveRecord::Migration[5.2]
def up
execute <<-DDL
ALTER TABLE `backlog_items` ADD COLUMN `child_backlog_id` int(11) unsigned NOT NULL DEFAULT '0'
DDL
end
def down
execute <<-DDL
ALTER TABLE `backlog_items` DROP COLUMN `child_backlog_id`
D... |
require 'spec_helper'
describe BlogManagement::Susanoo::PageContentsController do
describe "ใขใฏใทใงใณ" do
before do
@division = create(:division)
@sections = create_list(:section, 3, division: @division)
@user = create(:user, section: @sections[0])
# ใใญใฐใใใใๅนดใๆใฎใธใฃใณใซใไฝๆ
@blog_top_genre ... |
require_relative "piece"
require_relative "SteppingPiece"
class Knight < Piece
include SteppingPiece
def initialize(board, position, color)
super(board, position, color)
end
def symbol
color == :white ? "\u2658" : "\u265E"
end
def directions
[
[-2, 1],
[-1, 2],
[1, 2],
... |
class AchievementsController < ApplicationController
before_action :set_achievement, only: %i[edit update destroy]
before_action :authenticate_applicant!
before_action :achievement_authenticate, only: %i[edit update destroy]
def new
@achievement = Achievement.new
end
def edit; end
def create
@a... |
class AddQuestionToPins < ActiveRecord::Migration
def change
add_column :pins, :question, :text
end
end
|
require "spec_helper"
require "jani/from_json"
RSpec.describe Jani::FromJson do
let(:json_data) { build(:builder).json_data }
describe ".to_movie" do
subject { Jani::FromJson.to_movie(json_data) }
it { is_expected.to be_a_kind_of Jani::FromJson::Movie }
end
describe ".empty_movie" do
subject { J... |
class Msg < ApplicationRecord
enum status: { unread: 0, readed: 1, removed: 2 }
def info
slice(:id, :status, :content).merge(created_at: created_at.to_i)
end
def self.valid_statuses
statuses.values_at(:unread, :readed)
end
end
|
=begin
Instructions:
Personalized greeting
Create a function that gives a personalized greeting. This function takes two parameters: name and owner.
Use conditionals to return the proper message:
case return
name equals owner 'Hello boss'
otherwise 'Hello guest'
=end
#Solution:
def greet(name,owner)
if name == ow... |
class CreateEconomicEventSources < ActiveRecord::Migration[5.1]
def change
create_table :economic_event_sources do |t|
t.references :economic_event, foreign_key: true
t.string :url_path, limit: 2000
t.integer :priority
t.timestamps
end
end
end
|
# this should be a module really
class Weather
def initialize
@weather_condition = rand(10)
end
def sunny
@weather_condition <= 2
end
def stormy
@weather_condition >= 3
end
# this will always return 'true'
def weather
sunny || stormy
end
end
|
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Rails.application.load_tasks
task(:default).clear
task default: [:spec]
namespace :db do
def set_... |
#!/usr/bin/env ruby
require_relative './urls'
require_relative './websites'
require 'forwardable'
module Github
class Handler < ::Websites::CommandHandler
attr_reader :repo_abbr
def initialize(args: args)
@repo_abbr = args.shift
if repo_abbr
super args: args
end
end
pro... |
#!/usr/bin/env ruby
# encoding: utf-8
require File.join(File.dirname(__FILE__), "..", "spec_helper")
describe "glyph" do
before do
create_project_dir
end
after do
reset_quiet
delete_project
end
it "[init] should create a project in the current directory" do
delete_project
Glyph.enable "project:crea... |
RSpec.describe "Admin Feedback Message Management", type: :system, js: true do
context "While signed in as an Administrative User (super admin)" do
before :each do
sign_in(@super_admin)
end
it "viewing and marking feedback as resolved" do
feedback_message = FactoryBot.create(:feedback_message... |
module HarborPilot
class << self
attr_accessor :configuration
def configuration
@configuration ||= Configuration.new
end
end
def self.configure
yield(configuration)
end
class SecureCredentials < ActiveSupport::EncryptedConfiguration
def initialize(config_path: HarborPilot::Engine... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.