text stringlengths 10 2.61M |
|---|
class UserGeneratorWorker
include Sidekiq::Worker
def perform(user_id, name, address)
puts "worker creating user with id: #{user_id}"
User.create(id: user_id, name: name, address: address)
end
end
|
class Document < ActiveRecord::Base
belongs_to :user
validates :name, :language, :content,
presence: true,
length: {
minimum: 1
}
after_initialize :reference_forked_from
private
def reference_forked_from
if self.forked
parent_id = self.forke... |
module Roglew
module GL
BLEND_EQUATION_EXT ||= 0x8009
FUNC_ADD_EXT ||= 0x8006
MAX_EXT ||= 0x8008
MIN_EXT ||= 0x8007
end
end
module GL_EXT_blend_minmax
module RenderHandle
include Roglew::RenderHandleExtension
functions [
[:glBlendEquationEXT, [ :uint ]... |
class NetworkRacksController < ApplicationController
before_action :set_network_rack, only: [:show, :edit, :update, :destroy]
# GET /network_racks
# GET /network_racks.json
def index
@network_racks = NetworkRack.all
end
# GET /network_racks/1
# GET /network_racks/1.json
def show
end
# GET /ne... |
# frozen_string_literal: true
RSpec.describe Growi::ImageConverter::Body do
describe '#scan_markdown_image_esa' do
shared_examples 'match regular expression' do
it { expect(body.scan_markdown_image_esa.size).to eq 1 }
end
shared_examples 'not match regular expression' do
it { expect(body.sca... |
class ChangeTablesOnSections < ActiveRecord::Migration
def change
add_column :sections, :list_name, :string
remove_column :sections, :section_type
end
end
|
class Post < ActiveRecord::Base
extend FriendlyId
friendly_id :slug
belongs_to :postable, polymorphic: true
default_scope { order('publishDate DESC') }
def publish_age_less
@age ||= publish_age
if @age[:day] > 0
if @age[:day] == 1
html = "#{@age[:day]} day ago"
else
html... |
module Dartt
class Milestone
attr_reader :name
def initialize(name, date=nil, start_of: nil, tag: nil)
@milestone = Task.new(name).start(date).duration(1)
unless tag.nil?
@milestone = @milestone.tag(tag)
end
end
def ==(other)
name == other.name and date == other.date
... |
require 'erb'
require_relative 'enumerable_method'
require_relative 'problem'
require_relative 'exercise'
require_relative 'test_suite'
require_relative 'generator/map_problem'
require_relative 'generator/select_problem'
require_relative 'generator/reject_problem'
require_relative 'generator/any_problem'
require_relati... |
require_relative 'spec_helper'
require_relative '../lib/Movie'
describe Movie do
before(:context) do
@movie = Movie.new('Madagascar', 15, 112, 'Tyler', 'Jessie')
end
describe 'initialize' do
it 'should be a movie' do
expect(@movie).to be_instance_of(Movie)
end
it 'should be a digit... |
# Some tasks to import the 830,000-odd charities into GiveGoods for seeding.
# After the intial launch, we can likely remove these tasks.
module CharitiesLoader
extend self
def tmp(file)
Rails.root.join("tmp", File.basename(file))
end
def curl(url)
user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS... |
class State < ActiveRecord::Base
attr_accessible :name
has_many :districts
validates_presence_of :name
validates_uniqueness_of :name
end
|
class CreateNationImprovements < ActiveRecord::Migration
def change
create_table :nation_improvements, :id => false do |t|
t.integer :nation_id
t.integer :improvement_id
t.integer :number
t.timestamps
end
end
end
|
require 'rails_helper'
RSpec.describe SyncGithubWorker do
let(:user) { create :user }
describe '#perform' do
it { expect(SyncGithubWorker.new.perform(user.id)).to eq nil }
end
end
|
require 'rails_helper'
RSpec.describe "A visitor" do
it "can click links in the nav bar" do
visit "/"
within "nav" do
expect(page).to have_link("Artists")
expect(page).to have_link("Shops")
expect(page).to have_link("Styles")
expect(page).to have_link("Login with Goo... |
class User::PickupService < BaseService
# actually, add a subscription/order
def add params
pick_up_param = process_pickup_param(params)
pick_up = current_user.pick_ups.new(pick_up_param)
pick_up.status = PickUp::STATUSES[:pending]
pick_up.save
pick_up
end
def cancel params
pick_up = c... |
module TokenHelper
require 'jwt'
class << self
# wrapper for JWT.encode
# generates JWT with user_id and expiry_time as payload
def jwt_encode(user_id, expiry_time, refresh = false)
payload = Hash.new
payload['user_id'] = user_id.to_s
payload['expiry_time'] = expiry_time
# only ... |
class Admin::UsersController < ApplicationController
before_filter :authorized?
def index
@users = User.all
end
def update
@user = User.find(params[:id])
if @user.update_attributes(user_params)
redirect_to :admin_users, notice: "Admin status updated"
else
redirect_to 'pages#home'
en... |
class CreateSupportTaskStats < ActiveRecord::Migration
def self.up
create_table :support_task_stats do |t|
t.integer :owner_id
t.integer :script_id
t.integer :status
t.string :task_type
t.text :params
t.text :note
t.text :log
t.timestamps
end
end
def self.d... |
class ResourceCommentsController < ApplicationController
skip_before_action :authenticate_user!
def create
@resource_comment = ResourceComment.new(comment_params)
@resource_comment.resource_item_id = params[:resource_item_id]
@resource_comment.save!
redirect_to resource_item_path(@resource_comment... |
# coding: utf-8
require 'set'
class ApplicationController < ActionController::Base
before_filter :get_classifications, :get_all_used_tags
before_action :set_locale
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
lay... |
class RemoveNullFromCommandsIsDescription < ActiveRecord::Migration
def change
change_column :commands, :is_deployment, :boolean, :null => false, :default => false
end
end
|
require 'spec_helper'
describe Api::V1::Organizations::TagsController do
render_views
describe "#index" do
let(:organization) { FactoryGirl.create :organization, tag_list: tags }
let(:tags) { ["a", "b", "c"] }
let(:action) { get :index, organization_id: organization.id }
requires_authorizat... |
# Exercise 30: Else and If
# Answers to Exercise 27 Study Drills:
# 1. An 'if-statement' creates what is called a 'branch' in the code.
# The 'if-statement' tells your script, 'if this boolean expression is true,
# then run the code under it, otherwise skip it.'
# 2. In Ruby we indent code under statements like '... |
class CreateLandlords < ActiveRecord::Migration
def up
create_table :landlords do |t|
t.string :name, null: false
t.string :email
t.string :phone
t.timestamps
end
add_index :landlords, :name
end
def down
drop_table :landlords
end
end
|
require 'uri'
require 'puppet/property/boolean'
require 'puppet/property/list'
Puppet::Type.newtype(:nexus_repository_route) do
@doc = "Manages Nexus Repository Routes through a REST API"
@@nexus_all_group_repositories_marker = '*'
ensurable
newparam(:id) do
desc 'Read only value used to manage the resou... |
class Users::RegistrationsController < Devise::RegistrationsController
before_action :select_plan, only: :new
def create
#Extending devise's create action to add user id for each plan
super do |resource|
if params[:plan] #If there are parameters of plan
resource.plan_id = params[:plan] #Set p... |
module SharedWorkforce
class Client
class << self
def version
SharedWorkforce::VERSION
end
end
end
end |
class Admin::ItemsController < Admin::BaseController
def index
@items = Item.admin_alpha
end
def new
@item = Item.new
unless @item.itemable = Store.find_by(id: params[:store_id])
flash[:error] = "Please select a store's inventory to edit."
redirect_to admin_stores_path
end
end
de... |
class HorizontalProperty < ApplicationRecord
belongs_to :user
belongs_to :act
validates_presence_of :user_id, :act_id, :propiedad, :alicuota, :expensas, :comparece_menor, :nombres_tutor, :fecha_adjudicacion, :fecha_acta_notarial
end
|
# Allow the user to see a homepage.
#
# @author Matthew Rayner
# @since 0.1
class HomeController < ApplicationController
def index
@cv_url = cv_url
end
private
def cv_url
cv = CurriculumVitae.last
cv.file.url unless cv.nil?
end
end
|
# -*- encoding : utf-8 -*-
require 'logger'
require 'forwardable'
require 'ashikawa-core'
require 'active_support/core_ext'
require 'guacamole/document_model_mapper'
module Guacamole
class << self
# Configure Guacamole
#
# Takes a block in which you can configure Guacamole.
# @return [Configuratio... |
require 'common_substring'
class Task < ActiveRecord::Base
include CommonSubstring
belongs_to :partner
validates :title, :length => { :maximum => 500 }
validates :description, :length => { :maximum => 2000 }
#validate :deadline_cannot_be_in_the_past
after_initialize :set_default_values
after_find :add... |
FactoryBot.define do
factory :legal_services_service_offering, class: LegalServices::ServiceOffering do
association :supplier, factory: :legal_services_supplier
lot_number { '1' }
service_code { 'WPSLS.1.1' }
end
end
|
require 'spec_helper'
describe Synchronisable do
describe 'synchronization' do
subject do
-> { Synchronisable.sync }
end
describe 'models specified in configuration' do
context 'only Team and Match' do
before :all do
Synchronisable.config.models = %w(Match Team)
end... |
def parse ip
seqs = ip.split(/\[|\]/)
evens, odds = seqs.partition.with_index { |seq, i| i.even? }
yield evens, odds
end
def abba? seq
(/(\w)(\w)\2\1/ =~ seq) && ($1 != $2)
end
def supports_tls? ip
parse ip do |evens, odds|
evens.any? { |seq| abba? seq } &&
odds.none? { |seq| abba? seq }
end
end
... |
class EventsController < ApplicationController
swagger_controller :events, "Events management"
before_action :authenticate_volunteer!, except: [:index, :show, :pictures, :main_picture],
unless: :is_swagger_request?
before_action :authenticate_volunteer_if_needed,
only: [:index, :s... |
module Api
module V1
class UsersController < Api::V1::ApplicationBaseController
before_action :set_user, only: [:show, :update, :destroy]
skip_before_action :require_valid_token, only: :create
# GET /users
def index
@users = User.all
end
# GET /users/1
def show
... |
class Whitelist < ActiveRecord::Base
belongs_to :company
has_many :ips, dependent: :destroy
validates_presence_of :company, :name, :ips
accepts_nested_attributes_for :ips, reject_if: :all_blank, allow_destroy: true
validates_associated :ips, on: %i[create update]
validate :only_one_whitelist_by_company,... |
class HistoriesController < ApplicationController
before_action :set_history, only: [:update, :destroy]
def index
transpoter = facade.select :history
if transpoter.status == :green
render json: transpoter.bucket[:histories]
else
render json: transpoter.messages, status: 499
end
end
... |
module Skore
module API
class Category < Chainable
include Skore::DB::Category
def query
{
only: %i(id name)
}
end
def path
'/categories'
end
end
end
end
|
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... |
require 'spec_helper'
require 'json'
describe TestdroidAPI::FileSets do
before :all do
VCR.use_cassette('fs_oauth2_auth_files') do
@user = client_local_host.authorize
@user.file_sets.list.each{ |fs| fs.delete}
end
end
it 'get file sets ' do
VCR.use_cassette('fs_file_sets') do
fs = ... |
# frozen_string_literal: true
module V2
class UploadUnitOverrides < ::BaseCommand
attr_reader :override_code, :override, :unit, :csv, :parsed_csv
def initialize(override_code:, csv:)
@override_code = override_code
@override = ::V2::Override.find_by(code: override_code)
@unit = override&.uni... |
require "spec_helper"
require "fog/brightbox/models/compute/server"
describe Fog::Compute::Brightbox::Server do
include ModelSetup
include SupportsResourceLocking
subject { service.servers.new }
describe "when asked for collection name" do
it "responds 'servers'" do
assert_equal "servers", subject.... |
require_relative 'linked_list'
class WagonTrain
attr_accessor :list
def initialize
@list = LinkedList.new
end
def append(surname, supplies = {})
list.append(surname, supplies)
end
def count
list.count
end
def supplies
current = list.head
supplies = {}
until current.nil?
... |
Rails.application.routes.draw do
root to: 'tours#index'
namespace :admin do
resources :tours
resources :providers
resources :cities
end
resources :tours
end
|
class CreateDisciplinas < ActiveRecord::Migration
def change
create_table :disciplinas do |t|
t.string :lectivo
t.string :rne
t.date :fechaSancion
t.text :motivoSancion
t.string :maestroSancion
t.boolean :firmaSancion
t.string :tipoDisciplina
t.timestamps
end
... |
require 'thor/rails'
class Neo4j < Thor
include Thor::Rails
desc "clear_database", "Clear out the current neo4j database"
def clear_database
if yes?('Are you really, really, REALLY sure you want to delete all the data in your database?')
say "Clearing..."
::Neo4j::Session.current.query('MATCH (n... |
#!/usr/bin/env ruby
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "Lic... |
class TowersOfHanoi
# Towers of Hanoi: http://en.wikipedia.org/wiki/Tower_of_Hanoi
attr_accessor :towers, :from, :to
def initialize
@towers = {1 => [], 2 => [], 3 => []}
@from = 0
@to = 0
end
def play
num_ disks
until won?
display
move_from
move_to
@towe... |
#!/usr/bin/ruby -w
# -*- coding: UTF-8 -*-
#ruby 其他
#包括 文件的输入与输出、File类和方法、Dir类和方法、异常
puts ' --- 1 ---------------华丽丽的分割线------------'
#gets 语句可用于获取来自名为 STDIN 的标准屏幕的用户输入。
puts "enter a value :"
val = gets
puts val
######################################
#与 puts 语句不同,puts 语句输出整个字符串到屏幕上,而 putc 语句可用于依次输出一个字符。
str = "H... |
class Outing < ApplicationRecord
validates_presence_of :name,
:location,
:date
has_many :contestant_outings
has_many :contestants, through: :contestant_outings
def contestant_count
contestants.size
end
def contestant_names
names = contestants.pluck(:... |
# What happens if the user doesn't enter any students?
# It will try to print an empty list.
# How can you use an if statement (Control Flow) to only print the list if there is at least one student in there?
# question method
def question(string)
puts string
reply = gets.chomp()
return "n/a" if reply == ... |
require 'spec_helper'
describe 'Simulator' do
let(:robot) { double('robot') }
let(:simulator) { Simulator.new }
let(:table) { double('table') }
before do
allow(table).to receive(:place)
allow(Table).to receive(:new).and_return(table)
allow(robot).to receive(:orient)
allow(Robot).to receive(:new).and_retu... |
require 'belafonte/switch'
require 'belafonte/option'
require 'belafonte/argument'
require 'belafonte/errors'
module Belafonte
module DSL
# Class methods for defining apps
module Definition
def meta
@meta ||= {}
end
def info(item)
meta[item]
end
def title(title... |
class Assignment < ApplicationRecord
attr_accessor :smart_charger, :cell_phone_charger, :tablet_keyboard, :tablet_mouse, :user_search, :tablet_search, :cell_search
before_destroy :create_log
belongs_to :user
belongs_to :equipment
after_create :update_stock
after_update :update_stock
after_destroy :update_... |
require 'net/ssh'
require 'stringio'
def run(command, host, user: 'root', ignore_err: false)
# Execute a command on the remote server
# Not passing :password uses systems keys for auth
out = StringIO.new
err = StringIO.new
Net::SSH.start(host, user, verify_host_key: Net::SSH::Verifiers::Null.new) do |ssh|
... |
require 'rails_helper'
RSpec.describe FindVendor, type: :command do
context ".call with args" do
subject {
Inventory::Vendor.create!(
name: Faker::Lorem.word,
)
}
it "return result when id exists" do
cmd = FindVendor.call({id: subject.id.to_s})
expect(cmd.errors).to be {... |
class AddColorToAgents < ActiveRecord::Migration[5.1]
def change
add_column :agents, :color, :string, default: 'black'
end
end
|
FactoryBot.define do
factory :officer do
employee_id { 14242 }
factory :officer_kirk do
employee_id { 1701 }
hr_name { "Kirk,James T" }
doa { "2233-03-22" }
zip_code
earnings_rank { 42 }
organization { "Starfleet" }
title { "Starship Captain" }
rank { "capt" }
... |
require_relative 'teams.rb'
describe 'teams' do
it 'returns the number topics covered by a team' do
p1 = [1, 1, 0]
p2 = [0, 0, 1]
expect(topics_covered(p1, p2)).to eq 3
end
it 'returns a combination of teams' do
players = [[1], [2], [3]]
expect(team_combos(players)).to eq [[[1], [2]],[[1],[3... |
json.array!(@position_skills) do |position_skill|
json.extract! position_skill, :id
json.url position_skill_url(position_skill, format: :json)
end
|
class Stop
attr_reader :name, :queue
def initialize(name, queue)
@name = name
@queue = queue
end
def add_queueing_passenger(passenger)
@queue.push(passenger)
end
def get_queue_copy()
copy = @queue
return copy
end
def clear_queue()
@queue.clear()
end
end
|
class Answer < ActiveRecord::Base
belongs_to :question
has_many :users, :through => :user_answers
has_many :users
end
|
module ActiveRedis
module Constants
CALCULATION_METHODS = %w{count min max sum pluck}
SAVE_SUCCESS_ANSWER = "OK"
DEFAULT_ATTRIBUTES = {id: :integer, created_at: :time, updated_at: :time}
ASSOCIATIONS = [:has_one, :has_many, :belongs_to]
RELATION_METHODS = %w{where order limit first all}
... |
require 'test_helper'
class PrisedesangsControllerTest < ActionController::TestCase
setup do
@prisedesang = prisedesangs(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:prisedesangs)
end
test "should get new" do
get :new
assert_respon... |
module Bitemporal
module Mongoid
class Association
attr_writer :at, :valid_from
def initialize(opts = {})
@master = opts[:master]
@version_class = opts[:version_class].constantize
@version_ids = opts[:version_ids]
end
def scope
@version_class.where :_id.in =... |
class GradebooksController < ApplicationController
before_filter :login_required
filter_access_to :all, :except=>[:index,:exam_management]
filter_access_to [:index,:exam_management, :course_assessment_groups,:change_academic_year],:attribute_check=>true , :load_method => lambda { current_user }
before_filter... |
require_relative '../lib/uac'
require 'test/unit'
class UacTest < Test::Unit::TestCase
def test_join_args_discrete_args
options = {
:terminal => true,
:pause => true
}
args = [
"echo",
"hello",
]
uac_private = Uac::UacPrivate.new
(file, rest) = uac_private.join_args ... |
# @param {Integer[]} nums
# @param {Integer} target
# @return {Integer[]}
def two_sum(nums, target)
#error catching
if !nums
return []
end
#error catching
if nums.length < 1
return []
end
#A dictionary
indexHash = Hash.new
#Caching the length
numLength =... |
# frozen_string_literal: true
require "spec_helper"
describe GraphQL::Schema do
describe "instrumentation teardown bug" do
# This instrumenter records that it ran,
# or raises an error if instructed to do so
class InstrumenterError < StandardError
attr_reader :key
def initialize(key)
... |
module Spree
class ProductViewsToCartAdditionsReport < Spree::Report
DEFAULT_SORTABLE_ATTRIBUTE = :product_name
HEADERS = { product_name: :string, views: :integer, cart_additions: :integer, cart_to_view_ratio: :string }
SEARCH_ATTRIBUTES = { start_date: :product_view_from, end_date: :product_view_till }
... |
require 'json'
class Tootor
attr_accessor :id, :email, :username, :password, :name, :phone,
:street, :city, :state, :zip, :focus, :description, :created_at,
:updated_at, :visited_at, :seo_name, :picture, :video
attr_reader :price, :is_tootor
def initialize
@id = 0
@email = ''
@is_tootor = f... |
require "rails_helper"
feature "Login" do
given(:registered_user) do
FactoryBot.create(:user,
name: "Chaaartz",
level: 40,
trainer_phone_number: "9511234567",
password: "MyP@ssword1",
password_confirmati... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.provider "virtualbox"
config.vm.box = "ubuntu/trusty32"
config.vm.network "forwarded_port", guest: 8... |
require_relative '../../../lib/tax_calculator/file_reader'
RSpec.describe TaxCalculator::FileReader do
subject(:reader) { described_class.new(file_path) }
describe "#list_products" do
let(:file_path) { './input_test.md' }
let(:expected) do
[
{ quantity: 2, name: 'book', price: 12.49 },
... |
# Standard packages that install without any config or extra steps
standard_packages = [
]
# Packages that are an attended install
attended_packages = [
'python-software-properties'
]
standard_packages.each do |package|
dep "#{package}.managed" do
installs { via :apt, package }
end
end
attended_packages.ea... |
class ChangeTimeType < ActiveRecord::Migration
def change
change_column :meetings, :meeting_time, :string
end
end
|
module TroleGroups::Storage
class RefMany < BaseMany
def initialize rolegroup_subject
super
end
def display_roles
display_roles_for rolegroup_list
end
def display_roles_for *names
groups = find_rolegroups names.to_symbols_uniq
groups.inject([]) {|res, group| res << group.... |
class Addcolumnstotrack < ActiveRecord::Migration
def change
add_column :tracks, :combined_truncated, :string
add_column :tracks, :large_img, :string
add_column :tracks, :medium_img, :string
add_column :tracks, :small_img, :string
add_column :tracks, :via, :string
add_column :tracks, :via_url,... |
class AvengersHeadQuarter
attr_accessor :list
def initialize
self.list = []
end
def put(avenger)
self.list.push(avenger)
end
end
#TDD
describe AvengersHeadQuarter do
it 'Deve adicionar um vingador' do
hq = AvengersHeadQuarter.new
hq.put('Spiderman')
... |
require 'spec_helper'
describe "teams/new" do
before(:each) do
theStub = stub_model(Team,
:name => "MyString",
:sport => nil,
:league => nil,
:division => nil,
:conference => nil,
:location => nil,
:affiliation => nil,
:social_info => nil
).as_new_record
th... |
require 'rails_helper'
RSpec.feature 'List Comics', type: :feature do
it 'lists all the comics' do
VCR.use_cassette('comics_list', match_requests_on: [:path]) do
visit '/'
expect(page).to have_css('div.comic-box', count: 20)
end
end
end
|
class Start < ApplicationRecord
self.table_name = 'startlisten'
self.primary_keys = 'Regatta_ID', 'Rennen', 'Lauf', 'TNr'
belongs_to :regatta, foreign_key: 'Regatta_ID'
belongs_to :event, foreign_key: ['Regatta_ID', 'Rennen']
belongs_to :race, foreign_key: ['Regatta_ID', 'Rennen', 'Lauf']
belongs_to :par... |
class Program < ActiveRecord::Base
has_many :steps, inverse_of: :program, order: :position, dependent: :destroy
validates :name,
presence: true
end
|
require 'nokogiri'
require 'rest-client'
class WebScrapper
attr_reader :url, :page, :ext_links, :other_links
def initialize(url, http_method = :get, params = {})
@url = url
@page = Nokogiri::HTML(RestClient.method(http_method.to_sym).call(url, params))
end
def tags(name)
page.css(name)
end
d... |
module TaskMaster
RSpec.describe WebhookController do
describe "POST #create" do
before do
@routes = Engine.routes
end
it "finds the related resource and adds the response to its responses" do
fancyhands_response = JSON.parse(File.read(File.expand_path("../../../fixtures/custom_... |
class Task < ActiveRecord::Base
scope :complete, where(complete: true)
scope :incomplete, where(complete: false)
attr_accessible :complete, :name, :completed_at
end |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Identity, type: :model do
it 'has a valid factory' do
expect(build(:identity)).to be_valid
end
describe 'ActiveModel validations' do
subject { build(:identity) }
it { is_expected.to validate_presence_of(:uid) }
it { is_expected.... |
require "minitest/autorun"
require_relative "rocket"
class RocketTest < Minitest::Test
def setup
@rocket = Rocket.new
end
# ------------------------#
def test_new_name
@rocket.name=("aries i")
assert @rocket.name == "aries i"
end
#testing the negative
def test_new_name_old
@rocket.name=("h... |
require 'spec_helper.rb'
describe SyflNewswireCache::Story do
before(:each) do
@item = Item.create
@story = Story.create(lead_item: @item)
end
subject { SyflNewswireCache::Story.new(@story.id) }
describe '.lead_item' do
it 'should return a SyflNewswireCache::LeadItem' do
expect(subject.lead... |
class ResourcesController < ApplicationController
def index
lesson = Lesson.find_or_create_by(name: deslug(params[:slug]))
if lesson
render json: lesson.resources, :include => [:type], status: 200
# else
# render json: {error: "Lesson not found"}, status: 404
end
end
def create
r... |
require 'rails_helper'
RSpec.describe "covers/new", type: :view do
before(:each) do
assign(:cover, Cover.new(
image_link: "MyString"
))
end
it "renders new cover form" do
render
assert_select "form[action=?][method=?]", covers_path, "post" do
assert_select "input[name=?]", "cover[i... |
class JourneyLog
attr_reader :all_journeys
def initialize
@all_journeys = []
end
def start_journey(entry_station)
@journey = Journey.new(entry_station)
end
def end_journey(exit_station)
@journey.end_journey(exit_station)
@all_journeys << @journey
end
def in_journey
!@journey.nil?
... |
require "./display_impl.rb"
class CharDisplayImpl
include DisplayImpl
def initialize(head:, body:, foot:)
@head = head
@body = body
@foot = foot
end
def raw_open
print head
end
def raw_print
print body
end
def raw_close
puts foot
end
private
attr_accessor :head, :body... |
require 'byebug'
class Board
attr_accessor :grid
def initialize(grid = Board.default_grid)
@grid = grid
end
def self.default_grid
Array.new(10) { Array.new(10) }
end
def count
ship_count = 0
grid.each do |row|
row.each { |el| ship_count += 1 if el == :s }
end
ship_count
en... |
class Goembed < Formula
desc "goembed takes a list of local files and embeds them into golang source files."
homepage "https://github.com/koshatul/goembed"
version "0.4.0"
url "https://github.com/koshatul/goembed/releases/download/v0.4.0/goembed-v0.4.0-darwin-amd64.zip"
sha256 "e31e3af5fc39d80dbdd2596cf4059d... |
# frozen_string_literal: true
require 'spec_helper'
module CodeAnalyzer
describe Warning do
it 'should return error with filename, line number and message' do
expect(
Warning.new(filename: 'app/models/user.rb', line_number: '100', message: 'not good').to_s
).to eq 'app/models/user.rb:100 - n... |
class Post
attr_accessor :title, :author
def initialize(title)
@title = title
end
def author_name
if self.author
self.author.name
else
self.author = nil
end
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.