text
stringlengths
10
2.61M
module Fog module Compute class Brkt class Real def list_machine_types(filter = {}) request( :expects => [200], :path => "v1/api/config/machinetype", :query => filter ) end end class Mock def list_machine_types...
require 'active_support' require 'active_support/core_ext' require 'erb' require_relative './session' require 'active_support/inflector' class ControllerBase attr_reader :req, :res, :params def initialize(req, res, params={} ) @already_built_response = false @req = req @res = res @params = params ...
require 'spec_helper' require 'rest_spec_helper' require 'rhc' require 'rhc/commands/authorization' describe RHC::Commands::Authorization do def self.with_authorization let(:username) { 'foo' } let(:password) { 'pass' } let(:server) { mock_uri } before{ user_config } before{ stub_api(false, true...
class Admin::AsambleistasController < ApplicationController layout 'admin' require_role "administrador" # GET /asambleistas # GET /asambleistas.xml def index @asambleistas = Asambleista.paginate(:per_page => 20, :page => params[:page]) respond_to do |format| format.html # index.html.erb fo...
# Using this file for Rock Paper Scissors Bonus Features require 'pry' class History attr_accessor :human_moves, :computer_moves, :winner def initialize @turns = [] @human_moves = [] @computer_moves = [] @winner = [] end def add_turn!(number) @turns << number end def add_moves!(human...
require 'rubygems' require 'facets' require 'find' Dir.glob('tasks/*.rake').each do |t| load t end def zip_file_name 'osc_commander.source.zip' end def zip_dir 'OscCommander' end desc "zip up for book site" task :zip do `rm -rf "#{zip_dir}"` if File.exist? zip_dir `mkdir #{zip_dir}` pfiles = D...
class Prototype < ApplicationRecord validates :image, :catch_copy, :title, :conept, presence: true belongs_to :user has_one_attached :image has_many :comments, dependent: :destroy end
class Piece attr_reader :color attr_accessor :position def initialize(position, color, board) @color, @position, @board, @captured = color, position, board, false end def move(target) return nil unless valid_move?(target, @board) raise InvalidMoveError if puts_in_check?(target) @board[@posit...
class QuizResponse < ActiveRecord::Base belongs_to :answer belongs_to :question belongs_to :quiz after_validation :check_correctness def course_name question.course.name end def check_correctness self.correct = self.answer == question.correct_answer end end
describe Ahoy::VisitsController, type: :controller do routes { Ahoy::Engine.routes } it "creates visits" do begin previous_value = Ahoy.track_visits_immediately = true expect { post :create }.to change{ Visit.count }.by(1) ensure Ahoy.track_visits_immediately = previous_value end e...
=begin Write your code for the 'Series' exercise in this file. Make the tests in `series_test.rb` pass. To get started with TDD, see the `README.md` file in your `ruby/series` directory. =end class Series def initialize(s) @series = s end def slices(n) raise ArgumentError if n > @series.length ...
require 'spec_helper' describe Itrp::Export::Monitor::Exchange do before(:each) do # default configuration for testing @options = { root: "#{@spec_dir}/tmp/exports", to: "#{@spec_dir}/tmp/copy_to", unzip: true, to_ftp: 'ftp://ftp.example.com:888', to_ftp_dir: '.', ...
# # Copyright 2011-2013, Dell # Copyright 2013-2014, SUSE LINUX Products GmbH # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requi...
class Movie < ActiveRecord::Base def self.all_ratings self.select(:rating).map(&:rating).uniq.sort end end
class Shift attr_reader :time def initialize(time) @time = time end def shift_forward(offset) # parse initial time times = @time.split(" --> "); time_a = convert_to_seconds(times[0]) time_b = convert_to_seconds(times[1]) # shift times forward time_a += offset time_b += offset # output new res...
class CreatePortfolios < ActiveRecord::Migration[5.2] def change create_table :portfolios do |t| t.text :dpname t.text :pname t.text :text t.integer :catID t.timestamps end end end
require 'spec_helper' TEST_CATEGORIES = { 'Supermarket' => ['Sainsbury', 'Tesco', 'Asda', 'Morrison', 'Waitrose', { 'M and S' => ['Marks/Spencer', 'M and S Simply Food', 'Marks Spencer', 'Marks and Spencer', 'Sacat Marks and , Spencer'] }, 'Aldi', 'Lidl', { 'Co-op' => ['Co-op', 'Co-operative', 'Coop' ]...
class PagesController < ApplicationController before_filter :load_club before_filter :auth_admin, :only => [:admin, :new, :edit, :create, :update, :destroy] uses_tiny_mce :options => { :theme => 'advanced', :plugins => %w{ advimg media emotions...
class AddCheckedInToScouts < ActiveRecord::Migration def change add_column :scouts, :checked_in, :boolean, :default => false add_index :scouts, :checked_in end end
class AddAllocationsToActions < ActiveRecord::Migration def change add_column :actions, :money_alloc, :integer add_column :actions, :mil_alloc, :integer add_column :actions, :complete_time, :datetime add_column :actions, :host_id, :integer add_column :actions, :host_type, :string add_column :actions...
module OpTables class Adop < BaseOpTables LEVEL = ['высшее образование - бакалавриат'] CODE = ['49.03.02'] def initialize @main_url = 'https://publish.surgu.ru/bsm/' @result = {} end def func(program_tag) program_relative_path = href(program_tag) program_code = program_re...
class ApplicationController < Sinatra::Base set :default_content_type, 'application/json' get '/' do { message: "Hello world" }.to_json end get '/games' do games = Game.all.order(:title).limit(10) games.to_json end get '/games/:id' do games = Game.find(params[:id]) games.to_json(inc...
class AddAttachmentImageToPosts < ActiveRecord::Migration def up change_table :posts do |t| t.attachment :image end remove_column :posts, :image_url end def down drop_attached_file :posts, :image add_column :posts, :image_url, :string end end
require 'minitest/autorun' require 'net/http' require 'json' require_relative './lib/server' class PingTest < Minitest::Test @@server = nil def setup if @@server.nil? @@server = Server.new 5001 Thread.new { @@server.start } end @ur...
require 'test_helper' module JackCompiler module Parser class TestVisitorNodeTransformer < Minitest::Test class DummyFactory attr_reader :state, :children def initialize(node_type, kind: nil, value: nil) @state = {node_type: node_type, kind: kind, value: value}.compact en...
class AddDetailsToTasks < ActiveRecord::Migration def change add_column :tasks, :accepted_by_user_id, :integer add_column :tasks, :task_status, :string add_column :tasks, :task_completed_at, :datetime end end
class Round < ActiveRecord::Base belongs_to :bet has_many :contracts, dependent: :destroy accepts_nested_attributes_for :contracts #so you can create all contracts with a single button has_many :users, through: :contracts has_many :agree_players, -> { where(contracts: { agreed: true }) }, through: :con...
class DidGoodsController < ApplicationController before_action :set_did_good, only: [:show, :edit, :update, :destroy] # GET /did_goods # GET /did_goods.json def index @main_page = "Pessoal" @page_title = "DidGoods" @did_goods = DidGood.all end # GET /did_goods/1 # GET /did_goods/1.json def...
Rails.application.routes.draw do devise_for :users # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html root to: "users#index" get "/profile/", to: "users#index", as: :user get "/profile/gallery", to: "arts#index", as: :arts post "/profile/gallery", to: "art...
module CamaleonCms class Plugin < CamaleonCms::TermTaxonomy # attrs: # term_group => status active (1, nil) # slug => plugin key # name => plugin name attr_accessor :error belongs_to :site, foreign_key: :parent_id, required: false default_scope { where(taxonomy: :plugin) } sco...
require "spec_helper" describe SmtpMessagesController do describe "routing" do it "routes to #index" do get("/smtp_messages").should route_to("smtp_messages#index") end it "routes to #new" do get("/smtp_messages/new").should route_to("smtp_messages#new") end it "routes to #show" do...
module GenomeDB require 'bio' class Version < DBConnection end class Dna < DBConnection has_many :genes has_many :transcripts, :through => :genes def sequence path = GenomeDB::Version.find(:first).file_path return Bio::FastaFormat.open("#{path}/fasta/#{self.connection.current_d...
FactoryBot.define do factory :user do nickname { 'test1' } email {Faker::Internet.free_email} password = '1a' + Faker::Internet.password(min_length: 6) password { password } password_confirmation { password } first_name { '陸太郎' } family_name { '山田' } first_name_katakana { 'リクタロウ' } ...
# => Author:: Valentin, DanAurea # => Version:: 0.1 # => Copyright:: © 2016 # => License:: Distributes under the same terms as Ruby require "optparse" require "fileutils" ## ## Module regroupant les informations de base de chaque fenêtre ## module Fenetre ## Définit la couleur blanche COUL...
json.array!(@restaurants) do |restaurant| json.extract! restaurant, :id, :name, :content, :lat, :lon json.url restaurant_url(restaurant, format: :html) json.json_url restaurant_url(restaurant, format: :json) json.reviews_url restaurant_reviews_url(restaurant, format: :html) json.reviews_json_url restaurant_re...
class Client < ApplicationRecord has_many :customer has_many :customer_transaction end
# frozen_string_literal: true module Mutations class Login < BaseMutation description 'Obtain access tokens with user credentials' argument :email, Scalars::Email, required: true argument :password, String, required: true field :access_token, String, null: false field :refresh_token, String, nu...
module Hardware class << self def is_32_bit? odisabled "Hardware.is_32_bit?", "Hardware::CPU.is_32_bit?" end def is_64_bit? odisabled "Hardware.is_64_bit?", "Hardware::CPU.is_64_bit?" end def bits odisabled "Hardware.bits", "Hardware::CPU.bits" end def cpu_type o...
require "moneyexchange/version" class Money attr_accessor :currency, :amount #obviously in some real iteration of this gem,conversions rates would change, but they will be constant in this example CONVERSION_RATE_USD = 1.11.freeze CONVERSION_RATE_BITCOIN = 0.0047.freeze def initialize(currency, amount) ...
module Effect class Healing < Effect::ActOnTick def initialize(parent, interval, amount) super parent, interval @amount = amount.to_i end def tick_event(*entities) source = nil target = nil if entities.count > 1 source = entities[0] target = entities[1] else source = entities[0] ...
require 'htph'; require 'threach'; # Use this script for documents that lack good identifiers. # Once you have a list of documents that couldn't be clustered # based on their identifiers, run this. # Turn on verbosity with -v. Defaults to false. $verbose = false; v_flag = ARGV.select{|arg| arg =~ /^-v$/} if !v_flag.e...
require 'faker' # Create Users # Notes: # - Calling 'User.new', instead of 'User.create', we create # an instance of User that is not immediately saved to the # database. # # - The 'skip_confirmation!' method sets the 'confirmed_at' # attribute to avoid triggering a confirmation email when # User i...
require 'fog/core/collection' require 'fog/aliyun/models/compute/snapshot' module Fog module Compute class Aliyun class Snapshots < Fog::Collection # attribute :filters model Fog::Compute::Aliyun::Snapshot # def initialize(attributes) # self.filters ||= {} # sup...
class RenameSubjectIdInSubCutoffs < ActiveRecord::Migration def change remove_foreign_key "sub_cutoffs", name: "sub_cutoff_fK_to_subjects" remove_foreign_key "subject_details", name: "sub_deta_fk1" rename_column :sub_cutoffs, :subject_id, :main_subject_id end end
### To Do: Make grid object that handles display. Or display.rb class Grid def initialize(width, height) @width = width.to_i @height = height.to_i @number = @width * @height end attr_reader :width, :height, :number def show_empty_grid number.times do |i| if i % width == 0 puts ...
module ImportHelper def self.valid_extension?(file) File.extname(file.path) == ".csv" end def self.valid_headers?(headers) headers.has_key?("username") && headers.has_key?("fcm_token") && headers.has_key?("email") end def self.valid_fields?(fields) fields["username"].length >...
# Provides methods for handling the mapstory cookie. class MapstoryCookie # Pass in the contents of the cookie to verify and decode. # returns the username if success, false otherwise. def self.decode(data) raise "MissingCookieKey" unless Rails.application.secrets.mapstory_cookie_key.present? # Remove the quote...
module ParseRedom class PlaceParser < Parser NodesPath = '//schedule/place'.freeze def nodes_xpath NodesPath end def parse_node(place_node) r_id = place_node.attributes['id'].value unless Place.where(r_id: r_id).exists? Place.build_me do |place| place.r_id = r_id...
class BreakingNewsController < ApplicationController layout false def show if @breaking_news_alert = BreakingNewsAlert.latest_alert render(template: "/breaking_news/email/template", locals: { alert: @breaking_news_alert }) and return end end end
class AddRelationColumnsToPolicyTables < ActiveRecord::Migration def change add_column :automobile_policy_infos, :policy_id, :integer add_column :business_liability_policy_infos, :policy_id, :integer add_column :workers_compensation_policy_infos, :policy_id, :integer end end
class BookInStock attr_accessor :isbn attr_accessor :price def initialize(_isbn, _price) raise ArgumentError, 'isbn should not be empty' if _isbn.empty? raise ArgumentError, 'price should be positive' if _price <= 0 @isbn = _isbn @price = _price end def price_as_string price_array = [] price_array...
class Identity < ActiveRecord::Base belongs_to :user serialize :info, JSON serialize :extra, JSON def self.first_or_create_with_omniauth(auth) where(uid: auth['uid'], provider: auth['provider']).first_or_create(info: auth['info'], extra: auth['extra']) end def provider_title case provider w...
class CreateAdvanceFeeCategoryCollections < ActiveRecord::Migration def self.up create_table :advance_fee_category_collections do |t| t.integer :advance_fee_collection_id, :default => nil t.integer :advance_fee_category_id, :default => nil t.decimal :fees_paid, :precision =>15, :scale => 2, :def...
class Facility include Mongoid::Document include Mongoid::Timestamps::Short field :name, type: String field :code, type: String field :site_license, type: String field :license_type, type: String field :license_start, type: String field :license_end, type: String field :timezone, type: String, defaul...
require 'rails_helper' RSpec.describe Item, type: :model do describe '#create' do before do @item = FactoryBot.build(:item) end context '商品出品ができる時' do it '全ての情報があれば出品できる' do expect(@item).to be_valid end end context '商品出品ができない時' do it '画像がないと出品できない' do @it...
module DynamodbOrm class Model module LookupMethods delegate :where, :index, to: :chain delegate :each, :first, :limit, to: :chain_with_scan def find(id) response = client_execute(:get_item, key: { primary_key => id }) response.item.blank? ? nil : new(response.item, persisted: t...
require 'action_view' require 'action_controller' $: << File.expand_path(__FILE__).split('/')[0..-3].join('/') # append plugin root to load path module NotificationSystem autoload :Event, 'lib/notification_system/event' autoload :Notification, 'lib/notification_system/no...
class UserMailer < ApplicationMailer default from: DEFAULT_SENDER_EMAIL def welcome(user) @user = user mail to: user.email, subject: 'Welcome To Our Store' end end
require 'strokedb/repositories/helpers' require 'strokedb/repositories/abstract_repository' require 'strokedb/repositories/abstract_async_repository' require 'strokedb/repositories/metadata_hash_layer' require 'strokedb/repositories/iterators' require 'strokedb/repositories/tokyocabinet_repository' __END__ Repositori...
require "rails_helper" describe "As an authenticated admin" do describe "when I visit kids show page" do it 'should show all events' do kid = create(:kid) event_1, event_2, event_3 = create_list(:event, 3, kid: kid) admin = create(:admin) admin.kids << kid allow_any_instance_of(Appl...
class CancelationMailerPreview < ActionMailer::Preview include MailerPreviewHelpers def cancelation_notification CancelationMailer.cancelation_notification( recipient: new_user, canceler: user, proposal: canceled_proposal, reason: reason ) end def cancelation_confirmation C...
class CompensationResultsDataExtractor attr_accessor :payload, :target_profile def extract(data_in, target_profile) self.payload = Hashie::Rash.new(data_in).response_compensation self.target_profile = target_profile # this defines the public API for the compensation results data = {} data...
# QuickSort1 # The first step of Quicksort is to partition an array into two parts. # Challenge # Given an array 'array' and a number 'p' in the first cell in the array, can you partition the array so that all elements greater than 'p' are to the right of it and all the numbers smaller than 'p' are to its left? # For...
require File.expand_path('../spec_helper', __FILE__) describe DateFilter do before :each do User.delete_all Quality.delete_all end it "should add method newest to all models" do ActiveRecord::Base.should respond_to(:newest) end it "should add method oldest to all models" do ActiveRecord::B...
require "rubygems" gem "geoutm" require "geoutm" # Requires a dataset in csv form of columns lon,lat in a given input file (arg 1) converted = [] file = File.open(ARGV[0], "r") lines = file.readlines file.close lines.each do |line| lon = line.split.first.to_f lat = line.split.last.to_f lonlat = GeoUtm::LatLon.ne...
# Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do factory :legacy_node do node_id { Random.number(40) } end end
require 'knife-table/helpers' module KnifeTable class TableServe < Chef::Knife include KnifeTable::Helpers deps do require 'git' require 'chef/knife/core/object_loader' end banner "knife table serve [#PULLREQ|COMMITSHA[..COMMITSHA]]" option :environments, :short => '-e ENV[,...
class BaseNotificationService attr_reader :resource def initialize(resource) @resource = resource end def subscribers resource.subscribed_users end def notify subscribers.each do |user| if check_service_allowed(user) user.send_message(resource, service: self) end end ...
require_relative '../error' module Nipap class Error # Raised when JSON parsing fails class DecodeError < Nipap::Error end end end
class Hangman MAX_TURNS = 25 attr_reader :guesser, :referee, :board def initialize(players) @guesser = players[:guesser] @referee = players[:referee] end def play setup turns = 0 until turns == MAX_TURNS || won? take_turn turns += 1 end endgame e...
class FontIosevkaSs02 < Formula version "18.0.0" sha256 "f2a58a336e61a856a2906805e8a9dce522462c595e8e74c82b8af3a190a00db0" url "https://github.com/be5invis/Iosevka/releases/download/v#{version}/ttc-iosevka-ss02-#{version}.zip" desc "Iosevka SS02" desc "Sans-serif, slab-serif, monospace and quasi‑proportional ...
class CreateDays < ActiveRecord::Migration[5.2] def change create_table :days do |t| # The null part makes it so I can't create an entry in the DB if it doesn't have an actual date in it t.datetime :date, null: false t.timestamps end end end
class CreateCalendarAdvs < ActiveRecord::Migration def self.up create_table :calendar_advs do |t| t.string :name t.string :logo t.integer :tp #1:blank url 2:app url 3:code t.text :code t.string :status, :default=>'online' t.integer :position t.timestamps end end ...
class PolygonClass < ActiveRecord::Base has_many :polygons end
class CreateEventManagers < ActiveRecord::Migration def change create_table :event_managers do |t| t.string :state t.integer :active_sprinkle_id t.string :host_with_port t.timestamps end end end
class CreateDeckfiles < ActiveRecord::Migration def change create_table :deckfiles do |t| t.string :disposition, default: "ingest" t.boolean :remove, default: false t.string :path t.integer :dataset_id t.timestamps null: false end end end
require 'rails_helper' describe 'User Pages' do subject { page } describe 'Sign Up' do before { visit signup_path } let(:submit) { 'Create my account!' } describe 'with invalid information' do it 'does not create a user' do expect { click_button submit }.not_to change(User, :count) ...
class RemoveStartdateFromDebatesAddPublicChallenge < ActiveRecord::Migration def change remove_column :debates, :start_date, :date add_column :debates, :public_challenge, :boolean, default:false end end
$:.push File.expand_path("../lib", __FILE__) # Maintain your gem's version: require "compartment/core/version" # Describe your gem and declare its dependencies: Gem::Specification.new do |s| s.name = "compartment_core" s.version = Compartment::Core::VERSION s.authors = ["Felipe Doria"] s.email ...
class RemoveReference < ActiveRecord::Migration[5.0] def change remove_reference :feedbacks, :customer, index: false end end
require "vimeo_id/version" require "vimeo_id/regex" module VimeoId def self.from url REGEX.match( url ) do |m| m[:id] end end end
# encoding: utf-8 $: << 'RspecTests/Generated/http_infrastructure' $: << 'RspecTests' require 'rspec' require 'generated/http_infrastructure.rb' require 'helper' module HttpInfrastructureModule include HttpInfrastructureModule::Models describe 'HttpInfrastructure' do before(:all) do @base_ur...
class CreateDividends < ActiveRecord::Migration[5.0] def change create_table :dividends do |t| t.date :pay_date t.string :stock_code t.string :stock_name t.float :pay_rate_mny t.integer :pay_quantity t.integer :pay_profit_mny t.timestamps end end end
require 'rails_helper' feature "As a registered user" do before(:each) do User.create(name: "Mimi Le", email: "mimi@rebook.com", password: "password") visit '/' click_on "Sign In" fill_in "user[email]", with: "mimi@rebook.com" fill_in "user[password]", with: "password" click_button "Sign...
class User include Mongoid::Document validates :email, presence: true validates :name, presence: true validates :last_name, presence: true validates :password, presence: true field :email, type: String field :name, type: String field :last_name, type: String field :password, type: ...
# frozen_string_literal: true # Copyright (c) 2018-2020 Yegor Bugayenko # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the 'Software'), to deal # in the Software without restriction, including without limitation the rights # to us...
require 'spec_helper' require "#{Rails.root.to_s}/lib/authentication" class AuthenticatedModel include Authentication end describe Authentication do before(:each) do @authentication_spec = AuthenticatedModel.new end it "should have access to the password attribute" do @authentication_spec.password...
require 'spec_helper' describe "Properties pages" do subject { page } describe "property page" do before { visit properties_path } it { should have_selector('h1', text: 'My Properties') } end describe "property page" do let(:property) { FactoryGirl.create(:property) } before { visit propert...
require 'json' require 'tmpdir' require 'socket' require 'logger' require 'uri' module Robe class Server attr_reader :running, :port REQUEST_TIMEOUT = 0.15 def initialize(handler, host, port) @handler = handler @server = TCPServer.new(host, port) @running = true @port = @server....
class Ledger < ApplicationRecord belongs_to :user validates_uniqueness_of :user_id, :message => "can only have one Ledger" has_many :credit_cards, dependent: :destroy validates :account_name, presence: true validates :user_id, presence: true end
class Njt::RulesController < ApplicationController def show @rule = Rule.where(game: "njt").find(params[:id]) end end
class CreateCourtRemindersJob < ApplicationJob include ActionView::RecordIdentifier queue_as :default def perform(csv_file, user) dates_content = Paperclip.io_adapters.for(csv_file.file).read locs_content = File.read(Rails.root.join('app', 'assets', 'config', 'court_locations.csv')) court_locs = CSV....
require 'uuid' class ScansHelper def self.get_metadata(scan) metadata = { "team" => "unknown-team", "program" => "unknown-program" } if scan.nil? Rails.logger.warn "error obtaining scan metadata for nil scan" return metadata end if scan[:program].blank? Rails.logger.w...
class NYT_Bestsellers_CLI include Gettable def call puts "Welcome to the New York Times Best Seller list, CLI Edition!".colorize(:red) puts "------------------------------------------------------------".colorize(:yellow) puts "This project uses data from the NYT Books API (https://developer.nytimes.com)...
class Category < ActiveRecord::Base # after_save { |category| Tag.new(name: category.name).save } attr_accessible :name has_many :categories_posts has_many :posts, through: :categories_posts validates :name, presence: true, uniqueness: { case_sensitive: false } end
class OrderAddress include ActiveModel::Model attr_accessor :user_id, :item_id, :postcode, :area_id, :cities, :number, :building, :telephone, :order_id, :card_token, :customer_token, :token with_options presence: true do validates :cities, :number, :token validates :postcode, format: {with:/\A\d{3}[-]\d{4}\z...
class Review < ApplicationRecord enum question1: { yes: 0, no: 1 } enum question3: { relaxed: 0, quick_paced: 1, stressful: 2, collaborative: 3, competitive: 4, slow_paced: 5, cut_throat: 6 } enum question4: { yes!: 0, no!: 1 } enum question5: { full_time: 0, part_time: 1, contract: 2, intern: 3, nothing: 4 } ...
require File.dirname( File.expand_path( __FILE__) ) + "/../../../shared_ruby/euler.rb" class Fract include Comparable attr_reader :num, :den def initialize(num, den) @num = num @den = den end def to_s "#{num}/#{den}" end def terms [@num, @den] end def +(other) this_fract = red...
module Helpers def split_tags_contains_tag_names(expected_tags, actual_tags) actual_tag_names = [] actual_tags.each do |tag| actual_tag_names.push(tag.name) end expected_tags.each do |tag| expect(actual_tag_names).to include tag end end end
class Brand < ActiveRecord::Base has_many :brands_stores # join table has_many :stores, through: :brands_stores # two-way many-to-many relatioinship validates :title, {:presence => true, :length => {:maximum => 25}} validates_uniqueness_of :title before_save :capitalize_title private def capitalize_title ...