text stringlengths 10 2.61M |
|---|
require 'rails_helper'
RSpec.describe Discount do
describe 'Relationships' do
it {should belong_to :merchant}
end
describe 'Validations' do
it do
should validate_numericality_of(:percent_off).
is_less_than_or_equal_to(100)
end
it do
should validate_numericality_of(:min_quantity)... |
class PostsController < ApplicationController
def index
#我要去 Post model,也就是 posts table 找出每一筆資料,存進 @posts 變數
@posts = Post.all
end
#在 Posts Controller 裡面新增 show 方法
def show
# Rails 會把用戶所有傳進來的參數打包成一個叫 params 的 Hash
# find 代表搜尋某一比資料,而 params[:id] 代表用戶想查詢的資料 id
@post = Post.find(params[:id])... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
helper_method :user_signed_in?, :current_user
# 현재 로그인 된 상태니?
def user_signed_in?
session[:current_user].present?
end
# 로그인 되어 있지 않으면 로그인하는 페이지로 이동 시켜줘
def authenticate_user!
unless user_signed_in?
... |
describe TasksController do
describe "GET #index" do
it "calls authorize" do
expect(controller).to receive(:authorize).and_call_original
get :index
end
context "when authorized" do
let(:user) { User.create() }
before { authorize_user(user) }
it "returns http success" do
... |
class SignupTest
def initialize(pages)
@pages = pages
end
def load_signup_page
@pages.page_home.load
@pages.page_home.visible?
@pages.page_home.open_signup
end
def enter_signup_details(user)
@pages.page_home.signup_input_email user.email
@pages.page_home.signup_input_password1 user... |
# == Schema Information
#
# Table name: admin_resources
#
# id :integer not null, primary key
# address :string
# protocol :string
# credential_id :integer
# bears_instance_id :integer
# created_at :datetime not null
# updated_at :datetime ... |
require "test_helper"
class OrderTest < ActiveSupport::TestCase
test "creating an order from tickets and mail and amount" do
concert = create(:concert).add_tickets(5)
assert_equal 5, concert.tickets_remaining
order = Order.for_tickets(concert.find_tickets(3), "john@example.com", 3600)
assert_equal ... |
class DeleteAccountIdFromAccount < ActiveRecord::Migration[5.1]
def change
remove_column :accounts, :account_id
end
end
|
class RemoveAmountRequiredFromRecipeStep < ActiveRecord::Migration
def self.up
remove_column :recipe_steps, :amount_required
end
def self.down
end
end
|
require_relative 'movement'
module Ironwood
class Mob
include Movement
attr_accessor :map, :x, :y, :direction, :fov, :last_actions
def initialize map, x, y, direction
@map = map
@x = x
@y = y
@direction = direction
@fov = Visibility::FieldOfView.new(map, x, y, direction, Visibility::Shadow... |
# Benchmarks the TEM hardware's overhead for an APDU round-trip.
#
# This overhead applies to any TEM operation, because each operation involves
# one or more APDU exchanges.
#
# Author:: Victor Costan
# Copyright:: Copyright (C) 2008 Massachusetts Institute of Technology
# License:: MIT
# :nodoc:
class T... |
module SQLiterate
module Node
module Query
def common_tables
Hash[ with_section.tables.map { |t| [t.first, expand_table(t)] } ]
end
def tables
cte = common_tables
query_expression.tables.flat_map { |t| expand_table(t) }
.flat_map { |t| cte[... |
require "application_responder"
class ApplicationController < ActionController::Base
self.responder = ApplicationResponder
respond_to :html
before_action { @q = Work.includes(:entry, :flips).ransack(params[:q]) }
before_action :adjust_format_for_xhr_html
protected
def after_sign_in_path_for(resource)
if... |
Shindo.tests('Rackspace::Servers#reboot_server', 'rackspace') do
tests('success') do
@server = Rackspace[:servers].servers.create(:flavor_id => 1, :image_id => 19, :name => 'fogrebootserver')
before do
@server.wait_for { ready? }
end
tests("#reboot_server(#{@server.id}, 'HARD')").succeeds do
... |
class CreateSuperSets < ActiveRecord::Migration[5.1]
def change
create_table :super_sets do |t|
t.integer :exercise_one_id
t.integer :exercise_two_id
t.timestamps
end
end
end
|
class Message < ActiveRecord::Base
attr_accessible :message, :requester_email, :user_id, :secure_token
belongs_to :user
has_one :answer
has_one :payment
validates :message, :presence => true, :on => :create
validates :requester_email, :presence => true, :on => :create
end
|
# frozen_string_literal: true
require 'spec_helper'
require 'bolt_spec/config'
require 'bolt_spec/conn'
require 'bolt_spec/files'
require 'bolt_spec/integration'
describe "running YAML plans", ssh: true do
include BoltSpec::Integration
include BoltSpec::Config
include BoltSpec::Conn
after(:each) { Puppet.set... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
#match ':controller(/:action(/:id))', :via => [:get, :post]
#Auth Controller
post 'auth/user_login' => 'auth#user_login'
post 'auth/admin_login' => 'auth#admin_login'
delete '... |
class Pledge < ApplicationRecord
belongs_to :campaign
has_many :pledge_daily_reports, dependent: :destroy
extend Enumerize
enumerize :status, in: %w(all_gone available inactive deleted), scope: true, predicates: true
self.status.values.each do |status|
scope status.to_sym, -> { Pledge.with_status(status)... |
component 'rubygem-excon' do |pkg, settings, platform|
pkg.version '0.62.0'
pkg.md5sum 'b2bde24daf5cf688e4ea85f3477811a9'
instance_eval File.read('configs/components/_base-rubygem.rb')
end
|
require 'towers_of_hanoi'
require 'rspec'
# Towers of Hanoi
#
# Write a Towers of Hanoi game.
#
# Keep three arrays, which represents the piles of discs. Pick a representation of the discs to store in the arrays; maybe just a number representing their size. Don't worry too much about making the user interface pretty.... |
class AddRecipientToNotifications < ActiveRecord::Migration[5.2]
def change
add_reference :notifications, :recipient, polymorphic: true
end
end
|
require 'atom/feed'
module Sword2Ruby
#Extend existing Atom::Service with Sword methods
class ::Atom::Feed < ::Atom::Element
#This method returns an array of Atom::Categories of the original deposit (usually contained in the Sword Statement Atom Feed),
#or an empty array [ ] if none are defined.
... |
class Team < ActiveRecord::Base
attr_accessor :country
has_many :matches_as_home_team, class_name: "Match", foreign_key: "home_team_id"
has_many :matches_as_visitor_team, class_name: "Match", foreign_key: "visitor_team_id"
validates :country, :name, presence: true
validates :name, uniqueness: true
end
|
class SocialGroup < ApplicationRecord
ATTRIBUTE_PARAMS = %i(name).freeze
has_many :group_users, dependent: :destroy
has_many :microposts, dependent: :destroy
has_many :members, through: :group_users, source: :user
after_save :admin_join_group
def member? user
members.include? user
end
def feed
... |
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/../lib")
require 'strokedb-core'
include StrokeDB
dir = File.dirname(__FILE__)
MyDatabase = StrokeObjects::Database.new(
:path => File.join(dir, ".vkontakte_api.strokedb"),
:plugins => [ Validations ]
)
... |
class User < ActiveRecord::Base
has_many :documents, dependent: :destroy
def self.create_account(auth)
User.create provider: auth['provider'],
uid: auth['uid'],
username: auth['info']['nickname'],
avatar: auth['info']['image']
end
def to_param
userna... |
class AddSkillsToJobs < ActiveRecord::Migration
def change
add_column :jobs, :skills, :text
add_column :jobs, :experience, :text
end
end
|
require 'spec_helper'
describe IssuesController do
describe 'POST /issues' do
it 'should create an issue' do
post :create, {issue: {title:"Issue 1", description:"some text 1"}}
assigns(:issue).should be_true
end
end
describe 'updating an issue PUT /issues/:id' do
let(:test_issue){Issue.... |
class Friendship < ActiveRecord::Base
# constants
STATUS_ALREADY_FRIENDS = 1
STATUS_ALREADY_REQUESTED = 2
STATUS_IS_YOU = 3
STATUS_FRIEND_IS_REQUIRED = 4
STATUS_FRIENDSHIP_ACCEPTED = 5
STATUS_REQUESTED = 6
FRIENDSHIP_ACCEPTED = "accepted"
FRIENDSHIP_PENDING = "pending"... |
# Primary use is to locally serve SVG diagrams provided by JWS Online (The schema diagrams) as the SVGWEB javascript library
# requires that it is served locally, and also that the URL has a .svg extension
class SvgController < ApplicationController
before_filter :login_required
layout nil
def show
id = p... |
require 'spec_helper'
describe SubjectsController do
render_views
describe '#show' do
let!(:room) { create(:room, active: true) }
let!(:subject) { create(:subject, room: room)}
let(:call_request) { get :show, id: subject.id, room_id: room.id}
context 'after request' do
before { call_request... |
require_relative '../acceptance_helper'
feature 'Sign up' do
scenario 'New user can register' do
visit new_user_registration_path
fill_in 'Email', with: 'user1@test.com'
fill_in 'Password', with: '123456'
fill_in 'Password confirmation', with: '123456'
click_on 'Sign up'
expect(current_path... |
#!/usr/bin/ruby
# This example demonstrates the factory method pattern in the Ruby language.
class Product; end
class ConcreteProduct < Product; end
class Creator
def initialize
@product = factory_method
end
def factory_method
return Product.new
end
def show_product
puts @product.inspect
end
end
clas... |
require 'spec_helper'
require_relative '../lib/weapons/weapon.rb'
require_relative '../lib/weapons/axe.rb'
require_relative '../lib/weapons/bow.rb'
require_relative '../lib/viking.rb'
describe Viking do
let(:axe){Axe.new}
let(:bow){Bow.new}
let(:fists){Fists.new}
let(:viking){Viking.new('Fred', 75)}
let(:viking_... |
class CreateResponses < ActiveRecord::Migration
def change
create_table :responses do |t|
t.belongs_to :user
t.belongs_to :survey
t.string :answer
end
end
end
|
class IngredientsController < ApplicationController
helper_method :sort_column, :sort_direction
def new
@ingredient=Ingredient.new
end
def edit
@ingredient = Ingredient.find(params[:id])
end
def index
@search = Ingredient.search(params[:q])
@ingredient = @search.result
@change = Change.new
end
def ... |
Rails.application.routes.draw do
get 'tokens/create'
namespace :api do
namespace :v1 do
resources :tokens, only: [:create]
resources :users, only: [:create, :show] do
resources :projects
resources :tasks
put 'tasks', to: 'tasks#update_priority'
end
end
end
end
|
class LocksController < ApplicationController
before_action :find_stage, only: [:new, :edit, :create, :update, :destroy]
def new
@lock = @stage.build_lock
end
def edit
redirect_to(new_stage_lock_url(@stage)) unless (@lock = @stage.lock).present?
end
def create
return redirect_to(stages_url, n... |
# build a program that asks a user for the length and width
# of a room in meters and then displays the area of the room
# in both sq meters and sq feet
# 1 sq meter == 10.7639 sq ft
# Example run:
#
# Enter the length of the room in meters:
# 10
# Enter the width of the room in meters:
# 7
# The area of the room i... |
require 'spec_helper'
class Vigil
describe RevisionRepository do
before :each do
@os = double('os').as_null_object
Vigil.os = @os
end
describe "#empty?" do
it "returns true when no revisions are found" do
project = double('project', working_dir: '/run_dir')
@os.shou... |
require 'spec_helper'
describe 'Admin pages' do
subject { page }
describe "index" do
let(:admin) { FactoryGirl.create(:admin) }
let!(:post1) { FactoryGirl.create(:post, user: admin) }
let!(:post2) { FactoryGirl.create(:post, user: admin) }
before do
sign_in admin
visit admin_index... |
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe Admin::UploadsHelper do
include Admin::UploadsHelper
describe "truncate filename method" do
it "should shorten a long filename to show start, end and extension \
(with default seperator between)" do
trun... |
require 'spec_helper'
describe "Viewing Pages" do
subject { page }
before { @format = FactoryGirl.create(:format) }
before { @movie = FactoryGirl.create(:movie) }
describe "new viewing page" do
before { visit new_viewing_path }
it { should have_selector('h1', text: 'New viewing') }
it { should ... |
class CurrencyHistoriesController < ApplicationController
before_action :set_currency_history, only: [:show, :update, :destroy]
# GET /currency_histories
def index
# binding.pry
if params[:user_id]
user = User.find_by_id(params[:user_id])
@currency_histories = user.currency_histories
el... |
require 'yaml'
require 'erb'
require 'active_support/core_ext/hash'
class AppConfigs
CONFIG_ROOT = File.join(File.expand_path('../../', __FILE__), 'config', 'app_configs')
def self.[](file)
path = File.join(CONFIG_ROOT, "#{file}.yml")
# use ERB to parse <%= %> values
config = YAML.load(ERB.new(File.new... |
class QuestionSerializer < ActiveModel::Serializer
include ActionView::Helpers::DateHelper
attributes :id, :summary, :body, :created_at, :updated_at, :cached_votes_up, :cached_votes_down, :views_count, :cached_votes_score, :votes_for, :created_at_unformatted
has_one :user
has_many :answers, include_nested_asso... |
class Edge < ApplicationRecord
validates :src, presence: true
validates :dest, presence: true
validates :cost, presence: true
attr_reader :src, :dest, :cost
attr_writer :cost
def initialize(src, dest, cost)
@src = src
@dest = dest
@cost = cost
src.to_edges << sel... |
class Cart < ActiveRecord::Base
belongs_to :user
has_many :cart_items
def price
cart_items.map(&:price).sum
end
def self.active
where(validated_at: nil)
end
end
|
class ProgressBar
module Components
class Throttle
include Timer
def initialize(options = {})
@period = options.delete(:throttle_rate) { 0.01 } || 0.01
end
def choke(force = false, &block)
if !started? || @period.nil? || force || elapsed_seconds >= @period
yield... |
# encoding: utf-8
module Mongoid #:nodoc:
module Extensions #:nodoc:
module PolymorphicID #:nodoc:
module Conversions #:nodoc:
extend ActiveSupport::Concern
module ClassMethods #:nodoc
def find(value)
if value.is_a?(PolymorphicID)
value.find
... |
class ProjectTaskAttachment < ActiveRecord::Base
has_attached_file :avatar, styles: { }, default_url: "/images/:style/missing.png"
validates_attachment_content_type :avatar, :content_type => [
/\Aimage\/.*\Z/,
"application/pdf",
"application/vnd.ms-excel",
"application/... |
describe 'Sign Up Page' do
it 'lets the user click the signup button', :js => true do
visit '/signup'
fill_in('Username', with: 'Brozera')
fill_in('Password', with: 'password')
fill_in('Password confirmation', with: 'password')
click_link('Sign Up')
page.should have_content('Te... |
RSpec::Matchers.define :have_error do |text, options|
match do |page|
field = options[:on]
selector = ".//div[contains(@class,'error') and ./label[contains(text(),'#{field}')]]/*[contains(text(),\"#{text}\")]"
expect(page).to have_xpath(selector)
end
end
|
include_recipe 'torque::default'
include_recipe 'nfs::server'
nfs_export '/home' do
network '*'
writeable true
sync true
options %w(no_root_squash insecure)
end
%w(
torque-server
torque-scheduler
torque-client
).each do |pkg|
package pkg
end
if Chef::Config[:solo]
cnodes = [
{
hostname: '... |
class Admin::EventsController < Admin::AdminController
before_action :set_chapter
before_action :set_event, except: [:create]
def show
end
def create
@event = Event.new(event_params.merge(chapter: @chapter))
if @event.save
redirect_to admin_chapter_event_path(@chapter, @event), notice: "Event ... |
# frozen_string_literal: true
module Dealersocket
module Client
# This class is responsible for logic for CRUD actions of Dealersocket customers
class Customer < Base
APPROVED_ATTRIBUTES = %i[id given_name family_name line_one city_name postcode state uriid dealer_number_id home
... |
module CapitalOneClient
module Support
class BaseSession
EXPECTED_TYPES = %w{ accounts transactions days transaction-ids }
def initialize(user_id = nil, authentication_token = nil, api_token = nil)
@user_id = user_id.to_i
@authentication_token = authentication_token
... |
require 'rnmap/output_formatter'
module Rnmap
class Task
def initialize(address)
@address = address
end
def generate_nmap_command
"nmap -v0 -oX #{@address.to_filename} #{@address.to_s}"
end
def previous_output_file_exist?
File.file?(@address.to_filename)
end
def run_s... |
require 'formula'
class Yajl <Formula
homepage 'http://lloyd.github.com/yajl/'
url 'http://github.com/lloyd/yajl/tarball/1.0.11'
md5 '5b60f4d59b3b1fb42d7808d08460fb12'
def patches
# All YAJL releases so far have an rpath bug, though its fixed in upstream git:
# https://github.com/lloyd/yajl/commit/a31... |
class AddUrlToOpinion < ActiveRecord::Migration[5.2]
def change
add_column :opinions, :url, :string
end
end
|
require_relative "service"
require "docker"
require "logstash/devutils/rspec/logstash_helpers"
class KafkaService < Service
include LogStashHelper
def initialize(settings)
super("kafka", settings)
end
def setup
try(20) do
@kafka_image = Docker::Image.build_from_dir(File.expand_path("../kafka_do... |
class MakeUserNameNonNullable < ActiveRecord::Migration[6.1]
def change
change_column :users, :first_name, :string, null: false
change_column :users, :last_name, :string, null: false
end
end
|
class AddPafSentToBooking < ActiveRecord::Migration[6.1]
def change
add_column :bookings, :is_paf_sent, :boolean, default: false
end
end
|
FactoryBot.define do
factory :comment do
association :post, factory: :post
body Faker::Lorem.paragraph(2)
end
end
|
class My::CharactersController < MyController
def index
@characters = resources
end
def new
@character = resources.new(params[:character])
end
def create
@character = resources.new(params[:character])
respond_to do |format|
if @character.save
format.html { redirect_to my_chara... |
FactoryGirl.define do
factory :pick do
transient do
pool { build(:pool) }
end
entry { build(:entry, pool: pool) }
contestant { build(:contestant, pool: pool) }
end
end
|
class Due < ActiveRecord::Base
attr_accessible :amount, :last_paid, :worker_profile_id
belongs_to :worker_profile
end
|
require 'simple_spec_helper'
describe Lolita::Navigation::Tree do
let(:tree){Lolita::Navigation::Tree.new("test")}
context "#new" do
it "should create new navigation tree with name" do
tree=Lolita::Navigation::Tree.new("Test tree")
tree.name.should == "Test tree"
end
it "should raise err... |
# frozen_string_literal: true
class Group < ApplicationRecord
has_many :accounts, inverse_of: :group
accepts_nested_attributes_for :accounts
validates :slug, presence: true
validates :name, presence: true
def to_param
slug
end
def member?(account)
accounts.exists?(account.id)
end
end
|
# frozen_string_literal: true
class CordinatesController < ApplicationController
before_action :logged_in_user, only: %i[create edit delete update]
before_action :friend_user, only: %i[new edit create]
before_action :blocking?, only: %i[show]
def index
@item = Item.where(user_id: params[:user_id])
ite... |
module Antlr4::Runtime
class LexerPushModeAction < LexerAction
attr_reader :mode
def initialize(mode)
@mode = mode
end
def action_type
LexerActionType::PUSH_MODE
end
def position_dependent?
false
end
def execute(lexer)
lexer.push_mode(@mode)
end
de... |
require 'rails_helper'
describe ChangeItemVisibility do
let(:media_item) { FactoryGirl.create(:media_item, public: is_public) }
subject { described_class.new(media_item: media_item, public: going_to_be_public) }
def assert_visibility(media_item, is_public, going_to_be_public)
expect(media_item.public?).to ... |
#require 'resque'
#require 'resque_scheduler'
#require 'resque_scheduler/server'
require 'resque/server'
Ibet::Application.routes.draw do
get "trade/index"
get "event/index"
devise_for :users
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out ... |
module Inventory
class VendorInvoice
include Mongoid::Document
include Mongoid::Timestamps::Short
DRAFT = 'draft'
SUBMITTED = 'submitted'
PAID = 'paid'
INVENTORY_SETUP = 'inventory_setup'
field :invoice_no, type: String
field :invoice_date, type: DateTime
field :status, type: Str... |
class RouterController < ApplicationController
def index
path = case current_user.roles.first.name
when 'sys_admin'
restaurants_path
when 'manager'
restaurants_path
when 'guest'
guest_index_path
else
forbidden_acces_path
end
redirect_to path
end
end
|
class CreateMybusinesses < ActiveRecord::Migration
def change
create_table :mybusinesses do |t|
t.string :name
t.string :type_of
t.string :category
t.string :district
t.string :village
t.string :contact
t.text :description
t.timestamps null: false
end
end
end... |
Rails.application.routes.draw do
devise_for :admins
resources :comments
devise_for :members
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
resources :members, only: [:index, :show] do
resources :episodes do
resources :comments
end
end
au... |
module Zheng
module Parameters
module_function
# These values are taken from the European Go Rating. See http://gemma.ujf.cas.cz/~cieply/GO/gor.html
E = 0.014
def A rating
return 70 if rating >= 2700
return rating * (-1.0/20) + (205)
end
def Con rating
return 10 if rating > 2... |
#!/usr/bin/env ruby
class Tree
attr_accessor :id
attr_accessor :value
attr_reader :children
def initialize(id, value)
@id = id
@value = value
@children = []
end
def add_child(child)
@children.push(child)
end
def convert(trees)
@children.each_with_index do |val, idx|
@children[idx] = trees[val]... |
require "rails_helper"
RSpec.describe "Sessions API", type: :request do
let(:user) { FactoryBot.create(:user) }
let(:session) { { email: user.email, password: user.password } }
let(:auth_token) { { "AUTH-TOKEN" => user.authentication_token } }
describe "POST /sign_in" do
before { post "/api/v1/sign_in", p... |
module TeachersPet
class Cli
option :organization, required: true
students_option
common_options
desc 'create_student_teams', "Create teams for each student (or student group), and a team for all the instructors."
def create_student_teams
TeachersPet::Actions::CreateStudentTeams.new(option... |
require "spec_helper"
describe TheGrid::Api do
subject{ TheGrid::Api.new(relation) }
let(:child_relation) { double("Child Relation").as_null_object }
let(:relation) { double("Relation", :reflections => { :child_relation => child_relation }).as_null_object }
let(:commands) { lambda{ |name| ::TheGrid::Api::Comm... |
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
rescue_from Exception do |exception|
Rails.logger.error("********* EXCEPTION RAISED: #{exception.message} *******... |
# U2.W6: Refactoring for Code Readability
# I worked on this challenge by myself.
# Original Solution
=begin
class CreditCard
# initialize CreditCard object with a card numbers
def initialize(card_num)
@card_num = card_num
raise ArgumentError.new("Card length is not 16!") if (card_num.to_s.length != 16)
en... |
class NuclearActivity < ActiveRecord::Base
attr_accessible :task_id, :statement
belongs_to :task
validates_presence_of :statement
end
|
class AddRecordDateToAttendanceRecords < ActiveRecord::Migration
def change
add_column :attendance_records, :present, :boolean
add_column :attendance_records, :tardy, :boolean
add_column :attendance_records, :absent, :boolean
end
end
|
class CommentsController < ApplicationController
before_action :define_content_header
before_action :define_article
before_action :set_comment, only: [:show, :update, :destroy]
rescue_from ActiveRecord::RecordNotFound, :with => :record_not_found
# GET /comments
def index
@article = Article.find(param... |
# frozen_string_literal: true
require 'securerandom'
module ConfigurationHelper
def configuration_block(**configuration_settings)
lambda do |config|
configuration_settings.each do |attribute, value|
config.public_send(:"#{attribute}=", value)
end
end
end
def create_token
SecureR... |
class Episode < ActiveRecord::Base
belongs_to :season
has_many :script_beats
end
|
require 'rake'
require 'rake/clean'
require 'rake/tasklib'
require 'rbconfig'
# Rake tasks to build Ruby extensions
module Rake
# Create a build task that will generate a Ruby extension (e.g. .so) from one or more
# C (.c) or C++ (.cc, .cpp, .cxx) files, and is intended as a replcaement for mkmf.
# It determin... |
class Question < ActiveRecord::Base
has_many :answers, dependent: :destroy
has_many :user_answers
accepts_nested_attributes_for :answers
CATEGORIES = {
"Sports" => "sports",
"Politics" => "politics",
"Fashion" => "fashion",
"Pop Culture" => "pop culture"
}
end
|
require './lib/player.rb'
RSpec.describe Player do
context '#initialize' do
context 'when creating a player' do
subject { described_class.new(name: "Ray") }
it 'will show the player\'s name' do
expect(subject.name).to eq("Ray")
end
end
end
context '#roll' do
subject { d... |
require 'lava/audio_sampler'
RSpec.describe Lava::AudioSampler do
let(:tmp_dir) { "/tmp/lava/spec/#{rand(10000)}" }
describe ".initialize" do
it "creates a lava audio sampler object" do
expect( Lava::AudioSampler.new ).to be_a Lava::AudioSampler
end
it "creates the capture directory" d... |
require 'test_helper'
module PointlessFeedback
class MessagesControllerTest < ActionController::TestCase
setup do
@routes = Engine.routes
end
describe "getting new" do
setup { get :new }
it { assert_response :success }
it { assert_template :new }
it { assigns(:message).mus... |
require 'test_helper'
class CardPaymentsApiAuthorizationsTest < Minitest::Test
def test_create_authorization
auth = VCR.use_cassette('card_payments_api/create_authorization') do
profile = create_test_profile_with_card_and_address
card = profile.cards.first
authenticated_client.card_payments.c... |
=begin
#===============================================================================
Title: Count-up Clock
Author: Hime
Date: Sep 11, 2013
--------------------------------------------------------------------------------
** Change log
Sep 11, 2013
- initial release
--------------------------------------------... |
class DeliverDestination < ApplicationRecord
belongs_to :customer
validates :postcode, presence: true, numericality: { only_integer: true }, length: { is: 7 }
validates :address, presence: true
validates :destination, presence: true
# order/newで使用
def order_address
self.postcode + self.address + self.... |
class LessonsController < ApplicationController
before_action :authenticate_teacher!, only: [:new, :edit, :create, :update, :destroy]
before_action :set_teacher, only: [:new, :edit, :create, :update, :destroy]
before_action :set_lesson_for_teacher, only: [:edit, :update, :destroy]
# GET /lessons
# GET /lesson... |
require "rails_helper"
RSpec.describe Item, type: :model do
describe ".top_by_revenue" do
it "returns the top x items by total revenue" do
load_merchants_with_transactions
item1, item2 = Item.top_by_revenue(2)
expect(item1.id).to eq(Item.last.id)
expect(item2.id).to eq(Item.second.id)
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.