text stringlengths 10 2.61M |
|---|
require 'rails_helper'
RSpec.describe 'admin logs in' do
it 'sees admin tools in navbar' do
admin_logs_in
visit root_path
expect(page).to have_content('Admin Tools')
expect(page).to_not have_content('Moderator Tools')
end
end
|
require_relative '../test_case'
module RackRabbit
class TestSignals < TestCase
#--------------------------------------------------------------------------
def test_pop_is_fifo_queue
signals = Signals.new
signals.push(:TTIN)
signals.push(:TTOU)
signals.push(:QUIT)
assert_equal(... |
class SearchController < ApplicationController
skip_before_action :authenticate_user!
skip_authorization_check
before_action :load_query, :find_target, only: :search
def search
@result = ThinkingSphinx.search(@query, classes: [@target])
end
private
def find_target
models ={ answers: Answer, que... |
class ApplicationController < ActionController::Base
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
include Pundit
def user_not_authorized
flash[:warning] = "You are not authorized to perform this action."
redirect_to(request.referrer || root_path)
end
end
|
#spec/connectfour_spec.rb
require 'connectfour.rb'
require 'spec_helper.rb'
describe Player do
let(:player_one){ Player.new("player_one", 1) }
let(:player_two){ Player.new("player_two", 2) }
describe "#name" do
it "returns each player's name" do
expect(player_one.name).to eql("player_one")
exp... |
class CheckBacklinkJob < ActiveJob::Base
queue_as :default
def perform(backlink)
page_body = HTTParty.get(backlink.referrer_page).body
doc = Nokogiri::HTML(page_body)
link_exists = doc.css('a').any? do |link|
link.attr(:href) =~ /#{backlink.referent_domain}/
end
backlink.set_active(link_... |
#!/usr/bin/ruby
require 'pathname'
require 'tempfile'
require 'libreconv'
class Libreconv::Converter
def command_env
# HACK: TZ を渡さないとUTCで日付評価されてしまう
Hash[%w[TZ HOME PATH LANG LD_LIBRARY_PATH SYSTEMROOT TEMP].map { |k| [k, ENV[k]] }]
end
end
class Converter
def self.convert(input_file, output_file, conve... |
class Cockatrice < Formula
desc "Cross-platform virtual tabletop for multiplayer card games"
homepage "https://cockatrice.github.io/"
url "https://github.com/Cockatrice/Cockatrice.git",
:tag => "2018-04-16-Release-2.5.1",
:revision => "1fbdea0f35c25313e7cf481b98552c92cc70a6ec"
version "2.5.1"
vers... |
class RenameTimeIdColumnToSessionId < ActiveRecord::Migration
def change
rename_column :sanctuaries_times, :time_id, :session_id
end
end
|
Rails.application.routes.draw do
root 'boats#index'
get ':user_name', to: 'profiles#show', as: :profile
get ':user_name/edit', to: 'profiles#edit', as: :edit_profile
patch ':user_name/edit', to: 'profiles#update', as: :update_profile
devise_for :users, :controllers => { registrations: 'registrations' }
r... |
# -*- coding: utf-8 -*-
require 'colorize'
require 'charlock_holmes'
def check_templates(path, color = true)
fail Errno::ENOENT unless File.exist?(path)
if File.ftype(path) == 'directory'
check_folder(path, color)
else
check_file(path, color)
end
rescue Errno::ENOENT
puts_warn "#{format(get_message(:... |
class Ipsum < ActiveRecord::Base
validates :theme, :presence => true
validates :motto, :presence => true
validates :phrases, :presence => true
end
|
require_relative '../action'
class Screenplay
module Actions
# @todo source: lets you point to a URL instead of using on_fail
class Yum < Screenplay::Action
def initialize(
package: nil,
state: :installed,
update_cache: false,
upgrade: false,
sudo: false,
... |
require 'rails_helper'
describe 'admin/case_study_gallery_images/edit' do
let(:title) { 'Short' }
let(:case_study_gallery_image) do
create(:case_study_gallery_image,
title: title)
end
before do
assign(:case_study_gallery_image, case_study_gallery_image)
render
end
... |
module ApplicationHelper
def page_header(title, tag='h1')
content_tag(:div, :class => 'page-header') do
content_tag(tag.to_sym, title)
end
end
def app
@app ||= App.default
end
end
|
FactoryGirl.define do
factory :service_request do
protocol nil
trait :with_protocol do
protocol factory: :protocol_imported_from_sparc
end
factory :service_request_with_protocol, traits: [:with_protocol]
end
end
|
class Contact < ApplicationRecord
belongs_to :user
belongs_to :contact, class_name: 'User'
validates_uniqueness_of :user_id, scope: :contact_id
def self.find_by_users(user_id, contact_id)
where('user_id = ? AND contact_id = ?', user_id, contact_id).or(
where('user_id = ? AND contact_id = ?', contact... |
require 'aws-sdk'
require 'aws-base'
# Registered entity
# This entity is saved totally under
class RegisteredEntity < AWSBase
DEVICE_INFO_DB = "DevicePathInfoDB"
DEVICE_COLUMN_NAME = "DeviceRegId"
attr_reader :db
def initialize
super # call super to setup for AWS
# Find the db that saves the d... |
module Concerns::WebMonitor::Validation
extend ActiveSupport::Concern
included do
attr_accessor :password_confirmation
validates :name, presence: true
validates :login,
presence: true,
uniqueness: { scope: :genre_id },
length: { in: 3..20 }
validates :password,
presence: t... |
require 'spec_helper'
require 'byebug'
require 'fixtures/default_test'
describe Ddoc do
let :fixtures do
File.dirname(__FILE__) + '/fixtures'
end
let :expected do
File.read(fixtures + "/#{test_name}_expected.ddoc.rb")
end
let :result do
File.read(fixtures + "/#{test_name}_result.ddoc.rb")
end... |
class PostsController < ApplicationController
before_action :set_post, only: %i[edit update destroy]
def index
@posts = current_user.posts
end
def post_hot
@posts = Post.where(view: :desc)
end
def post_new
@posts = Post.where(created_at: :desc)
end
def show
@post = Post.find_by(id: p... |
class ProductsController < ApplicationController
def index
@products = Product.page(params[:page]).per(20)
end
end
|
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
def index
render text: 'DUMMY APP'
end
def default_url_options
{ locale: 'en' }
end
protected
def... |
class BoardsController < ApplicationController
include UsersHelper
include PostsHelper
include BoardsHelper
def show
@board = Board.first
# refactor sql query, right now orders by sum(value) then updated_at, also assuming all posts are associated with the first board, and all comments are for post, gro... |
class PetsController < ApplicationController
before_action :set_pet, only: [:show, :update, :destroy]
# GET /pets
def index
@pets = Pet.all
render json: @pets
end
# GET /pets/1
def show
render json: @pet
end
# POST /pets
def create
@pet = Pet.new(pet_params)
if @pet.save
... |
class AddUserGroupIdToFollowUsers < ActiveRecord::Migration
def self.up
add_column :follow_users, :follows_group_id, :integer
add_column :follow_users, :fans_group_id, :integer
end
def self.down
remove_column :follow_users, :follows_group_id
remove_column :follow_users, :fans_group_id
end
end
|
#
# Cookbook Name:: pgbouncer
# Recipe:: default
# Author:: Christoph Krybus <ckrybus@googlemail.com>
#
# Copyright 2011, Christoph Krybus
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# ... |
require "builder"
require 'json'
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Sitemap
page "/sitemap.xml", layout: false
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Global Configuration
# Global Variables
set :global_url, "http://charactercount.io... |
# coding: utf-8
require 'rake'
require 'rake/rdoctask'
begin
require 'spec/rake/spectask'
rescue LoadError
begin
gem 'rspec-rails', '>= 1.0.0'
require 'spec/rake/spectask'
rescue LoadError
puts "RSpec - or one of it's dependencies - is not available. Install it with: sudo gem install rspec-rails"
e... |
module Formtastic
module SeparateDateAndTimePickerInput
class Processor
def self.process(attrs)
if attrs
attrs = Hash[attrs.dup]
datetime_attrs = {}
attrs.each do |key, value|
if attr = key[/\A(.*)\((date|time)\)\Z/, 1]
datetime_attrs[attr] |... |
class CreatePoliticians < ActiveRecord::Migration[5.0]
def change
create_table :politicians do |t|
t.string :first_name
t.string :last_name
t.string :party
t.string :religion
t.string :prior_experience
t.string :education
t.integer :birth_year
t.string :email
... |
# == Schema Information
#
# Table name: task_orders
#
# id :integer not null, primary key
# game_id :integer
# team_id :integer
# task_id :integer
# order_n :integer
# solved :boolean
# dropped :boolean
# time_start :datetime
# time_hint1 :datetime
# time_hint2 :datetime
# ... |
require 'spec_helper'
describe "Circle Pages" do
subject { page }
describe "circle page" do
let(:circle) { FactoryGirl.create(:circle) }
before { visit circle_path(circle) }
it { should have_content(circle.name) }
it { should have_title(full_title(circle.name)) }
end
describe "regist circle... |
module ThoughtLeadr
VERSION = '0.10.0'.freeze unless defined?(::ThoughtLeadr::VERSION)
end |
require 'logger'
class Logger
def debug_var(ctx, *vars)
class_name = ctx.eval("self.class").to_s
if class_name != "Class"
sep = "#"
else
class_name = ctx.eval("self.name")
sep = "."
end
/^(.+?):(\d+)(?::in `(.*)')?/.match(caller.first)
method_name = $3 ? $3 : ""
messa... |
# -*- coding: utf-8 -*-
class ItemsController < ApplicationController
before_filter :set_project_to_variable
def copy
item = find_item_from_params
copy_item = item.dup_deep(@project.org_project_task_id_map)
category_id = params[:category_id]
sub_category_id = params[:sub_category_id]
dst_param... |
require 'pry'
class MP3Importer
attr_accessor :path
def initialize(path)
@path = path
end
def files
files = Dir.entries(self.path)
files.select{|file| file.match(/.+[mp3]/)}
end
def import
entries = self.files
artist_song = {}
new_artist_song = {}
artist_object = nil
song... |
class AddStudentId < ActiveRecord::Migration[6.0]
def change
add_column :lists, :student_id, :int
end
end
|
require 'csv'
module ActiveModel
class CsvSerializer
@_attributes = []
@associations = []
@root = true
class << self
attr_accessor :_attributes, :associations, :root
end
def self.inherited(base)
base._attributes = []
base.associations = []
base.root = true
end
... |
module ColorFormulas
# this module uses a system app -iccApplyNamedCmm that must be installed in the PAtH to work
# CONStANtS
RGB_RANGE = 0..255
L_RANGE = 0..100
A_RANGE = -127..127
B_RANGE = -127..127
PATCH_SORT_HASH = {'Paper' => 0, 'Cyan' => 1, 'C70' => 2, 'C30'=> 3, 'Magenta' => 4, 'M70' => 5, 'M30' => ... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe User do
let(:blank_photo) { 'https://static.bpsd9.org/no_profile.png' }
let(:user) { create(:user) }
context 'with a new user' do
let(:user) { build(:user) }
it 'defaults to the blank profile photo' do
expect(user.photo).to eql(... |
class CommentsController < ApplicationController
def index
comments = Comment.all.order({ :created_at => :asc })
render({ :json => comments.as_json })
end
def show
the_id = params.fetch(:the_comment_id)
comment = Comment.where({ :id => the_id }).at(0)
render({ :json => comment.as_json })
... |
class PhotosDAO
def self.create_photo( photo_h, relation )
if relation == "User"
user_id = photo_h.delete( :user_id )
elsif relation == "Product"
product_id = photo_h.delete( :product_id )
end
photo = Photo.create( photo_h )
if relation == "User"
user = User.load_user_by_id( user_id )
user.... |
class PagesController < ApplicationController
def front
redirect_to home_path if user_signed_in?
end
end |
class MyHashSet # Clone Set class
attr_accessor :store
def initialize
@store = Hash.new { |h, k| h[k] = false }
end
def insert(element)
@store[element] = true
end
def include?(element)
store[element]
end
def delete(element)
if store[element]
@store[element] = false
... |
class Player
attr_reader :name
attr_accessor :stack, :playing, :hand, :bet, :called, :acted
def initialize(name, stack)
@name = name
@stack = stack
@hand = Hand.new
@called = 0 # what player has committed
@playing = false
@acted = false
end
def fold
@playing = false
@stack... |
class Product < ActiveRecord::Base
include Filterable
has_many :images
has_many :order_items
belongs_to :product_category
validates :name, presence: true, uniqueness: true
validates :descr, presence: true
validates :product_category, presence: true
default_scope {
where(available: true)
}
de... |
class Chapter < ApplicationRecord
extend FriendlyId
friendly_id :title, use: [:slugged, :finders]
belongs_to :book
acts_as_taggable_on :chapter_tags
validates :title, :contents, presence: true
end
|
module Exceptions
class UnhandledException < StandardError
end
class WorkerFailedJobNotfound < StandardError
end
class JobFailedParamError < StandardError
end
class JobFailedStepRaised < StandardError
end
class JobFailedStepRun < StandardError
end
end |
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
def self.per(per_page)
per_page ||= 20
offset = @page * per_page
return [] if @page != 0 && (count / offset) < 1
return all if per_page >= count
limit(per_page).offset(offset)
end
def self.page(page)
@page = (page... |
class Location
include Mongoid::Document
include Mongoid::Timestamps
field :restaurant, type:String
field :style, type:String
field :upvotes, type:Array
field :downvotes, type:Array
field :suggester_id, type:String
embedded_in :lunch
end
|
class MockPresenter
attr_accessor :recorded_errors
@display_errors_called = false
@display_success_called = false
@display_logs_called = false
@recorded_errors = []
def display_errors(errors)
@display_errors_called = true
self.recorded_errors = errors
end
def display_success(message)
@dis... |
class Clients
attr_accessor :name, :children, :age, :num_pets, :pet_name
def initialize(name, children, age, num_pets)
@name = name
@children = children
@age = age
@num_pets = num_pets
@pet_name = []
end
def to_s
puts "The client is #{@name}, has #{@children} kids, is #{@age} years old... |
class AddingShowInReportToDescriptiveIndicator < ActiveRecord::Migration
def self.up
add_column :descriptive_indicators,:show_in_report,:boolean,:default=>false
end
def self.down
remove_column :descriptive_indicators,:show_in_report,:boolean
end
end
|
class AddTotalCaloresToSandwiches < ActiveRecord::Migration[5.0]
def change
add_column :sandwiches, :total_calores, :integer, :default => 0
end
end
|
describe Advisor::Factory do
subject(:factory) { described_class.new(advice_klass) }
let(:advice_klass) do
Struct.new(:obj, :method, :call_args, :args) do
define_method(:call) { 'overridden!' }
define_singleton_method(:applier_method) { 'apply_advice_to' }
end
end
let(:advice_instance) do
... |
# frozen_string_literal: true
require 'application_system_test_case'
class HouseholdsTest < ApplicationSystemTestCase
setup do
@household = households(:one)
end
test 'visiting the index' do
visit households_url
assert_selector 'h1', text: 'Households'
end
test 'creating a Household' do
vis... |
require 'set'
module Racc
# Helper to implement set-building algorithms, whereby each member which is
# added to a set may result in still others being added, until the entire
# set is found
# Each member of the set (and the initial `worklist` if an explicit one is
# given) will be yielded once; the block sh... |
FactoryGirl.define do
factory :note do
identity nil
kind 'note'
trait :followup do
kind 'followup'
end
trait :reason do
kind 'reason'
end
factory :note_followup, traits: [:followup]
factory :note_reason, traits: [:reason]
end
end
|
require 'hpricot'
class Page < ActiveRecord::Base
IMAGE_ATTRIBUTES = ['src', 'alt']
ALLOWED_TAGS = ["div", "img"]
belongs_to :site, :autosave => true, :validate => true
validates_presence_of :path
validates_uniqueness_of :path, :scope => :site_id
validate :permission
named_scope :enabled, :conditions =... |
OmniAuth.config.logger = Rails.logger
Rails.application.config.middleware.use OmniAuth::Builder do
provider :google_oauth2, ENV['GOOGLE_OAUTH2_ID'], ENV['GOOGLE_OAUTH2_SECRET'], {application_name: ENV['APPLICATION_NAME'], application_version: ENV['APPLICATION_VERSION'], scope: 'userinfo.email,userinfo.profile,cal... |
#!/usr/bin/env ruby
class Solution14
def initialize
@counts_hash = Hash.new
@counts_hash[1] = 0
end
def collatz(n)
if n % 2 == 0
c = n / 2
else
c = 3 * n + 1
end
if !@counts_hash[c].nil?
@counts_hash[n] = @counts_hash[c] + 1
return @counts_hash[n]
else
... |
RSpec.describe "Addition" do
it "adds to numbers" do
expect(1 + 1).to eq 2
end
end
|
# encoding: utf-8
# Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
module MobileCenterApi
module Models
#
# Device Set
# The name and devices of the device set
#
class DeviceSet
# @return... |
class ApplicationController < ActionController::Base
include ScramUtils
helper_method :current_holder
protect_from_forgery with: :exception
def select_team
authenticate_user!
if current_user.current_team.nil?
redirect_to teams_path, alert: t('teams.no-selection')
end
end
rescue_from S... |
class LeadsController < ApplicationController
def new
@lead = Lead.new
end
def create
@lead = Lead.new(insightly_params_lead)
if @lead.save
InsightlyWorker.perform_async(@lead.id)
EmailWorker.perform_async(@lead.id)
flash[:success] = "Success! I will get in contact with you soon!"
... |
# Generator class will create HTML
#
require 'erb'
class Generator
attr_reader :max_images
def initialize()
@max_images = 10
end
def getImageRangeTo(list, from)
to = from + @max_images - 1
to = from + list.size - 1 if list.size < @max_images
return to
end
def getCurrentLink(list... |
class Exam < ApplicationRecord
has_many :student_exam_results
has_many :students, through: :student_exam_results
end
|
module DayBuilder
class Week
attr_reader :user
attr_accessor :options
def initialize(user, options = {})
@user = user
@options = options
end
def build
start_day = @options.key?(:start) ? DateTime.parse(@options[:start]) : user.start_of_week
final_day = start_day + 7.days
... |
class ChangeAttachmentAttributes < ActiveRecord::Migration
def up
remove_column :attachments, :conversation_file_name
remove_column :attachments, :conversation_content_type
remove_column :attachments, :conversation_file_size
remove_column :attachments, :conversation_updated_at
add_column :attachme... |
# -*- encoding : utf-8 -*-
module BanksHelper
def banks; Hash[Bank::BANKS.map{|k,v| ["#{k} — #{v}".html_safe,k]}] end
end
|
class Product < SnapshotCluster
cluster_of :product_snapshots
has_signature :recommendation
def get_all_products
prod_set = Set.new
snapshots.each do |snap|
prod_set.add(snap.get_product_title)
end
puts "\n---"
prod_set.each do |prod|
puts prod
end
puts "---"
return p... |
require "cinch"
require "open-uri"
require "json"
class Greeter
include Cinch::Plugin
match /hello$/, method: :greet
def greet(m)
m.reply "Hi there"
end
end
class LibreFM
include Cinch::Plugin
match /np\ ?(.*)/, method: :scrobble
def snark(m)
nick = m.user.nick
data = open("https... |
class UrlIsReserved < ActiveRecord::Migration[5.1]
def change
rename_column :competitor_products, :url, :amazon_url
rename_column :products, :url, :amazon_url
end
end
|
# We want to know the index of the vowels in a given word, for example, there are two vowels in the word super (the second and fourth letters).
#
# So given a string "super", we should return a list of [2, 4].
#
# Some examples:
#
# Mmmm => []
# Super => [2,4]
# Apple => [1,5]
# YoMama -> [1,2,4,6]
# NOTE: Vowels in t... |
Rails.application.routes.draw do
get '/restaurants', to: "restaurants#index"
get '/restaurants/new', to: "restaurants#new"
post '/restaurants', to: "restaurants#create"
get '/restaurants/:id', to: "restaurants#show", as: :restaurant
get '/restaurants/:id/edit', to: "restaurants#edit", as: :edit_restaurant... |
class AddUsers < ActiveRecord::Migration
def change
add_column :users, :users_admin, :boolean
add_column :users, :email, :string
end
end
|
module MDML
class Renderer
def self.render(tree, context)
new.render(tree, context)
end
def render(tree, context)
rendered = ''
if !tree.nil?
tree.each do |node|
rendered += _render_node(node, context)
end
end
rendered
end
p... |
class ModifyAttachments < ActiveRecord::Migration
def change
change_table :posts do |t|
t.remove :attachment
end
change_table :attachments do |t|
t.belongs_to :post, index: true
end
end
end
|
require 'json'
require 'json_builder/member'
module JSONBuilder
class Compiler
class << self
# Public: The helper that builds the JSON structure by calling the
# specific methods needed to build the JSON.
#
# args - Any number of arguments needed for the JSONBuilder::Compiler.
# bl... |
class Web::WelcomeController < Web::ApplicationController
def index
@articles = Article.includes(:authors).published
@main_video = Video.main.last
@cool_videos = Video.cool.last 2
end
end
|
class FontSahitya < Formula
head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/sahitya"
desc "Sahitya"
homepage "https://fonts.google.com/specimen/Sahitya"
def install
(share/"fonts").install "Sahitya-Bold.ttf"
(share/"fonts").install "Sahity... |
require 'spec_helper'
describe Snippet do
def reset_snippet(options = {})
@valid_attributes = {
:id => 1,
:title => "RSpec is great for testing too"
}
@snippet.destroy! if @snippet
@snippet = Snippet.create!(@valid_attributes.update(options))
end
before(:each) do
reset_snippet
... |
unless defined?(::ApplicationFilterContext)
class ApplicationFilterContext < Datapimp::Filterable::Context
end
end
class FilterContext < ApplicationFilterContext
cached
def admin?
user.admin?
end
def sort_by
params.fetch(:sort_by, nil)
end
def limit
params.fetch(:limit, 150)
end
end
|
module Member
class BankCardsController < JsonController
def index
user = Users::User.find(params[:member_id])
@cards = user.bank_cards
end
end
end
|
class CredibilityScoreJob < ApplicationJob
def perform(id)
applicant = Applicant.find_by(id: id)
score = Credibility.new(applicant).get_score if applicant
applicant.update(credibility_score: score) if applicant && score.positive?
end
end
|
# Main entry point into the application.
module LifeGameViewer
class Main
def self.view_sample
LifeGameViewerFrame.view_sample
end
def self.view(model)
LifeGameViewerFrame.new(model).visible = true
end
end
end
|
require "rails_helper"
describe RemoteResources::IndividualResource do
let(:example_data) {
o_file = File.open(File.join(Rails.root, "spec/data/remote_resources/individual.xml"))
data = o_file.read
o_file.close
data
}
describe "given a requestable object and an individual id url" do
let(:re... |
hash = {
foo: 'bar'
}
pp hash[:boo] # => nil
h = Hash.new { |h, k| h[k] = k.to_i * 10 }
pp h[10] # => 100
pp hash[:foo] # => 'bar'
# Hash クラス実装の空想:
# class Hash
# def initialize(ifnone = nil)
# @ifnone = ifnone
# self # 自分自身を返す
# end
# def [](key)
# return @ifnone if self[key].nil?
# end
# e... |
class Public::SharedListsController < ApplicationController
skip_before_action :authenticate_user!, only: :show
before_action :find_shared_list, only: :show
layout "public"
def show
@documents = DocumentDecorator.decorate_collection(@shared_list.documents.validated.includes(attachment_attachment: :blob))
... |
require 'yaml'
require 'ostruct'
module Monexa
def self.config_file
path = File.join(ROOT, 'config')
path = '.' unless File.directory?(path)
File.expand_path(File.join(path, CONFIG_NAME))
end
def self.init_config(config = nil)
path = File.expand_path(config||config_file)
raise "Failed to ... |
require 'spec_helper'
describe 'omnitruck instance users' do
describe user('omnitruck') do
it { should exist }
it { should belong_to_group 'omnitruck' }
it { should have_home_directory '/srv/omnitruck' }
it { should have_login_shell '/bin/false' }
end
[
'/srv/omnitruck',
'/srv/omnitruck... |
require 'byebug'
class PolyTreeNode
attr_accessor :parent, :children
attr_reader :value
def initialize(value)
@value = value
@parent = nil
@children = []
end
def parent=(new_parent)
# debugger
if new_parent == nil
@parent.children.delete(self) if @parent
@parent = nil
e... |
# encoding: utf-8
$: << 'RspecTests/Generated/head'
require 'rspec'
require '1.0.0/generated/head'
include HeadModule
describe 'Head' do
before(:all) do
@base_url = ENV['StubServerURI']
dummyToken = 'dummy12321343423'
@credentials = MsRest::TokenCredentials.new(dummyToken)
@clien... |
class CreateTweets < ActiveRecord::Migration
def change
create_table :tweets do |t|
t.column :username, :string
t.column :handle, :string
t.column :tweet_text, :string
t.column :user_id, :integer
t.column :hashtag, :string
t.timestamps
end
end
end
|
#練習問題
#好きな数だけ単語の入力をしてもらい(1行に1単語、最後はEnterだけの空行)、 アルファベット順に並べ変えて出力するようなプログラムを書いてみましょう?
##ヒント: 配列を順番に並び替える(ソートする)には 素敵なメソッド sortがあります。 これを使いましょう。
#(訳注:配列 ary の最後に要素 elem を追加するには、ary << elem と 記述します。)
puts "気が済むまで単語をいれてね!"
tango = nil
ary = %w()
while tango != "\n"
tango = gets
ary << tango.chomp
end
puts ary.sort
... |
class FeatsController < ApplicationController
before_filter :get_user
# GET /feats
# GET /feats.xml
def index
@date = params[:date].present? ? Date.parse(params[:date]) : Date.today
beginning_of_day, end_of_day = @date.beginning_of_day, @date.end_of_day
@feats = @person.feats.all(
:include =>... |
require 'rspec'
require 'json'
require_relative '../model/calendario'
require_relative '../model/GestorCalendario'
require_relative '../model/calendario_nombre_existente_error'
require_relative '../model/calendario_sin_nombre_error'
require_relative '../model/calendario_inexistente_error'
describe 'GestorCalendario' ... |
class Category < ApplicationRecord
has_many :categorizes, dependent: :destroy
has_many :posts, through: :categorize
end
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Chat, type: :model do
it { should validate_presence_of(:name) }
it { should validate_presence_of(:privacy) }
it { should allow_values('public', 'private', 'protected').for(:privacy) }
it { should have_secure_password }
it 'is not valid wit... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.