text
stringlengths
10
2.61M
class Product < ActiveRecord::Base attr_accessible :name, :price, :description, :image_url has_many :reviews validates_uniqueness_of :name validates_presence_of :name, :price end
require 'rails_helper' describe User do it "is valid with a name" do expect(User.new(name: 'test_user')).to be_valid end it "is invalid without a name" do user = User.new(name: nil) user.valid? expect(user.errors[:name]).to include("can't be blank") end end
class DiaperDrivesController < ApplicationController include Importable before_action :set_diaper_drive, only: [:show, :edit, :update, :destroy] def index setup_date_range_picker @diaper_drives = current_organization .diaper_drives .class_filter(filter_params) ...
class FontIosevkaEtoile < Formula version "18.0.0" sha256 "c3e3276f1a6744fc2c64ef795e5698ca241cf660b74ed7738858f5de77220d4a" url "https://github.com/be5invis/Iosevka/releases/download/v#{version}/ttc-iosevka-etoile-#{version}.zip" desc "Iosevka Etoile" desc "Sans-serif, slab-serif, monospace and quasi‑proport...
class ScoreEvent < ActiveRecord::Base belongs_to :user validates_presence_of :score validates_presence_of :event validates_presence_of :user_id before_create :get_created_day after_create :push_notification def get_created_day self.created_day = Date.today end def self.user_score_events(user,p...
class AddIsActiveToParticularPaymentAndDiscounts < ActiveRecord::Migration def self.up add_column :particular_payments, :is_active, :boolean, :default => true add_column :particular_discounts, :is_active, :boolean, :default => true add_index :particular_payments, :is_active, :name => "is_active" add_...
class CreateLikesAndFbLikes < ActiveRecord::Migration def up create_table :fb_likes do |t| t.string :fb_id t.string :name t.string :category t.datetime :created_time # when did the user like this t.timestamps end create_table :likes do |t| t.references :user t.i...
class Unit attr_reader :health_points, :attack_power def initialize(hp, ap) @health_points = hp @attack_power = ap end def attack!(enemy, ap_mod = 1) raise DeadAttackError if self.dead? enemy.damage((attack_power * ap_mod.to_f).ceil.to_i) end def damage(ap) raise DeadDamageError if se...
# frozen_string_literal: true module Bolt class Plugin class EnvVar def initialize(*_args); end def name 'env_var' end def hooks %i[resolve_reference validate_resolve_reference] end def validate_resolve_reference(opts) unless opts['var'] ra...
module Scaffoldable extend ActiveSupport::Concern included do MODEL_CLASS = self.model_class before_action :set_object, only: [:show, :profile, :update, :destroy] end def index @temp = MODEL_CLASS set_model_collection end def show end def new set_model_instance(MODEL_CLASS.new) ...
class Player < ActiveRecord::Base belongs_to :room belongs_to :user has_one :area, dependent: :nullify def start_from_center? room.game.start_from_center? end def camera_rotate (area.nil? || start_from_center?) ? 0 : 360 - area.angle end def start_center return [0, 0] if area.nil? || start_from_cen...
# MongoidSphinx, a full text indexing extension for MongoDB/Mongoid using # Sphinx. module Mongoid module Sphinx extend ActiveSupport::Concern included do unless defined?(SPHINX_TYPE_MAPPING) SPHINX_TYPE_MAPPING = { 'Date' => 'timestamp', 'DateTime' => 'timestamp', ...
class Bank attr_reader :name def initialize(name) @name = name.to_sym end def open_account(person) person.bank_accounts[name] = { galleons: 0, silver_sickles: 0, bronze_knuts: 0 } end def deposit(person, deposit) return no_account_message(person) if not has_account?(perso...
class AdministerUsersController < ApplicationController before_action :authenticate_user! before_action :require_admin def edit @user = User.find(params[:id]) session[:return_to] ||= request.referer end def index session[:return_to]="" session.delete(:return_to) @users = User.where.not(...
# Description: # You are given an array strarr of strings and an integer k. Your task is to return the first longest string consisting of k consecutive strings taken in the array. # Example: longest_consec(["zone", "abigail", "theta", "form", "libe", "zas", "theta", "abigail"], 2) --> "abigailtheta" # n being the le...
class Benchwarmer attr_reader :results class << self def run(options = {gc: :enable}) if options[:gc] == :disable GC.disable elsif options[:gc] == :enable # collect memory allocated during library loading # and our own code before the measurement GC.start end ...
class CreatePushes < ActiveRecord::Migration[5.2] def change create_table :pushes do |t| t.references :commits, foreign_key: true t.references :repository, foreign_key: true t.datetime :pushed_at t.references :pusher, foreign_key: true t.timestamps end end end
# frozen_string_literal: true module MarkdownMetrics module Elements module Block class Table < MarkdownMetrics::Elements::Base def self.match_element(line, next_line) line.to_s.match(/^.* \| .*$/) && next_line.to_s.match(/^\-{1,} \| \-{1,}$/) end def name :tabl...
require 'rails_helper' RSpec.describe User, :type => :model do before { @user = User.new(name: "Example User", email: "user@example.com", password: "foobar", password_confirmation: "foobar", mtname: 'example') } subject { @user } it { should respond_to(:name) } it { should respond_to(:email) } it { should...
class AddContactInfoToStores < ActiveRecord::Migration def change add_column :stores, :franchise_number, :string add_column :stores, :phone, :integer add_column :stores, :franchisee_name, :string add_column :stores, :contact_name, :string add_column :stores, :contact_phone, :integer end end
# frozen_string_literal: true require "spec_helper" RSpec.describe Tikkie::Api::V1::Responses::BankAccount do subject { Tikkie::Api::V1::Responses::BankAccount.new(user[:bankAccounts].first) } let(:users) { JSON.parse(File.read("spec/fixtures/responses/v1/users/list.json"), symbolize_names: true) } let(:user) ...
require 'forwardable' module Mikon # Internal class for indexing class Index extend Forwardable def_delegators :@data, :[] def initialize(source, options={}) options = { name: nil }.merge(options) case when source.is_a?(Array) @data = Mikon::DArray.new(source) ...
require 'level_object/mixin/jumper' shared_examples 'jumper' do before do described_class.jump_power = 10 end it { should respond_to :jump_power } context '#jump_power' do its(:jump_power) { should == 10 } end context '#jump' do context 'on ground' do before do subject.on_groun...
class Order < ApplicationRecord belongs_to :user has_many :placements, dependent: :destroy has_many :products, through: :placements attribute :total def total placements.sum{ |place| place.product.price.*(place.quantity) } end end
class DropCarts < ActiveRecord::Migration def change execute "DROP TABLE carts" end end
require 'spec_helper' describe Fappu::Page do describe "#new_from_json" do let(:args) { {'1' => {'image' => 'http://a.url.com', 'thumb' => 'http://a.thumb_url.com'}}} subject{ described_class.new_from_json(args) } it { is_expected.to be_an_instance_of(described_class) } it { is_expected.to have_attr...
#require 'singleton' #path = File.expand_path '..', __FILE__ #$LOAD_PATH.unshift path unless $LOAD_PATH.include?(path) #path = File.expand_path '../../../../shared-test-ruby', __FILE__ #$LOAD_PATH.unshift path unless $LOAD_PATH.include?(path) # All the HTML Elements the tests need to access in order to conduct text se...
class AddStatusAndColorToPieces < ActiveRecord::Migration[5.2] def change add_column :pieces, :status, :boolean add_column :pieces, :color, :string end end
module Api class ActivitiesController < ApiController def index @activities = current_user.own_activities.includes(:user, :picture).page 1 end def destroy @activity = Activity.find(params[:id]) @activity.destroy render json: @activity end def update @activity = Acti...
feature 'authentication' do scenario 'a user can sign in' do visit('/') click_button 'Sign up' fill_in('email', :with => 'carlo@fonte.com') fill_in('password', :with => '1234') fill_in('name', :with => 'carlo') fill_in('username', :with => 'carlitos') click_button 'Submit' expect(page...
module Synchronisable module Input # Provides a set of helper methods # to describe user input. # # @api private # # @see Synchronisable::Input::Descriptor class Descriptor attr_reader :data def initialize(data) @data = data end def empty? @data.bl...
class Question < ActiveRecord::Base attr_accessor :tweet_it belongs_to :category belongs_to :user # This will establish a `has_many` association with answers. This assumes # that your answer model has a `question_id` integer field that references # the question. with has_many `answers` must be plural (Rail...
ActiveAdmin.register Caracteristica do # See permitted parameters documentation: # https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters # permit_params :segmento_id, :tipo, :nombre # # or # # permit_params do # permitted = [:permitted...
class Genre < ActiveHash::Base self.data = [ { id: 1, name: '---' }, { id: 2, name: '打撃' }, { id: 3, name: '投球' }, { id: 4, name: '守備' }, { id: 5, name: '送球' }, { id: 6, name: '走塁' }, { id: 7, name: '配球' }, { id: 8, name: '練習方法' }, { id: 9, name: '指導方法' }, { id: 10, name: '食事・サ...
require 'test_helper' class CarreraMateriaControllerTest < ActionDispatch::IntegrationTest setup do @carrera_materium = carrera_materia(:one) end test "should get index" do get carrera_materia_url assert_response :success end test "should get new" do get new_carrera_materium_url assert_...
class Retailer < ActiveRecord::Base has_many :deals has_and_belongs_to_many :categories validates :name, presence: true validates :host_url, presence: true validates :brief_description, presence: true mount_uploader :favicon, PictureUploader mount_uploader :logo, PictureUploader mount_uploader :cover, Picture...
class Hash def slice(*args) sliced_value = {} args.each do |arg| sliced_value[arg] = fetch(arg) end sliced_value end end
class RenameSyncsToSyncSessions < ActiveRecord::Migration def self.up remove_index :syncs, :user_id rename_table :syncs, :sync_sessions add_index :sync_sessions, :user_id remove_index :events, :sync_id rename_column :events, :sync_id, :sync_session_id add_index :events, :sync_session_i...
class Product < ApplicationRecord has_many :orders_products has_many :orders, through: :orders_products validates :quantity, numericality: { only_integer: true, greater_than_or_equal_to: 0 } default_scope :in_inventory, -> { where("quantity > :qty", qty: 0) } scope :not_expired, -> { where expired: false } ...
require 'formula' class Ltl2ba < Formula homepage 'http://www.lsv.ens-cachan.fr/~gastin/ltl2ba/' url 'http://www.lsv.ens-cachan.fr/~gastin/ltl2ba/ltl2ba-1.1.tar.gz' sha256 'a66bf05bc3fd030f19fd0114623d263870d864793b1b0a2ccf6ab6a40e7be09b' def install system "make" bin.install "ltl2ba" end end
require "rails_helper" feature "user views home page" do scenario "and visits about page" do visit root_path click_on "About" expect(page).to have_content "About" end end
Rails.application.routes.draw do root "bookmarks#index" get "signup" => "signup#new" post "signup" => "signup#create" get "login" => "sessions#new" post "login" => "sessions#create" get "logout" => "sessions#destroy" get "dashboard" => "bookmarks#index" resources :bookmarks, except: [:index] resou...
require "faker" require_relative "producto" class GeneradorProductos def self.generar #logica para crear productos producto_nuevo = Producto.new producto_nuevo.nombre = generar_nombre(producto_nuevo) producto_nuevo.precio = rand(1000..50000) produ...
require_relative "spider" module Crawler class Bot SPIDERS_NUMBER = 5 def self.start spiders = [] SPIDERS_NUMBER.times do |i| spiders << Spider.supervise({number:i}) end sleep end end end
class Website < ApplicationRecord has_many :tag_contents def self.search(params) keyword = params['keyword'] || '' order = params['order'] || 'id DESC' Website.where('url like ?', "%#{keyword}%").order(order) end end
require 'csv' require 'json' require 'open-uri' require 'trello' def configure_trello options Trello.configure do |config| config.developer_public_key = options[:key] config.member_token = options[:token] end end module Datamine::CLI desc 'Manipulate Trello Boards' command :trello do |c| c.desc ...
require 'spec_helper' describe Fudge::Tasks::Cucumber do it { is_expected.to be_registered_as :cucumber } describe '#run' do it 'turns on color if not specified' do expect(subject).to run_command /--color/ end it 'turns off color if specified' do expect(described_class.new(:color => false...
class AddPostIdAndLabelIdToLabeledPosts < ActiveRecord::Migration def change add_column :labelled_posts, :label_id, :integer add_column :labelled_posts, :post_id, :integer end end
module GeneratorsCore # some_entity def underscore_name singular_name.underscore end # some-entity def dash_name underscore_name.gsub '_', '-' end # SomeEntity def entity_name singular_name.camelcase end # someEntity def lowercase_entity_name singular_name.camelize(:lower) end...
class ValidateSuite def validate_post_suite(suite_params) errors = [] params = JSON.parse(suite_params.to_json) return { error: "Deve possuir um JSON" } if params == {} or params == "{}" or params.nil? return { error: "Deve possuir o campo Nome" } unless params.include?("nome") name = params["nome...
class Show < ApplicationRecord has_many :user_shows has_many :users, through: :shows has_many :seasons has_many :episodes, through: :seasons validates :description, uniqueness: true end
FactoryBot.define do factory :commodity do name { Faker.name } description { 'description' } category_id { 2 } state_id { 2 } postage_id { 2 } area_id { 1 } estimate_id { 2 } price { 8888 } after(:build) do |commodity| commodity.image.attach(io: File.open('public/images/test...
describe 'puppler init command' do it "runs without errors" do status = puppler 'init', '--package-name', 'foobar' expect(status).to be_truthy end %w[rules install control source/format].each do |fname| it "creates file debian/#{fname}" do file_path = workdir.join("debian", fname) expect...
class Api::V1::LinksController < ApplicationController def index @links = Link.all render json: @links end def update @link = Link.find(params[:id]) @link.update(link_params) if @link.save render json: @link else render json: {errors: @link.errors.full_messages}, status: 422 ...
module FeatureHelper def login(the_user) visit new_user_session_path fill_in 'Email', with: the_user.email fill_in 'Password', with: the_user.password click_on 'Sign in' expect(page).to have_text 'My clients' expect(page).to have_current_path(root_path) end def add_client(the_client) ...
require_relative "answers" require "colorize" class Main attr_accessor :answers def initialize @answers = Answers.new welcome end def e_menu puts "Have a wonderful day!" exit end # def user_add # puts "Please enter your suggestion" # @sugg = g...
# frozen_string_literal: true module GraphQL VERSION = "1.9.9" end
class Segmento < ActiveRecord::Base has_many :caracteristicas, dependent: :destroy end
class UserMailer < ApplicationMailer default from: 'shyam.shinde@neosofttech.com' def welcome_email(user) @user = user mail(to: @user.email, subject: 'Welcome to My Awesome Site') end end
class CreateCampaigns < ActiveRecord::Migration[5.0] def change create_table :campaigns do |t| t.references :creator, foreign_key: true t.string :name t.string :description t.string :kickstarter_url t.string :sidekick_url t.string :currency t.integer :funding_goal t...
class StartViewController < UIViewController def viewDidLoad self.title = "Magic Field" view.userInteractionEnabled = true drawBackgroundImage drawStartScreenWindow drawWelcomeMessage drawPlayerInputs drawPlayerOneManaButtons drawPlayerTwoManaButtons createStartButton end pri...
require 'pp' class Solution def self.min_cost(houses = [[]]) all_costs(houses).min end # recursively determine possible painting costs def self.all_costs(houses) return [0] if houses.empty? return houses.first.compact if houses.size == 1 costs = [] houses[0].each_with_index do |cost, pain...
module Dabooks class CLI::GraphCommand DETAILS = { description: 'ASCII graphing for account balances over time.', usage: 'dabooks graph <account> <filename>', schema: {}, } def initialize(clargs) @argv = clargs.free_args end def run target_account = Account[@argv.shift] balance = Amo...
class TeamsController < ApplicationController require 'will_paginate/array' def show @team = Team.find(params[:id]) end # GET /teams # GET /teams.json def index @teams = Team.all end def games @year = params[:year] @team = Team.find(params[:id]) @games = @team.games.where("games.y...
# 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 rails db:seed command (or created alongside the database with db:setup). # # Examples: # # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) # Ch...
helpers do def grandma_helper(input) if rand(100000) == 1 "I'm not grandma, I'm you! Follow me back to the pa-futur-ast!" elsif input.upcase == input "I LOVE AOL ONLINE. I MADE MY PROFILE IN #{rand(1930..1940)}" else "WHAT!?!?" end end end
module SessionsHelper def sign_in(user) session[:user_id] = user.id @current_user = user end def current_user @current_user ||= sign_in_from_session || sign_in_from_cookies unless defined?(@current_user) @current_user end def current_user?(user) user==current_user end def sign_in_f...
module Yoti # Encapsulates attribute anchor class Anchor attr_reader :value, :sub_type, :signed_time_stamp, :origin_server_certs def initialize(value, sub_type, signed_time_stamp, origin_server_certs) @value = value @sub_type = sub_type @signed_time_stamp = signed_time_stamp ...
class Good < ApplicationRecord has_one_attached :thumbnail has_one :seller, class_name: 'Review', foreign_key: 'id' has_one :buyer, class_name: 'Review', foreign_key: 'id' belongs_to :user has_many :opinions has_many :added_goods, through: :opinions, source: :user enum property_type: [0, 1, 2, 3, 4] end
class Parser attr_accessor :log, :lines def initialize(log) @log = log @lines = [] @cnt = 0 end def run lines = @log.split("\n") lines.each do |line| @lines[@cnt += 1] = self.parse_line(line) end end def parse_line(line) pat...
require 'spec_helper' module RailsSettings class Dummy end describe Configuration, 'successful' do it "should define single key" do Configuration.new(Dummy, :dashboard) expect(Dummy.default_settings).to eq({ :dashboard => {} }) expect(Dummy.setting_object_class_name).to eq('RailsSettings:...
$LOAD_PATH.unshift File.dirname(__FILE__) $LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'libs') require 'fileutils' require 'parseconfig' require 'page_control' require 'report_case/base/report_case_base' require 'report_summary' # # Function : download_xml_csv_main.rb # Parameter : # Purpose : Handle get ...
class PagesController < ApplicationController $user_logged_in = false @user = $user_logged_in $inventory_array = [{id: 1000, name: "T-Shirt", description: "A shirt with short sleeves.", price: 12, stock: 52, vip: false, category: "tops", image: "https://target.scene7.com/is/image/Target/53294273?wid=225&hei=2...
# encoding: UTF-8 # Copyright 2012 Twitter, Inc # http://www.apache.org/licenses/LICENSE-2.0 module TwitterCldr module Tokenizers class PatternTokenizer attr_reader :data_reader, :tokenizer def initialize(data_reader, tokenizer) @data_reader = data_reader @tokenizer = tokenizer ...
module CloudFoundry def self.raw_vcap_data ENV['VCAP_APPLICATION'] end def self.vcap_data if is_environment? JSON.parse(raw_vcap_data) else nil end end # returns `true` if this app is running in Cloud Foundry def self.is_environment? !!raw_vcap_data end def self.instan...
if Rails.env.production? || Rails.env.staging? raise "MAILCHIMP_LIST_ID is missing" if ENV["MAILCHIMP_LIST_ID"].nil? raise "MAILCHIMP_API_KEY is missing" if ENV["MAILCHIMP_API_KEY"].nil? end
class CreateLcResults < ActiveRecord::Migration[5.2] def change create_table :lc_results do |t| t.integer :lc_class_id t.string :name t.integer :runner_id t.string :ecard t.string :club t.string :start t.string :result t.string :rank t.string :speed t.st...
# -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.require_version ">= 1.3.5" VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "precise32" config.vm.box_url = "http://files.vagrantup.com/precise32.box" # Use vagrant-cachier or similar if available (ht...
require "spec_helper" describe BigML::Source do describe "#code" do it "return code when set" do source = BigML::Source.new('code' => 201) source.code.should == 201 end it "return nil when not set" do source = BigML::Source.new('code' => nil) source.code.should be_nil end ...
# -*- encoding : utf-8 -*- module EverythingClosedPeriodsHelper def samfundet_closed? EverythingClosedPeriod.current_period end end
module Shomen module Model # class Method < Abstract # def initialize(settings={}) super(settings) @table['declarations'] ||= [] end # Method's name. attr_accessor :name # Method's namespace. attr_accessor :namespace # Comment accompanying ...
class Api::V1::GoalsController < Api::V1::BaseController def index goals = Goal.where(goal_params) render :json => goals.as_json end def create goal = Goal.new(goal_params) if goal.save render :json => goal.as_json else render :json => goal.errors.as_json end end def upd...
# ASSUMPTIONS # # Not using any Gem, but a direct HTTP request to access YouTube provided API. # The value of the KEYWORD string to search through YouTube is given static as 'football' require "net/https" require "uri" require 'json' class YouTube attr_accessor :keyword KEYWORD = "football" def initialize(keyw...
class AddQuestionsToPins < ActiveRecord::Migration def change add_column :pins, :questions, :text end end
class Packaging < Tag validates :name, presence: true, uniqueness: true has_many :product_packagings has_many :products, through: :product_packagings end
require 'sshkit/runners/abstract' module SSHKit module Runner class Abstract private def backend(host, &block) back = SSHKit.config.backend.new(host, &block) back.instance_variable_set(:@user, @options[:root_user]) if @options[:root_user] back end end end end
require 'rails_helper' RSpec.describe User, type: :model do subject { described_class.new(first_name: "Peter", last_name: "Nolan", email: "example@example.com", password: "password", password_confirmation: "password") } describe 'Validations' do it 'is valid with valid attributes...
require_relative "abstract" class SpotifyClient < AbstractClient def initialize(auth) @api = Spotify::Client.new( access_token: auth.token, raise_errors: true, persistent: true, ) super end # :nocov: # def me @api.me end def ensure_playlist(playlist) spotify_playlis...
FactoryGirl.define do factory :plan do name { Faker::Book.title } planner { Faker::Name.first_name } location { Faker::Address.city } end end
require "pry" # Helper Method def position_taken?(board, index) !(board[index].nil? || board[index] == " ") end # Define your WIN_COMBINATIONS constant WIN_COMBINATIONS = [ [0,1,2], # top row win [3,4,5], [6,7,8], [0,3,6], [1,4,7], [2,5,8], [0,4,8], [2,4,6] ] def won?(board) ### ways to check if w...
describe Parser::BostonRetirementSystem do include_context "parser" let(:file) { file_fixture("sample_boston_retirement_system.csv") } it "parses a row" do expect(record[:sort_name]).to eql("KIRK, JAMES T") expect(record[:job_description]).to eql("Teacher - S20315") end end
class AddHtmlSummaryToJobdesc < ActiveRecord::Migration def self.up rename_column :jobdescs, :text, :txt add_column :jobdescs, :html, :text add_column :jobdescs, :summary, :text end def self.down remove_column :jobdescs, :html remove_column :jobdescs, :summary end end
require 'rails_helper' describe StaticPagesHelper do it 'resource name' do expect(resource_name).to eq(:user) end it 'resource' do resource expect(@resource).to be_a_new(User) end it 'devise_mapping' do devise_mapping expect(@devise_mapping).to be_instance_of(Devise::Mapping) end end
require 'rails_helper' RSpec.describe 'Stats', type: :request do describe 'GET /stats/weekly' do before do create(:trip, distance: 15.5, price: BigDecimal('15.15')) create(:trip, distance: 12.75, price: BigDecimal('10.50')) get '/api/stats/weekly' end let(:expected_result) do { ...
require "rails_helper" RSpec.describe Post do it 'has a valid factory' do factory = FactoryGirl.create(:post) expect(factory).to be_valid end it 'is valid with valid attributes' do post = FactoryGirl.build(:post) expect(post).to be_valid end it 'is not valid without a title' do post = F...
=begin - Add two methods: ::generic_greeting(class) and #personal_greeting(instance) =end class Cat attr_reader :name def initialize(name) @name = name end def self.generic_greeting puts "Hello! I'm a cat!" end def personal_greeting puts "Hello! My name is #{name}!" end end kitty =...
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib")) require 'bosdk/enterprise_session' module BOSDK describe EnterpriseSession do before(:each) do @session_mgr = mock("ISessionMgr").as_null_object @session = mock("IEnterpriseSession").as_null_object @infostore = mock("IInfo...
class ApplicationController < ActionController::Base protect_from_forgery with: :exception before_action :authenticate private def authenticate authentication_text = 'Administration password required. Please enter username && password.' authenticate_or_request_with_http_basic(authentication_t...
require 'test_helper' class ExtensionTest < Test::Unit::TestCase context String do should "return the string for to_param" do string = "my string!" assert_same string, string.to_param end end context Integer do should "return a string representation for to_param" do integer = 5 ...
# Build a class EmailParser that accepts a string of unformatted # emails. The parse method on the class should separate them into # unique email addresses. The delimiters to support are commas (',') # or whitespace (' '). class EmailParser attr_reader :emails def initialize(email_string) @emails = email_string e...