text
stringlengths
10
2.61M
# frozen_string_literal: true require 'test_helper' class StatusUpdateInterfaceTest < ActionDispatch::IntegrationTest include ActiveJob::TestHelper setup do @user = users(:maymie) StatusUpdate.find_each { |s| StatusUpdate.reset_counters(s.id, :comments) } StatusUpdate.find_each { |s| StatusUpdate.res...
require 'json' version = JSON.parse(File.read('package.json'))["version"] Pod::Spec.new do |s| s.name = "BpkIcon" s.version = version s.summary = "Backpack's collection of icons." s.homepage = "https://github.com/Skyscanner/backpack/tree/master/packages/react-native-bpk-component-...
class CommentsController < ApplicationController before_filter :protect_from_banned, only: :create def create @board = Board.friendly.find(params[:board_id]) @topic = Topic.find(params[:topic_id]) @comment = Comment.new(comment_params) @comment.topic = @topic @comment.ip = request.remote_addr...
class InvalidIndexError < StandardError def message "Invalid index" end end
#!/usr/bin/env ruby require 'soap/rpc/standaloneServer' require 'RAA.rb' class RAABaseServicePortType MappingRegistry = SOAP::Mapping::Registry.new MappingRegistry.set( StringArray, ::SOAP::SOAPArray, ::SOAP::Mapping::Registry::TypedArrayFactory, { :type => XSD::QName.new("http://www.w3.org/2001/X...
class TestSerializer < ActiveModel::Serializer has_many :levels, except: [:test] attributes :id, :image, :name, :brief end
class CreateEventCharity < ActiveRecord::Migration def change create_table :event_charities do |t| t.references :event t.references :charity t.timestamps end add_index :event_charities, :event_id add_index :event_charities, :charity_id end end
require('minitest/rg') require('minitest/autorun') require_relative('../ClassesLab') class TestAnimal < MiniTest::Test def test_animal animal = Animal.new("Bear", "Canada", 5) assert_equal(5, animal.age()) end def test_animal_age animal = Animal.new("Bear", "Canada", 5) animal.older() asser...
class RelsExtParser REL_NS = 'info:fedora/fedora-system:def/relations-external#' RDF_NS = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' attr_accessor :doc def initialize(rdf_xml) @doc = Nokogiri::XML.parse(rdf_xml) end def collection_member_ids rdf_ns = doc.namespaces.key(RDF_NS) rel_ns = do...
require 'base64' require 'active_support/core_ext/hash/deep_merge' module Configrr module Hosts def self.foreman_hosts Configrr::Foreman.hosts.deep_merge Configrr::Foreman.facts end def self.consul_hosts kv_prefix consul_kv = Configrr::Consul.get_kv kv_prefix hosts = Hash.new c...
class User < ApplicationRecord has_many :auctions has_many :favorites # Factory method to create a user from some omniauth data # Omniauth will use this to build a *NEW* user for us def self.from_omniauth(authentication_data) user = User.where(provider: authentication_data['provider'], ...
class StateFolderTree < FolderTree # Set filename in format [name_[0-9] - if u need to run states only for 1 block def initialize(args = nil) FileUtils.mkpath('./screenshots/states') unless File.directory?('./screenshots/states') @args = args @current_folder = './screenshots/states' @blocks = block_...
class IconDecorator < Draper::Decorator delegate_all def overview_icon h.image_tag model.overview_icon end def schedule_icon h.image_tag model.schedule_icon end def committee_icon h.image_tag model.committee_icon end def speaker_icon h.image_tag model.speaker_icon end def fee_icon h...
class Post < ActiveRecord::Base has_many :answers has_many :authors, through: :answers belongs_to :author can_count :answers can_count :authors end class Answer < ActiveRecord::Base belongs_to :post belongs_to :author end class Author < ActiveRecord::Base has_many :posts has_many :answers can...
class Answer < ApplicationRecord validates :order, presence: true validates :title, presence: true belongs_to :question, inverse_of: :answers has_many :votes end
require 'rails_helper' class Authentication include Authenticatable def request end end describe Authenticatable do let(:authentication) { Authentication.new } subject { authentication } describe "#current_user" do it "returns the user from the authorization header" do user = create(:user) ...
class Residue < ApplicationRecord belongs_to :laboratory belongs_to :collection has_many :registers, dependent: :destroy before_save { self.collection_id = (Collection.last == nil ? nil : Collection.last.id) } def weight total = 0.0 if Collection.all.empty? then total = self.registers.sum(...
require "epg_xml/version" require "nokogiri" require "time" # event = { # program_id: "uniq", # basic_description: { # title: { # main: "", # secondary: "" # }, # synopsis: { # short: "", # long: "" # }, # genre: { # name: "" # }, # parental_guidance: { # ...
require 'rails_helper' RSpec.describe "Cron job", type: :request do context "The reservation has expired" do let(:schedule) { Whenever::Test::Schedule.new(file: 'config/schedule.rb') } let!(:expired_reservation) { FactoryGirl.create(:reservation, :created_at => 1.days.ago) } let!(:reservation) { FactoryGirl....
# This migration comes from forem (originally 20120616193446) class AddForemAdmin < ActiveRecord::Migration def change unless column_exists?(user_class, :forem_admin) add_column user_class, :forem_admin, :boolean, :default => false end end def user_class Forem.user_class.table_name.downcase.to_...
require 'test_helper' class HouseholdMemberTest < ActiveSupport::TestCase test 'attributes' do household_member = HouseholdMember.new assert_respond_to(household_member, :name) assert_respond_to(household_member, :dob) assert_respond_to(household_member, :ssn) assert_respond_to(household_member,...
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 private def confirm_logged_in_admin unless session[:user_id] redirect_to(:controller=>'index',:action=>'...
#require 'HeaderValueGenerator.rb' #require 'CppHelper.rb' #require 'type_map.rb' module CodegenLib::YamlToIni class HeaderListValueGenerator include TypeResolver include CppHelper def initialize(env, type) @env = env @type = type end def generate(value_def) comment =...
class AddSplitDatesToAssignments < ActiveRecord::Migration def change add_column :assignments, :due_date, :date add_column :assignments, :due_time, :time end end
module Support module TestHelpers module LoginHelper def login_user(user) fill_login_form(user.email, "password") end private def fill_login_form(email, password) visit new_user_sessions_path begin fill_in "email", with: email fill_in "password...
require 'rails_helper' describe ApplicationController do describe 'GET #index' do it 'responds with status code 200' do get :index expect(response).to have_http_status 200 end it 'assigns @games' do get :index expect(assigns(:games)).to eq(Game.recent) end it 'renders th...
class XeroSessionsController < ApplicationController before_filter :authenticate_user! before_filter :setup_xero_interface def new request_token = @xero.request_token(oauth_callback: finish_xero_session_url(only_path: false)) session[:xero_token] = request_token.token session[:xero_secret] = request...
require_relative 'lib/tuga/version' Gem::Specification.new do |spec| spec.name = 'tuga' spec.version = Tuga::VERSION spec.authors = ['Wilson Silva'] spec.email = ['me@wilsonsilva.net'] spec.summary = 'A Portuguese script programming language.' spec.description = 'A Por...
class AddCollectionFieldsToMasterFeeReports < ActiveRecord::Migration def self.up add_column :master_particular_reports, :collection_type, :string, :null => false add_column :master_particular_reports, :collection_id, :integer, :null => false add_column :master_discount_reports, :collection_type, :string...
require 'green_gardens' require 'rspec' describe LushGreenGardens do let(:garden) { LushGreenGardens.new("REWEL") } let(:R) do [ 2,3,3,3,3,3,0, 2,3,2,3,2,2,0, 2,3,3,2,3,3,0, 2,2,2,2,2,2,0 ] end let(:E) do [ 2,3,3,3,3,3,0, 2,3,2,3,2,3,0, 2,3,2,2,2,3,0, ...
class Api::GradingLevelsController < ApiController filter_access_to :all def index @xml = Builder::XmlMarkup.new batch = Batch.active.find(:first,:conditions => ["CONCAT(courses.code, ' - ',name) LIKE ?",params[:batch]],:joins=>:course).try(:id) @grading_levels = GradingLevel.for_batch(batch) @grad...
# Leetcode setup: # Determine whether an integer is a palindrome. Do this without extra space. # @param {Integer} x # @return {Boolean} def is_palindrome(x) return false if x > 2147483647 || x < -2147483648 result = false str = x.to_s.reverse int = str.to_i return true if str.length <= 1 return false if ...
Rails.application.routes.draw do root 'sessions#login' get '/login', to: 'sessions#login' post '/login', to: 'sessions#create' get '/logout', to: 'sessions#logout' resources :students resources :instructors resources :courses resources :cohorts end
require 'rails_helper' describe Seed do before { @seed = create(:seed) } subject { @seed } it { should respond_to :seed } it { should respond_to :user } it { should respond_to :task } end
# Trigger shutdown on INT or TERM signals o_int = Signal.trap("INT") { o_int.call if o_int.respond_to?(:call) if Bogo::Cli.exit_on_signal == false Thread.main.raise SignalException.new("SIGINT") else exit 0 end } o_term = Signal.trap("TERM") { o_term.call if o_term.respond_to?(:call) if Bogo::Cli.e...
class RepresentativesStaffersJoin < ActiveRecord::Migration def change create_join_table :representatives, :staffers end end
def quick_sort(list, start_point = nil, end_point = nil) if start_point && end_point # This enables the initial call to quick_sort to require only the array as an argument return list if start_point >= end_point left = start_point right = end_point pivot = start_point else # In the initial call, lef...
module AddressesHelper def address_columns { id: 'ID', addressable: 'Addressable', title: 'Title', line1: 'Line 1', line2: 'Line 2', city: 'City', state: 'State', zip: 'ZIP', country: 'Country', ...
class Word < ActiveRecord::Base validates :kanji, :uniqueness => true has_and_belongs_to_many :characters def as_json(options={}) {'word' => kanji, 'reading' => reading, 'meaning' => meaning } end end
# -*- coding: utf-8 -*- require "ja_to_time" describe JaToTime do it do @ja = "2013年12月14日(土) 9時15分" expect(@ja.ja_to_time).to be_a_kind_of(Time) end it do @ja = "2013年12月14日(土) 9時15分" expect(@ja.ja_to_time).to eq(Time.new(2013, 12, 14, 9, 15)) end it do @ja = "2013年12月14日(土) 午前9時15分" ...
#!/usr/bin/env ruby require 'fileutils' require 'socket' require_relative 'sudome.rb' abort "Development URL and path must be provided" if ARGV.count != 2 abort "Must be run as root" if !is_root host = Socket.gethostname if host == 'server' CONFIG_DIR = "/home/matt/www/conf/" IP = "69.195.198.179" else CONFIG_DI...
describe Importer::Overtimes do include_context "importer" let(:record) {{ :id=>"001701", :name=>"Kirk,James", :rank=>"SgtDet", :assigned=>"A-1 DCU SQUAD", :charged=>"A-1 DCU SQUAD", :otdate=>"02-Jan-14", :descriptions=>"COURT CODE ONLY", :otcode=>"280", :description=>"COURT:TRI...
# encoding: utf-8 class Admin::AdminController < ActionController::Base #helper :all protect_from_forgery layout 'admin' before_filter :admin_login_required def current_admin # end def is_login? !!session[:admin] end helper_method :is_login? private def admin_login_required redirec...
class CoffeesController < ApplicationController def index coffees = Coffee.all render json: CoffeeSerializer.new(coffees).serializable_hash end def show coffee = Coffee.find(params[:id]) options = {include: [:reviews]} render json: CoffeeSerializer.new(coffee, options).serializable_hash end end
require File.expand_path("../../spec_helper", __FILE__) describe Secretary::Config do describe "::configure" do it "generates a new Config object" do Secretary::Config.should_receive(:new) Secretary::Config.configure end it "accepts a block with the config object" do Secretary::Con...
require File.dirname(__FILE__) + '/spec_helper' require "moneta/rufus" describe "Moneta::Rufus" do before(:each) do @cache = Moneta::Rufus.new(:file => "cache") @cache.clear end it_should_behave_like "a read/write Moneta cache" end
class SupplyTransactionsController < ApplicationController before_action :set_supply_transaction, only: [:show, :edit, :update, :destroy] before_action :authenticate_user! # GET /supply_transactions # GET /supply_transactions.json def index @supply_transactions = SupplyTransaction.all end # GET /supp...
class SolarSystem attr_reader :star_name, :planets def initialize(star_name) @star_name = star_name @planets = [] end def add_planet(planet) @planets << planet end def list_planets output = "Planets orbiting #{@star_name}\n" @planets.length.times do |index| output ...
# frozen_string_literal: true require 'spec_helper' require 'puppet/type/registry_value' describe Puppet::Type.type(:registry_value) do let(:catalog) { Puppet::Resource::Catalog.new } [:ensure, :type, :data].each do |property| it "has a #{property} property" do expect(described_class.attrclass(property...
class RemoveSpacesFromBoards < ActiveRecord::Migration[5.2] def change remove_column :boards, :spaces, :string end end
# :title: Pivotal Tracker RSS feed reader for rbot # Licensed under the terms of the GNU General Public License v2 or higher # Copyright Aziz Shamim and James Fryman 2011 require 'rubygems' require 'simple-rss' require 'open-uri' require 'htmlentities' require 'time' class RSSWatchPlugin < Plugin def initialize ...
# frozen_string_literal: true module Recipes module Entities class Chef < Dry::Struct module Types include Dry.Types() end attribute :id, Types::String attribute :name, Types::String def self.wrap_entity(item) new(id: item['sys']['id'], name: item['fields']['name']...
# frozen_string_literal: true module Api::V1::User::Relationships::FavoriteCoaches DestroySchema = Dry::Validation.Params(BaseSchema) do required(:favorite_coach_pks).each(:int?) end end
# Documentation: https://docs.brew.sh/Formula-Cookbook # https://rubydoc.brew.sh/Formula # PLEASE REMOVE ALL GENERATED COMMENTS BEFORE SUBMITTING YOUR PULL REQUEST! class Btplayersetup < Formula desc "" homepage "" url "https://github.com/pritamwipro/btplayersetup/archive/v1.1.5.tar.gz" sha256 "7...
require 'ruby2d' set background: 'navy' GRID_SIZE = 20 class Snake def intialize @postions = [[2, 0], [2, 1], [2, 2], [2, 3]] end def draw @postions.each_do |position| Square.new(x: position[0] GRID_SIZE, y: position[1] * GRID_SIZE, size: GRID_SIZE, color: 'white') end end end Snake.new snake.draw
require 'spec_helper' require 'item' describe Item do name = 'fixme' sell_in = 10 quality = 5 let(:item) { Item.new(name, sell_in, quality) } describe '#new' do it 'is the name of item being sold' do expect(item.name).to eq 'fixme' end end it 'tells us how many days are left for the item ...
class HomeController < ApplicationController before_action :post_params, only: %I[show destroy] before_action :posts_params, only: %I[show] before_action :comment_params, only: %I[index show] def index @user = current_user @users = User.all @post = Post.new @posts = Post.order('created_at desc'...
FactoryGirl.define do factory :task do name { FFaker::Lorem.sentence } end factory :completed_task, parent: :task do complete true end end
module Referrer module TrackedModelAdditions extend ActiveSupport::Concern included do has_one :tracked_relation, as: :trackable, class_name: 'Referrer::SourcesTrackedObject' def referrer_link_with(r_user, linked_at: nil) create_tracked_relation(user: r_user, linked_at: linked_at) ...
class CreateChampionshipPlayers < ActiveRecord::Migration def change create_table :championship_players do |t| t.references :championship, index: true, null: false t.references :player, index: true, null: false t.timestamps end add_index :championship_players, [:championship_id, :playe...
class BrowserStakeout class Application class << self def run!(*arguments) options = BrowserStakeout::Options.new(arguments) if options[:invalid_argument] $stderr.puts "Invalid argument: #{options[:invalid_argument]}" options[:show_help] = true end ...
class ChannelsController < ApplicationController before_action :channel begin require 'piface' rescue Exception puts 'Error: piface not defined!' end def on render text: set_channel(@channel, 1) end def off render text: set_channel(@channel, 0) end def status render text: read_...
require 'mail' class EmailValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) begin mail = Mail::Address.new(value) # check legal address res = mail.domain and mail.address == value # analyze tree = mail.__send__(:tree) res &&= (tree.domain.dot...
class Book #get method def title @title end #set method with capialization logic built in def title=(new_title) split_up_title = new_title.split working_title = [] uncapitalized = ["the","and","to","a","an","in","of"] working_title.push(split_up_title.shift.capitalize) split_up_title.each do |wor...
require 'rest-client' require 'json' require_relative 'activity_class' #Data for API access #Info on creating an app and authenticated token here: http://developer.runkeeper.com/healthgraph/getting-started base_url = 'https://api.runkeeper.com' params = { :access_token => ENV['RUNKEEPER_USER_TOKEN'] } #Get Activity L...
class ApplicationController < ActionController::Base rescue_from CanCan::AccessDenied do |exception| flash[:error] = "Zugriff Verweigert! Bitte registrieren Sie sich! " redirect_to root_url end def authenticate_admin_user! redirect to new_user_session_path unless current_user && current_user.has_role?(:admin) ...
class Pin < ApplicationRecord acts_as_votable belongs_to :user has_attached_file :image, styles: { medium: "300x300" } validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/ validates_attachment_file_name :image, matches: [/png\z/, /jpe?g\z/] # validates :title, :description, :image, prese...
class RemoveAccountTypeFromTransactions < ActiveRecord::Migration def change remove_column :transactions, :account_type, :string end end
class AccountsController < ApplicationController before_filter :grab_user_from_session def home @page = (params[:page] || 0).to_i @date = grab_date || Time.zone.today @spots = @user.spots.order("id desc").where("created_at > :begin AND created_at <= :end", begin: @date.beginning_of_day, end: @date.en...
require './lib/ppt_game.rb' describe PiedraPapelTijera do it 'Muestra la seleccion del usuario' do ppt= PiedraPapelTijera.new seleccion= ppt.seleccion_usuario("Piedra") expect(seleccion).to eq "Piedra" end it 'Muestra la seleccion de la maquina se envia 1 y regresa Papel' do ...
#!/usr/bin/env ruby # (c) Copyright 2016 Thoughtgang <http://www.thoughtgang.org> # Unit tests for PlanR plugin API require 'test/unit' require 'plan-r/plugin' $TG_PLUGIN_FORCE_VALID_RETURN = true # =========================================================================== # Interfaces SPEC_UNARY=:unary_operation S...
require 'spec_helper' describe Product do it { should belong_to(:seller) } it { should have_and_belong_to_many(:tags) } it { should have_and_belong_to_many(:sizes) } it { should have_and_belong_to_many(:colors) } it { should have_one(:price) } it { should validate_presence_of(:name) } it { should validat...
lib = File.expand_path('../lib/', __FILE__) $:.unshift lib unless $:.include?(lib) require 'bcdatabase/version' Gem::Specification.new do |s| s.name = 'bcdatabase' s.version = Bcdatabase::VERSION s.summary = %Q{Server-central database configuration for rails and other ruby apps} s.description = %Q{bcdatabase ...
def dir(*args); Dir.chdir(File.join(File.dirname(__FILE__), *args)); end desc "Compile local copy" task :compile do cd("ext") do system "ruby extconf.rb" system "make" end end task :clean do cd("ext") do system "make clean" end end desc "Package the gem" task :gem do dir('.') system "gem bui...
require 'sqlite3' require 'active_record' require 'byebug' ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => 'customers.sqlite3') class Customer < ActiveRecord::Base def to_s " [#{id}] #{first} #{last}, <#{email}>, #{birthdate.strftime('%Y-%m-%d')}" end # NOTE: Every one of thes...
# -*- encoding : utf-8 -*- require 'rails_helper' RSpec.describe Users::RegistrationsController, type: :controller do include Devise::TestHelpers self.use_transactional_fixtures = false before(:all) do DatabaseCleaner.strategy = :truncation end after(:all) do DatabaseCleaner.strategy = :transactio...
class Collection < ActiveRecord::Base validates_presence_of :name # validates :name, uniqueness: { case_sensitive: false } validate :unique_name, :on => :create validates :about, length: { maximum: 255 } has_many :items, inverse_of: :collection belongs_to :publisher, inverse_of: :collections def to...
class Task < ApplicationRecord belongs_to :category has_many :sub_tasks, class_name: "Task", dependent: :destroy accepts_nested_attributes_for :sub_tasks validates :title, presence: true end
class HealthInsurance < ApplicationRecord belongs_to :user validates_presence_of :company, :plan, :card_number end
class SessionsController < ApplicationController def create @user = User.find_by :email => params[:email] if @user.nil? flash[:danger] = "No such user." elsif @user.authenticate params[:password] session[:current_user_id] = @user.id flash[:info] = "Thank you for logging in, #{@user.na...
require 'legion/transport/exchanges/task' module Legion module Exception class InvalidTaskStatus < ArgumentError # exception class end class InvalidTaskId < ArgumentError # exception class end end end module Legion module Transport module Messages class TaskUpdate < Legion...
module Effect class MoralityRestriction attr_reader :parent attr_reader :mo_min, :mo_max def initialize(parent, min, max) @parent = parent @mo_min = min @mo_max = max end def learn_intent_callback(action, intent) intent.entity.mo >= @mo_min * 10 && intent.entity.mo <= @mo_max * 10 if action ==...
require 'irobot' class RequestCacheTest NAMESPACE = 'request_spec' attr_accessor :cache def initialize @cache = {} end def get(request) if cache.has_key?(request.to_key) Marshal::load(cache[request.to_key]) end end def set(request, response, details = {}) cache[request.to_key] = ...
module DmcKanye class TimeoutException < RuntimeError; end module DriverHelpers # If the browser is waiting for ajax or loading a page, Kanye is smart # enough to deal with this. However, if the browser is busy doing something # else for a significant period of time (such as long-running JavaScript)...
require 'spec_helper' describe MessagePresenter do let(:message) { double('message', id: 22, content: 'Hey Ya!', created_at: 2.hours.ago, sender_handle: 'bob@CUSS', attachment: nil, ...
# taken from https://raw.githubusercontent.com/collectiveidea/audited/master/lib/generators/audited/install_generator.rb require 'rails/generators' require 'rails/generators/migration' require 'active_record' require 'rails/generators/active_record' require 'generators/specmon/migration' module Specmon module Genera...
class Pokeset include Comparable def initialize(set = []) @set = set end def <=>(other) if other.nil? 1 elsif length != other.length length <=> other.length elsif total_length != other.total_length total_length <=> other.total_length else 0 end end def code...
require "application_system_test_case" class TrnProdPlanHeadersTest < ApplicationSystemTestCase setup do @trn_prod_plan_header = trn_prod_plan_headers(:one) end test "visiting the index" do visit trn_prod_plan_headers_url assert_selector "h1", text: "Trn Prod Plan Headers" end test "creating a ...
# coding: utf-8 FactoryGirl.define do factory :artist, aliases: [:rap_group_member] do sequence(:name) { |n| "Эмси-#{n}" } city 'Харьков' bio 'Экспериментальный абстрактно-оральный хип-хоп с элементами легкой философской мысли, которая вредна.' rap_group false end factory :rap_group, parent: :ar...
# # Cookbook Name:: zarafa-sabredav # Recipe:: default # # Copyright 2014, computerlyrik, Christian Fischer # # 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/licen...
class Msp430Gcc < Formula homepage "http://mspgcc.sourceforge.net" url "https://ftpmirror.gnu.org/gcc/gcc-4.7.0/gcc-4.7.0.tar.bz2" sha256 "a680083e016f656dab7acd45b9729912e70e71bbffcbf0e3e8aa1cccf19dc9a5" env :std depends_on "msp430-binutils" depends_on "mpfr" depends_on "gmp" depends_on "isl" depend...
class AddUserToGifts < ActiveRecord::Migration[5.1] def change add_column :gifts, :user_id, :integer add_index :gifts, :user_id add_foreign_key :gifts, :users end end
# a Crop is the basic searchable unit within OpenFarm. The term 'plant' was # avoided to stay generic (ex: edible fungi). class Crop include Mongoid::Document include Mongoid::Timestamps include Mongoid::Slug searchkick is_impressionable counter_cache: true, column_name: :impressions, ...
require 'rails_helper' RSpec.describe Bigcategory, type: :model do describe 'validation' do it { should validate_presence_of(:name) } end describe 'association' do it { should have_many(:categories) } end end
require 'gosu' class GameWindow < Gosu::Window attr_reader :score attr_reader :blip_sound attr_reader :explosion_sound def initialize super 640, 480 self.caption = "Pong" margin = 20 @player = Paddle.new( margin, margin ) @last_mouse_y = margin @enemy = Paddle.new( self.width - Pad...
# encoding: utf-8 require File.expand_path("../spec_helper", __FILE__) bug "WTR-357", :watir do describe "TableHeaders" do before :each do browser.goto(WatirSpec.files + "/tables.html") end describe "#length" do it "returns the correct number of table theads (page context)" do browse...
require 'extensions/mktmpdir' require 'astrails/safe/tmp_file' require 'astrails/safe/config/node' require 'astrails/safe/config/builder' require 'astrails/safe/stream' require 'astrails/safe/source' require 'astrails/safe/mysqldump' require 'astrails/safe/archive' require 'astrails/safe/pipe' require 'astrails/saf...
# coding: utf-8 require 'natto/binding' require 'natto/option_parse' require 'natto/struct' module Natto # `MeCab` is a class providing an interface to the MeCab library. # Options to the MeCab Model, Tagger and Lattice are passed in # as a string (MeCab command-line style) or as a Ruby-style hash at # initia...
class Post < ActiveRecord::Base belongs_to :user has_attached_file :image, styles: { medium: '300x300>', thumb: '100x100>' }, default_url: '/images/:style/missing.jpg' validates_attachment_content_type :image, content_type: ['image/jpeg'...
require 'rexml/document' require 'digest/md5' module ActiveMerchant #:nodoc: module Billing #:nodoc: class PiryxGateway < Gateway self.money_format = :dollars self.supported_cardtypes = [:visa, :master, :american_express, :discover] self.supported_countries = ['US'] self.display_name = '...