text stringlengths 10 2.61M |
|---|
require 'spec_helper'
module Fakes
class MyClass
end
describe ClassSwap do
context 'when created' do
let(:sut) { ClassSwap.new(MyClass, Object.new) }
it 'should store the symbol of the class it is going to replace' do
expect(sut.klass).to eql(:MyClass)
end
end
context 'when... |
class ArticlesController < ApplicationController
http_basic_authenticate_with name: "dhh",password: "secret",except: [:index, :show]
before_action :authenticate_user!, only: [:show, :create]
def index
@articles = Article.all
end
def show
@article = Article.find(params[:id])
... |
require 'spec_helper'
describe ListsController do
describe "UPDATE /lists/:id" do
before do
@list = List.create :name => "Test List 3"
@attr = { :name => "new name test", :id => @list.id }
end
it "should update list name" do
put :update, :id => @list.id, :list => @attr
@list.rel... |
class Newsletter < ActionMailer::Base
default from: "no-reply@bitzen.com"
def registration_confirmation(user)
@user = user
mail(:to => user.email, :subject => 'Thanks for signing up!')
end
end
|
#! /usr/bin/env ruby
require 'rubygems'
require 'optparse'
require 'yaml'
require 'fileutils'
require 'logger'
require 'mvp'
NAME = File.basename($PROGRAM_NAME)
options = {:config => File.expand_path('~/.mvp/config.yaml')}
optparse = OptionParser.new { |opts|
opts.banner = "Usage : #{NAME} [command] [target] [... |
class CreateTemporaryManagers < ActiveRecord::Migration[6.0]
def change
create_table :temporary_managers do |t|
t.belongs_to :user
t.belongs_to :event
t.timestamps
end
add_index :temporary_managers, [:user_id, :event_id], unique: true
end
end
|
# @author Kristian Mandrup
#
# @note all methods should operate on the data store via the #store
#
module Troles::Common::Api
module Write
# Do we need a static_roles! method? I think so!
def static_role! role_name
raise ArgumentError, "Take a single role name, was: #{role_name}" if !role_name || !role... |
class AccessKey < ApplicationRecord
before_create :default_values
belongs_to :guestbook, optional: true
validates :label, presence: true
def self.validate(key)
AccessKey.where(key: key).count > 0
end
def default_values
begin
self.key = SecureRandom.hex(16)
end while AccessKey.where(key: ... |
=begin
Write a method that will take a short line of text, and print it within a box.
Example:
print_in_box('To boldly go where no one has gone before.')
+--------------------------------------------+
| |
| To boldly go where no one has gone before. |
| ... |
class ProfitController < ApplicationController
before_action :require_login
def index
@profits = Profit.where(user_id: current_user.id)
end
end
|
# frozen_string_literal: true
# == Schema Information
#
# Table name: timeslots
#
# id :bigint(8) not null, primary key
# mc_only :boolean
# default_user_id :bigint(8)
# time_range_id :bigint(8)
# place_id :bigint(8)
# created_at :datetime not null
# updated_at ... |
require "recipiez/capistrano"
server "176.58.115.227", :web, :app, :db, primary: true
set :application, "taygeta"
set :user, "deployer"
set :deploy_to, "/var/www/apps/#{application}"
set :deploy_via, :remote_cache
set :use_sudo, false
set :rails_env, 'staging'
set :scm, "git"
set :repository, "git@github.com:rebelc... |
class GameSerializer < ActiveModel::Serializer
attributes :id, :attempts, :playtime, :status
has_one :user
end
|
class Wunderground
include HTTParty
@api_key = ENV["WUNDERGROUND_KEY"]
base_uri "http://api.wunderground.com/api/#{@api_key}/v:2.0"
def conditions_for(location)
self.class.get("/conditions/q/#{location}.json")
end
def history_for(time, location)
self.class.get("/history_#{time.strftime('%Y%m%d')}/... |
# encoding: utf-8
# Популярная детская игра
# https://ru.wikipedia.org/wiki/Виселица_(игра)
#
# Этот код необходим только при использовании русских букв на Windows
if Gem.win_platform?
Encoding.default_external = Encoding.find(Encoding.locale_charmap)
Encoding.default_internal = __ENCODING__
[STDIN, STDOUT].eac... |
module BillOfMaterialsItemTypeRepresenter
include Roar::JSON
property :count, :getter => lambda {|args| item_type_count}
property :item, :getter => lambda {|args| item_type}, :extend => ItemTypeRepresenter, :class => ItemType
end
|
# Represents a single human player
class Player
attr_accessor :name, :mark
# Sets the players name and marker
def initialize(name, marker)
@name = name
@mark = marker
end
end
|
# == Schema Information
#
# Table name: quotes
#
# id :integer(4) not null, primary key
# sid :string(255)
# market :string(255)
# name :string(255)
# open :decimal(8, 3)
# close :decimal(8, 3)
# adjClose :decimal(8, 3)
# current :decimal(8, 3)
# high ... |
require 'rails_helper'
describe GamesController do
describe '#new' do
it 'assigns new game' do
get :new
expect(response).to render_template(:new)
end
end
describe '#create' do
let(:winner_id) { '1' }
let(:loser_id) { '2' }
let(:params) { { game: { winner_id: winner_id, loser_id: ... |
class PreferencesController < ApplicationController
before_action :set_preference, only: [:show, :edit, :update, :destroy]
def index
@preferences = Preference.all
render json: @preferences
end
def show
render json: @preference, include: {poem: { only: [:name, :author] ... |
class AxeTemplate
PERKS = {
attack: 4,
defence: -1
}
def apply_perks
return PERKS
end
def name
return 'Axe'
end
end |
require 'rails_helper'
RSpec.describe User, :type => :model do
it 'should display admin name if it exists else User' do
user = User.new first_name: 'Udit', last_name: 'Mittal'
expect(user.name).to eq('Udit Mittal')
end
context 'validations' do
# it { should validate_format_of(:pan_card).with('AAAAA... |
class ServersController < ApplicationController
def index
@servers = Server.all
end
def new
@server = Server.new
end
def create
@server = Server.new(server_params)
if @server.save
redirect_to action: :index
else
render :new
end
end
def search
@count = params[:cou... |
require 'thor'
require 'json'
require 'diffy'
require 'term/ansicolor'
require 'legitable'
require_relative 'linode/stackscript'
class Stackscript < Thor
include Term::ANSIColor
desc "ls", "List stackscripts (from Linode)"
option :raw, type: :boolean, default: false
def ls
if options[:raw]
puts JSON... |
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe Joyce::Behaviour::Subscriber do
let(:subscriber) { create(:person) }
describe "#stream_subscriptions" do
it { subscriber.stream_subscriptions.should be_empty }
end
describe "#subscriptions" do
it { subscriber.subscripti... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# Start Kibana and go to localhost:5666 in your host's browser
config.vm.network :forwarded_port, guest: 5601, host: 5666
config.vm.provider "virtualbox" do |vbox|
vbox.customize ["modifyvm", :id, "--audio", "none"]
vbox.memory ... |
class AddBodyHtmlToUpdate < ActiveRecord::Migration
def change
add_column :updates, :body_html, :text
end
end
|
class AddFieldsToNobreaks < ActiveRecord::Migration
def change
add_column :nobreaks, :capacidadeBateria, :integer
end
end
|
class StaticPage < ActiveRecord::Base
before_save :update_permalink
has_permalink :permalink, :update => true
validates_presence_of :ru_title, :message => "^Русское название обязательно к заполнению"
validates_presence_of :en_title, :message => "^Английское название обязательно к заполнению"
protected
... |
module StructPacking
public
# internal C-like_structure_declaration
class Util
private
def self.struct_template(type, arraylen, mod=nil)
type =~ /struct\s*(\w*)\s*/
if arraylen != ""
find_hier_mod(mod, $1).pack_template * arraylen.to_i
else
find_hier_mod(mod, $1... |
# -*- mode: ruby -*-
# # vi: set ft=ruby :
$num_instances = 3
$instance_name_prefix = "docker-swarm-test"
$share_home = false
$vm_gui = false
$vm_memory = 512
$vm_cpus = 1
# Use old vb_xxx config variables when set
def vm_gui
$vb_gui.nil? ? $vm_gui : $vb_gui
end
def vm_memory
$vb_memory.nil? ? $vm_memory : $vb_mem... |
class StusController < ApplicationController
before_action :set_stu, only: [:show, :edit, :update, :destroy]
# GET /stus
# GET /stus.json
def index
@stus = Stu.all
end
# GET /stus/1
# GET /stus/1.json
def show
end
# GET /stus/new
def new
@stu = Stu.new
end
# GET /stus/1/edit
def ... |
module Admin::ContentDataRoutesHelper
def content_data_base_url
@content_data_base_url ||= "#{Plek.current.external_url_for('content-data')}/content"
end
end
|
module Spree
module Api
module V1
class TaxonInteriorsController < Spree::Api::BaseController
helper ::SpreeApiV1TaxonInteriorsHelper
def index
@taxon_interiors = scope.interiors.accessible_by(current_ability, :read)
respond_with(@taxon_interiors)
end
def sho... |
PUMA_PID = File.expand_path("../../../tmp/pids/puma.pid", __FILE__)
namespace :puma do
desc "start Puma server"
task :start => :environment do
if puma_is_running?
raise "Puma is already running"
else
puts "Puma is starting"
system 'RACK_ENV=production pumactl start'
end
end
desc... |
require 'knuckle_cluster/asg_instance_registry'
require 'knuckle_cluster/ecs_agent_registry'
require 'knuckle_cluster/spot_request_instance_registry'
require "knuckle_cluster/scp"
require "knuckle_cluster/version"
require "knuckle_cluster/configuration"
require 'aws-sdk-core'
require 'aws-sdk-ec2'
require 'aws-sdk-ecs... |
require 'yaml'
require 'ostruct'
module Topograf
class Config
attr_reader :settings
def initialize
@settings = OpenStruct.new(load_settings)
end
def load_settings
YAML.load_file('config/settings.yaml')
end
end
end
|
module ODFReport
module Images
IMAGE_DIR_NAME = "Pictures"
def find_image_name_matches(content)
@images.each_pair do |image_name, path|
if node = content.xpath("//draw:frame[@draw:name='#{image_name}']/draw:image").first
placeholder_path = node.attribute('href').value
@im... |
# Given an integer `product`, find the *smallest positive integer* the product of whose digits is equal to product. If there is no such integer, return -1 instead.
# Input/Output:
# [input] integer `product`
# Constraints: 0 ≤ product ≤ 600.
# [output] a positive integer the product of whose digits is `product`
=begi... |
#!/usr/bin/env rake
require 'rubygems'
require 'jsmin'
# Output files
COMBINED_JS_FILE = 'webaction.js'
COMBINED_CSS_FILE = 'webaction.css'
# Source files
BASE_DIRECTORY = File.dirname(__FILE__)
CORE_DIRECTORY = File.join(BASE_DIRECTORY, 'core')
CONTROLS_DIRECTORY = File.join(BASE_DIRECTORY, 'controls')
def find_s... |
class Test::Unit::TestCase
include RR::Adapters::TestUnit
end
# These methods are used to change the flow of control so that the
# test can state what is to happen before stating what the mock should
# receive.
class Test::Unit::TestCase
def during(&block)
# Use of global needed for current way of handling
... |
module Issues::Comments
extend ActiveSupport::Concern
included do
has_many :comments, dependent: :destroy
has_one :last_comment, -> {
includes(:user).reorder created_at: :desc
}, class_name: 'Comment'
accepts_nested_attributes_for :comments, reject_if: :all_blank
end
end
|
class Subject < ActiveRecord::Base
has_many :questions
has_many :exams
end
|
class HomeController < ApplicationController
# @description Current User's dashboard
def dashboard
respond_with_interaction Dashboard::Dashboard, params
end
end
|
class Api::V1::BusinessesController < ApplicationController
skip_before_filter :verify_authenticity_token, :only => [:create, :update]
before_action :authenticate, only: [:create,:update,:destroy]
before_action :set_business, only: [ :show,:update,:destroy ]
before_action(only: [:update,:destroy]) { |controlador| ... |
class BillentriesController < ApplicationController
before_action :set_billentry, only: [:show, :edit, :update, :destroy]
before_action :authenticate_user!
# GET /billentries
# GET /billentries.json
def index
@billentries = Billentry.all.where(secure: true, user_id: current_user.id)
end
# GET /bille... |
# frozen_string_literal: true
require 'rails_helper'
describe 'as a registed user' do
before :each do
user = create(:user)
user.token = Token.new(github_token: ENV['GITHUB_API_KEY_2'])
user2 = create(:user, github_email: '1234@test.com', github_login: 'D')
user2.token = Token.new(github_token: ENV['... |
begin
ActiveRecord::Schema.define(:version => 1) do
create_table :articles, :force => true do |t|
t.string :name
t.string :type
t.timestamps
end
create_table :tags, :force => true do |t|
t.string :name
t.integer :article_id
t.timestamps
end
create_table... |
class Rating < ActiveRecord::Base
attr_accessible :name, :value
has_many :events
has_many :prompts
validates :name, presence: true
validates :value, presence: true
end
|
class ChangeTokenColumnName < ActiveRecord::Migration[5.1]
def change
rename_column :groups, :join_token, :token
end
end
|
class Point < ActiveRecord::Base
#=================== Gmaps4Rails===================================
acts_as_gmappable :process_geocoding => true, :validation => false
before_create :address_presence
#==================================================================
#=================== Geocoder ==========... |
class ChaptersController < ApplicationController
before_action :set_chapter, only: [:update, :destroy]
def show
chapter = current_user.find_chapter(params[:id])
render json: chapter
end
def create
chapter = Chapter.new(params_chapter)
chapter.save!
render json: chapter
end
def update
... |
class Merchant < ApplicationRecord
has_many :items
has_many :invoices
has_many :transactions
has_many :invoice_items
def self.import_merchants
merchants = []
CSV.foreach('db/seeds/merchants.csv', headers: true) do |row|
merchants << row.to_h
end
Merchant.import(merchants)
end
def s... |
# Given an array of non-negative numbers, find continuous subarray with given sum
def sub_array_with_sum(arr, sum)
#Since it is all positive, very easy to do sliding window technique with 2 pointers
puts "Array: #{arr}, sum:#{sum}"
left = 0
right = 0
sum_so_far = 0
while (right < arr.size)
sum_so_far +... |
# encoding: utf-8
# copyright: 2016, you
# license: All rights reserved
# date: 2015-08-28
# description: All directives specified in this STIG must be specifically set (i.e. the server is not allowed to revert to programmed defaults for these directives). Included files should be reviewed if they are used. Procedure... |
class DatasetsController < ApplicationController
def index
@datasets = current_account.datasets.all
end
def new
@dataset = Dataset.new
@object = @dataset
end
def preview
@dataset = Dataset.new(params[:dataset])
if @dataset.format == nil || @dataset.format.empty?
redirect_t... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'reserves/_reserves_item.html.erb' do
let(:item) { {} }
let(:index) { 0 }
before do
render 'reserves/reserves_item', item: item, index: index
end
describe 'SearchWorks title' do
let(:item) { { 'ckey' => '12345', 'title' => 'Cats!'... |
#!/usr/bin/ruby -w
require_relative 'SiteDump'
class WikiDump < SiteDump
def initialize(articles)
super()
@articles = articles
end
protected
def urls
@articles.map do |a|
a.strip!
a.gsub!(" ", "_")
a.prepend("http://en.wikipedia.org/wiki/")
... |
module ActiveRecordShards
module Model
def not_sharded
if self == ActiveRecord::Base || self != base_class
raise "You should only call not_sharded on direct descendants of ActiveRecord::Base"
end
@sharded = false
end
def is_sharded?
if self == ActiveRecord::Base
tr... |
require 'pry'
class PerfectNumber
def self.classify(number)
return raise RuntimeError if number < 0
sum = (1...number).select { |num| number % num == 0 }.inject(:+)
return 'perfect' if sum == number
sum < number ? 'deficient' : 'abundant'
end
end
PerfectNumber.classify(28)
|
module CDI
module V1
class LearningTrackHomeSerializer < SimpleLearningTrackSerializer
has_one :user, serializer: SimpleUserSerializer
has_many :categories, serializer: SimpleCategorySerializer
end
end
end
|
class AdminController < ActionController::Base
protect_from_forgery with: :exception
before_action :activate_tab
before_action :authenticate_user!
layout 'admin'
protected
def tab_after_redirect=(tab)
session[:tab_to_open] = tab
end
def tab_after_render=(tab)
@active_tab = tab
end
priva... |
###########
# Syntax
###########
# if構文
x = 123
if x % 2 == 0 then
puts x.to_s + ' -> even'
else
puts x.to_s + ' -> odd'
end
# for構文
list = ['a','b','c','d']
for item in list
puts item
end
# 範囲演算子
total = 0
for item in 1..100
total += item
end
puts 'TOTAL:' + total.to_s
# 配列のeach
fruits = ['apple','banana'... |
class Generator::User
def welcome
puts 'Hello, and welcome to an alcoholics dream, fill up your glass and lets go'
beers
menu
end
def menu
puts 'Enter a beer name or type "list"'
input = gets.chomp
if input == "list"
ten_beer_list
get_more_info
elsif get_beer_by_name(in... |
require 'singleton'
class Kyaru::Baby
include Singleton
def self.config(config)
@@config = config
end
attr_reader :bot, :db, :money, :stress
def initialize(config = @@config)
@config = config
@bot = Discordrb::Bot.new token: @config['discord_token']
@db = Sequel.connect @config['database_u... |
class Schedule < ApplicationRecord
validates :room_number, :period, presence: true
belongs_to :student
belongs_to :classroom
end
|
class Avatar < ActiveRecord::Base
belongs_to :skill_set
scope :admin_alpha, -> { order(name: :asc) }
scope :active, -> { where(status: "active") }
def money
skill_set.money if skill_set
end
def strength
skill_set.strength if skill_set
end
def intelligence
skill_set.intelligence if skill_... |
# frozen_string_literal: true
module SerializerHelpers
def serialize_entity(entity, **options)
JSONAPI::Serializable::Renderer.new.render(entity, options)
end
end
|
MutationType = GraphQL::ObjectType.define do
name 'Mutation'
description "The mutation root of this schema"
field :new_post do
description "Find a Post by ID"
type PostType
argument :title, !types.String
argument :body, !types.String
resolve ->(obj, args, ctx) do
Service::Mutation::New... |
class SentencesController < ApplicationController
def generate
@generator = SentenceGenerator::Generator.new
@sentences = Sentence.where('length < 8').limit(10) # @generator.generate_sentences()
end
def create
@sentence = Sentence.where(sentence_params).first_or_create!
end
private
def senten... |
module Acessors
def attr_accessor_with_history(*argms)
argms.each do |name|
var_name = "@#{name}".to_sym
define_method(name) { instance_variable_get(var_name) }
define_method("#{name}=") do |value|
instance_variable_set(var_name, value)
@var_massiv ||= {}
@var_ma... |
Rails.application.routes.draw do
resources :computadors
resources :libros
resources :futbolista
resources :estudiantes
resources :mascota
resources :vehiculos
resources :users
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
|
require "rails_helper"
RSpec.describe Queries::PoolType do
subject { Queries::PoolType }
context "fields" do
let(:fields) { %w(id model_id title contestants entries GraphQL::Relay::Define::AssignConnection) }
it "has the proper fields" do
expect(subject.fields.keys).to match_array fields
end
... |
require 'rails_helper'
describe Order do
describe '#create' do
before do
@item = create(:item)
end
it 'zipcode,prefecture,city,address,building,seller_id,buyer_id,item_id,reciever_last_name,receiver_first_nameがあれば登録できること' do
order = build(:order)
expect(order).to be_valid
end
... |
class GroupInformationPagesController < ApplicationController
def preview_pdf_page(template_name, output_file_name)
respond_to do |format|
format.pdf do
# 詳細画面のHTMLを取得
html = render_to_string template: "group_information_pages/#{template_name}"
# PDFKitを作成
pdf = PDFKit.new(h... |
# == Schema Information
#
# Table name: evaluacions
#
# id :integer not null, primary key
# porc_sugerido_condonacion :integer
# concepto :string(255)
# created_at :datetime
# updated_at :datetime
# evaluador_id :integer
#... |
module ClientDataMixin
extend ActiveSupport::Concern
included do
include FiscalYearMixin
Proposal::CLIENT_MODELS << self
has_paper_trail class_name: "C2Version"
has_one :proposal, as: :client_data
has_many :steps, through: :proposal
has_many :observations, through: :proposal
has_many... |
# Our code only works with the student name and cohort.
# Add more information: hobbies, country of birth, height, etc
def input_students
puts "Please enter the names of the students"
puts "To finish, just hit return twice"
# empty array
students = []
# while loop for getting information
while tru... |
class CreateWeapons < ActiveRecord::Migration
def change
create_table :weapons do |t|
t.string :damage
t.integer :enhancementBonus
t.boolean :masterwork
t.string :type
t.timestamps
end
end
end
|
require 'spec_helper'
describe Chanko do
shared_examples_for 'method proxy' do
let(:receiver) do
dummy_klass = Class.new
dummy_klass.send(:include, Chanko::MethodProxy)
dummy_klass.send(:include, Chanko::Helper)
dummy_klass.new
end
let(:proxy) { receiver.unit(:proxy_test) }
... |
class AddMediaToPosts < ActiveRecord::Migration[5.2]
def up
add_attachment :posts, :media
end
def down
remove_attachment :posts, :media
end
end
|
require 'mini_magick/command_builder'
require 'mini_magick/errors'
require 'mini_magick/image'
require 'mini_magick/utilities'
module MiniMagick
@validate_on_create = true
@validate_on_write = true
class << self
attr_accessor :processor
attr_accessor :processor_path
attr_accessor :timeout
attr_a... |
require 'rails_helper'
RSpec.feature "Admin can log in" do
scenario "exist admin can log in" do
admin = User.create(username: "admin",
email: "admin@admin.com",
password: "password",
role: 1)
visit login_path
fill_in "Username", w... |
class MatchesController < ApplicationController
def index
@matches = Match.all
render("matches/index.html.erb")
end
def show
@match = Match.find(params[:id])
render("matches/show.html.erb")
end
def new
@match = Match.new
render("matches/new.html.erb")
end
def create
@match... |
require 'rake'
require 'rspec/core/rake_task'
require 'faker'
require_relative 'db/config'
task :console do
exec "irb -r./app.rb"
end
namespace :db do
task :seed do
require_relative 'app'
2000.times do
Contact.create :first_name => Faker::Name.first_name,
:last_name => Faker:... |
##
# Runs a remote if condition and returns true/false.
#
# @param [String] conditional to be tested
# @return [true, false] whether or not the conditional passes
def cmd_if(test, rvm=false)
load_rvm = ""
load_rvm = "#{rvm_env} " if rvm
r = capture %{#{load_rvm}if #{test} ; then echo true; else echo false; fi},
... |
module Sumac
module Messages
module Component
# Representes a _Sumac_ +exception+ message component.
# Translates from an +Exception+ but to a +RemoteError+ in Ruby.
# We don't convert it to a native error as the object would not language agnostic.
# We would not want to raise an error in... |
# frozen_string_literal: true
require 'hanami/view/context'
module Sandbox
module View
class Context < Hanami::View::Context
include Deps[
'assets',
'settings'
]
def initialize(**args)
defaults = { content: {} }
super(**defaults.merge(args))
end
d... |
require File.dirname(__FILE__) + '/spec_helper.rb'
describe ImMagick::Image do
before(:all) do
@input = File.dirname(__FILE__) + '/fixtures'
@output = File.dirname(__FILE__) + '/output'
@fontpath = File.dirname(__FILE__) + '/fonts'
@fnormal = @fontpath + '/union.ttf'
@fbold = @fontpat... |
require 'test_helper'
class DeviceAssignmentsControllerTest < ActionController::TestCase
setup do
@device_assignment = device_assignments(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:device_assignments)
end
test "should get new" do
get... |
module CollectiveIdea #:nodoc:
module ActionController #:nodoc:
module Audited #:nodoc:
def audit(*models)
ActiveSupport::Deprecation.warn("#audit is deprecated. Declare #acts_as_audited in your models.", caller)
options = models.extract_options!
# Parse the options hash lo... |
require File.expand_path("../lib/scrivener", File.dirname(__FILE__))
class S < Scrivener
attr_accessor :a
attr_accessor :b
end
scope do
test "raise when there are extra fields" do
atts = { :a => 1, :b => 2, :c => 3 }
assert_raise NoMethodError do
s = S.new(atts)
end
end
test "not raise w... |
require 'csv'
require_relative 'test_helper'
require_relative '../lib/item'
require_relative '../lib/sales_engine'
class ItemTest < Minitest::Test
attr_reader :sample, :engine
def setup
@engine = SalesEngine.new
data = CSV.open("./data/item_test.csv", headers: true, header_converters: :symbol)
@sample = dat... |
require 'spec_helper'
require 'walkon/entrance_music'
module Walkon
describe EntranceMusic do
subject { EntranceMusic.new 'iPhone5' }
context "when the mp3 file is found" do
before do
allow(File).to receive(:exists?).with(subject.filename).and_return true
end
it "is considered to ... |
# encoding: UTF-8
require_relative '../test_helper'
describe Parser do
describe "parse_attributes" do
it 'must return {} for text.empty?' do
Parser.parse_attributes("").must_equal({})
end
it 'must split attributes by \n or ","' do
text = "source: creq; parent: id\nstatus: approve... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
# always use rails s -b 0.0.0.0
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define :web do |web|
web.vm.box = "ubuntu/trusty64"
web.vm.network :private_network, ip: "10.33.33.33"
web.vm.network :forwarded_port, ... |
#!/usr/bin/env ruby
require 'multi_json'
require_relative '../lib/config/app'
require_relative '../lib/config/redis'
require_relative '../lib/scraper'
SEPARATOR = "\t"
type = ARGV[0]
if type.nil? || type.empty?
puts 'Error: No export type given'
exit
end
unless Config::App.supported_type?(type)
puts 'Error:... |
class Job < ApplicationRecord
belongs_to :category, optional:true
belongs_to :company
has_many :comments
validates :title, :level_of_interest, :city, presence: true
def sort_comments
comments.order(created_at: :desc)
end
def self.level_of_interest_count
group(:level_of_interest).order(level_of_i... |
class SchedulerGame
class Map
include CyberarmEngine::Common
TILE_SIZE = 16
TILE_TYPES = {
"#" => :wall,
" " => :floor,
"F" => :field,
"P" => :pit,
"D" => :entry_door,
"I" => :competition_inlet,
"O" => :competition_outlet,
"Q" => :team_queue,
"A" => ... |
require 'rwordnet'
require 'ruby-progressbar'
require 'lemmatizer'
require 'linguistics'
require 'pry'
Linguistics.use(:en, monkeypatch: false)
class Lexicon
@@path = File.join(File.dirname(__FILE__), 'lexicon')
SPACE = ' '
attr_reader :word_pos_frequencies, :ngram_frequencies, :word_list
def initialize
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.