text stringlengths 10 2.61M |
|---|
# -*- coding: utf-8 -*-
require 'rack/ketai/carrier/au'
describe "Rack::Ketai::Carrier::Au" do
before(:each) do
end
describe "WAP2.0ブラウザ搭載端末で" do
# http://ke-tai.org/blog/2008/09/08/phoneid/
# http://www.au.kddi.com/ezfactory/tec/spec/4_4.html
describe "EZ番号(サブスクライバID)を取得できたとき" do
be... |
require 'rsql_ruby/parser'
# Main module
module RsqlRuby
VERSION = "1.0.0"
# Parse string to structures.
def self.parse(str)
parser = RsqlRuby::Parser.new
parser.parse(str)
end
end
|
class Song
attr_accessor :name, :artist
@@all = [ ]
def initialize(name)
@name = name
@@all << self #refers to the instance
end
#.all reffers to class variable @@all, returns array of all songs
def self.all #self is referring to the class Song and not an instance of a song. outside of the scope of the method.
@@all
... |
require 'spec_helper'
describe Legend::Client do
context "When asked for a description" do
let(:desc) {l = Legend::Client.new; l.description}
it 'describes the zone' do
desc.should =~ /You are in a room./
end
it 'lists objects in the zone' do
desc.should =~ /There is a candle on a table in the co... |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
class User < ApplicationRecord
# CONFIG
ROLES = [SUPERADMIN = 'superadmin', ADMIN = 'admin', MEMBER = 'member']
authenticates_with_sorcery!
include Destroyable
# CALLBACKS
after_initialize :set_role
# RELATIONS
# SCOPES
# VALIDATIONS
validates :email, :role, presence: true
validates :ema... |
class CreateProfessionalOpportunities < ActiveRecord::Migration
def change
create_table :professional_opportunities do |t|
t.string :position
t.string :position_link
t.string :organization
t.string :organization_link
t.string :location
t.string :apply_by_email
t.text :des... |
# frozen_string_literal: true
module GraphQL
module Introspection
class EntryPoints < Introspection::BaseObject
field :__schema, GraphQL::Schema::LateBoundType.new("__Schema"), "This GraphQL schema", null: false
field :__type, GraphQL::Schema::LateBoundType.new("__Type"), "A type in the GraphQL system... |
#
# Author:: Matt Eldridge (<matt.eldridge@us.ibm.com>)
# © Copyright IBM Corporation 2014.
#
# LICENSE: MIT (http://opensource.org/licenses/MIT)
#
module Fog
module Softlayer
class Network
class Mock
def get_network_tags(id)
response = Excon::Response.new
response.status = s... |
module Campfire
class User
attr_reader :id, :name, :email
def initialize(manager, attributes)
@manager = manager
@id = attributes["id"]
@name = attributes["name"]
@email= attributes["email_address"]
end
def to_s
%Q[User #{@id}: #{@name} (#{@email})]
end
end
end
|
class OderMailer < ApplicationMailer
def send_order_info order
@order = order
mail to: @order.email, subject: "[Trung Manucian Restaurant] Order Information Confirm"
end
end
|
class AssignmentsController < ApplicationController
def index
@assignments = if params[:all]
Assignment.all
else
Assignment.where team: current_user.active_team
end
end
def show
@assignment = Assignment.find params[:id]
end
def new
@assignment = Assignment.new
end
def cr... |
module ApplicationHelper
def build_status build
css_class = 'build-label'
css_class << ' build-label-green' if build.success?
css_class << ' build-label-red' if build.fail?
css_class << ' build-label-yellow' if build.in_progress?
spinner = content_tag(:span, content_tag(:i, nil, class: 'fa fa-ci... |
class Wiki < ActiveRecord::Base
paginates_per 10
belongs_to :user
validates :name, presence: true
after_save :move_to_wiki_histories
def move_to_wiki_histories
history = WikiHistory.new
history.content = self.content
history.reason = self.reason
history.wiki_id = self.id
history.user... |
Quando(/^eu entro na página de cadastrar pedido$/) do
@order = FactoryGirl.create( :order )
visit new_order_path
end
E(/^eu preencho o campo quantidade com (.*) da pizza (.*)$/) do |quantity, pizza|
find("##{pizza}-row").fill_in( "quantity_pizzas_order", with: quantity )
end
E(/^eu clico no botão de realização... |
class ShowsController < ApplicationController
before_filter :find_show, only: [:like, :dislike]
# Somehow ActiveModelSerializer isn't working with the proper
# snakeCasing....
#
def index
if params[:preferences].present?
filter_options = params[:preferences]
filter_options = filter_options.me... |
module FellowshipOne
class PersonReader < ApiReader
# Constructor.
#
# @param person_id The ID of the user to load.
def initialize(person_id)
@url_data_path = "/v1/People/#{person_id}"
end
end
end
|
module Rdomino
module Db
module Log
# @param [Regexp] pattern
# @param [Hash] intervall offset from now (:years, :months, :days, :hours, :minutes, :seconds) => -1
def find(pattern,intervall={:minutes => -5})
time = unless intervall.nil?
DateTime.current.advance intervall
... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
# source: https://github.com/mitchellh/vagrant/issues/5774
def usbfilter_exists(vendor_id, product_id)
#
# Determine if a usbfilter with the provided Vendor/Product ID combination
# already exists on this VM.
#
# TODO: Use a more reliable way of retrieving this inform... |
class ApplicationController < ActionController::Base
protect_from_forgery
# TODO remove it when devise will complete
def fake_current_user
User.first
end
protected
def parse_errors model
if model.errors.size > 0
model.errors.messages.map{|k, v| "#{k}: #{v.join(', ')}"}.join("\n")
end
... |
# My first Ruby program, first use of Sinatra, first us of Dwolla API
# basic functions send money and request money work
# this is a proof of concept
# possible improvements abound: unit test & test driven development, validate user inputs, avoid global variables, find better way to pass Dwolla object and token, catch... |
require 'decorator'
describe Decorator do
describe '.decorate_diff' do
let(:arr1) { [nil, 'a', 'b', 'c', 'm', 'd', 'e', 'f', 'g', 'h', nil, nil] }
let(:arr2) { ['l', 'a', 'b', nil, 'j', nil, nil, 'f', 'g', 'h', 'c', 'd'] }
subject { described_class.decorate_diff(arr1, arr2) }
it 'decorates diff' do... |
require 'order'
describe Order do
subject(:order) { described_class.new(menu_klass = menu, order_summary_klass\
= OrderSummary.new, sms_klass = sms)}
let(:sms) { double('sms')}
let(:menu) { double('menu', :dishes => { "Golden French Fries" => 0.5 }) }
context 'selecting an item from the menu' do
it 'a... |
require 'spec_helper'
describe "ranged matches for TheModel collections" do
before :each do
stub_const("LOAD_BALANCERS", [])
create :the_model, name: 'foo', description: "The Foo the_model",
created_at: "2013-03-01T00:00:00Z"
create :the_model, name: 'bar', description: "The Bar the_model",
... |
#!/usr/bin/ruby
# file: polyrex-xslt.rb
class PolyrexXSLT
attr_accessor :schema, :xslt_schema
def initialize(options={})
o = {schema: '', xslt_schema: ''}.merge(options)
@schema, @xslt_schema = o.values
end
def to_xslt()
header =<<HEADER
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xml... |
RSpec.describe Mutant::Matcher::Null do
let(:object) { described_class.new }
describe '#each' do
let(:yields) { [] }
subject { object.each { |entry| yields << entry } }
# it_should_behave_like 'an #each method'
context 'with no block' do
subject { object.each }
it { should be_instanc... |
require 'rails_helper'
describe User do
describe '#create' do
before do
@user = build(:user)
end
it "nickname、email、password、password_confirmation、first_name、family_name、first_name_kana、family_name_kana、birth_dateがあれば登録できること" do
expect(@user).to be_valid
end
it "nicknameが空では登録できないこと"... |
class Cat < ApplicationRecord
# @@valid_colors = ["yellow", "black", "white", "grey"]
VALID_COLORS = ["yellow", "black", "white", "grey"]
validates :birth_date, :name, :description, presence: true
validates :color, presence: true, inclusion: {in: VALID_COLORS }
validates :sex, presence: true, inclusion: {in:... |
class AddSenderAndRecIndexToChallenges < ActiveRecord::Migration
def change
add_index("challenges", "sender_id")
add_index("challenges", "recipient_id")
end
end
|
module ApplicationHelper
def audio_config_json
return '{}' unless File.exist? 'audio_config.yaml'
config = YAML.load_file('audio_config.yaml').deep_symbolize_keys
config[:schemas].each do |schema, schema_config|
schema_config[:events].keys.each do |event|
next if event == :new_files
... |
class ResultsController < ApplicationController
def displayChart
@results = Results.all
end
end
|
require 'rails_helper'
RSpec.describe VisitationsController, type: :routing do
describe 'routing' do
it 'routes to #index' do
expect(get: '/visitations').to route_to('visitations#index')
end
it 'routes to #new' do
expect(get: '/visitations/new').to route_to('visitations#new')
end
it... |
Rails.application.routes.draw do
namespace "api", defaults: {format: :json} do
post '/metrics', to: "metrics#create"
get '/metrics', to: "metrics#index"
resources :thresholds
get '/alert_update', to: "alerts#alert_update"
end
end
|
class AddSubdomainToAccounts < ActiveRecord::Migration[5.1]
def change
add_column :accounts, :subdomain, :string, null: false, limit: 60
add_index :accounts, :subdomain, unique: true
end
end
|
# encoding: utf-8
class ApplicationController < ActionController::Base
include ApplicationHelper
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
### ActiveRecord error handling functions
%w(
RecordNotFound r... |
#encoding: UTF-8
module Tener
module Ext
module Grid
def ext_grid_html(id)
"<div id='#{id}-grid'></div>"
end
def ext_grid_script(options)
options = {
:new => true,
:edit => true,
:delete => true,
:height => 200,
... |
require 'spec_helper'
describe "location" do
before :each do
allow(Net::HTTP).to receive(:get_response).and_return(Net::HTTPResponse)
end
it "should return a pickup location if given a valid code" do
allow(Net::HTTPResponse).to receive(:body)
.and_return(File.read('./spec/fixtures/nypl-core-by_rec... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :mileage_record do
record_date "2013-11-03"
start_mileage 0
end_mileage 243
route_description "Store 91 to Store 89"
notes "Going to do something to turn in something for the meeting next something"... |
class UsersController < ApplicationController
before_action :find_user, only: %i[show edit update]
before_action :check_user_belongs_to_current_user, only: %i[edit update]
before_action :authorize_user, only: %i[edit update]
def show
@posts = @user.posts
@pages = @user.pages
end
def search
... |
class RemoveMarketsFromStartup < ActiveRecord::Migration
def change
remove_column :startups, :markets, :string
end
end
|
class AddPhoneToLandlords < ActiveRecord::Migration
def change
add_column :landlords, :phone, :string
end
end
|
#encoding: utf-8
require "model-base"
class ApiLog
include DataMapper::Resource
include Utils::DataMapper::Model
extend Utils::DataMapper::Model
property :id, Serial
property :image, String # image
property :name, String, :required => true # name
property :market, String # market desc, e... |
When /^I fill in the following:$/ do |fields|
fields.rows_hash.each do |name, value|
step %{I fill in "#{name}" with "#{value}"}
end
end
When /^I fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
fill_in(field, :with => value)
end
When /^I select "(.*?)" as the "(.*?)"$/ do |selection, field|
find(:css... |
module LandlordsHelper
def landlord_row_for landlord
columns = [
content_tag(:td, landlord.name),
content_tag(:td, link_to_associated(landlord, :commissions)),
content_tag(:td, link_to_associated(landlord, :leases)),
content_tag(:td, landlord.email),
content_tag(:td, landlord.phone_n... |
require 'spec_helper'
describe CampaignStat do
let(:campaign) { mock_model(Campaign) }
describe "#for" do
it "returns a new CampaignStat for the specified campaign" do
campaign_stat = mock('CampaignStat')
CampaignStat.should_receive(:new).with(:campaign => campaign).and_return(campaign_stat)
... |
# frozen_string_literal: true
class Queries::PrayersQuery < Queries::BaseQuery
type Types::Location::PrayerType.connection_type, null: false
argument :ids, [ID], required: false
argument :location_ids, [ID], required: false
def resolve(ids: nil, location_ids: nil)
scope(ids, location_ids).all
end
pro... |
class Dog
attr_accessor :name, :breed, :age
@@dogs = []
def initialize(name, breed, age)
@name=name
@breed=breed
@age=age
@@dogs<<self
end
def self.all
@@dogs
end
end |
class ChangeExpirationDateToDate < ActiveRecord::Migration
def change
change_column :bets, :expiration_date, :date
end
end
|
module Scheherazade
module Extension
def imagine(attributes = nil)
story.imagine(self, attributes)
end
end
end
|
=begin
Write a method that counts down to zero using recursion.
count_to_zero(5) -> print out 5 4 3 2 1 0
count_to_zero(0) -> print out 0
count_to_zero(-1) -> print out -1
=end
def count_to_zero(n)
return print "#{n} \n" if n <= 0
print "#{n} "
(count_to_zero(n-1))
end
count_to_zero(5)
count_to_zero(... |
#
# Usage: ./ab-mruby -m ab-mruby.conf.rb -M ab-mruby.text.rb [http[s]://]hostname[:port]/path
#
# BENCHMARK RESULT AND TEST PARAMETERS
#
# get_config "TargetURL"
# get_config "TargetHost"
# get_config "TargetPort"
# get_config "TargetPath"
# get_config "TargetisSSL"
# get_config "TargetServerSoftware"
# get_config "Ta... |
class Debater < ActiveRecord::Base
belongs_to :user
has_many :affirmative_debates, class_name: "Debate", foreign_key: "affirmative_id"
has_many :negative_debates, class_name: "Debate", foreign_key: "negative_id"
has_many :civility_votes
has_many :messages, foreign_key: "author_id"
ha... |
# frozen_string_literal: true
module J8
class Function
include J8::Common
def apply(o)
@callable.call(o)
end
def compose(before = nil, &block)
callable = from_callable(before, block)
J8::Function.new(->(o) { apply(callable.apply(o)) })
end
def then(after = nil, &block)
... |
# frozen_string_literal: true
require 'spec_helper'
require 'bolt/puppetdb/client'
require 'bolt_spec/puppetdb'
describe Bolt::PuppetDB::Client do
let(:uri) { 'https://puppetdb:8081' }
let(:cacert) { File.expand_path('/path/to/cacert') }
let(:config) { double('config', server_urls: [uri], cacert: cacert, token:... |
class ApplicationController < ActionController::Base
# prevent CSFR attacks by raising an exception. For APIs use :null_session instead of :exception
protect_from_forgery with: :null_session
end
|
class Header < ActiveRecord::Base
default_scope :order => :position
acts_as_list
has_attached_file :photo,
:url => "/system/photos/:id/:style_:basename.:extension",
:path => ":rails_root/public/system/photos/:id/:style_:basename.:extension",
:styles => {
:thumb => "75x55#",
:small => "15... |
class AddDormantToProducts < ActiveRecord::Migration
def up
add_column :products, :dormant, :boolean
end
def down
remove_column :products, :dormant
end
end
|
class RemoveColumnReview < ActiveRecord::Migration[5.2]
def change
remove_column :restaurants, :reviews, :references
end
end
|
class Keydate < ApplicationRecord
belongs_to :project, foreign_key: 'project_id', optional: true
belongs_to :tract, foreign_key: 'tract_id', optional: true
validates :name, :date, :presence => true
rails_admin do
configure :project do
label 'Project that this keydate is associate... |
class User < ApplicationRecord
include Friendlyable
belongs_to :role, optional: true
after_initialize :set_default_role
# Include default devise modules. Others available are:
# :timeoutable, :omniauthable
devise :database_authenticatable,
:registerable,
:confirmable,
:lockable,
... |
require 'spec_helper'
describe 'magnum::keystone::auth' do
shared_examples 'magnum::keystone::auth' do
context 'with default class parameters' do
let :params do
{
:password => 'magnum_password',
:tenant => 'foobar'
}
end
it { should contain_keystone_user('... |
class AddIndexesOnRecyclingCentersAndSigns < ActiveRecord::Migration
def change
add_index :recycling_centers, :name
add_index :recycling_centers, :lat
add_index :recycling_centers, :lng
add_index :recycling_centers, :factions
add_index :recycling_centers, :category
add_index :signs, :name
... |
class Page < ActiveRecord::Base
has_many :quotes
validates :page_name, :presence => true
end
|
class AddBookingRoom < ActiveRecord::Migration[6.0]
def change
create_table :booking_rooms do |t|
t.references :booking
t.references :booking_request_room
t.string :confirmation_number
t.references :tenant
t.references :client
t.timestamps
end
end
end
|
class Cliente < ActiveRecord::Base
has_many :ventas
has_many :articulos, :through => :ventas
validates_presence_of :nombre
validates_uniqueness_of :nombre
def self.to_select
all(:order => 'nombre').collect{|x| [x.nombre, x.id]}
end
end
|
begin
require 'codeclimate-test-reporter'
CodeClimate::TestReporter.start
rescue LoadError => e
$stderr.puts "not recording test coverage: #{e.inspect}"
end
require File.expand_path('../../lib/fog/vsphere', __FILE__)
|
class CategoryTree
attr_accessor :category, :parent, :children
def initialize
@children = []
end
def add_category(category,parent)
if parent == nil
@category = category
@parent = parent
end
node = self
parent = parent
child = CategoryTree.new()
child.category = categor... |
class Api::ReportesController < ApplicationController
before_filter :find_user
def find_user
@user = User.find_by(facebook_id: params[:user_id])
end
def index
render json: @user.reportes
end
def reporte_params
params.permit(:lat,:long,:zone,:picture, :user_id)
end
def picture_params
params.pe... |
class Api::V1::BoardsControllerTest < ApplicationIntegrationTest
test "client can generate new board" do
POST create_board_url(number: 1, format: :json)
assert response.code, equal: OK
boards = response.parsed_body["data"]
assert boards.first["attributes"]["id"].present?, true
assert boards.first[... |
class OrderFrequency < ActiveRecord::Base
enum unit: {hr: 0}
end |
# frozen_string_literal: true
module CountryStateSelect
VERSION = '3.1.5'
end
|
class CreateUsers < ActiveRecord::Migration[5.2]
def change
create_table :users do |t|
t.string :nick_name
t.string :profile_image
t.integer :gender
t.timestamp :deleted_at
t.timestamps
end
end
end
|
# MRI 中 Timeout 的实现, 原理比较简单, lib/timeout 中就 100 多行, 核心代码如下:
bl = proc do |exception|
begin
x = Thread.current
y = Thread.start {
begin
sleep sec
rescue => e
x.raise e
else
x.raise exception, message
end
}
return yield(sec)
ensure
if y
k.kill... |
require 'rails_helper'
RSpec.describe Backoffice::V1::UsersController do
let(:company) { FactoryBot.create(:company) }
let(:headers) do
{
'Accept' => 'application/json',
'COMPANY' => company.uid
}
end
before do
http_login
headers.each { |k, v| request.headers[k] = v }
end
des... |
class SongsController < ApplicationController
def index
# @songs = Song.all
@songs = Song.order('created_at DESC')
end
def show
id = params[:id]
@song = Song.find(id)
end
def new
@song = Song.new
end
def create
@song = Song.new(son... |
feature 'Linking to full message' do
scenario 'clicking on truncated message takes you to full text' do
visit '/'
fill_in :message, with: 'This message exceeds 20 characters'
click_button 'Submit'
click_link 'This message exceeds'
expect(page).to have_content 'This message exceeds 20 characters'
... |
class HomePage < SitePrism::Page
element :create_list, :xpath, "//*[@id='quickcreatetop']/a"
element :task_option, "a[href='index.php?module=Tasks&action=EditView&return_module=Tasks&return_action=DetailView']"
def create (create,task)
create_list.hover
task_option.click
end
end
|
# Problem 84: Monopoly odds
# http://projecteuler.net/problem=84
# In the game, Monopoly, the standard board is set up in the following way:
#
# GO
# A1
# CC1
# A2
# T1
# R1
# B1
# CH1
# B2
# B3
# JAIL
# H2
#
# C1
# T2
#
# U1
# H1
#
# C2
# CH3
#
# C3
# R4
#
# R2
# G3
#
# D1
# CC3
#
# CC2
# G2
#
# D2
#... |
class GameCreator::RoundQuestionsBuilder
include Interactor
def call
context[:round_questions] = build_round_questions
end
private
delegate :category, to: :context
def build_round_questions
random_questions.map do |question|
RoundQuestion.new(question: question)
end
end
def random... |
require 'spec_helper'
describe Relation do
subject(:relation) { Relation.new(dataset) }
let(:dataset) { DB[:users] }
let(:jane) { { id: 1, name: 'Jane' } }
let(:joe) { { id: 2, name: 'Joe' } }
before do
seed
end
after do
deseed
end
describe "#header" do
it "return's duplicated and fr... |
class ChangeFromAndToToHostAndGuest < ActiveRecord::Migration
def up
rename_column :rosham_matches, :from, :host
rename_column :rosham_matches, :to, :guest
end
def down
end
end
|
class Confirmation < ActiveRecord::Base
include Token
belongs_to :account
attr_accessible :confirmation_sent_at, :confirmation_token, :confirmed_at, :unconfirmed_email
def self.confirm_by_token!(token)
confirmation = Confirmation.find_by_confirmation_token(token)
if confirmation
account = co... |
# frozen_string_literal: true
RSpec.describe ActiveEncryption::EncryptionSetting::Record do
subject(:record) do
described_class.new(
cipher: attributes[:cipher],
digest: attributes[:digest],
id: attributes[:id],
key: attributes[:key],
purpose: attributes[:purpose],
secret: att... |
include ActionDispatch::TestProcess
FactoryGirl.define do
factory :user do
email {Faker::Internet.email }
password "1234567"
password_confirmation "1234567"
end
factory :repo do
url {Faker::Internet.url('https://github.com', '/foobar.html')}
name {Faker::Name.name}
user
end
end
|
class CreatePratosRestaurantesJoinTable < ActiveRecord::Migration
def change
create_table :pratos_restaurantes, id: false do |t|
t.integer :prato_id
t.integer :restaurante_id
end
end
|
class User < ActiveRecord::Base
has_many :playlists
has_attached_file :avatar, :styles => { :medium => "200x200>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png"
validates_attachment_content_type :avatar, :content_type => /\Aimage\/.*\Z/
def password
@password ||= BCrypt::Password.ne... |
$LOAD_PATH << '../comrank/lib'
require 'cxbrank/const'
class CreateMusics < ActiveRecord::Migration
def self.up
music_diffs = CxbRank::MUSIC_DIFFS[CxbRank::MODE_REV]
create_table :musics do |t|
t.string :text_id, :null => false
t.integer :number, :default => 0
t.string :title, :null => fals... |
#
# Author:: Barry Davis (barryd@jetstreamsoftware.com)
# Copyright:: Copyright (c) 2010-2011 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# 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 Licens... |
require 'spec_helper'
require_relative '../../lib/models/restriction_group.rb'
RSpec.describe RestrictionGroup, group: :model do
let(:restriction_group) { FactoryBot.create(:restriction_group) }
it "should be valid is created with the correct attributes" do
expect(FactoryBot.build(:restriction_group)).to be_v... |
module Fastlane
module Actions
module SharedValues
#UNITY_BUILD_CUSTOM_VALUE = :UNITY_BUILD_CUSTOM_VALUE
end
class UnityBuildAction < Action
def self.run(params)
# fastlane will take care of reading in the parameter and fetching the environment variable:
#UI.message "Parameter... |
require "./lib/Lesson 99 Future Training/ArrayInversionCount/array_inversion_count"
describe 'ArrayInversionCount' do
describe 'Example Test' do
it 'Example' do
expect(array_inversion_count([-1,6,3,4,7,4])).to eq 4
end
end
describe 'Correctness Tests' do
context 'Simple1' do
it 'Simple'... |
class ApplicationController < ActionController::Base
def access_controll
if current_user.nil? || !current_user.admin
redirect_to new_user_session_path
end
end
def after_sign_in_path_for(resource)
catagories_path
end
end
|
require('spec_helper')
describe(Doctor) do
describe('#first_name') do
it("returns the doctor's first name") do
doctor = Doctor.new(id: nil, first_name: "Bill", last_name: "Brasky", specialty_id: 1)
expect(doctor.first_name).to(eq("Bill"))
end
end
describe('#last_name') do
it("returns the... |
require 'parslet'
module Calculator
class Parser < Parslet::Parser
rule(:space) { match('\s').repeat(1) }
rule(:sp) { space.maybe }
rule(:integer) { match('[0-9]').repeat(1).as(:int) }
rule(:add) { integer.as(:left) >> sp >> match('\+') >> sp >> expr.as(:right) }
rule(:expr) { add | integer... |
class Admin::MatchVideosController < Admin::BaseController
before_action :set_admin_match_video, only: [:show, :edit, :update, :destroy]
# GET /admin/match_videos
def index
@admin_match_videos = Admin::MatchVideo.search params
end
# GET /admin/match_videos/1
def show
end
# GET /admin/match_videos/ne... |
require 'tahi_epub'
require 'nokogiri'
class DocxExporter
XSLT_PATH = "../../../../lib/xslt/docx_to_html.xslt"
DOCX_TEMPLATE_PATH = '../../../../lib/docx/default.docx'
attr_reader :stream
def initialize(stream)
@stream = stream
end
def call
TahiEpub::Tempfile.create docx_stream.string, format: '.... |
class Api::AreasEventsController < ApplicationController
respond_to :json
def index
@areaevent = AreaEvent.all.map { |i| AreaEventSerializer.new(i).serializable_hash }
render json: {
success: true,
response: @areaevent
}
end
def create
@are... |
require_relative('station')
require_relative('route')
require_relative('train')
require_relative('passenger_train')
require_relative('cargo_train')
require_relative('cargo_car')
require_relative('passenger_car')
require_relative('storage')
class MyProgram
COMMANDS = %w(
create_station create_train create_route
... |
class ExpenseSourcesController < ApplicationController
# GET /expense_sources
# GET /expense_sources.json
def index
@expense_sources = ExpenseSource.where(:user_id => current_user.id)
respond_to do |format|
format.html # index.html.erb
format.json { render json: @expense_sources }
end
e... |
module BuildingDefence
class Dictionary
def initialize
@words = []
@max_len = 0
@number = 20
@dic = IO.readlines File.expand_path "../dictionary/brit-a-z", __FILE__
srand
reload_words
end
def max_len
@max_len
end
def number
@number
end
def... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.