text stringlengths 10 2.61M |
|---|
class LuaPam < Formula
desc "Lua module for PAM authentication"
homepage "https://github.com/devurandom/lua-pam"
head "https://github.com/dustinwilson/lua-pam.git"
depends_on "lua51"
keg_only ""
def install
ENV.deparallelize
lua51 = Formula["lua51"]
system "make LUA_VERSION=5.1 LUA_CPP... |
class QuestionsChannel < ApplicationCable::Channel
def subscribed
stream_for 'questions'
end
def follow
unfollow
stream_from 'questions'
end
def unfollow
stop_all_streams
end
end
|
class Chapter < ApplicationRecord
has_many :comments, dependent: :destroy
has_many :pictures, dependent: :destroy
belongs_to :comic
accepts_nested_attributes_for :pictures, allow_destroy: true,
reject_if: proc{|attributes| attributes["picture"].blank?}
validates :name, presence: true,
... |
require "base_stitch"
# Decorator pattern
class Increase < BaseStitch
attr_reader :children
def initialize(children = [])
@children = children
end
def make
"#{@children.map(&:make).join(' ')} #{self.class.abbrev}"
end
def self.abbrev
"inc"
end
def count
children_count = @children.su... |
require 'prawn' unless defined?Prawn
require 'prawn/qrcode' unless defined?Prawn::QRCode
module Yito
module Model
module Booking
module Pdf
#
# See https://es.qr-code-generator.com/#text
# See https://github.com/jabbrwcky/prawn-qrcode
# See https://github.com/whomwah/rqrcode
... |
class CreateWines < ActiveRecord::Migration
def change
create_table :wines,{:primary_key => :wine_id} do |t|
t.string :wine_id
t.string :wine_name
t.string :comments
t.decimal :price
t.timestamps
end
end
end |
class RemoveDefaultsFromCompetitions < ActiveRecord::Migration
def up
change_column :competitions, :puzzle_id, :integer, :null => false
change_column_default :competitions, :puzzle_id, nil
end
def down
change_column :competitions, :puzzle_id, :integer, :null => false, :default => 0
end
end
|
class JobSerializer < ActiveModel::Serializer
attributes :id, :state, :metadata, :url
end
|
class Router
def initialize
@controller = Controller.new
end
def run
welcome_user
loop do
print_menu
action = gets.chomp.to_i
route_action(action)
end
end
def route_action(action)
case action
when 1 then @controller.index
when 2 then @controller.create
when 3 then @controller.delete
... |
class Router
@defined_routes = {}
def self.draw &block
yield block
end
def self.parse(path)
return { controller: 'home', action: 'page_not_found' } unless @defined_routes.has_key?(path)
@defined_routes[path]
end
def self.get(path, options)
controller, action = options[:to].split('#')
... |
# frozen_string_literal: true
module Dataprobe
class Ipio
attr_reader :ip, :port
attr_accessor :username, :password
def initialize(host, options = {})
@ip = host
@port = options[:port] || 9100
@username = (options[:username].presence || "user").ljust(21, "\x00")
@password = (op... |
class Owner::BookingsController < ApplicationController
before_action :authenticate_user!
before_action :set_booking, only: [:show, :update, :destroy]
#GET booking
def index
@bookings=Club.find_by(id: params[:club_id]).bookings
json_resp... |
require "json"
require 'securerandom'
require 'byebug'
# Utility method. Extract from http://bit.ly/2s18jyO
def distance loc1, loc2
rad_per_deg = Math::PI/180
rkm = 6371
rm = rkm * 1000
dlat_rad = (loc2[0]-loc1[0]) * rad_per_deg
dlon_rad = (loc2[1]-loc1[1]) * rad_per_deg
... |
require "benchmark"
ADD = 110
SUB = 111
MUL = 112
DIV = 113
FSET_START = ADD
FSET_END = DIV
MAX_LEN = 10000
POPSIZE = 10000
DEPTH = 5
GENERATIONS = 100
TSIZE = 2
PMUT_PER_NODE = 0.05
CROSSOVER_PROB = 0.9
class TinyGP
attr_accessor :pop
def initialize(fname, s)
@buffer = Array.new(MAX_LEN, 0)
@fbestpop = 0... |
module Fog
module Compute
class Brkt
class Real
def list_servers(filter = {})
request(
:expects => [200],
:path => "v2/api/config/instance",
:query => filter
)
end
end
class Mock
def list_servers(filter = {})
... |
# 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... |
AutocompleteSelect::Engine.routes.draw do
resources :autocompletes, :path => '/', :only => [:show]
end
|
require File.dirname(__FILE__) + '/spec_helper'
require 'support/sequel_environment'
describe Machinist::Sequel do
include SequelEnvironment
before(:each) do
empty_database!
end
context "make" do
it "returns an unsaved object" do
SequelEnvironment::Post.blueprint { }
post = SequelEnvironm... |
class Account < ApplicationRecord
belongs_to :customer
has_many :loans
has_many :lockers
has_many :transactions
validates :account_no, presence: true, length: { minimum: 4 }
validates :balance, presence: true
end
|
#encoding: utf-8
class Cpanel::TrashController< Cpanel::ApplicationController
set :views, ENV["VIEW_PATH"] + "/cpanel/trash"
before do
authenticate!
end
# GET /account
get "/" do
@campaigns = Campaign.not_normals
@orders = Order.not_normals
@packages = Package.not_normals
haml :inde... |
class Activity < ActiveRecord::Base
belongs_to :user
belongs_to :student
belongs_to :activity_type
validates :title, :student_id, :activity_type_id, :description, :activity_datetime, presence: true
end
|
Rails.application.routes.draw do
namespace :api do
namespace :v1 do
get 'merchants/find', to: 'merchants/search#find'
get 'items/find_all', to: 'items/search#find_all'
scope 'revenue' do
get '/merchants/:id', to: 'revenue#merchant_total_revenue'
get '/items', to: 'revenue#item_ra... |
KwFasterm::Application.routes.draw do
match 'vantagens' => "static_content#advantages"
match 'aquisicoes' => "static_content#acquisition"
#Inicio Namespace Admin
namespace(:admin){
resources(:sections){
resources :categories
}
resources(:categories){
resources :products
}... |
module AuthorizedByUpdater
extend ActiveSupport::Concern
included do
attr_accessor :updater
validate :can_update, on: :update
end
private
def can_update
errors.add(:id, "you can not update that #{self.class.name}") unless updater.try("can_update_#{self.class.name.downcase}?".to_sym, self) || Us... |
module PostsHelper
def index_display(blog)
final_html = "<div id='post-body'>"
final_html += content_tag :div do
[ "<div class='post-topic'",
link_to(blog.title,post_path(blog.id)),
"</div>"
].join(' ').html_safe
end
final_html += content_tag :div do
[
"<di... |
LightweightStandalone::Application.routes.draw do
resources :approved_scripts
resources :projects do
member do
get :about
get :help
get :contact_us
end
end
resources :themes
root :to => 'home#home'
resources :question_trackers do
member do
post 'add_embeddable'
... |
# frozen_string_literal: true
Rails.application.routes.draw do
root to: 'products#index'
get 'products/search', to: 'products#search', as: :search_products
resources :products, only: %w[new create destroy edit update]
resources :departments
end
|
FactoryGirl.define do
factory :symptom do
transient do
supplement_count 0
end
name { Faker::StarWars.planet }
description { Faker::StarWars.quote }
symptom_group
supplements { build_list :supplement, supplement_count }
end
end
|
require 'racc/util'
require 'racc/color'
require 'tempfile'
require 'set'
module Racc
module Graph
# Algorithms which work on any of the graph implementations below
module Algorithms
# shortest path between nodes; both start and end points are included
def shortest_path(start, dest)
# Dij... |
class PoliticiansController < ApplicationController
def show
@politician = Politician.find(params[:id])
end
def index
if !params['query'].nil?
@politicians = Politician.send(search_method,search_value).send(filter_method)
else
@politicians = Politician.order('Random()').first(9)
end
... |
class MailerWorker < BaseWorker
def perform(mailer_method_name, mailer_method_arguments)
log "Sending Email"
mail = Notify.send(mailer_method_name, *mailer_method_arguments)
mail.deliver!
log "Email Sent"
rescue Exception => e
log e.message
log e.backtrace
raise e
end
end |
class Item < ActiveRecord::Base
has_one :item_detail
validates_presence_of :category_id, :name, :top_img_url, :price, :star, :asin
validates :category_id, numericality: {only_integer: true}
validates :price, numericality: {only_integer: true, greater_than: 0}
validates :star, numericality: true
end
|
class SendSecondNotificationJob < ApplicationJob
queue_as :default
def perform(ticket)
@ticket = ticket
SecondNotificationMailer.second_notification_email(@ticket).deliver_later
end
end
|
# Read about factories at https://github.com/thoughtbot/factory_bot
FactoryBot.define do
factory :sensor do
sequence(:name) { |i| "MyString#{i}" }
trait(:with_user) do
user
end
end
end
|
class Address < ApplicationRecord
belong_to :customer
validates :postal_code, format: { with: /\A\d{3}[-]\d{4}\z/ }
validates :address, presence: true
end
|
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'netvisor/version'
Gem::Specification.new do |spec|
spec.name = "netvisor"
spec.version = Netvisor::VERSION
spec.authors = ["Timo Sand"]
spec.email = ["timo.j.... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root to: "static_pages#root"
namespace :api, default: { format: :json } do
resource :session, only: [:create, :destroy], defaults: {format: :json}
resources :users, only: ... |
# Write another method that returns true if the string passed as an argument is a palindrome, false otherwise. This time, however, your method should be case-insensitive, and it should ignore all non-alphanumeric characters. If you wish, you may simplify things by calling the palindrome? method you wrote in the previou... |
class DocprefixesController < ApplicationController
def index
@docprefixes = Docprefixes.all
render json: @docprefixes
end
end
|
class DateRangeSearch
attr_reader :date_from, :date_to
def initialize(date_range={})
## params[:date_range]
# date_range ||= {}
@date_from = parsed_date(date_range[:date_from], 1.year.ago.to_date.to_s)
@date_to = parsed_date(date_range[:date_to], Date.today.to_s)
end
# define date range q... |
require 'stringio'
module CaptureStdout
def capture_stdout
hoge = StringIO.new
$stdout = hoge
yield
$stdout = STDOUT
hoge.string
end
end
|
namespace :find_new_partner do
desc 'Looking for partners'
task go: :environment do
orders = Order.joins(:booking_line).where(
'order_booking_lines.status = ? and order_booking_lines.expiry_at < ?',
Constants::BookingLineStatus::PROCESSING,
Time.now
).includes(:booking_line)
orders.ea... |
require 'optparse'
module Repub
class App
module Options
include Logger
attr_reader :options
def parse_options(args)
# Default options
@options = {
:add => [],
:after => [],
:before => [],
:browser => ... |
class LawyersController < ApplicationController
before_action :register
def index
@grid = LawyersGrid.new(params[:lawyers_grid])
respond_to do |f|
f.html do
@grid.scope {|scope| scope.page(params[:page]) }
end
f.csv do
send_data @grid.to_csv(col_sep: ";").encode("ISO-8859-1"),
type: "text/c... |
require "./lib/event"
describe Event do
context "the event with only one tag named description" do
subject(:event1) {
Event.new("Programming", "some ruby fastive events about programming scince", "Tambov", "10.02.2005", "12.02.2005", "tambov@fastive.ru", "google")
}
it "returns the event with all ... |
require 'yaml'
module Shomen
# Encapsulate metadata, which preferably comes from a .ruby file,
# but can fallback to a gemspec.
#
class Metadata
include Enumerable
# Present working directoty.
PWD = Dir.pwd
# Glob pattern for looking up gemspec.
GEMSPEC_PATTERN = '{.gemspec,*.gemspec}'
... |
class Article < ApplicationRecord
include ActionView::Helpers::DateHelper
belongs_to :user
has_many :comments
validates_presence_of :title, :content, :user
def posted_at
distance_of_time_in_words(Time.now, created_at)
end
def comments_count
comments.size
end
end
|
class AddSharingOptionsToProject < ActiveRecord::Migration
def change
add_column :projects, :share_on_twitter, :boolean, :default => false
add_column :projects, :share_on_facebook, :boolean, :default => false
end
end
|
module PhoneGapRepo
@@BASE_URL = "http://github.com/phonegap/phonegap-PLATFORM.git".freeze
def self.url_for name
@@BASE_URL.sub("PLATFORM", name.to_s)
end
end
class PhoneGapVersionNumber
include Comparable
attr_accessor :string_rep, :major, :global, :minor, :patch
def initialize version_string
... |
class AddPositionToTopimages < ActiveRecord::Migration
def change
add_column :topimages, :position, :integer, :default =>0
end
end
|
class BilligTicketCard < ActiveRecord::Base
self.primary_key = :card
belongs_to :member, foreign_key: :owner_member_id
has_many :billig_purchases, foreign_key: :owner_member_id, primary_key: :owner_member_id
attr_accessible :card, :owner_member_id, :membership_ends
end
|
class TaskComment < ActiveRecord::Base
attr_accessor :linked_content
belongs_to :task
belongs_to :creator, class_name: 'User'
validates :task_id, presence: true
validates :creator_id, presence: true
validates :content, presence: true
# 自動リンク
def linked_content
content_safe = ERB::Util.html... |
class CreateLocations < ActiveRecord::Migration
def change
create_table :locations do |t|
t.string :original_address # actual location as typed in by user, usually equals geocoded_location
t.string :geocoded_address # as geocoded by geocoder gem
t.string :country_code, limit: 2 # alpha2 ISO cou... |
require 'rspec'
require 'exercises'
describe "#strange_sums" do
it "accepts an array of numbers" do
expect(strange_sums([]))
end
it "should return number of distinct pairs of elements with a sum of zero" do
expect(strange_sums([2,-3,3, 4, -2])).to eq(2)
expect(strange_sums([42... |
# -*- encoding : utf-8 -*-
class ArticlesController < ApplicationController
#简单身份认证,除了:index,:show都需要认证
http_basic_authenticate_with name: 'quanpower',password: '123',except: [:index, :show]
def new
@article = Article.new
end
def create
@article = Article.new(article_params) # 获取Article.new属性,自动映射... |
class ProfilesController < ApplicationController
before_filter :authenticate_user!
before_action :set_profile, only: [:show, :edit, :update, :destroy]
# GET /profiles
# GET /profiles.json
def index
@profiles = Profile.all
end
# GET /profiles/1
# GET /profiles/1.json
def show
end... |
FactoryBot.define do
factory :management_consultancy_supplier, class: ManagementConsultancy::Supplier do
name { Faker::Name.unique.name }
contact_name { Faker::Name.unique.name }
contact_email { Faker::Internet.unique.email }
telephone_number { Faker::PhoneNumber.unique.phone_number }
after :crea... |
require 'helper'
class TransitionsTest < Minitest::Test
class UserStates < StateManager::Base
module TrackEnterExitCounts
attr_reader :enter_count
attr_reader :exit_count
def initialize(*args)
super(*args)
@enter_count = 0
@exit_count = 0
end
def enter
... |
module ActsAsCsv
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def acts_as_csv
include InstanceMethods
end
end
class CsvRow
def method_missing name, *args
header_name = name.to_s
index = @headers.find_in... |
class CreateLooks < ActiveRecord::Migration
def change
create_table :looks do |t|
t.references :color, index: true, foreign_key: true
t.references :room, index: true, foreign_key: true
t.references :user, index: true, foreign_key: true
t.string :title
t.string :img
t.integer :b... |
class CreateMerchantStores < ActiveRecord::Migration
def change
create_table :merchant_stores do |t|
t.string :name
t.string :address
t.string :telephone
t.string :business_hours
t.references :canton
t.references :business_circle
t.string :description
t.decimal :gps... |
#!/usr/bin/env ruby
require 'net/http'
require 'net/https'
require 'net/smtp'
require 'uri'
require 'rubygems'
require 'markaby'
require 'json'
require 'pp'
user=ARGV[0]
def get_base_url()
url = "https://my.vocalocity.com/appserver/rest"
end
def get_response_from_url(url)
url = get_base_url + url
uri = URI.par... |
Rails.application.routes.draw do
# root :to => 'main#index'
root :to => 'accounts#index'
get 'dashboard' => 'main#index', :as => :dashboard
get 'account/index' => 'accounts#index', :as => :account_index
get 'account/login' => 'accounts#login', :as => :account_login
post 'account/login' => 'accou... |
require 'rails_helper'
RSpec.describe UploadController, type: :controller do
describe '#create' do
it 'upload images' do
pintassilgo_file = File.join(Rails.root, '/spec/fixtures/images/pintassilgo.jpg')
rouxinol_file = File.join(Rails.root, '/spec/fixtures/images/rouxinol.jpg')
params = {
... |
class CreateFinanceTransactionFines < ActiveRecord::Migration
def self.up
create_table :finance_transaction_fines do |t|
t.integer :finance_transaction_id, :null => false, :index => true
t.integer :multi_transaction_fine_id, :null => false, :index => true
t.timestamps
end
add_index :fina... |
class MomentumCms::PageSerializer < ActiveModel::Serializer
#-- Attributes ------------------------------------------------------------
attributes :id,
:identifier,
:label,
:slug,
:template_id,
:created_at,
:updated_at
end
|
#!/usr/bin/env ruby
require 't'
# Output message to $stderr, prefixed with the program name
def pute(message="")
$stderr.puts "#{$0}: #{message}"
end
begin
T::CLI.start(ARGV)
rescue Interrupt
pute "Quitting..."
exit 1
rescue Twitter::Error::BadRequest => error
pute error.message
exit 400
rescue OAuth::Un... |
class FavoritesController < ApplicationController
def index
@favorite = Favorite.all
end
def new
@favorite = Favorite.new
end
def create
@favorite = Favorite.new(favorite_params)
if @favorite.valid?
@favorite.save!
redirect_to favorite_path(@favorite)
else
render :new
... |
# frozen_string_literal: true
module Decidim
module Opinions
# Simple helpers to handle markup variations for opinions
module OpinionsHelper
def opinion_reason_callout_args
{
announcement: {
title: opinion_reason_callout_title,
body: decidim_sanitize(translated... |
class Schedule < ApplicationRecord
has_many :answer
default_scope -> { order(ymd: :asc) }
end
|
# Basic Assignment 2
# .next .skip
# There is a method called 'next' within Ruby class Fixnum that returns the next number assigned to itself. For example, 4.next returns 5. 4.next.next would return 6. Create a new method called 'prev' and have this method be added to Ruby class Fixnum. Have prev method return the pr... |
class SessionsController < ApplicationController
def create
@user = User.koala(auth_hash['credentials'])
session = UserSession.new(@user)
session.save
redirect_to new_dashboard_expense_path
end
def destroy
current_user_session.destroy if current_user_session
redirect_to root_path
end
... |
class Bear
attr_accessor :name, :type
def initialize(name,type)
@name = name
@type = type
@food = []
end
def roar
return "Hello"
end
def food_collection
@food.length
end
# def take_fish_from_river
#
# end
end
|
module Gradebook
module Components
class SubjectFactory < ComponentFactory
def process_and_build_components
@subject_sets = new_collection
return @subject_sets if activity_exam_report?
student_subjects = student.subjects.collect(&:id)
skill_assessments_present = has_exam_grou... |
class Highlight < Formula
desc "Convert source code to formatted text with syntax highlighting"
homepage "http://www.andre-simon.de/doku/highlight/en/highlight.php"
url "http://www.andre-simon.de/zip/highlight-4.1.tar.bz2"
sha256 "3a4b6aa55b9837ea217f78e1f52bb294dbf3aaf4ccf8a5553cf859be4fbf3907"
license "GPL-... |
Rails.application.routes.draw do
get '/sign_in', to: 'sessions#new'
delete '/sign_out', to: 'sessions#destroy'
post 'sessions/create'
resources :competences
get 'hello/greeting'
get 'hello/bye'
root to: 'competences#index'
# For details on the DSL available within this file, see http://guides.ruby... |
class AddPictureToEvenement < ActiveRecord::Migration[5.2]
def change
add_column :evenements, :picture, :text
end
end
|
class ShortUrl < ApplicationRecord
has_many :activities, :dependent => :destroy
before_create :assign_short_id
def self.get_short_id(full_url)
return Digest::MD5.hexdigest(full_url + "SALTSALTSALT").slice(0..6)
end
private
def assign_short_id
self.short_id = ShortUrl.get_short_id(self.full_url)
... |
class PrinterFunction < ActiveRecord::Base
attr_accessible :name
has_many :installations
validates :name, presence: true, uniqueness: true
def can_delete?
( self.installations.empty? )
end
end |
class Supermarket < ApplicationRecord
has_many :supermarket_products
has_many :products, through: :supermarket_products
def basket_total_price(ids)
products.where(products: { id: ids })
.sum("products.price_cents")
end
def basket_average_price(ids)
products.where(products: { id: ids })
... |
module MotionBuild ; module Rules
class CopyFileRule < MotionBuild::FileRule
attr_reader :destination
def run
project.builder.notify('cp', source, destination)
project.builder.run('cp', [source, destination])
end
def initialize(project, source, destination)
super(project, sour... |
require 'studio_game/game'
require 'studio_game/player'
require 'studio_game/die'
module StudioGame
describe Game do
before do
$stdout = StringIO.new
@game = Game.new("Knuckleheads")
@initial_health = 100
@player = Player.new("moe", @initial_health)
@game.add_player(@player)
en... |
require 'rmagick'
require_relative 'helper'
require_relative 'trees'
class Cell
attr_reader :row, :column, :type
attr_accessor :north, :south, :east, :west
attr_accessor :northwest, :southwest, :northeast, :southeast
CELL_TYPE_MAP =
{:grass => "¨",
:tree => "t"}
def initialize(row, column, cell_t... |
# frozen_string_literal: true
require "spec_helper"
describe GraphQL::Query::Variables do
let(:query_string) {%|
query getCheese(
$animals: [DairyAnimal!],
$intDefaultNull: Int = null,
$int: Int,
$intWithDefault: Int = 10)
{
cheese(id: 1) {
similarCheese(source: $animals)
}
}
|}... |
json.review do
json.partial! 'review', review: @review
end
json.spot do
json.extract! @review.spot, :id, :host_id, :site, :location_name, :max_guests
json.photoUrls @review.spot.photos.map {|file| url_for(file)}
end |
=begin
#### Question 8
Shorten this sentence:
advice = "Few things in life are as important as house training your pet dinosaur."
..remove everything starting from "house".
Review the [String#slice!](http://ruby-doc.org/core/String.html#method-i-slice-21) documentation, and use that method to make the return value... |
class MembershipsCreator
attr_reader :errors, :new_collaborators
def initialize(agent, user_identities, rights)
@agent = agent
@user_identities = user_identities.split(/[;,\,]/).map(&:strip).reject(&:empty?)
@rights = rights
@errors = []
@new_collaborators = []
end
def valid?
@errors.... |
class CreateOrders < ActiveRecord::Migration
def self.up
create_table :orders do |t|
t.references :customer
t.references :sale
t.references :shipping_option
t.datetime :date_received
t.datetime :date_shipped
t.datetime :purchased_at
t.string :card_type
t.d... |
# U2.W5: A Nested Array to Model a Boggle Board
# I worked on this challenge [by myself].
boggle_board = [["b", "r", "a", "e"],
["i", "o", "d", "t"],
["e", "c", "l", "r"],
["t", "a", "k", "e"]]
# Part 1: Access multiple elements of a nested array
# Pseudocode (This ... |
class CardsController < ApplicationController
def index
@cards = Card.where(set: params[:sets])
render json: @cards.to_json
end
end |
module Gameboy
module Interrupt
extend self
NAMES = {
0 => "vblank",
1 => "lcd_stat",
2 => "timer",
3 => "serial",
4 => "joypad"
}
# Interrupt enabler
def _ie
MMU.bread(0xffff) & 0b0001_1111
end
def _ie=(value)
MMU.bwrite(0xffff, value... |
class Shark < ApplicationRecord
has_many :posts, dependent: :destroy
validates :name, presence: true, uniqueness: true
validates :facts, presence: true
end
|
Rails.application.routes.draw do
get 'homepages/index'
root 'homepages#index'
resources :works
get "/works/:id/upvote", to: "works#upvote", as: :upvote_work
get "/users", to: "users#index", as: :users
get "/users/:id", to: "users#show", as: :user
get "/login", to: "users#login_form", as: "login"
post ... |
require 'rails_helper'
describe Exercise do
it { should validate_presence_of :title}
it { should validate_presence_of :calories_burned}
end
|
require File.dirname(__FILE__) + '/../../spec_helper'
describe 'EC2.describe_addresses' do
before(:all) do
@public_ip = ec2.allocate_address
end
after(:all) do
ec2.release_address(@public_ip)
end
it "should return proper attributes" do
actual = ec2.describe_addresses(@public_ip)
item = act... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :destination do
title "MyString"
user nil
url "MyString"
destination_id 1
destination_type "MyString"
end
end
|
require_relative '../test_helper'
require_relative '../../lib/cc_deville'
require 'minitest/autorun'
class CcDevilleTest < ActiveSupport::TestCase
test "should clear cache" do
WebMock.stub_request(:post, /api\.cloudflare\.com/).to_return(body: {
"success": true,
"errors": [],
"messages": [],
... |
=begin
#Rakam API Documentation
#An analytics platform API that lets you create your own analytics services.
OpenAPI spec version: 0.5
Contact: contact@rakam.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file e... |
class Animal
attr_reader :name
def initialize(opts)
@name = opts[:name]
@is_small = opts[:is_small]
end
def to_s
@name
end
def has_size?
!@is_small.nil?
end
def is_small=(answer)
@is_small = answer
end
def is_small
@is_small == 'y' ? true : false
end
end |
require 'spec_helper'
describe RoleMapper do
it "should define the 4 roles" do
expect(RoleMapper.role_names.sort).to eq %w(admin_policy_object_editor archivist donor patron researcher)
end
it "should quer[iy]able for roles for a given user" do
expect(RoleMapper.roles('leland_himself@example.com').sort).... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.