text stringlengths 10 2.61M |
|---|
feature "Entity Class - Create" do
context 'Visitor' do
scenario "Access invalid" do
entity_class = (create :entity_class)
visit edit_entity_class_path entity_class
expect(current_path).to eq new_session_path
end
end
context 'Admin' do
let(:user)... |
require 'rails_helper'
RSpec.describe "events" do
describe "POST #create" do
it "create a new event" do
user = create(:user)
header = {
authorization: ActionController::HttpAuthentication::Token.encode_credentials("#{user.authentication_token}")
}
service = create(:service, user_i... |
class Person
include Mongoid::Document
include Mongoid::Slug
field :name
slug :name, :as => :permalink, :permanent => true, :scope => :author
embeds_many :relationships
referenced_in :author, :inverse_of => :characters
end
|
array = ["one", "two", "three"]
array.each_with_index do |word, number|
puts "#{number + 1}) #{word}"
end
|
# write a method that returns true if the string
# passed is as an arguement is a palindrome
# false if otherwise
# a palindrome reads the same forwards and backwards
# for this exercise, case, punctuation and spaces matter
# Examples:
def palindrome?(string)
string == string.reverse!
end
p palindrome?('madam') =... |
module Datamappify
module Repository
module QueryMethod
class Find < Method
# @param options (see Method#initialize)
#
# @param id [Integer]
def initialize(options, id)
super
@id = id
end
# @return [Entity, nil]
def perform
... |
class Town < ActiveRecord::Base
belongs_to :municipality
validates :kind, presence: true
validates :code, presence: true, uniqueness: true
validates :name, presence: true
validates :municipality_id, presence: true
delegate :state, to: :municipality
def full_name
components = [name_with_kind]
co... |
module AccessSchema
class SchemaBuilder < BasicBuilder
def self.build(&block)
builder = new(Schema.new)
builder.instance_eval(&block)
Proxy.new(builder.schema)
end
def self.build_file(filename)
builder = new(Schema.new)
builder.instance_eval(File.read(filename))
Proxy... |
require 'securerandom'
module TestSupport
module Data
def metadata_attributes
metadata_response.merge(tasks_response)
end
def metadata_response
{
'Cluster' => cluster,
'ContainerInstanceArn' => container_instance_arn,
'Version' => ecs_agent_v... |
class Post < ApplicationRecord
acts_as_votable
belongs_to :user
has_many :comments, dependent: :destroy
mount_uploader :image, ImageUploader
has_many :taggings, dependent: :destroy
has_many :tags, through: :taggings, dependent: :destroy
# validations
validates :image, presence: true
validates :user_id, prese... |
#!/usr/bin/env ruby
# encoding: utf-8
# File: command_frame.rb
# Created: 17/08/13
#
# (c) Michel Demazure <michel@demazure.com>
module JacintheManagement
module GuiQt
# Individual command frames for the manager GUI
class CommandFrame < EmptyFrame
slots :written, :execute, :help
signals :output_... |
class AddPaidEventsCounterToStadium < ActiveRecord::Migration
def up
add_column :stadiums, :paid_events_counter, :integer, default: 0
Event.all.each(&:update_counter_cache)
end
def down
remove_column :stadiums, :paid_events_counter, :integer, default: 0
end
end
|
require 'json'
class InventoryItem
attr_reader :name
attr_reader :sku
attr_accessor :price
attr_reader :bulk_deal_amount
attr_reader :bulk_deal_price
attr_reader :bonus_item_sku
attr_reader :three_for_two
def initialize(item_data)
# These variables should always be present in the pricing rules
... |
#!/usr/bin/env ruby
require_relative '../../../framework/Feature'
class InformEuropeanEmergencyCall
@@name = :inform_european_emergency_call
@@feature = Feature.new(@@name)
@@feature.add_alteration(
:instance_attribute,
:ERS,
:emergency_call,
112)
def self.get
... |
# frozen_string_literal: true
require 'rails_helper'
describe HealthQuest::PatientGeneratedData::FHIRClient do
include HealthQuest::PatientGeneratedData::FHIRClient
describe '#accept_headers' do
it 'has default Accept header' do
expect(accept_headers).to eq({ 'Accept' => 'application/json+fhir' })
... |
require "open-uri"
require "nokogiri"
require "coveralls"
Coveralls.wear!
SimpleCov.command_name "pry-test"
require_relative "../lib/pipe_envy"
using PipeEnvy
class PipeEnvyTest < PryTest::Test
test "simple readme example" do
assert "Ruby Rocks" | :upcase | :split == ["RUBY", "ROCKS"]
end
test "chained pip... |
class Api::ServerMembersController < ApplicationController
def create
@server = Server.find_by(instant_invite: params[:instant_invite])
if @server
current_user.servers << @server
render 'api/servers/show', server: @server
else
render json: ['Server does not exist'], status: 404
end
... |
module CDI
module V1
class StudentLearningTrackSerializer < SimpleLearningTrackSerializer
has_many :categories,
serializer: SimpleCategorySerializer,
embed: :ids,
embed_in_root_key: :linked_data,
embed_in_root: true
has_many :skills,
... |
require 'spec_helper'
describe TvveetsController do
describe "POST #create" do
let(:user) { FactoryGirl.create(:user) }
before { valid_sign_in user }
context "with valid content" do
let(:valid_tvveet) { FactoryGirl.build(:tvveet, user: user) }
it "saves the new tvveet" do
expect {
... |
class Happening < ActiveRecord::Base
belongs_to :creator, foreign_key: :creator_id, class_name: "User"
has_many :rsvps
has_many :attendees, through: :rsvps
end
|
#encoding:utf-8
require 'nokogiri'
require 'open-uri'
require File.expand_path("../grabepg/grab_base.rb", __FILE__)
require File.expand_path("../grabepg/grab_tvsou.rb", __FILE__)
module Grabepg
class GrabTvmao
# To change this template use File | Settings | File Templates.
#图片的获取: Net::HTTP.get(url)
#图片的文件... |
require_relative 'hand'
class Player
include Hand
attr_accessor :name, :cards
def initialize
@cards = []
set_name
end
def set_name
name = ''
loop do
puts "Tell me your name:"
name = gets.chomp
break unless name.empty?
puts "Sorry, must enter a value"
end
sel... |
class Element < ActiveRecord::Base
belongs_to :piece
has_one :amiante
assignable_values_for :nom do
['Sol','Murs','Plafond','Plinthes','Porte','Fenêtre', 'Porte d\'entrée','Fenêtre avec volets']
end
end
|
class IntegerToStringArticles < ActiveRecord::Migration
def change
change_column :articles, :fb_post_id, :string
end
end
|
require_relative "../test_helper"
class RestaurantTest < ActiveSupport::TestCase
test "a resturant is inactive by defualt" do
restaurant = Restaurant.create
refute restaurant.active
end
test "a restaurant is unpublished by default" do
restaurant = Restaurant.create
refute restaurant.pub... |
class JuggernautObserver < ActiveRecord::Observer
observe SpineJuggernautRails.config.observe
def after_create(rec)
publish(:create, rec)
end
def after_update(rec)
publish(:update, rec)
end
def after_destroy(rec)
publish(:destroy, rec)
end
protected
... |
#!/usr/bin/env ruby
require 'gli'
require 'doing'
require 'tempfile'
if RUBY_VERSION.to_f > 1.9
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
end
include GLI::App
version Doing::VERSION
wwid = WWID.new
program_desc 'A CLI for a What Was I Doing system'
default_command ... |
# encoding: UTF-8
require 'spec_helper'
describe 'Categories' do
before(:all) do
@categories = Array.new(2) { Category.sham! }
end
describe "On the categories path"
it "listing all categories" do
visit categories_path
page.should have_selector(".category", :text => "")
end
it "creates a n... |
class Rental < ApplicationRecord
belongs_to :user
belongs_to :van
validates :start_date, :end_date, presence: true
# validates :start_date, :end_date, :price, :status, :photo, presence: true
mount_uploader :photo, PhotoUploader
end
|
require 'fluent-logger'
require File.expand_path('json_formatter', File.dirname(__FILE__))
module RailsFluentLogging
class LogDevice
SEVERITY_MAP = %w(DEBUG INFO WARN ERROR FATAL UNKNOWN)
class << self
def configure
yield(config)
reconfigure!
end
def config
@config... |
class Engine
def initialize
#TODO must be provided from config
@url = 'http://54.148.156.110:4567/sync-module/converters'
end
def converters ids
ids.map do |i|
body = RestClient.get "#{@url}/#{i}"
JSON.parse body, symbolize_names: true
end
end
def process input, converters_names,... |
require 'mocha'
module MockedFixtures
module Mocks
module Mocha
def mock_model_with_mocha(model_class, options_and_stubs={})
all_attributes = options_and_stubs.delete(:all_attributes)
add_errors = options_and_stubs.delete(:add_errors)
if all_attributes
schema = Moc... |
class PatientCase < ActiveRecord::Base
# time_in_words needs this
include ActionView::Helpers::DateHelper
def self.possible_statuses
["Pre-Screen","Registered","Checked In","Scheduled","Unscheduled","Preparation","Procedure","Recovery","Discharge","Checked Out"]
end
def self.complexity_units
[1,2,3... |
class UserValidator < ActiveModel::Validator
def validate(record)
record.errors.add :base, "Password should be reverse of email" unless password.eql?(email.reverse)
end
end
|
require 'securerandom'
# Model representing the result message posted to Kinesis stream about everything that has gone on here -- good, bad, or otherwise.
class RequestResult
require 'aws-sdk'
require_relative './sierra_request.rb'
require_relative './hold_request.rb'
# Sends a JSON message to Kinesis after e... |
class PostcodeValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
postcode = UKPostcode.parse(value || '')
return if postcode.valid?
record.errors.add attribute, :invalid_postcode
end
end
|
class HomepageController < ApplicationController
skip_before_action :require_login
before_action :require_login, only: [:notifications, :history]
def index
categories = ['All','Accessories', 'Books', 'Clothing', 'Electronics',
'Home and Kitchen', 'Luggages and Bags', 'Office Products',
... |
class Plan < ActiveRecord::Base
self.inheritance_column = :_type_disabled
scope :monthly, -> { where(type: 'monthly', active: true).last }
scope :half_yearly, -> { where(type: 'half_yearly', active: true).last }
scope :yearly, -> { where(type: 'yearly', active: true).last }
def amount
units * price
en... |
# -*- coding: utf-8 -*-
require 'spec_helper'
describe RpcController do
let(:member) { FactoryBot.create(:member, password: 'mala', password_confirmation: 'mala') }
before do
member.set_auth_key
allow_any_instance_of(Member).to receive(:subscribe_feed).and_return(FactoryBot.create(:subscription))
end
... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Set vagrant box to ubuntu 14.04.1 with puppet 3.7.2
config.vm.box = 'ubuntu-14.04.1-64bit-vbox-4.3.18-puppet-3.7.2'
config.vm.hostname = 'web.vagrant.local'
# Set box memory to 102... |
Vagrant.configure("2") do |config|
config.vm.define "master" do |master|
master.vm.box = "debian/stretch64"
master.vm.hostname = 'gitlab'
master.vm.provision "shell", path: "server.sh"
master.vm.network "forwarded_port", guest: 80, host: 81
master.vm.provider :virtualbox do |v|
... |
class Email < ApplicationRecord
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z\d\-]+)*\.[a-z]+\z/i
validates :email, presence: true, length: { maximum: 255 },
format: { with: VALID_EMAIL_REGEX },
uniqueness: { case_sensitive: false }
# after_create :send_email
def send_email
EmailMailer... |
require_relative "./card_kind.rb"
module Model
class Pack
def initialize
@cards = []
reshuffle
end
def reshuffle_if_necessary
return if @cards.count > 2
reshuffle
end
def draw
reshuffle_if_necessary
@cards.pop
end
private
def reshuffle
puts "RESHUFFLING"
@cards = 4.t... |
module Sinatra
module CMS
module Application
module Helpers
def placeholder
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed in tempor lacus. Suspendisse fermentum aliquam magna, vitae condimentum ante adipiscing nec. Phasellus hendrerit lacinia congue."
end
d... |
class Company < ActiveRecord::Base
has_many :passports
validates :name, :city, :address, :country, presence: true
end
|
FactoryBot.define do
factory(:nav_item) do
title_sv
title_en
trait :menu do
nav_item_type 'menu'
end
trait :page do
nav_item_type 'page'
page
end
trait :link do
nav_item_type 'link'
link
end
end
end
|
FactoryGirl.define do
sequence(:ldap_uid) { |n| "ldap#{n}@musc.edu" }
factory :identity do
email 'email@musc.edu' # need this for fake data
ldap_uid
sequence(:first_name) { |n| "Sally-#{n}"}
last_name "Smith"
password "password"
password_confirmation "password"
time_zone "Eastern Time ... |
module Vocabulary
class Concept < ApplicationRecord
self.inheritance_column = :_type_disabled
TYPES = %w(Concept Collection)
# searchkick
# has paper trail
include AttrJson::Record
include AttrJson::NestedAttributes
include AttrJson::Record::QueryScopes
attr_json_config(default_conta... |
# initializeメソッド
=begin
class Drink
def initialize
puts "新しいオブジェクト"
end
end
Drink.new
# インスタンス変数の初期値を設定する
class Drink
def initialize
@name = "カフェラテ"
end
def name
@name
end
end
drink = Drink.new
puts drink.name
=end
# initializeメソッドへ引数を渡す
class Drink
def initialize(name)
@name = name
e... |
App0922::Application.routes.draw do
resources :payments
root to: 'payments#index'
end
|
class Search
def initialize(query)
@raw_query = query
end
def sanitize(raw_query)
raw_query.gsub!(/ë/, 'e')
raw_query.gsub!(/ö/, 'o')
raw_query.gsub!(/ğ/, 'g')
raw_query.gsub!(/Ö/, 'O')
raw_query.split.map(&:capitalize).join(' ').strip
end
def search
sanitized_query = sanitize(@... |
class Channel < ActiveRecord::Base
belongs_to :user
has_many :posts
def owned_by(user)
return self.user_id==user.id
end
end
|
#!/usr/bin/env ruby
#Just a simple example command.
# @param <random> - Random Parameter 1
# @param - Random Parameter 2
def result(foo)
# @param <foo>
puts "It worked! 🎩✨ " + foo
end
result(ARGV.join(" "))
|
require 'player'
describe Player do
let(:player) { Player.new }
describe "#recieve_card" do
it "recieves a card, and puts the card in its hand" do
new_card = instance_double("Card", :suit => :S, :value => 14)
player.recieve_card(new_card)
expect(player.hand_size).to eq(1)
end
end
de... |
class MoviesController < ApplicationController
def index
@movies = Movie.all
end
def movie_params
movie_params = params.require(:movie).permit(:title, :description, :rating, :released_on, :total_grossm, :cast, :director, :duration, :inmage)
end
def show
@movie = Movie.find(params[:id])
end
def... |
require 'test_helper'
class HTMLTest < Curtain::TestCase
class ::HTMLView < Curtain::View
end
def use(lang)
HTMLView.template_directories File.join(File.dirname(__FILE__), "examples", "html", lang)
end
%w[erb slim].each do |lang|
test "void tag with #{lang}" do
use lang
assert_equal '<b... |
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
def bool(name, default=nil)
p = params[name]
return default.nil? ? nil : default if p.nil?
%w(1 on o true t yes y).... |
# frozen_string_literal: true
class Monologue::PostsController < Monologue::ApplicationController
def index
@page = params[:page].nil? ? 1 : params[:page]
@posts = posts_for_site.page(@page)
.includes(:user, :tags)
.published
end
def show
if monol... |
require_relative './dance_module.rb'
require_relative './class_methods_module.rb'
require_relative './fancy_dance.rb'
class Kid
#include lets us use all the dance module methods
#as instance methods that only the newly created obj can access
include Dance
#including a CLASS method here with the keyword extend
... |
class CreateExoticPlants <ActiveRecord::Migration
def change
create_table :plants do |t|
t.string :name
t.text :description
t.timestamps
end
end
end |
# frozen_string_literal: true
require 'spec_helper'
require 'bolt_spec/conn'
require 'bolt_spec/files'
require 'bolt_spec/integration'
require 'bolt_spec/puppetdb'
require 'bolt/catalog'
require 'bolt/task'
describe "passes parsed AST to the apply_catalog task" do
include BoltSpec::Conn
include BoltSpec::Files
... |
# location.rb
require 'json'
module GoCLI
# Location class
class Location
attr_accessor :name, :coord
def initialize(opts = {})
@name = opts[:name] || ''
@coord = opts[:coord] || []
end
def self.load_all
locs = []
return locs unless File.file?("#{Dir.pwd}/data/locations.js... |
class Patient < ApplicationRecord
validates :name, presence: true
validates :age, presence: true, :numericality => true
validates :weight, presence: true, :numericality => true
validates :disease, presence: true
validates :admit_date, presence: true
validates :release_date, presence: true
end
|
class Api::V1::UsersController < ApplicationController
def index
@users = User.all
render json: @users
end
def show
@user = User.find(params[:id])
render json: @user
end
def create
@user = User.new(user_params)
if @user.save
jwt = encode_token({user_id: @user.id})
render... |
extend Algebrick::Matching # => main
def deliver_email(email)
true
end
Contact = Algebrick.type do |contact|
variants Null = atom,
contact
fields username: String, email: String
end
# => Contact(Null | Contact(username: String, email: String))
module Contact
def userna... |
require 'rails_helper'
describe 'Proxies: Slug' do
before do
@user = create(:user)
login_as(@user)
end
it 'saves the slug and redirects to wizard step one' do
visit dashboard_slug_path
fill_in 'user_slug', with: 'mothers-of-invention'
click_button 'Save'
expect(page).to have_current_pat... |
jruby = !!()
Gem::Specification.new do |s|
s.name = "c_geohash"
s.version = '1.1.2'
s.date = "2014-11-12"
s.summary = "Geohash library that wraps native C in Ruby"
s.email = ["dave@popvox.com", "drew@mapzen.com"]
s.homepage = "https://github.com/mapzen/geohash"
s.description = "C_Geohash pro... |
class Photo < ActiveRecord::Base
belongs_to :category
def self.new_flickr(flickr_id)
Photo.find_by_flickr_id(flickr_id)
end
end
|
require 'tre-ruby'
class FuzzyScanner
attr_accessor :regex
# allow fuzziness of 2 by default
def fscan!(str, fuzziness=2)
str.gsub!(/\n/, " ")
words = str.extend(TRE).ascan regex, TRE.fuzziness(fuzziness)
words.uniq
end
end |
module ValidationHelpers
# Returns translated AR validation message
# Example usage
# dsc_validation_msg(:contact, :email_address, :too_long, count: 255)
def dsc_validation_msg(model, attribute, validation, args = {})
key = ".#{model}.attributes.#{attribute}.#{validation}"
args[:scope] = "activerecord.... |
class Admin::UsersController < AdminController
def index
@users = User.all
end
def new
@user = User.new
end
def create
@user = User.new(user_params)
if @user.save
redirect_to [:admin, @user]
else
render 'new'
end
end
def edit
@user = User.find(params[:id])
end... |
class PokemonsController < ApplicationController
def create
trainer = Trainer.find(params[:trainerId])
if trainer.pokemons.length < 6
name = Faker::Name.first_name
species = Faker::Games::Pokemon.name
trainer.pokemons.build(nickname: name, species: species)
... |
# This is both a feature and a controller spec and the controller spec doesn't test the route
describe "Logging out" do
context 'a user is signed in' do
before do
login_as(create(:user))
end
it 'allows logout via the header button' do
visit '/'
expect(page).not_to have_content('Sign in'... |
require 'spec_helper'
describe User do
it { should validate_presence_of :username}
it { should validate_presence_of :email }
it { should validate_presence_of :first_name }
it { should validate_presence_of :last_name}
it { should validate_presence_of :promotion }
it { should validate_uniqueness_of :username... |
require 'cocoapods-core'
require 'fileutils'
require 'cocoapods-lazy/logger'
module Pod
module Lazy
class Repository
def initialize(repository)
@repository = repository
end
def fetch
@fetched_checksum = read_podfile_checksum()
if @fetched_checksum.nil?
Pod::La... |
# Using the code from hello_sophie.rb, move the greeting from the
# #initialize method to an instance method named #greet that prints a greeting
# when invoked.
class Cat
def initialize(name)
@name = name
end
def greet
puts "Hello, #{@name}!"
end
end
kitty = Cat.new("Owen")
kitty.greet
|
class CartsController < ApplicationController
before_action :authenticate_user!, only: [:index, :new, :create, :edit, :destroy, :update]
def new
if Cart.exists?(user_id: current_user.id)
@carts = Cart.where(user_id: current_user.id) ## whereで該当するデータ全てが返ってくる
else
redirect_to root_path ## 空の場合のリ... |
require 'mysql'
# Monkey patch Mysql::Result to yield hashes with symbol keys
class Mysql::Result
MYSQL_TYPES = {
0 => :to_d, # MYSQL_TYPE_DECIMAL
1 => :to_i, # MYSQL_TYPE_TINY
2 => :to_i, # MYSQL_TYPE_SHORT
3 => :to_i, # MYSQL_TYPE_LONG
4 => :to_f, # MYSQL_TYPE_FLOA... |
desc "Anchore Security Docker Vulnerability Scan"
namespace :anchore do
desc "Deploy a new ebrelayer to an existing cluster"
task :scan, [:image, :image_tag, :app_name] do |t, args|
cluster_automation = %Q{
set +x
curl -s https://ci-tools.anchore.io/inline_scan-latest | bash -s -- -f -r -d cmd/#{arg... |
class PhotosController < ApplicationController
before_filter :authenticate_user!, only: [:new, :create, :edit]
def index
@photos = Photo.all
end
def show
@photo = Photo.find(params[:id])
end
def new
@photo = Photo.new
end
def create
@photo = Photo.new(photo_params)
if @photo.save
redirect_to @p... |
# frozen_string_literal: true
require_relative 'events'
require_relative 'organization'
# Represents overall organization information for JSON API output
class OrganizationEventsRepresenter < EventsRepresenter
include Roar::JSON
property :organization, extend: OrganizationRepresenter, class: Organization
end
|
# frozen_string_literal: true
class User
module Tokens
def tokens
unless current_user.any_current_tokens?
redirect_to(profile_path, alert: 'You do not have any current API tokens.')
end
@api_tokens = current_user.api_tokens.current
@persistent_api_tokens = current_user.persistent... |
require_relative "version"
module BootswatchRails
module ActionViewExtensions
OFFLINE = (Rails.env.development? or Rails.env.test?)
def bootswatch_link_tag(theme = nil, options = {})
theme ||= BootswatchRails::THEMES[BootswatchRails::DEFAULT].to_s
return stylesheet_link_tag(theme) if !options.de... |
# TEM cryptographic key manipulation using the APDU API.
#
# Author:: Victor Costan
# Copyright:: Copyright (C) 2007 Massachusetts Institute of Technology
# License:: MIT
# :nodoc: namespace
module Tem::Apdus
module Keys
def devchip_generate_key_pair(symmetric_key = false)
response = @transport.is... |
class ChangePaperclipColumns < ActiveRecord::Migration
def change
rename_column :attachments, :image_file_name, :attachment_file_name
rename_column :attachments, :image_content_type, :attachment_content_type
rename_column :attachments, :image_file_size, :attachment_file_size
rename_column :attachments, :image_upd... |
require 'minitest/autorun'
require 'minitest/pride'
require './lib/grid'
class GridTest < Minitest::Test
def test_it_exists
g = Grid.new
assert g
end
def test_it_starts_with_4x4_grid_by_default
g = Grid.new
assert_equal [[' ']*4]*4, g.grid
assert_equal 4, g.size
end
def test_it_can_star... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
post 'auth/token', to: 'auth#token'
resources :notes, only: [:index, :create]
match '*path', via: [:options], to: lambda {|_| [204, {'Content-Type' => 'text/plain'}, []]}
end
|
#
# Author:: Matt Eldridge (<matt.eldridge@us.ibm.com>)
# © Copyright IBM Corporation 2014.
#
# LICENSE: MIT (http://opensource.org/licenses/MIT)
#
Shindo.tests("Fog::Compute[:softlayer] | server requests", ["softlayer"]) do
tests('success') do
@sl_connection = Fog::Compute[:softlayer]
@bmc = {
:op... |
# frozen_string_literal: true
require "spec_helper"
RSpec.describe Tikkie::Api::V1::Requests::Users do
subject { Tikkie::Api::V1::Requests::Users.new(request) }
let(:config) { Tikkie::Api::V1::Configuration.new("12345", "spec/fixtures/private_rsa.pem") }
let(:request) { Tikkie::Api::V1::Request.new(config) }
... |
class AddOtherToEvents < ActiveRecord::Migration
def change
add_column :events, :other_games, :boolean
add_column :events, :other_types, :boolean
end
end
|
class QuestionVotes < ActiveRecord::Migration
def change
create_table :question_votes do |qv|
qv.integer :question_id
qv.integer :user_id
qv.integer :vote
end
end
end
|
require 'sinatra/base'
require 'sinatra/reloader'
require 'sinatra/flash'
require 'haml'
require 'json'
require_relative 'database'
require_relative 'models/user'
require_relative 'models/site'
require_relative 'models/validation_error'
require_relative 'models/event'
require_relative 'models/analytic'
require_relativ... |
require File.dirname(__FILE__) + '/../spec_helper'
describe MessagesController do
fixtures :all
render_views
describe "as guest" do
it "create action should redirect to signin url" do
get :create
response.should redirect_to(signin_url)
end
end
describe "as user" do
before(:each) do
... |
require 'rails_helper'
RSpec.describe Beer, type: :model do
it "is saved with a proper name, style and brewery" do
beer = FactoryBot.create :beer
expect(beer).to be_valid
expect(Beer.count).to eq(1)
end
describe "that is otherwise valid" do
let(:brewery) { FactoryBot.create :brewery }... |
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'mobmanager/version'
Gem::Specification.new do |spec|
spec.name = "mobmanager"
spec.version = Mobmanager::VERSION
spec.authors = ['Milton Davalos']
spec.email ... |
class Dispensacao < ActiveRecord::Base
belongs_to :dispensavel, :polymorphic => true
belongs_to :usuario
has_many :agendamentos_sms
attr_accessor :data_formatada
validates :medicamento, :presence => true, :numericality => {:only_integer => true}
validates :posologia, :presence => true
validates ... |
class AddEventIndexToGame < ActiveRecord::Migration
def change
add_column :games, :event_index, :integer
end
end
|
require 'spec_helper'
describe UsersHelper do
describe "gravatar_for" do
before(:each) do
@user.stub_chain(:email).and_return("benbruneau@gmail.com")
@user.stub_chain(:name).and_return("Ben")
end
it "builds an image tag with a gravatar link in it" do
expect(helper.gravatar_for(@us... |
class AddColumnUser < ActiveRecord::Migration[5.1]
def change
add_column :users, :image_binary, :binary
add_column :users, :image_type, :string
end
end
|
def sequence(num)
array = []
1.upto(num) { |idx| array << idx }
array
end
puts sequence(5) == [1, 2, 3, 4, 5]
puts sequence(3) == [1, 2, 3]
puts sequence(1) == [1]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.