text stringlengths 10 2.61M |
|---|
require "yaml"
# Add a .sum method to all arrays, for convenience
class Array
def sum
self.reduce(&:+) # & is `to_proc`
# self.reduce(:+) works here, but not for all functions taking a block
# self.reduce { |a,b| a + b }
end
end
path = ARGV.first || raise("Please specify a file to load")
puts "Readin... |
require 'orocos/test'
describe Orocos::OutputReader do
if !defined? TEST_DIR
TEST_DIR = File.expand_path(File.dirname(__FILE__))
DATA_DIR = File.join(TEST_DIR, 'data')
WORK_DIR = File.join(TEST_DIR, 'working_copy')
end
include Orocos::Spec
it "should not be possible to create ... |
Given(/^I am on the capital one home page$/) do
visit(StatementsPage)
end
When(/^I click the "([^"]*)" link in the footer$/) do |footer_link|
on(StatementsPage).select_link footer_link
end
Then(/^I land on the url "(.*?)"$/) do |url|
on(StatementsPage).wait_until do
@browser.windows.last.url.include? url
... |
require 'spec_helper'
require 'resque'
describe Item do
it { should validate_presence_of(:name) }
it { should validate_presence_of(:price_in_dollars) }
it { should validate_numericality_of(:price_in_dollars, :allow_blank => true) }
it { should validate_length_of(:name, :maximum => 255) }
it { should belong_t... |
class Reply < ActiveRecord::Base
validates_length_of :raw, :within => 3..900, :too_long => "De reactie is te lang", :too_short =>"De reactie is te kort."
belongs_to :kunstvoorwerp
belongs_to :user
end
|
# Author:: Marta Garcia (mailto:alu0101015927@ull.edu.es)
# Copyright:: Cretive Commons
# License:: Distributes under the same terms as Ruby
#
# == Estructura Node
# Esta estructura se ha creado para describir a los nodos
# que contiene la clase lista
#
Node = Struct.new(:value, :next, :prev)
#
# == Cla... |
class AddDefaultValueToPriceCents100 < ActiveRecord::Migration[5.2]
def change
change_column :tshirts, :price_cents, :integer, :default => 2500
end
end
|
class Game
@@dictionary = File.open("dictionary.txt").map do |line|
line.chomp
end
attr_reader :fragment
def initialize(*players)
@players = players
@fragment = ''
@losses = Hash.new(0)
end
def self.dictionary
@@dictionary
end
def valid_play?(letter)
return false if !('a'..'... |
require './telegraph'
describe 'telegraph' do
it 'should decode morse signal arrays' do
expect(decode([DOT])).to eq('E')
expect(decode([DOT, DOT, DOT])).to eq('S')
expect(decode([DASH, DOT, DOT, DOT, DOT])).to eq('6')
expect(decode([DOT, DOT, DASH, DASH])).to eq('?')
end
it 'should convert bits ... |
# frozen_string_literal: true
require 'test_helper'
class DeployTaskTest < KubernetesDeploy::TestCase
include EnvTestHelper
def test_that_it_has_a_version_number
refute_nil(::KubernetesDeploy::VERSION)
end
def test_initializer
KubernetesDeploy::DeployTask.new(
namespace: "",
context: "",
... |
RSpec::Matchers.define :have_audit_row do |expected|
match do |actual|
actual.all(:xpath, "//tr[td[contains(.,'#{expected}')]]").any?
end
failure_message do |actual|
"expected that a table row for audit '#{expected}' would be found"
end
failure_message_when_negated do |actual|
"expected that a t... |
require 'digest/sha1'
class User < ActiveRecord::Base
# Virtual attribute for the unencrypted password
attr_accessor :password
attr_protected :is_admin
attr_protected :twitter_friend_with
has_many :claims, :order => "created_at desc", :dependent => :destroy
has_many :scores, :order => "created_at desc",... |
class UserCourseship < ActiveRecord::Base
validates_uniqueness_of :user_id, :scope => :course_id
belongs_to :user
belongs_to :course
attr_accessible :course_id, :user_id
end |
require "test_helper"
class CarbideActionTest < Minitest::Test
def test_execute_block_within_context
context = TestContext.new
action = Carbide::Action.new(context) do
self.value = 42
end
action.execute
assert_equal 42, context.value
end
def test_execute_pass_args_to_block
contex... |
class Api::V1::ConfirmationsController < Devise::ConfirmationsController
respond_to :json
def create
self.resource = resource_class.send_confirmation_instructions(resource_params)
yield resource if block_given?
if successfully_sent?(resource)
respond_with({}, location: after_resending_confirma... |
class Format < ActiveRecord::Base
belongs_to :developer, :class_name => "Developer",
:foreign_key => "id_developer";
end |
class User < ApplicationRecord
has_many :course_users
has_many :courses, through: :course_users
has_many :tasks
has_many :posts
has_many :comments
#Esta asosiacion es solo si la asosiacion es directa. En este caso es indirecta pues cuenta con un modelo intermedio
#Por tal razon se utiliza has_many :co... |
# frozen_string_literal: true
require_relative 'chronometer/dsl'
require_relative 'chronometer/event'
require_relative 'chronometer/trace_event'
require_relative 'chronometer/version'
class Chronometer
attr_reader :trace_events
def self.from_file(path, contents: File.read(path))
new do
instance_eval(co... |
class ShortenedUrl < ApplicationRecord
validates :user_id, presence: true
validates :short_url, presence: true,
uniqueness: { scope: :user_id, message: 'Users can only have one instance of specific URL'}
validates :long_url, presence: true,
uniqueness: { scope: :user_id, message: 'Users ca... |
require 'action_dispatch'
module TwirpRails
module Routes # :nodoc:
module Helper
def mount_twirp(name, handler: nil, scope: 'twirp')
TwirpRails.handle_dev_error "mount twirp route #{name}" do
case name
when Class
raise 'handler param required when name is a class' u... |
=begin
irb(main):024:0> family = { uncles: ["bob", "joe", "steve"],
irb(main):025:1* sisters: ["jane", "jill", "beth"],
irb(main):026:1* brothers: ["frank","rob","david"],
irb(main):027:1* aunts: ["mary","sally","susan"]
irb(main):028:1> }
=> {:uncles=>["bob", "joe", "stev... |
# -*- coding: utf-8 -*-
#
# Environment
#
# 変更不能な設定たち
# コアで変更されるもの
# CHIの設定
require 'config'
module Environment
# このアプリケーションの名前。
NAME = CHIConfig::NAME
# 名前の略称
ACRO = CHIConfig::ACRO
# pidファイル
PIDFILE = CHIConfig::PIDFILE
# コンフィグファイルのディレクトリ
CONFROOT = CHIConfig::CONFROOT
# 一時ディレクトリ
TMPDIR = C... |
DeleteTeamStatusMutation = GraphQL::Relay::Mutation.define do
name 'DeleteTeamStatus'
input_field :team_id, !types.ID
input_field :status_id, !types.String
input_field :fallback_status_id, !types.String
return_field :team, TeamType
resolve -> (_root, inputs, ctx) {
_type_name, id = CheckGraphql.decod... |
require 'net/ssh'
require_relative 'config_parser'
require 'pry'
class Deployer
attr_accessor :session
def initialize(config_parser)
@config_parser = config_parser
@ssh_config = Net::SSH
@session = Net::SSH.start('viagem', nil, config: true)
end
def configs
@config_parser.to_h
end
end |
require 'rails_helper'
describe User do
context 'when create a user' do
subject(:user) { build_stubbed(:user) }
# == Attributes ===============================================================================
# == Relationships ====================================================================... |
class Api::UsersController < ApplicationController
def index
@users = User.all
render "api/users/index"
end
def create
@user = User.create(user_params)
if @user.save
login(@user)
render "api/users/show"
else
render json: @user.errors.full_messages, status: 422
end
en... |
class CreateOrbitzImports < ActiveRecord::Migration
def self.up
create_table :orbitz_imports do |t|
t.column :filename, :string
t.column :created_at, :datetime
end
add_index :orbitz_imports, :filename
end
def self.down
drop_table :orbitz_imports
end
end
|
class Story < ActiveRecord::Base
include Flagging
belongs_to :author, class_name: "User"
belongs_to :parent, class_name: "Story"
belongs_to :snippet
has_many :story_tags
has_many :tags, through: :story_tags
has_many :votes
has_many :children, class_name: "Story", foreign_key: :parent_id
has_many :... |
require "bundler/setup"
require "rack/access_log"
RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = ".rspec_status"
config.expect_with :rspec do |c|
c.syntax = :expect
end
end
RSpec::Matchers.define "log_with" do |logger, leve... |
# frozen_string_literal: true
require "rails_helper"
RSpec.describe ReportPresenter do
describe "#state" do
it "returns the string for the state" do
report = build(:report, state: "active")
result = described_class.new(report).state
expect(result).to eql("Active")
end
end
describe "#c... |
# frozen_string_literal: true
require 'feature_helper'
feature 'Admin accepts invitation' do
context 'library card login user' do
let(:library_card_org) { FactoryBot.create(:organization, :library_card_login, subdomain: 'lco') }
before do
switch_to_subdomain(library_card_org.subdomain)
@invite... |
require 'rack/request'
require 'rack/less'
require 'rack/less/options'
require 'rack/less/source'
module Rack::Less
# Provides access to the HTTP request.
# Request objects respond to everything defined by Rack::Request
# as well as some additional convenience methods defined here
# => from: http://github.com... |
class Pizza
attr_reader :name, :toppings, :state
def initialize(name, toppings)
@name = name
@toppings = toppings
@state = 'raw'
end
def bake
puts "Baking #{name} ..."
@state = 'baked'
end
end
class PizzaStore
def take_order(pizza_type)
case pizza_type
when 'pepperoni'
p... |
class AddTypeToHistory < ActiveRecord::Migration[5.2]
def change
add_column :histories, :type_history, :integer
end
end
|
class AddCurrentPointsToUsers < ActiveRecord::Migration[6.0]
def change
add_column :users, :current_points, :integer, default: 0
end
end
|
class ReviewSerializer < ActiveModel::Serializer
attributes :id, :title, :rating, :body, :user_id, :recipe_id
end
|
require 'test_helper'
class ProductTest < ActiveSupport::TestCase
fixtures :products
test "product attributes must not be empty" do
product = Product.new
assert product.invalid?
assert product.errors[:title].any?
assert product.errors[:description].any?
assert product.errors[:price].any?
assert ... |
class AsyncCommandsUpdateStatusEnum < ActiveRecord::Migration
def self.up
change_column :async_commands, :status, :enum, AsyncCommand::STATUS_DB_OPTS
end
def self.down
end
end
|
class CreateUser < ActiveRecord::Migration
def change
create_table(:users) do |t|
t.string :college_id
t.string :laundry_id
t.string :name, null: false
t.decimal :mobile_number, null: false, precision: 10, scale: 0
t.string :gender, null: false
t.string ... |
require 'securerandom'
require 'base64'
module Travis
module GithubSync
module Encryption
require 'travis/github_sync/support/encryption/decrypt'
require 'travis/github_sync/support/encryption/encrypt'
ENCRYPTION_PREFIX = '--ENCR--'
class << self
def encrypt(string, options)
... |
class UserAnswer < ApplicationRecord
belongs_to :answer
belongs_to :user
belongs_to :team
validates :answer, presence: true
validates :user, presence: true
validates :team, presence: true
end
|
class User < ActiveRecord::Base
has_many :usertoengines, foreign_key: "idusers", primary_key: "idusers"
has_many :engines, :through => :usertoengines
default_scope {order(:username => :ASC)}
end |
require "pp"
class RomanNumerals
class << self
def to_roman(numeric)
added = recur_to_roman(numeric, [])
added.join
end
def from_roman(roman)
added, subtracted = recur_from_roman(roman.split(//), [], [])
added.reduce(:+) - subtracted.reduce(:+).to_i
end
private
def re... |
# To enable email activation messages copy the file:
# config/mailer.sample.yml
# to: config/mailer.yml
# and enter valid email settings.
#
# the default_url_option are used when resolving named routes
#
if (File.exists?("#{RAILS_ROOT}/config/mailer.yml"))
mailer_settings = YAML::load(IO.read("#{RAILS_ROOT}/co... |
class Api::V1::PostsController < BaseApiController
def index
posts = Post.all.order(created_at: "DESC")
render json: posts
end
def create
post = Post.create post_params
render json: post
end
private
def post_params
params.permit(:title, :body, :published_at)
end
end
|
class CreateCollectionVirtualRepositoryJoins < ActiveRecord::Migration
def change
create_table :collection_virtual_repository_joins do |t|
t.references :collection, index: false, foreign_key: true
t.references :virtual_repository, index: false, foreign_key: true
t.timestamps null: false
end
... |
require 'singleton'
class Settings
include Singleton
attr_accessor :location
attr_accessor :local_addresses
class <<self
attr_accessor :configuration_file
end
self.configuration_file=Rails.root.join('config', 'sk_web.yml').to_s
def initialize
filename=Settings.configuration_file
# Require that the fil... |
# prints the current prices for Bitcoin, Dogecoin, and Litecoin against USD from all available exchanges
require 'httpclient'
require 'json'
api_key = '0223-428b-9ecd-120a' # bitcoin from block.io
response = HTTPClient.new.get("https://block.io/api/v1/get_current_price/?api_key=#{api_key}&price_base=USD")
response =... |
module SS::Model::File
extend ActiveSupport::Concern
extend SS::Translation
include SS::Document
include SS::Reference::User
attr_accessor :in_file, :in_files, :resizing
included do
store_in collection: "ss_files"
seqid :id
field :model, type: String
field :state, type: String, default: "... |
namespace :dev do
desc "Configura o ambiente de desenvolvimento"
task setup: :environment do
if Rails.env.development?
# spinner = TTY::Spinner.new("[:spinner] Executando tarefas ...", format: :pulse_2)
# outro modelo
# spinner = TTY::Spinner.new("[:spinner] Apagando ... |
# encoding: utf-8
module Antelope
module Generator
# Generates an output file, mainly for debugging. Included always
# as a generator for a grammar.
class Output < Group
register_as "output"
register_generator Info, "info"
register_generator Error, "error"
end
end
end
|
Given(/^I have no cheese$/) do
puts "I am so sad I have no cheese"
end
When(/^I press the cheese button$/) do
puts "There is hope. I hope this machine works"
end
Then(/^I should have (\d+) piece of cheese$/) do |num_pieces|
puts "Rejoice! We have #{num_pieces} pieces of cheese."
end
|
require 'kiba'
require 'kiba-common/sources/csv'
require 'kiba-common/destinations/csv'
require 'kiba-common/dsl_extensions/show_me'
module Lookup
module_function
def csv_to_hash(file)
CSV.foreach(file, headers: true).each_with_object({}) do |r, memo|
memo[r.fetch("id")] = r.to_h
end
end
end
|
# -*- coding: utf-8 -*-
#
# Copyright 2013 whiteleaf. All rights reserved.
#
require_relative "../database"
require_relative "../downloader"
module Command
class Update < CommandBase
def self.oneline_help
"小説を更新します"
end
def initialize
super("[<target> ...] [options]")
@opt.separator <... |
class PurchaseUploader < CarrierWave::Uploader::Base
def store_dir
"uploads/purchase/#{mounted_as}/#{model.id}"
end
end
|
Rails.application.routes.draw do
# Scoped to place locale in URL instead of at the end
# If now setting included in URL the default is used
scope "(:locale)", locale: /en|es/ do
# Static pages
get '/:locale' => 'pages#home'
root to: 'pages#home'
get 'about', to: 'pages#about'
# Articles page... |
class Room < ActiveRecord::Base
validates :name, presence: true
validates :capacity, presence: true, numericality: { greater_than: 0 }
has_many :reservations
end
|
#only need one of the two conditions to be truthy
#takes two arguments and return true if only one arguments is true
#false otherwise
#input: two boolean
#output: one boolean
def xor?(one, two)
(one && two) || !(one || two) ? false : true
end
def xor2?(value1, value2)
!!(value1 && !value2) || (value2 && !value1)
... |
class FilmMailer < ApplicationMailer
default from: "aspdata@gmail.com"
def film_list
@films = Film.all.limit 2
@url = 'http://www.themodernview.com'
mail(to: 'aspdata@gmail.com', subject: 'New Film List')
end
end
|
class ProductsController < ApplicationController
before_action :set_product, only: [:show, :edit, :update, :destroy,:back,:report,:like]
before_action :authenticate_user!, except: [:index]
# GET /products
# GET /products.json
def index
if params["category_id"].nil?
@products = Product.all.where(:act... |
require_relative "operations"
require_relative "configuration"
require_relative "paths"
module Gaudi
# A Gaudi::Component is a logical grouping of a set of source and header files that maps to a directory structure.
#
# Given a base directory where sources reside, the name of Component is used to map to one or m... |
require 'pry'
class WordProblem
attr_reader :question
def initialize(str)
@question = str
end
def format_equation(string)
string = string.dup
string = string.gsub('plus', '+')
string = string.gsub('minus', '-')
string = string.gsub('divided by', '/')
string = string.gsub('multiplied b... |
# encoding: utf-8
require 'spec_helper'
describe SourcingsController do
before(:each) do
#the following recognizes that there is a before filter without execution of it.
controller.should_receive(:require_signin)
controller.should_receive(:require_employee)
end
render_views
describe "'inde... |
class User < ApplicationRecord
has_secure_password
has_many :exes
validates :name, presence: true
validates :email, presence: true, format: /\A[a-z0-9_\-\.]+@[a-z0-9_\-\.]+\.[a-z]+\z/i
validates :password, presence: true, confirmation: true
end
|
class Post < ActiveRecord::Base
attr_accessible :content, :published_at, :title, :publish
attr_accessor :publish
belongs_to :user
validates :title, :presence => true, :length => { :minimum => 3, :maximum => 255 }
validates :content, :length => { :minimum => 0, :maximum => 10000 }
before_save :set_publis... |
class Picture::CompleteSerializer < ActiveModel::Serializer
attributes :id, :original, :mini, :thumb, :medium, :normal, :large, :kind, :imageable_type
def original
object.attachment.url
end
def mini
object.attachment.url :mini
end
def thumb
object.attachment.url :thumb
end
def medium
... |
Pod::Spec.new do |s|
s.name = "AdobeVideoHeartbeat"
s.version = "1.4.1.2"
s.homepage = "https://github.com/Adobe-Marketing-Cloud/video-heartbeat"
s.source = { :http => "http://repository.neonstingray.com/content/repositories/thirdparty/com/adobe/ios/video-heartbeat/1.4.1.2/vid... |
#!/usr/bin/env ruby -w
# encoding: UTF-8
require 'rubygems'
require "em-http-request"
require 'htmlentities' #decode html special caracter to caracter
require_relative '../../../../lib/logging'
require_relative '../../../flow'
require_relative 'traffic_source'
#--------------------------------------------------------... |
# == Schema Information
#
# Table name: datasets
#
# id :bigint not null, primary key
# file_count :integer
# name :string(255)
# programming_language :string(255)
# token :string(255) not null
# created_at :datetime not n... |
# See Programming Ruby, p. 96
0.upto(9) do |x|
print x, " "
end
|
# frozen_string_literal: true
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'entity_test_extensions'
require 'rails/test_help'
require 'minitest/reporters'
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
MOCK_ACCOUNT_ID = 1010101010101010
class MockM... |
$:.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version:
require "autogrid/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "autogrid"
s.version = Autogrid::VERSION
s.authors = ["Christopher Thornton"]
s.email = ["rmdirbi... |
module Rfm
module Metadata
class LayoutMeta < CaseInsensitiveHash
def initialize(layout)
@layout = layout
end
def field_controls
self['field_controls'] ||= CaseInsensitiveHash.new
end
def field_names
field_controls.values.collect{|v| v.name}
end
... |
class CreateItems < ActiveRecord::Migration[5.1]
def change
create_table :items do |t|
t.string :name
t.string :description
t.string :image_url, default: 'http://www.spore.com/static/image/500/404/515/500404515704_lrg.png'
t.integer :quantity
t.money :current_price
t.boolean :e... |
require 'active_admin'
require 'active_admin/async_export/build_download_format_links'
require 'active_admin/async_export/version'
require 'active_admin/async_export/resource_controller_extension'
require 'active_admin/async_export/async_export_mailer'
require 'active_admin/async_export/railtie'
module ActiveAdmin
m... |
require 'byebug'
class MaxIntSet
def initialize(max)
@max = max
@store = Array.new(max, false)
end
def insert(num)
raise "Out of bounds" unless is_valid?(num)
@store[num] = true
end
def remove(num)
@store[num] = false
end
def include?(num)
@store[num] == true
end
private
... |
class Scorecard
attr_reader :score
def initialize(team)
@team = team
@score = scorecard
end
def scorecard
{@team => {1.1=>0, 1.2=>0, 2.1=>0, 2.2=>0, 3.1=>0, 3.2=>0, 4.1=>0, 4.2=>0, 5.1=>0,
5.2=>0, 6.1=>0, 6.2=>0, 7.1=>0, 7.2=>0, 8.1=>0, 8.2=>0, 9.1=>0, 9.2=>0, 10.1=>0, 10.2=>0, 10.3=>0} }
e... |
# frozen_string_literal: true
module Neighbour
def neighbour?(cell, mine)
is_between?(cell[:x], mine[:x]) && is_between?(cell[:y], mine[:y])
end
def is_between?(cell_position, mine_position)
cell_position + 1 == mine_position ||
cell_position - 1 == mine_position
end
end
|
module MeditationSessionsHelper
def options_for_duration
options_for_select(available_duration_options)
end
private
def available_duration_options
[
[ '1 minute', 1 ],
[ '2 minutes', 2 ],
[ '5 minutes', 5 ],
[ '10 minutes', 10 ],
[ '15 minutes', 15 ],
[ '20 minutes'... |
module PostsHelper
def destroy_post_link(post)
if can? :destroy, post
link_to t('post.button.destroy'),
post_path(post),
class: 'btn btn-danger',
method: :delete,
data: { confirm: t('common.delete_confirmation'), confirm_title: t('common.delete') }
end
end
def edit_p... |
class KensakusController < ApplicationController
include AdminHelper
layout "admin"
before_filter :validate_admin
before_filter :set_tab_index
before_filter :prepare_config
FILTER_NO_RESULT = "no_result"
FILTER_HAS_RESULT = "has_result"
def set_tab_index
@tab = 5
end
def index
@filter =... |
class UpdateColumnsWorkerCenterOfStudies < ActiveRecord::Migration
def change
change_column :worker_center_of_studies, :start_date, :integer
change_column :worker_center_of_studies, :end_date, :integer
end
end
|
class Car
attr_reader :name, :price
attr_writer :name, :price
def to_s
"#{@name}: #{@price}"
end
end
c1 = Car.new
c2 = Car.new
c1.name = "Porsche"
c1.price = 23500
c2.name = "Volkswagen"
c2.price = 9500
puts "The #{c1.name} costs #{c1.price}"
p c1
p c2
# All Ruby variables ar... |
class Pelicula < ApplicationRecord
# belongs_to :language
# belongs_to :country
# belongs_to :genre
has_many :comentarios, dependent: :destroy
has_attached_file :poster, styles: { medium: "300x300>", thumb: "100x100>" }, default_url: "/images/:style/missing.png"
validates_attachment_content_type :poster, conten... |
# frozen_string_literal: true
class ChaptersController < HtmlController
include Pagy::Backend
has_scope :table_order, type: :hash
has_scope :search, only: [:index]
def index
authorize Chapter
@pagy, @chapters = pagy apply_scopes(policy_scope(ChapterSummary, policy_scope_class: ChapterPolicy::Scope))
... |
# == Schema Information
#
# Table name: health_posts
#
# id :integer not null, primary key
# phone_number :string
# health_center_id :integer
# created_at :datetime not null
# updated_at :datetime not null
# code :string
#
class HealthPost < Acti... |
module Cms::ResourceHelper
def assc(attr)
attr.gsub('_id', '').to_sym
end
def attributes
@attributes ||=
if params[:action] == 'index'
remove_text_column_types column_names
else
remove_system_updated_fields column_names
end
end
def column_names
@column_names ||... |
class CreateEventSaleCategories < ActiveRecord::Migration
def up
create_table :event_sale_categories do |t|
t.integer :event_id
t.string :name
t.integer :price
end
add_column :event_payments, :event_sale_category_id, :integer
end
def down
drop_table :event_sale_categories
end
... |
class ChangeColumnCompanyToCostCenterFromPartWorker < ActiveRecord::Migration
def change
rename_column :part_workers, :company_id, :cost_center_id
end
end
|
Given(/^there are some questions$/) do
@questions = FactoryGirl.create_list :question, 3
end
When(/^I go to the homepage$/) do
visit ('/')
end
Then(/^I see all the questions$/) do
expect(page).to have_content('baldness or cancer')
end
Given(/^all questions are answered$/) do
@candidate = FactoryGirl.create :... |
class ProfilesController < ApplicationController
def new
if session[:id] != nil
@website = Website.find(session[:id])
else
redirect_to new_website_path
end
end
def create
if session[:id] != nil
@website = Website.find(session[:id])
@profile = @website.create_profile(profile... |
require 'dist_server/server/serial_object'
class ServerInfo
extend SerialObject
include SerialObject
attr_reader :name
attr_reader :type
attr_reader :klass
attr_reader :host
attr_reader :port
attr_reader :services
def initialize(name, type, klass, host, port, services)
@name = name
@type = type
@kla... |
# Simple Shell
#
# @author Justin Leavitt
#
# @since 0.0.1
module BixsbyShell
class Simple < Shell
READLINE_PROMPT = "bixsby > "
def initialize(server)
@server = server
run_simple_shell
end
def run_simple_shell
message = parse_response(@server.gets.chomp)
display_simple_... |
require 'test/test_helper'
require 'build_result'
require 'gruff_build_time_grapher'
require 'gruff_test_count_grapher'
class OutputSampleTest < Test::Unit::TestCase
def test_gruff_makes_a_nice_pretty_graph_of_build_times
File.delete(filename+".png") if File.exist?(filename+".png")
GruffBuildTimeGr... |
require "./test/test_helper"
class TeamStatsTest < Minitest::Test
def setup
@game_path = './data/game_fixture.csv'
@team_path = './data/team_info.csv'
@game_teams_path = './data/game_team_stats_fixture_corey.csv'
@locations = {games: @game_path,
teams: @team_path,
game_teams: @game_tea... |
class OrderImportProcessor
@queue = :normal
def self.perform
Rails.logger.info "start OrderImportProcessor::perform"
Client.order_importers.each do |client|
folder = client.abbreviation
Rails.logger.info "import orders from #{client.name} (#{folder})"
ORDER_IMPORT_FILE_PROVIDER.get_and_de... |
class Board
attr_accessor :grid, :colors
def initialize (colors)
@grid = Array.new(8){ Array.new(8, nil) }
@colors = colors # board can be created with initial colors b/c the board is going to create new peices with these colors; these can also be initialized in the game if we askt he players to choose thi... |
class CreateCompanyLeadInterviews < ActiveRecord::Migration[5.1]
def change
create_table :company_lead_interviews do |t|
t.string :title, default: nil
t.integer :trainer_id, default: nil
t.string :date, default: nil
t.string :location, default: nil
t.integer :company_lead_id
t.... |
require "rails_helper"
RSpec.describe ActivityFormsController do
let(:user) { create(:partner_organisation_user, organisation: organisation) }
let(:organisation) { create(:partner_organisation) }
before do
allow(controller).to receive(:current_user).and_return(user)
end
describe "#show" do
context ... |
# frozen_string_literal: true
require "song_pro/version"
require "song_pro/song"
require "song_pro/section"
require "song_pro/line"
require "song_pro/part"
require "song_pro/measure"
module SongPro
SECTION_REGEX = /#\s*([^$]*)/
ATTRIBUTE_REGEX = /@(\w*)=([^%]*)/
CUSTOM_ATTRIBUTE_REGEX = /!(\w*)=([^%]*)/
CHORD... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.