text
stringlengths
10
2.61M
require 'date' module ControlledRecord GRACE_DAYS = 90 ControlRelationship = Struct.new(:definition, :jsonmodel, :agency_model, :record, :agency) def self.included(base) base.extend(ClassMethods) end def update_from_json(json, opts = {}, apply_nested_records = true) self.class.ensure_controller_...
# -*- mode: ruby -*- # vim: set ft=ruby : home = ENV['HOME'] ENV["LC_ALL"] = "en_US.UTF-8" MACHINES = { :pam => { :box_name => "centos/7", :ip_addr => '172.16.0.100', } } Vagrant.configure("2") do |config| MACHINES.each do |boxname, boxconfig| config.vm.define boxname do ...
class Effect < ApplicationRecord belongs_to :symptom belongs_to :supplement belongs_to :user, optional: true has_and_belongs_to_many :packs validates :symptom, :supplement, presence: true end
require "stringfire/version" module Stringfire class Interpreter def split_first_word str result = str.strip.split /\s/, 2 result << "" while result.size < 2 result end def initialize @commands = { } default { |command, *args| command } end def command name, &bloc...
# Welcome Stranger =begin (Understand the Problem) Problem: Create a method that takes 2 arguments, an array and a hash - The array will contain 2 or more elements that, when combined with adjoining spaces, will produce a person's name - The hash will contain two keys, :title and :occupation, and the...
namespace :carrierwave do desc 'Will iterate through all images, moving the file from the file from Dragonfly (and Lunicores S3) to a Carrierwave field in each post (and TLTHs S3).' task(images: :environment) do images = Image.all failed = [] images.each do |i| begin if i.file.present? ...
class FeedbacksController < ApplicationController expose(:feedback, attributes: :feedback_params) def new end def create if feedback.save FeedbackMailer.feedback_message(feedback).deliver flash[:success] = "Your feedback has been submitted" redirect_to root_path else render :ne...
# frozen_string_literal: true class YhArticlesController < ApplicationController before_action :set_yh_article, only: %i[show edit update destroy taken] # GET /yh_articles # GET /yh_articles.json def index @q = YhArticle.ransack(params[:q]) @yh_articles = @q.result(distinct: true) @yh_articles = @...
Given /^an url "([^"]*)"$/ do |url| Capybara.app_host = url visit "" @Sitebuilder=Sitebuilderfinch.new(Capybara.current_session) #website is the iframe name of droppable area @droppableiframe="website" end When /^user drag and drop "([^"]*)" box$/ do |modulename| @Sitebuilder.dragelement_into_...
class Account include Mongoid::Document include BCrypt attr_accessor :password field :first_name, type: String field :last_name, type: String field :username, type: String field :password_digest, type: String validates :username, uniqueness: { message: ': "%{value}" is already taken'}, presence: {mes...
class Subject < ActiveRecord::Base acts_as_cached attr_accessible :name, :description, :visible belongs_to :domain belongs_to :user has_many :studies validates_presence_of :name end
class Country < ActiveRecord::Base belongs_to :region, :inverse_of => :countries attr_accessible :region_id attr_accessible :description, :h1, :keywords, :name attr_accessible :datanezavis, :stolica, :ploscha, :delenie, :glava, :zakon, :ispolnit, :naselenie, :language, :offname, :valute attr_accessible :descf...
require 'date' class GuardEvent attr_reader :id, :date, :event def initialize(date, a, id, event) @id = id.to_i @date = DateTime.parse(date) @event = event end def <=>(other) @date <=> other.date end def sleep? @event == "falls asleep" end def wake? @event == "wakes up" en...
class UserMailer < ActionMailer::Base default from: "info@dailydocket.org" def password_reset(user) @user = user mail :to => user.email, :subject => "DailyDocket: Password Reset" end # => method for post activated # => method for notification end
module Repository def download_vendor(options) options = { artifacts: options[:product], unzip_directory: "#{node[:installs_directory]}\\#{options[:product]}", }.merge options download(options) unzip(options) end def download(options) target_directory = node[:installs_directory] ...
# frozen_string_literal: true # Repeat the block until it returns a truthy value. Returns the value. Puppet::Functions.create_function(:'ctrl::do_until') do # @param options A hash of additional options. # @option options [Numeric] limit The number of times to repeat the block. # @example Run a task until it suc...
Rails.application.routes.draw do resources :stimulus, only: [:index] do collection do get :clock get :nested_form end end root 'stimulus#index' end
class UsersController < ApplicationController before_filter :authenticate_user! def show @user = User.find(params[:id]) end def index # @users = User.paginate(:page => params[:page], :per_page => 5) @filterrific = initialize_filterrific( User, p...
class TeamsController < ApplicationController before_action :find_team_and_authorize, only: [:show, :edit, :update, :delete, :destroy, :import, :chart_fields_details_by_team] before_action :find_teams, only: [:index, :create, :update, :destroy] before_action :find_questions, only: [:index, :chart_questions_by_tea...
require 'rails_helper' RSpec.describe Api::DishesController, type: :controller do describe "GET #index" do let!(:restaurant) { create(:restaurant, :with_dishes) } let!(:dishes) { restaurant.dishes } context "without restaurant id parameters" do before(:each) { get :index } it "returns all d...
# frozen_string_literal: true module Decidim module Opinions module Admin # A form object to be used when admin users want to review a collection of opinions # from a participatory text. class PreviewParticipatoryTextForm < Decidim::Form attribute :opinions, Array[Decidim::Opinions::Adm...
class User < ApplicationRecord extend FriendlyId include ApplyJob include SaveJobs include ViewJob include PgSearch # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable has_one :employer, class_name: 'CompanyEmployee' has_one :company, thro...
require 'spec_helper' describe Title do it { should have_and_belong_to_many :authors } it "validates the presence of title" do title = Title.new(title: '') expect(title.save()).to eq(false) end it "will capitalize the name of the title" do title = Title.create(title: "the divide") expect(titl...
# frozen_string_literal: true require 'rails_helper' RSpec.describe V1::BanksController, type: :routing do describe 'routing' do let(:default_version) { 'v1' } it 'routes to #index' do expect(get: 'http://api.example.com/banks').to route_to( controller: "#{default_version}/banks", act...
module ApplicationHelper def diver(n) (12/n).to_i end def append_first(base_text, append_text) @appended ||= {} appended_text = append_text(base_text, append_text, !@appended[base_text]) @appended[base_text] ||= true appended_text end def append_text(base_text, append_text, if_true) if_...
class CreateCharacterEnvironments < ActiveRecord::Migration[5.0] def change create_table :characterenvironments do |t| t.integer :character_id t.integer :environment_id end end end
require 'net/http' module BswTech module JenkinsGem module JenkinsListFetcher def self.get_available_versions response = Net::HTTP.get_response(URI('http://mirrors.jenkins.io/war-stable/')) response.body.scan(/href="(\S+)\/"/) .map {|groups| groups[0]} .reject {|version|...
require "test_helper" class SmokeTest < ActionDispatch::IntegrationTest test "view home page" do visit root_path assert page.has_content?('Bmore on Rails is a community of Baltimore folks') end test "navigate to school page" do visit root_path within('header') { click_on 'School' } assert pa...
class ChangeNewsitemsIndex < ActiveRecord::Migration[4.2] def change remove_index :newsitems, :feed_id add_index :newsitems, [:feed_id, :id], :unique => true remove_index :feeds, :category_id add_index :feeds, [:category_id, :id], :unique => true end end
# Adapted from jnunemaker/httparty/examples/delicious.rb to demonstrate path-to's metadata-driven client API capability require 'path-to/described_routes' require 'pp' # read $HOME/.delicious (YAML format): # username: <username> # password: <password> config = YAML::load(File.read(File.join(ENV['HOME'], '.delici...
#!/usr/local/bin/ruby # Class Impedance: インピーダンスオージオメータ データ取扱い用クラス # Copyright 2012 S Mamiya # 0.20121102 : initial ver if defined? Rails require 'RS22.rb' require 'bitmap.rb' else require './RS22.rb' require './bitmap.rb' end # railsの場合,directoryの相対表示の起点は rails/audiserv であるようだ class Impedance < Bitmap ...
class AddUsingToInventories < ActiveRecord::Migration def change add_column :inventories, :wearing, :boolean end end
class AddColumnCategoryToEquipment < ActiveRecord::Migration[5.2] def up add_column :equipment, :category_id, :bigint, null: false, default: 0 change_column :equipment, :category_id, :bigint, default: nil add_index :equipment, :category_id end def down remove_column :equipment, :category_id end...
# frozen_string_literal: true module Types class Application < GraphQL::Schema::Object description "Application's Object Type" field :id, Integer, null: false field :description, String, null: true end class Player < GraphQL::Schema::Object field :id, Integer, null: false field :name, Strin...
# Source: https://launchschool.com/exercises/db673773 def rotate_array(arr) arr[1..-1] + [arr[0]] end def rotate_rightmost_digits(int, place) arr = int.to_s.chars arr[-place..-1] = rotate_array(arr[-place..-1]) arr.join.to_i end def max_rotation(int) rotation_digits = int.to_s.size rotation_digits.downto...
class Course < ApplicationRecord has_many :users, primary_key: :id, foreign_key: :student_id, class_name: :User end
class FundingRound attr_reader :startup, :venture_capitalist, :investment attr_accessor :type @@all = [] def initialize(startup, venture_capitalist, type, investment) @startup = startup @venture_capitalist = venture_capitalist @type = type @investment = investment.to_f @@all << self end ...
class Incident < ApplicationRecord scope :filter_by_last_name, -> (last_name) { where last_name: last_name } scope :filter_by_age, -> (age) { where age: age } scope :filter_by_gender, -> (gender) { where gender: gender } scope :filter_by_race, -> (race) { where race: race } scope :filter_by_date, -> (date) { ...
=begin Write a program that prints a greeting message. This program should contain a method called greeting that takes a name as its parameter and returns a string. greeting('Ben') -> print out 'Hello Ben. How are you doing?' =end def greeting(name) print "Hello #{name}. How are you doing?" end greeting("Ben")
class CreateProjects < ActiveRecord::Migration def change create_table :projects do |t| t.string :url, null: true t.string :title, null: false t.integer :user_id, null: false t.integer :stars_count, null: true, default: 0 t.integer :comments_count, null: true, default: 0 t.text...
module MastersHelper def services_empty? @master.predefined_master_services.empty? and @master.custom_master_services.empty? end end
# frozen_string_literal: true module ActiveAny module Core extend ActiveSupport::Concern included do class_attribute :primary_key, instance_writer: false self.primary_key = nil end class_methods do delegate :includes, :take, :take!, :first, :last, to: :all end module Clas...
# Write a method that takes a string argument, and returns true if all of the alphabetic characters inside the string are uppercase, false otherwise. Characters that are not alphabetic should be ignored. def uppercase?(string) string.chars.all? do |char| if /[a-zA-Z]/.match(char) char.upcase == char el...
require 'rspec' require_relative '../lib/vending_machine' require_relative '../lib/coins' require_relative '../lib/products' describe 'Vending Machine' do subject(:vendingMachine) {VendingMachine.new} it 'has a method to display info to customers' do is_expected.to respond_to :check_display end ...
# This is a compressed migration for creating all Alchemy 2.6 tables at once. # # === Notice # # In order to upgrade from an old version of Alchemy, you have to run all migrations from # each version you missed up to the version you want to upgrade to, before running this migration. # class AlchemyTwoPointSix < ActiveR...
Rails.application.routes.draw do devise_for :users # Routes for the Comment resource: # CREATE # get "/comments/new", :controller => "comments", :action => "new" # post "/create_comment", :controller => "comments", :action => "create" # # # READ # get "/comments", :controller => "comments", :action => "...
require 'zlib' require 'rake/tasklib' module RequirejsOptimizer class Rake::Task < ::Rake::TaskLib include ::Rake::DSL include ::RequirejsOptimizer::Rake::Utils attr_accessor :name def initialize(name="requirejs") @name = name end def define_tasks define_task_deeply(name, "Opti...
class VisitLog < ActiveRecord::Base attr_protected :category_ids, :content_id, :uniq_key, :unsigned_user_id def self.visit_log(category_ids, content_id, uniq_key) category_ids = "none" if category_ids.blank? uniq_key = Digest::MD5.hexdigest(uniq_key) unsigned_user = UnsignedUser.where(:uniq_key => un...
require_relative("engine") require_relative("order") require_relative("product_bundle") class Application def self.run(input) products = self.populate_products order_engine = Engine.new parser = OrderParser.new(input) customer_order = parser.order customer_order.each do |item| if ...
Pod::Spec.new do |s| s.name = 'Stripe' # Do not update s.version directly. # Instead, update the VERSION file and run ./ci_scripts/update_version.sh s.version = '23.15.0' s.summary = 'Accept online payments using Stripe.' s.license ...
require File.dirname(__FILE__) + '/setup' require 'javaclass/classlist/jar_searcher' require 'javaclass/classpath/folder_classpath' require 'javaclass/classpath/jar_classpath' module TestJavaClass module TestClassList class TestJarSearcher < Test::Unit::TestCase PACKAGE_CLASS = "packagename/PackageClass....
# == 分散ロック # # # Author: Yuji Mise # Copyright 2014 # module Grape module Support module DistributeLock class LockError < StandardError; end def lock_for_update(key, timeout: 60, max_attempts: 10) return unless lock(key, timeout, max_attempts) yield if block_given? ensure ...
class JoinUsernameControllerStylesheet < ApplicationStylesheet # Add your view stylesheets here. You can then override styles if needed, example: # include FooStylesheet def setup # Add stylesheet specific setup stuff here. # Add application specific setup stuff in application_stylesheet.rb end def ...
class StaticPagesController < ApplicationController def home if (current_user) redirect_to dashboard_path end end end
class Experience < ApplicationRecord belongs_to :user belongs_to :category has_many :bookings, dependent: :destroy has_many :schedules, dependent: :destroy has_attachments :photos, maximum: 5 validates :title, presence: true,length: {maximum: 20}, on: :create, allow_nil: false validates :description, pre...
# 剪绳子 # 一根长度为n的绳子,请把绳子剪成m段 (m和n都是整数,n>1且m>1), 每段绳子的长度记为k[0],k[1],…,k[m].请问k[0]*k[1]…*k[m]可能的最大乘积是多少? # 例如: 当绳子的长度为8时,我们把它剪成长度分别为2,3,3的三段,此时得到的最大乘积是18. def cut_string(string_len) # 长度小于等等于1没办法剪 # 长度为2的绳子,只有一种剪法,剪成长度为1的绳子,剪后的乘积为1 # 长度为3的绳子,只有一种剪法,剪成长度为1和2的绳子,剪后的乘积为2 return 0 if string_len <= 1 return 1 if st...
# 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...
require "rails_helper" describe Mediable, vcr: true, order: :defined do let(:username) { ENV["MDS_USERNAME"] } let(:password) { ENV["MDS_PASSWORD"] } let(:options) { { username: username, password: password } } let(:doi) { "10.14454/05MB-Q396" } let(:data) { "application/pdf=https://schema.datacite.org/meta/...
class RenameToProfileUrls < ActiveRecord::Migration def self.up rename_table :plugin_data_posts, :profile_urls end def self.down end end
require "#{File.dirname(__FILE__)}/spec_helper" describe 'main application' do include Rack::Test::Methods def app Gitserved::Application end before(:each) do @id = '62ce8735d9db521de4c840d1a3975d3af420a596' Gitserved::Application.any_instance.stubs(:repo).returns(TestRepo.repo) end it 'shou...
lib = File.expand_path("../lib", __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "pg/doc/version" Gem::Specification.new do |gem| gem.name = "pg-doc" gem.version = PG::Doc::VERSION gem.authors = ["Kenaniah Cerny"] gem.email = ["kenaniah@gmail.com"] gem.l...
class Donation < ApplicationRecord belongs_to :campaign validates :amount, numericality: { greater_than: 0 } end
class Product < ActiveRecord::Base attr_accessible :title, :price, :description, :img_url, :stock validates_numericality_of :price validates_numericality_of :stock, greater_than_or_equal_to: 0, :with=>/\A[+\-]?\d+\Z/ end
require 'test_helper' class FootprintsControllerTest < ActionController::TestCase setup do @footprint = footprints(:one) end test "should get index" do get :index assert_response :success assert_not_nil assigns(:footprints) end test "should get new" do get :new assert_response :succ...
class Quiz < ActiveRecord::Base belongs_to :client has_many :sections has_many :answers def average_for section section = Section.where(name: section) question = Question.where(section: section) section_answers = answers.where(question: question) section_length = section_answers.length secti...
class AdminMailer < ApplicationMailer default to: 'email@example.com' def user_details(user) @user = user application_name = t 'application_name' attachments["#{application_name} - User details.pdf"] = render_to_string mail( subject: t('.subject', application_name: application_name, id: use...
FactoryBot.define do factory :court_reminder do reporting_relationship { create :reporting_relationship } body { "i am a court reminder #{SecureRandom.hex(17)}" } court_date_csv { create :court_date_csv } send_at { Time.zone.now + 2.days } end end
class CreateAdherences < ActiveRecord::Migration def change create_table :adherences do |t| t.integer :patient_id t.integer :message_id t.integer :response_rate t.string :overall_adherence t.timestamps end end end
module PdfTempura module Render class BoxedCharacters include OptionAccess include FieldBounds attr_accessor :field,:value def initialize(field, value, options = {}) @field = field @options = options @value = value ? value.dup : "" validate_value_length! ...
Rails.application.routes.draw do # Serve websocket cable requests in-process mount ActionCable.server => '/cable' devise_for :users resources :user do resources :chats, only: [:index, :show, :create] end resources :messages, only:[:create] root 'chats#index' end
require('minitest/autorun') require('minitest/rg') require_relative('../bears') require_relative('../river') require_relative('../fish') class TestRiver <MiniTest::Test def setup blinky_fish = Fish.new('Blinky') jp_fish = Fish.new('James Pond') dory_fish = Fish.new('Dory') cleo_fish = Fish.new('Cleo...
require 'drb/drb' module Haystack class IPC class << self def forked! Server.stop Client.start Haystack.agent.stop_thread end end class Server class << self attr_reader :uri def start local_tmp_path = File.join(Haystack.config.root_pat...
require 'rails_helper' RSpec.describe BatchItem, :clean, type: :model, admin_set: true do subject { batch.batch_items.create(accession_number: accession_number, attribute_hash: attributes, row_number: 1) } let(:batch_item) { subject } let(:submitter) { 'jqdoe@example.edu' } let(:job_id) { 'e5942432-cfd1-46f0-...
require 'test_helper' class OutputTest < ActiveSupport::TestCase test "output attributes must not be empty" do output = Output.new assert output.invalid? assert output.errors[:title].any? assert output.errors[:inventor].any? assert output.errors[:idfdate].any? assert output.errors[:cifdate]....
# Tealeaf Academy Prep Course # Intro to Programming Workbook # Intermediate Questions - Quiz 2 # Exercise 3 def tricky_method(a_string_param, an_array_param) a_string_param += "rutabaga" an_array_param += ["rutabaga"] return a_string_param, an_array_param end my_string = "pumpkins" my_array = ["pumpkins"] my_...
class WingOrdersController < ApplicationController def index @wing_orders = WingOrder.all end def new @wing_order = WingOrder.new @state_collection = WingOrder::STATES @quantity_collection = WingOrder::QUANTITIES @flavor_collection = Flavor.all end def create @wing_order = WingOrder....
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') include BlacklightHelper describe BlacklightHelper do describe "#application_name" do it "should return the name of the application" do expect(helper.application_name).to eq("SALT (Self Archiving Legacy Toolkit)") end end descr...
describe ProposalPolicy::Scope do let(:proposal) { create(:proposal, :with_parallel_approvers, :with_observers) } it "allows the requester to see" do user = proposal.requester proposals = ProposalPolicy::Scope.new(user, Proposal).resolve expect(proposals).to eq([proposal]) end it "allows an reques...
# encoding: utf-8 require 'spec_helper' describe 'bin/ktl topic' do include_context 'integration setup' before do register_broker(0) register_broker(1) end describe 'list' do before do create_topic(%w[topic1 --partitions 1 --replication-factor 1]) end it 'lists current topics to ...
class VotingEndingJob < ActiveJob::Base queue_as :default def perform @expired_petitions = Petition.expired @expired_petitions.each do |petition| if petition.successful_vote? UserMailer.succeed_petition_notice(petition.user, petition).deliver_later UserMailer.succeed_petition_admin_no...
module Workers class GlobalUserNotifier < Base def perform(user_id) user = User[user_id] return unless user ::Notification.create({ user: user, subject: "#matchfunding", text: "Batemos nossa meta! Graças a você o Tem Açúcar 2.0 vai acontecer!!! Muito obrigada pela colabor...
# Question::find_by_author_id(author_id) # Question#author # Question#replies (use Reply::find_by_question_id) require_relative 'users' require_relative 'question_follows' require_relative 'questions_database' require_relative 'question_likes' class Question attr_accessor :id, :title, :body, :user_id def self.al...
require "colorize" require_relative "square.rb" class Board def initialize @object_board = Array.new(8){Array.new(8){Square.new}} @display_board = [] end def to_s @display_board = Marshal.load(Marshal.dump(@object_board)) convert_each_square_to_string add_borders_a...
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'nutracoapi/version' Gem::Specification.new do |spec| spec.name = "nutracoapi" spec.version = Nutracoapi::VERSION spec.authors = ["Filipe Chagas"] spec.email =...
module OverridesField module ClassMethods def overrides_field(*fields) options = fields.extract_options! fields.each do |field| override_field field, options end end def override_field(field, options) from = options[:from] condition = options[:if] ...
require 'sinatra' require 'sinatra/reloader' if development? require 'fileutils' class KickstartServer < Sinatra::Base configure :development do register Sinatra::Reloader end def initialize super @current_version = "0.1.0" end get '/kickstart' do mac = "#{%x[arp #{request.ip}].split(/\s+...
class CreateCourseSurvey2Records < ActiveRecord::Migration def change create_table :course_survey_2_records do |t| t.integer :course_survey_id t.string :attend_class t.text :attend_class_reason t.string :interesting_level t.string :keywords t.string :understand_level t.t...
require "rspec/helper" describe "configuration" do let(:env) { Jekyll::Assets::Env.new(stub_jekyll_site) } it "adds the configuration onto env" do expect(env.config).not_to be_empty end end
require File.dirname(__FILE__) + '/../../spec_helper' require 'cucumber/paths' module Cucumber module Paths describe Paths do it "does a block of code for Regexp" do Path /^I am simple step$/ do "simple" end path_to("I am simple step").should == "simple" end it "does a block ...
require 'okcomputer' require 'timeout' # /status for 'upness', e.g. for load balancer # /status/all to show all dependencies # /status/<name-of-check> for a specific check (e.g. for nagios warning) OkComputer.mount_at = 'status' OkComputer.check_in_parallel = true # REQUIRED checks, required to pass for /status/all #...
class QwyzItemsController < ApplicationController before_filter :authenticate, only: [:destroy, :edit, :update, :create] before_filter :correct_user, only: [:destroy, :edit, :update] def new @title = "Add a new Qwyz Item" @qwyz = Qwyz.find(params[:qwyz_id]) @qwyz_item = QwyzItem.new @qwyz_item.qwyz_id = @q...
module Private::ConversationsHelper include Private::MessagesHelper def private_conv_recipient(conversation) conversation.opposed_user(current_user) end def add_to_contacts_partial_path(contact) if recipient_is_contact? 'private/conversations/show/heading/already_in_contacts' else non_...
require 'regexp_senario' class AlternationPattern1 < RegexpSenario def initialize super( "/a(b|c)d/.match(\"acd\")", %w('a' ALT PAT 'b' /PAT) + %w(PAT 'c' /PAT /ALT 'd'), "acd".split(//) ) end def body [status(0, 0), match('a', "i+=1; r+=1"), status(1, 1), reaction("r == AlternationOpen",...
class Item < ActiveRecord::Base belongs_to :user belongs_to :list before_create :default_attributes, :capitalize validates :name, presence: true, length: { minimum: 1 } validates :user, presence: true scope :incomplete, -> { where(complete: false).order('created_at') } scope :complete, -> { where...
class CreateEduClusters < ActiveRecord::Migration def self.up create_table :edu_clusters do |t| t.string :name t.integer :ugroups_count end end def self.down drop_table :edu_clusters end end
require "spec_helper" describe "Add rating on event", :type => :request, :js => true do it_behaves_like "a rateable" do let!(:rateable) { create(:event, :tasafoconf, :users => [ user ], :owner => user.id) } let!(:rateable_path) { event_path rateable } end end
require 'oystercard.rb' describe Oystercard do it 'checks that the oystercard has an initial value of 0' do expect(subject.balance).to eq 0 end describe '#top_up' do it { is_expected.to respond_to(:top_up).with(1).argument } it 'checks the increase balance in the card' do expect{ subjec...
require 'dabooks/filter' require 'dabooks/formatter' require 'dabooks/table_formatter' require 'dabooks/parser' module Dabooks class Amount include Comparable value_semantics do cents Either(Integer, nil), coerce: true end def self.coerce_cents(value) if value.is_a?(String) Inte...
# frozen_string_literal: true module FS module Rmk2 class Node class << self attr_accessor :logger, :datadir def init(mp, logger: LOGGER) @logger = logger return unless @mounted ||= system("mount #{mp}") @datadir = File.join(mp, ...
require 'rails_helper' RSpec.describe Artist, type: :model do describe 'validations' do it { is_expected.to validate_presence_of(:name) } it { is_expected.to validate_presence_of(:spotify_url) } it { is_expected.to validate_presence_of(:spotify_id) } end describe 'relations' do it { is_expected....