text
stringlengths
10
2.61M
module RemoteCommandHelpers def test_dir_exists(path) exists?('d', path) end def test_symlink_exists(path) exists?('L', path) end def test_file_exists(path) exists?('f', path) end def exists?(type, path) %{[ -#{type} "#{path}" ] && echo "#{path} exists." || echo "Error: #{path} does no...
# save a screenshot to cloudinary class Screenshot def initialize(url) @url = url end def destroy! uploader.destroy(@url, type: 'url2png') if @response end def save! @response = uploader.explicit(@url, type: 'url2png') end def remote_url @response['url'] if @response end private ...
ActiveRecord::Schema.define(version: 2021_07_13_202427) do create_table "carts", force: :cascade do |t| t.integer "customer_id", null: false t.float "total" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false t.index ["customer_id"], name: "index_...
N = 1 server_ips = Array.new(N) { |i| "192.168.71.#{20 + i}"} M = 3 client_ips = Array.new(M) { |k| "192.168.74.#{20 + k}"} Vagrant.configure("2") do |config| (0..M-1).each do |j| config.vm.define "rabbit#{j}" do |machine| machine.vm.box = "ValFadeev/rabbitmq" machine.vm.hostnam...
class UserMailer < ActionMailer::Base default from: "powerprjct@gmail.com" def welcome_email(user) @user = user @url = 'http://www.powerproject.com' attachments.inline["powerpuff-girls.jpg"] = File.read(Rails.root.join('app/assets/images/powerpuff-girls.jpg')) mail(to: @user.email, subject: "Welco...
And(/^User gives a name to the circle$/) do @app.createcircle.enter_crcl_name end And(/^User selects new "([^"]*)" circle$/) do |circle_type| @app.createcircle.select_circle_type(circle_type) end And(/^User selects "([^"]*)" as contribution frequency$/) do |frqncy_type| @app.createcircle.select_cntrb...
class RenameTreeElementSortOrdrt < ActiveRecord::Migration def self.up rename_column :tree_elements, :sort_ordrt, :sort_order end def self.down rename_column :tree_elements, :sort_order, :sort_ordrt end end
require 'result' module Core class Estimations def initialize @estimation_rooms = {} end def add(room: nil, name:, description:) return Result.failure(:empty_name) if name.strip.empty? estimations = estimations_in(room) estimation = estimations.find{|e|e[:name] == name} ret...
class GameItemAnswer < ActiveRecord::Base include Accessable has_one :origin, as: :originable belongs_to :game_item belongs_to :user has_one :game_related_item, through: :game_item scope :correct, -> { where(correct: true) } scope :wrong, -> { where.not(correct: true) } validates :game_item, :user...
class UsersController < ApplicationController before_action :logged_in_user, only: [:index, :edit, :update, :destroy] before_action :correct_user, only: [:edit, :update] before_action :admin_user, only: [:index, :destroy] def index @users = User.paginate(page: params[:page]).per_page(5) end def show @user =...
Rails.application.routes.draw do # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html get '/404', :to => 'errors#not_found' get '/500', :to => 'errors#internal_server_error' authenticated_constraint = lambda do |request| request.env['rack.session'][:user_id]....
class Anuncio < ActiveRecord::Base belongs_to :usuario validates :contenido, presence: true, length: {in: 1..140} validates :usuario, presence: true end
class Tartarus::Notifiers::Mail < ActionMailer::Base def notification(address, exception) subject = "#{Tartarus.configuration['notification_prefix']}Exception raised at #{exception.controller_path}##{exception.action_name} (#{exception.exception_class}) #{exception.message}" mail(:to => address, :from => ...
class ApplicationController < ActionController::Base protect_from_forgery def authorize redirect_to login_url, alert: "Not authorized" if current_user.nil? end def admin_filter if current_user.nil? or !current_user.admin redirect_to login_url, alert: "You are not authorized to perform that actio...
class FontMonoton < Formula head "https://github.com/google/fonts/raw/main/ofl/monoton/Monoton-Regular.ttf", verified: "github.com/google/fonts/" desc "Monoton" homepage "https://fonts.google.com/specimen/Monoton" def install (share/"fonts").install "Monoton-Regular.ttf" end test do end end
class ReminderDeadlineJob < ApplicationJob def perform if Flipper.enabled?(:reminders_active) # TODO: This query can probably be improved organizations = Organization.where('reminder_day = ? and deadline_day is not null', Date.current.day) organizations.each do |organization| organizatio...
class ThermostatsController < ApplicationController before_action :set_thermostat, only: :show # GET /thermostats/1 def show render json: @thermostat end private # Use callbacks to share common setup or constraints between actions. def set_thermostat @thermostat = Thermostat.find(params[:i...
require 'tmpdir' require 'timeout' require 'open3' require 'faraday' require 'pathname' require 'minitest/autorun' $LOAD_PATH.unshift('./lib') require 'stubborn' class BaseTest < Minitest::Test DEBUG = false STUBBORN_EXECUTABLE = File.expand_path('bin/stubborn', Dir.pwd) def current_command @current_comm...
VM_NAME = "ubuntu-devbox" VM_IP = "10.10.10.10" # 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| config.vm.box = "bento/ubuntu-16.04" config.vm.hostname = VM_NAME config.vm.provision "file", sou...
class UsersController < ApplicationController # before_action :require_login, except: [:main, :create] # before_action :require_correct_user, only: [:main, :show, :info] def main end def create @user = User.create(user_params) if @user.valid? session[:user_id] = @user.id redirect_to "/bright_ideas" e...
class ActivityPlansController < ApplicationController def new if params[:date] @activity_plan.date = params[:date] end end def create if current_user.activity_plans << @activity_plan redirect_to activity_plans_overview_path else render action: 'new' end end def edit e...
# frozen_string_literal: true RSpec.describe Might::Fetcher, 'Filter DSL' do describe '.filter' do let(:fetcher_class) do Class.new(described_class) end before do fetcher_class.filter_parameters_definition = Might::FilterParameters.new end subject { fetcher_class.filter_parameters_de...
class UserTroubleshootingTasksController < ApplicationController def update @user_troubleshooting_task = UserTroubleshootingTask.find_by(id: params[:id]) @ticket = @user_troubleshooting_task.troubleshooting_task.ticket if @user_troubleshooting_task.update(task_params) redirect_to root_path, not...
# frozen_string_literal: true # Copyright 2016 Liqwyd Ltd. # # 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
require 'nobbie/wx/command/reporter' module Nobbie module Wx module Command class Executor #:nodoc: def self.execute(command) executor.execute(command) end def self.executor @executor ||= new end def self.reporter= reporter ...
Rails.application.routes.draw do # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html resources :resources, only: [:show, :create, :update, :destroy] get 'lesson/:slug/resources', to: 'resources#index', as: 'lesson_resources' delete 'lesson/:slug/resources/:id', to:...
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 # Most of the time, try to log in. # in some cases we'll want to skip this before_filter :login_from_mapstory ...
class StatusesController < ApplicationController before_action :set_status, only: [:show, :edit, :update, :destroy, :add_to_favourities, :remove_from_favourities, :report] before_action :authenticate_user!, except: [:index, :show, :tagged] before_action :find_tagged_statuses, only: [:tagged] # GET /statuses #...
rackup DefaultRackup env = ENV['RACK_ENV'] || 'development' environment env workers Integer(ENV['WEB_CONCURRENCY'] || 2) unless env == 'development' if env == 'development' cert_path = File.expand_path('../certs', __FILE__) localhost_crt = File.join(cert_path, 'localhost.crt') localhost_key = File.join(cert_pat...
class CreateProductionLines < ActiveRecord::Migration def change create_table :production_lines do |t| t.integer :packaging_id t.integer :line_id # audit markers t.boolean :record_exists, default: true t.integer :record_last_change_by t.integer :record_created_by t.times...
# == Schema Information # # Table name: users # # id :integer not null, primary key # nickname :string not null # email :string not null # password_digest :string not null # session_token :string not null # created_at :datetime ...
# Rewrite your recursive fibonacci_nth method so that it computes its results # without recursion. # LS Solution: # def fibonacci(nth) # first, last = [1, 1] # 3.upto(nth) do # first, last = [last, first + last] # end # last # end def fibonacci(n) fib = [1, 1] (n-2).times do fib[0], fib[1] = fi...
class MuppetController < ApplicationController get "/muppets/new" do redirect_if_not_logged_in erb :"muppets/new" end post "/muppets" do muppet = Muppet.create(name: params[:name], job: params[:job], user_id: session[:user_id]) redirect "/muppets" end get "/muppets" do redirect_if_not_lo...
# -*- encoding : utf-8 -*- require 'rails_helper' # This spec was generated by rspec-rails when you ran the scaffold generator. # It demonstrates how one might use RSpec to specify the controller code that # was generated by Rails when you ran the scaffold generator. # # It assumes that the implementation code is gene...
require 'test_helper' class Sims::SimsBigaVehiclePeopleControllerTest < ActionDispatch::IntegrationTest setup do @sims_biga_vehicle_person = sims_biga_vehicle_people(:one) end test "should get index" do get sims_biga_vehicle_people_url assert_response :success end test "should get new" do g...
module Engine module Definitions class SceneCollectionVideo < AbstractDefinition alias_method :scene_collection, :video_content def content if video_data.user_audio.present? b.audio(video_data.user_audio, volume: -5, file: true) music_volume = -20 else mu...
class FeedTypesController < ApplicationController # GET /feed_types # GET /feed_types.json def index @feed_types = FeedType.all respond_to do |format| format.html # index.html.erb format.json { render json: @feed_types } end end # GET /feed_types/1 # GET /feed_types/1.json def sh...
FactoryBot.define do factory :order do amount { "9.99" } pay_way { "account" } association :event association :user pay_time { "2017-04-23 00:31:14" } end end
require "set" class WordChainer attr_reader :dictionary, :current_words, :all_seen_words def initialize(dictionary="dictionary.txt") @dictionary = File.readlines(dictionary).map { |line| line.strip } @dictionary = @dictionary.to_set end def run(source, target) @current_words = [source] @all_s...
# -*- coding: utf-8 -*- =begin Classe Conta Corrente: Crie uma classe para implementar uma conta corrente. A classe deve possuir os seguintes atributos: número da conta, nome do correntista e saldo. Os métodos são os seguintes: alterarNome, depósito e saque; No construtor, saldo é opcional, com valor default zero e os...
class ChangedSurveyQuestsRenamedType < ActiveRecord::Migration def self.up rename_column :survey_quests, :type, :qtype end def self.down rename_column :survey_quests, :qtype, :type end end
require 'spec_helper' describe TextsController, :type => :controller do render_views describe "PUT" do before :each do permit_with 200 request.headers['HTTP_ACCEPT'] = "application/json" request.headers['X-API-Token'] = "incredibly-fake!" @u = create :text, result: "foo" ...
=begin Create a class called Car with these attributes: year(getter + setter), model (getter + setter), color (getter + setter), current_speed (no getter + no setter). We can init car instance by 3 attributes: year, model, color. Default current_speed is 0 when init. Cr...
# config/app.rb require 'dotenv/load' class Application return [ # |-------------------------------------------------------------------------- # | Application Environment # |-------------------------------------------------------------------------- # | # | This value deter...
class ProjectsController < ApplicationController def index @projects = Project.all end def show @project = Project.find(params[:id]) @bids = @project.bids end def new @project = current_user.projects.new end def create @project = current_user.projects.new(project_params) if @pr...
# == Schema Information # # Table name: matches # # id :integer not null, primary key # winner_id :integer # loser_id :integer # created_at :datetime # updated_at :datetime class Match < ActiveRecord::Base belongs_to :winner, class_name: 'User' belongs_to :loser, class_name: 'User' scop...
class ActionView::Helpers::FormBuilder include ActionView::Helpers include ActionView::Context include Rails.application.routes.url_helpers # f.multiple_user_select :author_ids def multiple_user_select(method, options={}) stringy_method = "stringy_#{method}" dom_class_name = "#{@object_name}_#{string...
class Section::Post < Section has_many :comments, :as => :commentable end
require 'spec_helper' require 'rqrcode/data' describe 'Export::SVG' do it 'must respond_to svg' do expect(RQRCode::QRCode.new('qrcode')).to respond_to(:as_svg) end it 'must export to svg' do expect(RQRCode::QRCode.new('qrcode').as_svg).to eq(AS_SVG) end describe "options" do it 'has standalone ...
class Exam < ActiveRecord::Base belongs_to :author, :class_name => "User", :foreign_key => "author_id" has_many :questions, :as => :questionable, :order => :position has_and_belongs_to_many :lessons has_many :assessments belongs_to :organization before_save :sanitize_name validates_presence_of :name ...
class Launch::Component::Card::Body < Launch::Component def nested_components [:footer] end def html content_tag :div, class: css_class do nested_content end end private def css_classes ["card--body"] end end
# # Cookbook Name:: lb # # Copyright RightScale, Inc. All rights reserved. # All access and use subject to the RightScale Terms of Service available at # http://www.rightscale.com/terms.php and, if applicable, other agreements # such as a RightScale Master Subscription Agreement. # LB attributes # # Below are the attr...
class Shifumi VALUES = ["PAPER", "ROCK", "SCISSORS"] attr_reader :type def self.can_win(type_id) VALUES[(VALUES.index(type_id.to_s) + 2) % 3] end def self.can_loose(type_id) VALUES[(VALUES.index(type_id.to_s) - 2) % 3] end def initialize(type); @type = type.to_s; end def alive?; @type != "DE...
# Version of the gems are described here as a constant # Change the VERSION before submitting to rubygems.org # For initial phase keep it as it is # For every update change the version before submitting to Rubygems.org module KoducExpressPaypal VERSION = "1.1.0" end
# This is a junky script that I wrote to transform the # Census Bureau's TIGER Shapefiles into separate # KML files for each city. require 'nokogiri' require 'ostruct' require 'csv' require 'fileutils' downloads = <<-CSV state,url_id Alabama,"01" Alaska,"02" Arizona,"04" Arkansas,"05" California,"06" Colorado,"08...
class Recipe attr_accessor :name ALL = [] def initialize(name) @name = name ALL << self end def self.all ALL end def recipe_cards RecipeCard.all.select {|recipe_card| recipe_card.recipe == self} end def self.most_popular self.all.max_by {|recipe| recipe.recipe_cards.count} ...
#Attr Methods # I worked on this challenge by myself. # I spent 1.5 hours on this challenge. class NameData attr_reader :name def initialize(name) @name = name end end class Greetings def initialize @becca = NameData.new("Becca") end def hello puts "Hello " + @becca.name + ", nice to see you!" end en...
require 'setup_tests' class CiscoNXOSCoreTest < BaseTestSetup context 'a Cisco NXOS target' do setup do @connector = @target.connector = SSHConnector.new(@host, {}) @target.stubs(:target_profiler).returns(Profilers::CiscoNXOSCore) @target.force_profiler_to(Profilers::CiscoNXOSCore) @profi...
class ArticlesController < ApplicationController def create @person = Person.find(params[:person_id]) @article = @person.articles.create(article_params) redirect_to person_path(@person) end private def article_params params.require(:article).permit(:name, :publication_date) end end
class AddProviderToUserAssociations < ActiveRecord::Migration def change add_column :household_associations, :provider_id, :integer add_column :household_associations, :provider_type, :string remove_column :household_associations, :service_provider_id if column_exists?(:household_associations, :servi...
class CreateUserSessions < ActiveRecord::Migration def change create_table :user_sessions do |t| t.references :user, index: true t.string :token, null: false t.datetime :accessed_at, null: false, index: true t.datetime :revoked_at, index: true t.string :ip t.string :user_agent ...
class AddMissingFieldsToOrders < ActiveRecord::Migration[6.0] def change add_column :orders, :address1, :string add_column :orders, :address2, :string add_column :orders, :address_town_or_city, :string add_column :orders, :state_or_county, :string add_column :orders, :postal_or_zip_code, :string ...
# encoding: utf-8 require 'digest' puts "Введите слово или фразу для шифрования:" phrase = STDIN.gets.chomp crypt_methods = ['MD5', 'SHA1', 'SHA2'] puts "Каким способом зашифровать:" crypt_methods.each_with_index do |item, index| puts "#{index + 1}. #{item}" end user_input = STDIN.gets.to_i case crypt_methods[...
class Cake attr_accessor :color, :price, :description, :images def initialize(color, price, description,images) @color = color @price = price @description = description @images = images end end class Cookies attr_accessor :flavor, :price, :description, :images def init...
require 'rails_generator/secret_key_generator' require 'action_controller/cgi_ext/session' namespace :funda do desc "Generate new secret keys for session, cookies and authentication" task :generate_secret_keys do config_file = "#{RAILS_ROOT}/config/config.yml" config_settings = YAML.load_file(config_file)...
class AddUrlToComments < ActiveRecord::Migration def up change_column :comments, :content, :text, :null => true add_column :comments, :url, :string end def down change_column :comments, :content, :text, :null => false remove_column :comments, :url, :string end end
describe Ahoy::EventsController, type: :controller do routes { Ahoy::Engine.routes } it "creates event with other attr" do time = (Time.now - 30).utc.change(usec: 0) post :create, id: "11111111-2222-3333-4444-555555555555", name: "$submit", properties: {"bar" => "baz"}, time: time eve...
class User < ActiveRecord::Base has_many :registered_applications, dependent: :destroy # Include default devise modules. Others available are: # :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :trackable, :validatable, :confirmable, :rememberabl...
module Readers class HomeController < ReadersController helper_method :reading_time def index @posts = Post.published.most_recently_published end def reading_time(post) words_per_minute = 150 @content = "" post.elements.each do |element| if element.element_type == "pa...
require 'spec_helper' require 'tackle_box/email/template/tags/link' describe TackleBox::Email::Template::Tags::Link do let(:template) { Liquid::Template.parse('{% link %}') } let(:link) { 'http://apt.trailofbits.com/uas/request-password-reset?trk=signin_fpwd' } let(:url) { URI(link) } let(:param) { describ...
class Model::Section::ExternalLink < SitePrism::Section element :title, '[id*="title"]' element :link, '[id*="url"]' end
class UsersController < ApplicationController before_action :require_no_user! def new @user = User.new render :new end def create @user = User.new(users_params) if @user.save login(@user) #session[:session_token] = @user.session_token # refactor this line with login(@user) redir...
require 'ostruct' require 'httpclient' require 'savon' require 'cgi' require 'crack/xml' require 'mime/types' require 'digest/sha1' require 'nokogiri' class NestedOpenStruct < OpenStruct def initialize(hash = nil) @table = {} if hash for k, v in hash @table[k.to_sym] = v.instance_of?(Hash) ? Ne...
class Post < ApplicationRecord include MultipleMan::Publisher publish fields: [:token] def self.rain(total) make(total) { total_created: Post.count } end def self.rain_for(seconds, per_second = 1) total = seconds * per_second total.times do |i| Post.create(token: i) puts "#{i}/#...
# bot.rb require_relative './../modules/talktext' require_relative './../modules/talkblocks' require_relative './../modules/checkdoif' require_relative './../modules/inputs' require_relative './../modules/typewriter' class Bot include Greet, HungryAsk, FoodMatching, Goodbye, TalkBlocks, Checks, DoIf, GetInputs...
require 'rubygems' class GameBot attr_accessor :enabled, :callAfter, :callBefore, :dependencies def initialize(mother) @parent = mother @enabled = true @callAfter = true @callBefore = false @dependencies = { 'author' => 'Lynx', 'version' => '0.1', 'hook_type' => 'game' } @botInfo = { 'bo...
require 'rails_helper' describe "StripeService" do it ".fetch_customer" do user = User.create(name: "Mimi Le", email: "mimilettd@gmail.com", password: "password") raw_data = StripeService.fetch_customer(user) expect(raw_data).to be_a(Hash) end end
class Restaurant attr_accessor :name, :cuisine_type #attr_reader :rating @@restaurants = [] def initialize(name,cuisine_type) @name = name @@restaurants << self self.cuisine_type = cuisine_type cuisine_type.add_restaurant(self) end def self.all @@restaurants end def rating...
require 'rails_helper' RSpec.describe Join, type: :model do describe 'relationships' do before do @user = create(:user) @event = create(:event, name: 'name 1', detail: "It's gonna be lit", date: '2000-01-01', location: 'location 1', user: @user) @join = create(:join, event: @event, user: @user) ...
require 'spec_helper' describe ItemMaster do it "should let us make add a new one" do item_master = FactoryGirl.create(:item_master) item_master.save.should be_true end it "should require an code" do item_master = FactoryGirl.build(:item_master, code: nil) item_master.should_not be_valid item...
class GildedRose def initialize(items) @items = items end def update_quality @items.each do |item| class_for(item).new(item).update end end def class_for(item) { 'Sulfuras, Hand of Ragnaros' => SulfurasRules, 'Aged Brie' => AgedBrieRules, 'Backstage pas...
class Status < ActiveRecord::Base self.table_name = :statuses self.primary_key = :status_id include EbrsMetadata has_many :person_record_statuses, foreign_key: "status_id" end
# -*- mode: ruby -*- # vim: set ft=ruby : BRIDGE_NET='192.168.11.' DOMAIN='mydomen.local' home = ENV['HOME'] servers = [ { :box_name => "centos/7", :hostname => 'backup-server.' + DOMAIN, :ip_addr => BRIDGE_NET + '101', :memory => '1024', :cpus => '1', :hdd_path => home + '/VirtualBox VMs/d...
module SplitIoClient class SplitClient # # Creates a new split client instance that connects to split.io API. # # @param api_key [String] the API key for your split account # # @return [SplitIoClient] split.io client instance def initialize(api_key, config = {}, adapter = nil, splits_repos...
require 'rails_helper' RSpec.describe CSURN do before(:all) do CacheObject.destroy_all end let(:vocab_urn) { "urn:cspace:core.collectionspace.org:vocabularies:name(languages):item:name(english)'English'" } it "can generate vocabulary urn when not in cache" do expect( CSURN.get_vocab_urn('...
class OrderItem < ApplicationRecord belongs_to :order #heeft 1 bestelling belongs_to :product #heeft 1 product validates :amount, :numericality => { :greater_than_or_equal_to => 1 } #valideerd op minimaal 1 of meer validates :product_id, presence: true #valideerd aanwezigheid end
class PartiesController < ApplicationController before_action :authenticate_user! def show @guardianship = Guardianship.find(params[:guardianship_id]) @party = Party.find(params[:id]) end def new @guardianship = Guardianship.find(params[:guardianship_id]) @party = @guardianship.parties.new ...
# frozen_string_literal: true # rubocop:disable Style/RescueModifier require "English" require "dry-types" RSpec.describe(Dry::Monads::Result) do result = Dry::Monads::Result success = result::Success.method(:new) failure = result::Failure.method(:new) subject { Test::Operation.new } context "dry-types" ...
module TravnotyClient class Bitmap < Wx::Bitmap IMAGE_PATH = TravnotyClient.root_path + "/imgs" class << self def image_path IMAGE_PATH end def create_flag(hub) create("flags/#{hub.code.upcase}.png") end def create(file_path, type=Wx::BITMAP_TYPE_PNG) ...
require 'minitest/autorun' require 'minitest/rg' require_relative '../album' class TestAlbum < MiniTest::Test def setup @album = Album.new( 'id' => '1', 'title' => 'Flame Rave', 'quantity' => '5', 'buy_price' => '500', 'sell_price' => '1000', 'artist_id' => '2', 'genre_...
namespace :stats do Rails.logger = Logger.new(STDOUT) if ENV['debug'] desc "update user account stats" task :accounts => [:environment] do User.has_logged_in.each do |user| begin log_t "User #{user.id}: updating account stats" user.update_account_stats rescue => e log "\t#...
class Ingredient < ActiveRecord::Base belongs_to :recipe, :dependent => :destroy belongs_to :unit belongs_to :food validates_presence_of :unit_id validates_presence_of :food_id validates_presence_of :amount def food_name food.name if food end def unit_name unit.name if unit end def food...
# frozen_string_literal: true require "spec_helper" describe GraphQL::Schema::NonNull do let(:of_type) { Jazz::Musician } let(:non_null_type) { GraphQL::Schema::NonNull.new(of_type) } it "returns list? to be false" do refute non_null_type.list? end it "returns non_null? to be true" do assert non_n...
# frozen_string_literal: true title 'kubernetes archives profile' control 'kubernetes archive' do impact 1.0 title 'should be installed' describe file('/etc/systemd/system/k3s.service') do it { should exist } it { should_not be_directory } its('type') { should eq :file } end describe file('/usr...
require File.dirname(__FILE__) + '/../spec_helper' describe PaisesController do describe "handling GET /paises" do before(:each) do @paise = mock_model(Paise) Paise.stub!(:find).and_return([@paise]) end def do_get get :index end it "should be successful" do do_get ...
# Input: roster # output: hash of people in each group # create method with input names array # create a counter to keep track of group number # add people to array # add array to group once specific number of people is reached def create_group(names) counter=1 people=1 groups={} array=[] names.ea...
class AddIsActiveToTransportTransactionDiscount < ActiveRecord::Migration def self.up add_column :transport_transaction_discounts, :is_active, :boolean, :default => true add_index :transport_transaction_discounts, :is_active, :name => "index_by_active" end def self.down remove_index :transport_trans...
# 13 - Case print "Enter you language: " language = gets.chomp case language when "English", "english" puts "Hello!" when "French", "french" puts "Bonjour!" when "Vietnamese", "vietnamese" puts "Xin Chao!" else puts "I don't know your language!" end # Result # Enter you language: vietnamese # Xin Chao!
# module to match a code to a school or educator. module SchoolCodeMatcher def is_matching_code?(body_text) # get all available codes... all_codes = School.map(:code).compact all_codes += Teacher.map(:code).compact # puts "all codes (teachers, schools) = #{all_codes}" all_codes = all_...
class Trip < ActiveRecord::Base attr_accessible :dayNumber, :startDate belongs_to :user belongs_to :tourist_spot validates_presence_of :dayNumber validates_presence_of :startDate validates :dayNumber, :numericality => { :greater_than => 0 , :allow_nil => true} validates :dayNumber, :uniqueness => {:scop...