text stringlengths 10 2.61M |
|---|
module Spec
module Rails
module Matchers
# describe Comment do
# it 'should delegate author_name to user' do
# Comment.should delegate(:author_name, :to => :user, :via => :name)
# end
# end
class Delegation
private
attr_reader :expected, :actual, :method_name, :... |
# make sure we're running inside Merb
if defined?(Merb::Plugins)
dependency "activerecord"
# Merb gives you a Merb::Plugins.config hash...feel free to put your stuff in your piece of it
Merb::Plugins.config[:merb_paperclip] = {
:chickens => false
}
Merb::BootLoader.before_app_loads do
require ... |
require "application_system_test_case"
class FacilityDivisionDataTest < ApplicationSystemTestCase
setup do
@facility_division_datum = facility_division_data(:one)
end
test "visiting the index" do
visit facility_division_data_url
assert_selector "h1", text: "Facility Division Data"
end
test "cre... |
module UserAccountKeyService
def self.update(email, account_key)
user = User.find_by_email(email)
raise ActiveRecord::RecordNotFound if user.nil?
user.update_attribute(:account_key, account_key)
end
def self.request_account_key(email, key)
new_user_event = NewUserEvent.new(email, key)
queue_... |
class ApplicationController < ActionController::Base
def index
if params[:order] == 'asc'
order = :asc
else
order = :desc
end
@influencers = Influencers.where(starred: 0)
@starred = Influencers.where(starred: 1).order(statistics_engagement: order)
end
end
|
class WelcomeMailer < ApplicationMailer
default from: "sistemas@notaria-104.com.mx"
def welcome_email(user)
@user = user
mail(to: @user.email, subject: "#{@user.name} Ha Solicitado Información")
end
end
|
class Skill < ActiveRecord::Base
attr_accessible :instrument_id, :user_id
belongs_to :user
belongs_to :instrument
end
|
require 'knife-table/helpers'
module KnifeTable
class TableSet < Chef::Knife
include KnifeTable::Helpers
deps do
require 'git'
require 'chef/knife/core/object_loader'
end
banner 'knife table set NEW_FEATURE_OR_FIX'
option :cookbooks,
:short => '-c [COOKBOOK,COOKBOOK,...]',
... |
class School
attr_accessor :roster
attr_reader :name
def initialize(school_name)
@school_name = school_name
@roster = {}
end
def add_student(student_name, grade)
@roster[grade] = [] if @roster[grade] == nil
@roster[grade] << student_name
end
def grade(num)
@roster[num]
end
def... |
require "rails_helper"
describe Contact do
it "should have a factory" do
expect(FactoryGirl.build(:contact)).to be_valid
end
context "validations" do
it { should validate_uniqueness_of(:email) }
it { should validate_presence_of(:first_name) }
it { should validate_presence_of(:last_name) }
it... |
#Méthode 1 : retourne "true" si et seulement si la lettre est (=> on va utiliser son "ord"):
#-comprise entre A et Z inclus
def between_A_and_Z? (letter)
(letter.ord > 64 && letter.ord < 91) ? true : false
end
#Méthode 2 : retourne "true" si et seulement si la lettre est (=> on va utiliser son "ord"):
#-com... |
class FontAmita < Formula
head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/amita"
desc "Amita"
homepage "https://fonts.google.com/specimen/Amita"
def install
(share/"fonts").install "Amita-Bold.ttf"
(share/"fonts").install "Amita-Regular.tt... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :minimum_wage do
user
sequence(:price) {|n| n}
deleted_at nil
end
end
|
class CreatePresentationToDocumentTasks < ActiveRecord::Migration
def change
create_table :presentation_to_document_tasks do |t|
t.references :presentation, index: true
t.integer :status, default: 0
t.integer :retries, default: 0
t.string :ins, array: true
end
end
end
|
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# use Ubuntu12.04LTS
config.vm.box = "Ubuntu12.04"
config.vm.box_url = "http://download.appscale.com/do... |
class PhoneNumberFormatValidator < ActiveModel::EachValidator
def validate_each(object, attribute, value)
if value =~ /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/
return true
elsif value =~ /^(?:\+?1[-. ]?)?\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/
return true
else
obje... |
class CreateNpcDialogs < ActiveRecord::Migration[5.0]
def change
create_table :npc_dialogs do |t|
t.string :text
t.boolean :is_end
t.integer :path_a_trigger_id
t.integer :path_b_trigger_id
t.integer :path_c_trigger_id
t.timestamps
end
end
end
|
class AddProteinToClinicalBloodRecords < ActiveRecord::Migration
def change
add_column :clinical_blood_records, :protein, :integer
end
end
|
require 'test_helper'
class LinkTest < ActiveSupport::TestCase
def setup
@response = Object.new
def @response.parsed
{ }
end
def @response.body
"{}"
end
@empty_lastfm_response = { "foo" => "bar" }.to_json
@listens_response = Object.new
def @listens_response.listen=(l)
@listen = l
en... |
class Bike
def initialize(working=true)
@working = working
end
def working?
@working
end
end |
Rails.application.routes.draw do
root to: 'meals#index'
get '/logout', to: 'sessions#destroy'
get '/login', to: 'sessions#index'
post '/login', to: 'sessions#create'
get '/pages', to: 'pages#index'
resources :meals, only: [:index, :show] do
resources :orders, only: [:create]
end
namespace :... |
require_relative 'move_tree'
require_relative 'knight_searcher'
class Benchmarking
attr_accessor :bfs_time, :dfs_time, :knight_searcher
def initialize
tree = MoveTree.new([1,2],1)
@knight_searcher = KnightSearcher.new( tree )
@bfs_time = 0
@dfs_time = 0
end
def bfs_measure(coords)
s... |
class ProbationsController < ApplicationController
# GET /probations
# GET /probations.json
before_filter :authenticate_user!
load_and_authorize_resource
def index
@probations = Probation.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @probations }
... |
# frozen_string_literal: true
RubyNext::Core.patch Time, method: :ceil, version: "2.7" do
<<~'RUBY'
def ceil(den = 0)
change = subsec.ceil(den) - subsec
self + change
end
RUBY
end
|
module Company
class Wrapper
attr_accessor :errors, :query, :body
def initialize(errors, query, body)
@errors, @query, @body = errors, query, body
end
def to_json
h = {
:errors => @errors,
:query => @query,
:body => @body
}
JSON.pretty_generate h... |
require 'rest-client'
require 'date'
require 'uri'
require 'json'
require 'binance_api/result'
module BinanceAPI
class Base
BASE_URL = 'https://api.binance.com'.freeze
def initialize(options: {})
@api_key = options.fetch(:api_key, nil)
@api_secret = options.fetch(:api_secret, nil)
end
a... |
module V8
class Access
def get(obj, name, &dontintercept)
puts "V8 get: #{obj.class.name} - #{name}"
methods = accessible_methods(obj)
if methods.include?(name)
method = obj.method(name)
method.arity == 0 ? method.call : method.unbind
elsif obj.respond_to?(:[])
obj.... |
module Auth
extend ActiveSupport::Concern
include Jwt
# トークンの検証によるユーザ認証を実施する。
def authenticate(request_headers)
token = request_headers["Authorization"]
decoded = nil
err = nil
begin
decoded = validate(token)
rescue => e
err = e
... |
Rails.application.routes.draw do
resources :sightseeings
#location
get '/locations', to: 'locations#index'
get '/locations/:id', to: 'locations#show'
#review
get '/reviews', to: 'reviews#index'
get '/reviews/:id', to: 'reviews#show'
get '/reviews/new', to: 'reviews#new'
post '/reviews', to: 'revi... |
module Reuters
# This class enables the rapid and relatively painless
# construction of the body of Reuters API calls.
#
# It extends the Hash class, which means that it is
# compatible with the Savon request call and includes
# all the basic functionality of a Hash.
#
# @note This class is documented w... |
# frozen_string_literal: true
module NewDawn
Container.boot(:users) do
init do
require 'new_dawn/users/events'
use :event_bus
Users::Events.register_events(event_bus)
end
start do
Users::Events.subscribe_to_events(event_bus)
end
end
end
|
# frozen_string_literal: true
class Store < Base
belongs_to :organization
has_many :items
end
|
# frozen_string_literal: true
module Zonebie
VERSION = '0.6.0'.freeze
end
|
require 'spec_helper'
module QBIntegration
module Service
describe SalesReceipt do
let(:payload) do
{
"order" => Factories.order
}.with_indifferent_access
end
let(:config) do
{
'quickbooks_realm' => "1081126165",
'quickbooks_access_token' =... |
#this class is inherited from ApplicationRecord.
require 'csv'
class Article < ApplicationRecord
# has_many :comments
mount_uploader :attchment, AttachmentUploader
validates :title, presence: true,
length: { minimum: 5 }
def self.to_csv #Download File
CSV.generate do |csv|
csv << column_names
all.eac... |
# the method takes two arguments
# strings are printed using puts to print out the arguments inside strings.
def cheese_and_crackers(cheese_count, boxes_of_crackers)
puts "You have #{cheese_count} cheeses!"
puts "You have #{boxes_of_crackers} boxes of crackers!"
puts "Man that's enough for a party!"
puts "Get a... |
#
# Cookbook Name:: router
# Recipe:: default
#
# Copyright 2014, oshiire
#
# All rights reserved - Do Not Redistribute
#
execute "sysctl" do
command "sysctl -p"
action :nothing
end
template "sysctl.conf" do
path "/etc/sysctl.conf"
owner "root"
group "root"
mode 0640
notifies :run, 'execute[sy... |
# Run `bundle exec rspec` and satisy the specs.
# You should implement your methods in this file.
# Feel free to use the debugger when you get stuck.
require "prime"
def largest_prime_factor(num)
num.downto(2).each { |n| return n if Prime.prime?(n) && num % n == 0 }
end
def unique_chars?(str)
str == str.split(""... |
class UserMailer < BaseMailer
default from: "eaton.cw@gmail.com"
def contact_form(email, name, message)
@message = message
mail(:from => email,
:to => 'eaton.cw@gmail.com',
:subject => "A new contact form message from #{@name}")
end
def welcome(user)
@appname = "Fruitree"
mail( :to => user.ema... |
class Poedit < Cask
url 'http://www.poedit.net/dl/Poedit-1.6.3.zip'
homepage 'http://www.poedit.net'
version '1.6.3'
sha1 '69896fc6d45af68f598635572c62116dd91e21ad'
link 'Poedit.app'
end
|
module SoccerAPI
extend ActiveSupport::Concern
included do
EPA = "d8ddadd3-9a93-46bc-82b2-bc88c08b7255" # English Premier League ID
EPA_START = Date.parse("August 17, 2013")
API_PREFIX = "https://api.sportsdatallc.org/soccer-t2/eu/"
API_SUFFIX = "?api_key=#{ENV['SPORTS_DATA_KEY']}"
de... |
class AddMorePhotoInformation < ActiveRecord::Migration
def change
add_column :photos, :flickr_id, :string
add_column :photos, :url_z, :string
add_column :photos, :url_m, :string
add_column :photos, :url_o, :string
add_column :photos, :country, :string
add_index :photos, :flickr_id
end
end
|
class MessagesController < ApplicationController
before_filter :authenticate_user!
def index
@messages = Message.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @messages }
end
end
def new
@message = Message.new
respond_to do |... |
# frozen_string_literal: true
class UsersController < ApplicationController
skip_before_action :authorized, only: %i[new create]
# shows all users
def index
@users = User.all.order(id: :asc)
end
# shows a particular user with id: id
def show
@user = User.find(params[:id])
end
def new
# f... |
# frozen_string_literal: true
class CommentsController < ApplicationController
def create
post = Post.find(params[:post_id])
@comment = post.comments.build(comment_params)
@comment.user = current_user
@comment.save
redirect_to posts_path
end
def index; end
private
def comment_params
... |
class AddLikeLocationToLocations < ActiveRecord::Migration[5.2]
def change
add_column :locations, :like_location, :integer
end
end
|
class AddPreparerIdToMedicinePrescriptInternals < ActiveRecord::Migration[5.0]
def change
add_column :medicine_prescript_internals, :preparer_id, :integer
end
end
|
module LinterHelpers
def self.traverse_dir(root, store, filter = 'rb')
Dir.foreach(root) do |x|
path = File.join(root, x)
next if (x == '.') || (x == '..')
if Dir.exist?(path)
traverse_dir(path, store)
else
x.split('.')[-1] == filter and store[path] = x
end
end
... |
require "rails_helper"
feature "User creating loan" do
include_context "features"
scenario "without image succeeds while logged in as admin" do
log_in_as("admin", "password")
click_link("View Loans")
click_link("Create Loan")
fill_in "loan[title]", with: "Test loan"
fill_in "loan[description]... |
class Entry < ActiveRecord::Base
has_one :entry_meta
has_one :entry_content
has_many :entry_word_relations
has_many :words, through: :entry_word_relations
has_many :keywords
end
|
namespace :data do
desc 'Fix imported appointments which have completed procedures but themselves do not have start/complete dates'
task fix_imported_appointment_dates: :environment do
appointments = Appointment.unstarted.with_completed_procedures
bar = ProgressBar.new(appointments.count)
appointm... |
require "spec_helper"
require 'capybara/rspec'
feature 'editing an app' do
let!(:app) { FactoryGirl.create(:app, user: admin) }
let!(:admin) { FactoryGirl.create(:user, :admin) }
let!(:member) { FactoryGirl.create(:user, :confirmed) }
scenario 'as regular user who does not own the app' do
sign_in_as!(memb... |
#You have 2 lists of positive integers. Write a program which multiplies corresponding elements in these lists.
class MultiplyLists
def initialize(line)
@line = line
end
def multiply
x, y = line.split(' | ').map(&:split)
res = []
(0..x.length-1).each do |a|
res << (x[a].to_i)*(y[a].to_i)
... |
#
# Recipe for developing gitlabhq software
#
# Differences with default recipe:
# * no git sync, rely on vagrant to sync the codebase
# * leave bundle install & gitlab:setup for the developer
# Assumes that development vagrant will use Ubuntu/Debian based base box
# Set attributes for development
node.set['gitlab'... |
##-----------------------------------------------------------------------------
# Project Destroyer v1.0
# Created by Neon Black
# v1.0 - 8.27.15 - Main script completed
# For both commercial and non-commercial use as long as credit is given to
# Neon Black and any additional authors. Licensed under Creative Comm... |
class UpdatePhotos < ActiveRecord::Migration[5.2]
def change
change_column_null :photos, :img_title, false
end
end
|
class SudokuSolver < Array
attr_accessor :blocks
def initialize(puzzle)
add_squares(puzzle)
@blocks = PuzzleMap.new
set_square_relationships
end
def solve
solve_each_square until solved?
end
def solved?
self.each { |row| row.each { |square| return false unless square.solved? } }
... |
# frozen_string_literal: true
require "spec_helper"
module Decidim
module Amendable
describe Promote do
let!(:component) { create(:opinion_component) }
let!(:other_user) { create(:user, :confirmed, organization: component.organization) }
let!(:amendable) { create(:opinion, component: componen... |
require 'spec_helper'
describe Susanoo::Admin::UsersController do
shared_examples_for "未ログイン時のアクセス制限" do |action|
it "#{action} ログイン画面にリダイレクトされること" do
expect(response).to redirect_to(login_susanoo_users_path)
end
end
shared_examples_for "情報提供責任者ログイン時のアクセス制限" do |action|
before{@user = login(c... |
# frozen_string_literal: true
Factory.define(:user) do |f|
f.username { Faker::Internet.username }
f.email { Faker::Internet.email }
end
|
class Brochure < ActiveRecord::Base
before_save do
self.slug = self.name.downcase.gsub(' ','_').gsub('__', '_')
end
end
# == Schema Information
#
# Table name: brochures
#
# id :integer not null, primary key
# slug :string(255)
# name :string(255)
# body :text
# created... |
# sounds :
# Beetlemuse, JonnyRuss01, zivs, unadamlar, Mudkip2016 and Kastenfrosch from https://freesound.org/
# music opengamearts syncopika
require 'gosu'
$sounds = {
'pallet_ok': Gosu::Sample.new('./sfx/423930__mudkip2016__correct.wav'),
'box_ok': Gosu::Sample.new('./sfx/476178__unadamlar__correct-choice.wav')... |
#encoding:utf-8
#用户
require 'digest/sha1'
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable#,:confirmable, :lo... |
require 'json'
require 'sinatra/base'
require './backend'
# Fake rails
module ActiveRecord
class Base
attr_accessor :resource_name, :attributes
def initialize(attributes = {})
self.resource_name = "book"
self.attributes = attributes
attributes.each do |key, value|
self.class.send... |
class OrdersController < ApplicationController
before_action :redirect_to_sign_in
def index
@orders = current_user.orders.where.not(product_id: nil).page(params[:page])
@orders_count = current_user.orders.where.not(product_id: nil).count
end
def create
@order = current_user.orders.create(create_par... |
class CreateSeatPrices < ActiveRecord::Migration
def change
create_table :seat_prices do |t|
t.references :theater, index: true, foreign_key: true
t.decimal :weekdays, precision: 7, scale: 2
t.decimal :weekends, precision: 7, scale: 2
t.boolean :is_deleted
t.timestamps null: false
... |
require "find_as_hashes/version"
require 'active_resource'
module ActiveResource
class Base
class << self
def find_as_hashes(*args)
@skip_instantiate = true
find(*args)
end
def all_as_hashes(*args)
find_as_hashes(:all, *args)
end
def first_as_hash(*args)
... |
# JIRA -- An Example of Temporary Infrastructure
#
# This Rudy configuration demonstrates how to install JIRA
# to an EBS volume.
#
# ----------------------------------------------------------- DEFAULTS --------
# These values are used as defaults for their respective global settings. They
# can be overridden by the ... |
require 'spec_helper'
RSpec.describe MarkdownMetrics::TopElementsParser do
let(:lines) do
[
"# Main header",
"paragraph",
"## Header level 2",
"### Header level 3",
"#### Header level 4",
"##### Header level 5",
"###### Header level 6",
"",
" ... |
ActiveAdmin.register BankItem do
menu false
belongs_to :bank_account, optional: true
index do
selectable_column
column :id
column :from_account do |bi|
if bi.from_account.present?
link_to bi.from_account.name, admin_bank_account_path(bi.from_account.id)
else
"Deposit"
... |
class Bs::Elawa::EventSerializer < ActiveModel::Serializer
attributes :id, :name, :status
has_many :segments
end
|
class ApplicationController < ActionController::Base
protect_from_forgery
ensure_security_headers
before_filter :authenticate_user!
def route
if track = current_user.tracks.first
redirect_to track
else
redirect_to new_track_url
end
end
end
|
#----------EXERCISES----------
#http://tl-ruby.s3.amazonaws.com/drop1/assignments/RubyExercises.txt
#--01--
arr = [1,2,3,4,5,6,7,8,9,10]
arr.each do |a|
puts a
end
#--02--
arr.each do |a|
if a > 5
puts a
else
end
end
arr.each { |a| puts a if a > 5 } #same as above, more concise
#--03--
odd_arr = arr.sele... |
class Sponsoredcontent < ActiveRecord::Migration[6.0]
def change
#Ajout d'une colonne pour préciser si une série est sponsorisé.
add_column(:references, :isSponso, :boolean, null: false, default: false)
end
end
|
require_relative 'Models/account'
class AccountRepository
def query name
query = Models::Account.where(name: name)
query.first unless query.nil?
end
end
|
class CreateTracks < ActiveRecord::Migration
def change
create_table :tracks do |t|
t.string :title
t.string :artist
t.decimal :duration, precision: 6, scale: 2
t.string :date
t.string :album
t.string :genre
t.string :language
t.string :description
t.boolean :... |
require 'excon'
require 'net/ping/tcp'
class StatusCheck
def initialize(host:, type:)
@host = host
@type = type
end
def run
{ http: http, ping: ping }[@type]
end
def ping
host = Net::Ping::TCP.new("#{@host}", 'http')
host.ping
ping_time = host.duration
if ping_time.nil?
... |
class AccountTotals
def initialize(forecast, frequency)
@forecast = forecast
@frequency = frequency
@start_date = @forecast.forecast_start_date
@end_date = @start_date + 60.months
end
def revenues
@forecast.revenues
end
def cogs
@forecast.cost_of_goods_sold
end... |
require 'rails_helper'
RSpec.describe User, type: :model do
it { should validate_presence_of (:login) }
it { should validate_length_of (:login) }
it "has a valid factory" do
expect(build(:user)).to be_valid
end
end
|
require 'spec_helper'
describe String do
describe '#mb_downcase' do
it { expect("Кириллица".mb_downcase).to eq("кириллица") }
end
describe '#remove_nonprintable' do
let(:string) { "\uFDD1string\uFFFE \uFFFFwith\uFDEF weird characters\uFDD0" }
it { expect(string.remove_nonprintable).to eq 'string wi... |
module MinesFileParser
def parse_file_and_load_mines(mine_file)
File.foreach(mine_file) do |current_mine|
current_mine = current_mine.gsub(/^\s+|\s+$/m, '')
validate_mine_format(current_mine)
mines << current_mine
end
end
private
def validate_mine_format(current_mine)
if current... |
require 'protip/transformer'
require 'protip/transformers/delegating_transformer'
module Protip
module Transformers
# Transforms ints, strings, booleans, floats, and bytes to/from their
# well-known types (for scalars) and Protip repeated types.
class PrimitivesTransformer < DelegatingTransformer
... |
require "./Rectangle.rb"
class Rectangle3d < Rectangle
attr_accessor :heigth
def initialize(width, length, heigth)
super(width, length)
@heigth = heigth
end
def printVolume
puts ("Volume: #{@width} * #{@length} * #{@heigth} = " + volume.to_s)
end
def print
puts ("Width: #{@width} Leng... |
require 'spec_helper'
require 'rails_helper'
feature 'admin sign in' do
scenario 'admin signs in successfully' do
admin = FactoryGirl.create(:admin)
visit root_path
click_link "Login Admin"
fill_in "Email", with: admin.email
fill_in "Password", with: admin.password
click_button "Log in"
e... |
Given "I'm a Device with the following information:" do |device_info|
info = device_info.hashes.first
memorize_fact(
:device_info,
{
serial_number: info['Serial Number'],
firmware: info['Firmware Version']
}
)
end
Given "I'm not yet registered on the API" do
expect(Device.all.count).to... |
class Domain < ActiveRecord::Base
# associations
belongs_to :organization
# validations
VALID_NAME_REGEX = /\A[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6}+\z/i
validates :name, presence: true, format: { with: VALID_NAME_REGEX }, uniqueness: { case_sensitive: false }
validates_existence_of :organizatio... |
class AddVendorCompanyIdToDemands < ActiveRecord::Migration[5.0]
def change
add_column :demands, :vendor_company_id, :integer
end
end
|
class TasksController < ApplicationController
before_action :logged_in_user
def index
@task = Task.find(params[:id])
end
def new
@task = Task.new
end
def edit
@task = Task.find(params[:id])
end
def update
@project = Project.find(params[:project_id])
@task = Task.find(params[:id])... |
if defined? BetterErrors
# Private subnets defined by RFC1918 as stated in https://docs.docker.com/v1.5/articles/networking/
BetterErrors::Middleware.allow_ip! '0.0.0.0/0'
BetterErrors::Middleware.allow_ip! '192.168.33.10'
end |
class AddAssociationsToImages < ActiveRecord::Migration
def change
add_column :images, :image_reference_id, :integer
add_column :images, :image_reference_type, :string
add_index :images, [:image_reference_id, :image_reference_type]
end
end
|
require 'rails_helper'
FRUITS = %w(apples apricots acai blueberry cherry donut durean)
describe 'Home page' do
before(:each) do
FRUITS.each { |fruit| create(:element, name: fruit) }
visit root_path
end
context 'Sample list' do
it 'presents' do
expect(page).to have_css('#elements')
end
... |
module Lolita
module Extensions
module Authentication
class DefaultAdapter
def initialize context, options={}
end
def current_user
nil
end
def user_signed_in?
false
end
def authenticate_user!
true
end
end... |
require 'rspec'
require 'samwise/version'
require 'rspec/expectations'
require 'uri'
require 'vcr'
require 'webmock/rspec'
require 'pry'
include Samwise
WebMock.disable_net_connect!(allow_localhost: true)
RSpec.configure do |config|
def capture(stream)
begin
stream = stream.to_s
eval "$#{stream} = Strin... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
private
def current_patient
@current_patient ||= Patient.find(session[:patient_id]) if session[:patient_id]
e... |
class DrawCard
DRAW_CARD_TO_CLASS = {
"Community Chest" => CommunityChestCard,
"Chance" => ChanceCard
}.freeze
def self.run(turn_action)
new(turn_action).run
end
def initialize(turn_action)
@turn_action = turn_action
end
def run
event_name = @turn_action.turn.end_space.event.name
... |
class Shoes
class Radio < Element
def initialize(opts = {})
super
group = nil
# Set the radio button group to all other radio buttons in this slot.
@parent.children.each do |element|
if element.class == Radio
group = element.real
break
end
end
... |
require 'digest/sha1'
class User < ActiveRecord::Base
belongs_to :member
has_many :user_preferences
has_many :pageviews
validates_presence_of :name
validates_uniqueness_of :name
attr_accessor :password_confirmation
validates_confirmation_of:password
def validate
errors.add_to_base("Missing Password")... |
# Transitive class used to manipulate tasks on timesheets
class TimesheetTask
attr_accessor :id
attr_accessor :code
attr_accessor :name
attr_accessor :description
attr_accessor :tag_list
attr_accessor :monday
attr_accessor :tuesday
attr_accessor :wednesday
attr_accessor :thursday
attr_accessor :fri... |
class CreateContactsTours < ActiveRecord::Migration
def self.up
create_table :contacts_tours, :id => false do |t|
t.references :contact
t.references :tour
end
end
def self.down
drop_table :contacts_tours
end
end
|
require "spec_helper"
RSpec.describe "Day 18: Like a GIF For Your Yard" do
let(:runner) { Runner.new("2015/18") }
let(:input) do
<<~TXT
.#.#.#
...##.
#....#
..#...
#.#..#
####..
TXT
end
describe "Part One" do
let(:solution) { runner.execute!(input, part: 1, STEP... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.