repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
pay-rails/pay | https://github.com/pay-rails/pay/blob/98eb2a4f8556b111e551a7990522bb6a46be65f1/lib/pay/stripe/webhooks/checkout_session_async_payment_succeeded.rb | lib/pay/stripe/webhooks/checkout_session_async_payment_succeeded.rb | module Pay
module Stripe
module Webhooks
class CheckoutSessionAsyncPaymentSucceeded < CheckoutSessionCompleted
end
end
end
end
| ruby | MIT | 98eb2a4f8556b111e551a7990522bb6a46be65f1 | 2026-01-04T15:57:25.277088Z | false |
pay-rails/pay | https://github.com/pay-rails/pay/blob/98eb2a4f8556b111e551a7990522bb6a46be65f1/lib/pay/stripe/webhooks/payment_method_updated.rb | lib/pay/stripe/webhooks/payment_method_updated.rb | module Pay
module Stripe
module Webhooks
class PaymentMethodUpdated
def call(event)
object = event.data.object
if object.customer
Pay::Stripe::PaymentMethod.sync(object.id, stripe_account: event.try(:account))
else
# If customer was removed, we s... | ruby | MIT | 98eb2a4f8556b111e551a7990522bb6a46be65f1 | 2026-01-04T15:57:25.277088Z | false |
pay-rails/pay | https://github.com/pay-rails/pay/blob/98eb2a4f8556b111e551a7990522bb6a46be65f1/lib/pay/stripe/webhooks/checkout_session_completed.rb | lib/pay/stripe/webhooks/checkout_session_completed.rb | module Pay
module Stripe
module Webhooks
class CheckoutSessionCompleted
def call(event)
locate_owner(event.data.object)
# By the time CheckoutSessionCompleted is fired, we probably missed the original events
# Instead, we can sync the payment intent or subscription dur... | ruby | MIT | 98eb2a4f8556b111e551a7990522bb6a46be65f1 | 2026-01-04T15:57:25.277088Z | false |
pay-rails/pay | https://github.com/pay-rails/pay/blob/98eb2a4f8556b111e551a7990522bb6a46be65f1/lib/pay/stripe/webhooks/customer_deleted.rb | lib/pay/stripe/webhooks/customer_deleted.rb | module Pay
module Stripe
module Webhooks
class CustomerDeleted
def call(event)
object = event.data.object
pay_customer = Pay::Customer.find_by(processor: :stripe, processor_id: object.id)
# Skip processing if this customer is not in the database
return unless... | ruby | MIT | 98eb2a4f8556b111e551a7990522bb6a46be65f1 | 2026-01-04T15:57:25.277088Z | false |
pay-rails/pay | https://github.com/pay-rails/pay/blob/98eb2a4f8556b111e551a7990522bb6a46be65f1/lib/pay/stripe/webhooks/charge_refunded.rb | lib/pay/stripe/webhooks/charge_refunded.rb | module Pay
module Stripe
module Webhooks
class ChargeRefunded
def call(event)
pay_charge = Pay::Stripe::Charge.sync(event.data.object.id, stripe_account: event.try(:account))
if pay_charge && Pay.send_email?(:refund, pay_charge)
Pay.mailer.with(pay_customer: pay_char... | ruby | MIT | 98eb2a4f8556b111e551a7990522bb6a46be65f1 | 2026-01-04T15:57:25.277088Z | false |
pay-rails/pay | https://github.com/pay-rails/pay/blob/98eb2a4f8556b111e551a7990522bb6a46be65f1/lib/pay/stripe/webhooks/payment_action_required.rb | lib/pay/stripe/webhooks/payment_action_required.rb | module Pay
module Stripe
module Webhooks
class PaymentActionRequired
def call(event)
# Event is of type "invoice" see:
# https://stripe.com/docs/api/invoices/object
invoice = event.data.object
subscription_id = invoice.parent.try(:subscription_details).try(:s... | ruby | MIT | 98eb2a4f8556b111e551a7990522bb6a46be65f1 | 2026-01-04T15:57:25.277088Z | false |
pay-rails/pay | https://github.com/pay-rails/pay/blob/98eb2a4f8556b111e551a7990522bb6a46be65f1/lib/pay/stripe/webhooks/payment_failed.rb | lib/pay/stripe/webhooks/payment_failed.rb | module Pay
module Stripe
module Webhooks
class PaymentFailed
def call(event)
# Event is of type "invoice" see:
# https://stripe.com/docs/api/invoices/object
invoice = event.data.object
subscription_id = invoice.parent.try(:subscription_details).try(:subscript... | ruby | MIT | 98eb2a4f8556b111e551a7990522bb6a46be65f1 | 2026-01-04T15:57:25.277088Z | false |
pay-rails/pay | https://github.com/pay-rails/pay/blob/98eb2a4f8556b111e551a7990522bb6a46be65f1/lib/pay/stripe/webhooks/subscription_renewing.rb | lib/pay/stripe/webhooks/subscription_renewing.rb | module Pay
module Stripe
module Webhooks
class SubscriptionRenewing
# Handles `invoice.upcoming` webhook from Stripe
# Occurs X number of days before a subscription is scheduled to create an invoice that is automatically charged—where X is determined by your subscriptions settings. Note: The... | ruby | MIT | 98eb2a4f8556b111e551a7990522bb6a46be65f1 | 2026-01-04T15:57:25.277088Z | false |
pay-rails/pay | https://github.com/pay-rails/pay/blob/98eb2a4f8556b111e551a7990522bb6a46be65f1/lib/pay/stripe/webhooks/payment_method_attached.rb | lib/pay/stripe/webhooks/payment_method_attached.rb | module Pay
module Stripe
module Webhooks
class PaymentMethodAttached
def call(event)
object = event.data.object
Pay::Stripe::PaymentMethod.sync(object.id, stripe_account: event.try(:account))
end
end
end
end
end
| ruby | MIT | 98eb2a4f8556b111e551a7990522bb6a46be65f1 | 2026-01-04T15:57:25.277088Z | false |
pay-rails/pay | https://github.com/pay-rails/pay/blob/98eb2a4f8556b111e551a7990522bb6a46be65f1/lib/pay/stripe/webhooks/subscription_updated.rb | lib/pay/stripe/webhooks/subscription_updated.rb | module Pay
module Stripe
module Webhooks
class SubscriptionUpdated
def call(event)
Pay::Stripe::Subscription.sync(event.data.object.id, stripe_account: event.try(:account))
end
end
end
end
end
| ruby | MIT | 98eb2a4f8556b111e551a7990522bb6a46be65f1 | 2026-01-04T15:57:25.277088Z | false |
pay-rails/pay | https://github.com/pay-rails/pay/blob/98eb2a4f8556b111e551a7990522bb6a46be65f1/lib/pay/stripe/webhooks/subscription_trial_will_end.rb | lib/pay/stripe/webhooks/subscription_trial_will_end.rb | module Pay
module Stripe
module Webhooks
class SubscriptionTrialWillEnd
def call(event)
object = event.data.object
pay_subscription = Pay::Subscription.find_by_processor_and_id(:stripe, object.id)
return if pay_subscription.nil?
pay_subscription.sync!(stripe... | ruby | MIT | 98eb2a4f8556b111e551a7990522bb6a46be65f1 | 2026-01-04T15:57:25.277088Z | false |
pay-rails/pay | https://github.com/pay-rails/pay/blob/98eb2a4f8556b111e551a7990522bb6a46be65f1/lib/pay/stripe/webhooks/account_updated.rb | lib/pay/stripe/webhooks/account_updated.rb | module Pay
module Stripe
module Webhooks
class AccountUpdated
def call(event)
object = event.data.object
merchant = Pay::Merchant.find_by(processor: :stripe, processor_id: object.id)
return unless merchant
merchant.update(onboarding_complete: object.charges_... | ruby | MIT | 98eb2a4f8556b111e551a7990522bb6a46be65f1 | 2026-01-04T15:57:25.277088Z | false |
pay-rails/pay | https://github.com/pay-rails/pay/blob/98eb2a4f8556b111e551a7990522bb6a46be65f1/lib/pay/stripe/webhooks/charge_succeeded.rb | lib/pay/stripe/webhooks/charge_succeeded.rb | module Pay
module Stripe
module Webhooks
class ChargeSucceeded
def call(event)
pay_charge = Pay::Stripe::Charge.sync(event.data.object.id, stripe_account: event.try(:account))
if pay_charge && Pay.send_email?(:receipt, pay_charge)
Pay.mailer.with(pay_customer: pay_ch... | ruby | MIT | 98eb2a4f8556b111e551a7990522bb6a46be65f1 | 2026-01-04T15:57:25.277088Z | false |
pay-rails/pay | https://github.com/pay-rails/pay/blob/98eb2a4f8556b111e551a7990522bb6a46be65f1/lib/pay/stripe/webhooks/customer_updated.rb | lib/pay/stripe/webhooks/customer_updated.rb | module Pay
module Stripe
module Webhooks
class CustomerUpdated
def call(event)
object = event.data.object
pay_customer = Pay::Customer.find_by(processor: :stripe, processor_id: object.id)
# Couldn't find user, we can skip
return unless pay_customer.present?
... | ruby | MIT | 98eb2a4f8556b111e551a7990522bb6a46be65f1 | 2026-01-04T15:57:25.277088Z | false |
pay-rails/pay | https://github.com/pay-rails/pay/blob/98eb2a4f8556b111e551a7990522bb6a46be65f1/lib/pay/stripe/webhooks/payment_method_detached.rb | lib/pay/stripe/webhooks/payment_method_detached.rb | module Pay
module Stripe
module Webhooks
class PaymentMethodDetached
def call(event)
object = event.data.object
Pay::PaymentMethod.find_by_processor_and_id(:stripe, object.id)&.destroy
end
end
end
end
end
| ruby | MIT | 98eb2a4f8556b111e551a7990522bb6a46be65f1 | 2026-01-04T15:57:25.277088Z | false |
pay-rails/pay | https://github.com/pay-rails/pay/blob/98eb2a4f8556b111e551a7990522bb6a46be65f1/lib/pay/stripe/webhooks/charge_updated.rb | lib/pay/stripe/webhooks/charge_updated.rb | module Pay
module Stripe
module Webhooks
class ChargeUpdated
def call(event)
Pay::Stripe::Charge.sync(event.data.object.id, stripe_account: event.try(:account))
end
end
end
end
end
| ruby | MIT | 98eb2a4f8556b111e551a7990522bb6a46be65f1 | 2026-01-04T15:57:25.277088Z | false |
pay-rails/pay | https://github.com/pay-rails/pay/blob/98eb2a4f8556b111e551a7990522bb6a46be65f1/lib/pay/webhooks/delegator.rb | lib/pay/webhooks/delegator.rb | module Pay
module Webhooks
class Delegator
attr_reader :backend
def initialize
@backend = ActiveSupport::Notifications
end
# Configure DSL
def configure(&block)
raise ArgumentError, "must provide a block" unless block
block.arity.zero? ? instance_eval(&block... | ruby | MIT | 98eb2a4f8556b111e551a7990522bb6a46be65f1 | 2026-01-04T15:57:25.277088Z | false |
pay-rails/pay | https://github.com/pay-rails/pay/blob/98eb2a4f8556b111e551a7990522bb6a46be65f1/lib/pay/webhooks/process_job.rb | lib/pay/webhooks/process_job.rb | module Pay
module Webhooks
class ProcessJob < ApplicationJob
def perform(pay_webhook)
pay_webhook.process!
end
end
end
end
| ruby | MIT | 98eb2a4f8556b111e551a7990522bb6a46be65f1 | 2026-01-04T15:57:25.277088Z | false |
pay-rails/pay | https://github.com/pay-rails/pay/blob/98eb2a4f8556b111e551a7990522bb6a46be65f1/lib/pay/paddle_billing/webhooks/subscription.rb | lib/pay/paddle_billing/webhooks/subscription.rb | module Pay
module PaddleBilling
module Webhooks
class Subscription
def call(event)
Pay::PaddleBilling::Subscription.sync(event.id, object: event)
end
end
end
end
end
| ruby | MIT | 98eb2a4f8556b111e551a7990522bb6a46be65f1 | 2026-01-04T15:57:25.277088Z | false |
pay-rails/pay | https://github.com/pay-rails/pay/blob/98eb2a4f8556b111e551a7990522bb6a46be65f1/lib/pay/paddle_billing/webhooks/transaction_completed.rb | lib/pay/paddle_billing/webhooks/transaction_completed.rb | module Pay
module PaddleBilling
module Webhooks
class TransactionCompleted
def call(event)
Pay::PaddleBilling::Charge.sync(event.id)
end
end
end
end
end
| ruby | MIT | 98eb2a4f8556b111e551a7990522bb6a46be65f1 | 2026-01-04T15:57:25.277088Z | false |
pay-rails/pay | https://github.com/pay-rails/pay/blob/98eb2a4f8556b111e551a7990522bb6a46be65f1/lib/pay/paddle_classic/webhooks/subscription_created.rb | lib/pay/paddle_classic/webhooks/subscription_created.rb | module Pay
module PaddleClassic
module Webhooks
class SubscriptionCreated
def call(event)
Pay::PaddleClassic::Subscription.sync(event.subscription_id, object: event)
end
end
end
end
end
| ruby | MIT | 98eb2a4f8556b111e551a7990522bb6a46be65f1 | 2026-01-04T15:57:25.277088Z | false |
pay-rails/pay | https://github.com/pay-rails/pay/blob/98eb2a4f8556b111e551a7990522bb6a46be65f1/lib/pay/paddle_classic/webhooks/subscription_payment_refunded.rb | lib/pay/paddle_classic/webhooks/subscription_payment_refunded.rb | module Pay
module PaddleClassic
module Webhooks
class SubscriptionPaymentRefunded
def call(event)
pay_charge = Pay::Charge.find_by_processor_and_id(:paddle_classic, event.subscription_payment_id)
return unless pay_charge.present?
pay_charge.update!(amount_refunded: (ev... | ruby | MIT | 98eb2a4f8556b111e551a7990522bb6a46be65f1 | 2026-01-04T15:57:25.277088Z | false |
pay-rails/pay | https://github.com/pay-rails/pay/blob/98eb2a4f8556b111e551a7990522bb6a46be65f1/lib/pay/paddle_classic/webhooks/subscription_payment_succeeded.rb | lib/pay/paddle_classic/webhooks/subscription_payment_succeeded.rb | module Pay
module PaddleClassic
module Webhooks
class SubscriptionPaymentSucceeded
def call(event)
pay_customer = Pay::Customer.find_by(processor: :paddle_classic, processor_id: event.user_id)
if pay_customer.nil?
owner = Pay::PaddleClassic.owner_from_passthrough(eve... | ruby | MIT | 98eb2a4f8556b111e551a7990522bb6a46be65f1 | 2026-01-04T15:57:25.277088Z | false |
pay-rails/pay | https://github.com/pay-rails/pay/blob/98eb2a4f8556b111e551a7990522bb6a46be65f1/lib/pay/paddle_classic/webhooks/subscription_updated.rb | lib/pay/paddle_classic/webhooks/subscription_updated.rb | module Pay
module PaddleClassic
module Webhooks
class SubscriptionUpdated
def call(event)
pay_subscription = Pay::Subscription.find_by_processor_and_id(:paddle_classic, event["subscription_id"])
return if pay_subscription.nil?
case event["status"]
when "dele... | ruby | MIT | 98eb2a4f8556b111e551a7990522bb6a46be65f1 | 2026-01-04T15:57:25.277088Z | false |
pay-rails/pay | https://github.com/pay-rails/pay/blob/98eb2a4f8556b111e551a7990522bb6a46be65f1/lib/pay/paddle_classic/webhooks/signature_verifier.rb | lib/pay/paddle_classic/webhooks/signature_verifier.rb | require "base64"
require "json"
require "openssl"
module Pay
module PaddleClassic
module Webhooks
class SignatureVerifier
def initialize(data)
@data = data
@public_key_file = Pay::PaddleClassic.public_key_file
@public_key = Pay::PaddleClassic.public_key
@publ... | ruby | MIT | 98eb2a4f8556b111e551a7990522bb6a46be65f1 | 2026-01-04T15:57:25.277088Z | false |
pay-rails/pay | https://github.com/pay-rails/pay/blob/98eb2a4f8556b111e551a7990522bb6a46be65f1/lib/pay/paddle_classic/webhooks/subscription_cancelled.rb | lib/pay/paddle_classic/webhooks/subscription_cancelled.rb | module Pay
module PaddleClassic
module Webhooks
class SubscriptionCancelled
def call(event)
pay_subscription = Pay::Subscription.find_by_processor_and_id(:paddle_classic, event.subscription_id)
# We couldn't find the subscription for some reason, maybe it's from another service
... | ruby | MIT | 98eb2a4f8556b111e551a7990522bb6a46be65f1 | 2026-01-04T15:57:25.277088Z | false |
pay-rails/pay | https://github.com/pay-rails/pay/blob/98eb2a4f8556b111e551a7990522bb6a46be65f1/lib/generators/pay/email_views_generator.rb | lib/generators/pay/email_views_generator.rb | require "rails/generators"
module Pay
module Generators
class EmailViewsGenerator < Rails::Generators::Base
source_root File.expand_path("../../../..", __FILE__)
def copy_views
directory "app/views/pay/user_mailer", "app/views/pay/user_mailer"
end
end
end
end
| ruby | MIT | 98eb2a4f8556b111e551a7990522bb6a46be65f1 | 2026-01-04T15:57:25.277088Z | false |
pay-rails/pay | https://github.com/pay-rails/pay/blob/98eb2a4f8556b111e551a7990522bb6a46be65f1/lib/generators/pay/views_generator.rb | lib/generators/pay/views_generator.rb | require "rails/generators"
module Pay
module Generators
class ViewsGenerator < Rails::Generators::Base
source_root File.expand_path("../../../..", __FILE__)
def copy_views
directory "app/views/pay", "app/views/pay"
end
end
end
end
| ruby | MIT | 98eb2a4f8556b111e551a7990522bb6a46be65f1 | 2026-01-04T15:57:25.277088Z | false |
pay-rails/pay | https://github.com/pay-rails/pay/blob/98eb2a4f8556b111e551a7990522bb6a46be65f1/config/routes.rb | config/routes.rb | # frozen_string_literal: true
Pay::Engine.routes.draw do
resources :payments, only: [:show], module: :pay
post "webhooks/stripe", to: "pay/webhooks/stripe#create" if Pay::Stripe.enabled?
post "webhooks/braintree", to: "pay/webhooks/braintree#create" if Pay::Braintree.enabled?
post "webhooks/paddle_billing", to... | ruby | MIT | 98eb2a4f8556b111e551a7990522bb6a46be65f1 | 2026-01-04T15:57:25.277088Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/app/jobs/headline_scraper_job.rb | app/jobs/headline_scraper_job.rb | require 'open-uri'
class HeadlineScraperJob < ActiveJob::Base
queue_as :default
def perform(url:, recipient:)
headlines = []
page = Nokogiri::HTML(open(url))
headlines = page.css("section h1").map(&:text)
NewsMailer.send_headlines(headlines: headlines, to: recipient)
end
end
| ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/app/helpers/application_helper.rb | app/helpers/application_helper.rb | module ApplicationHelper
attr_writer :page_title
def page_title
@page_title ||= "RSpec Rails Examples"
end
end
| ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/app/controllers/subscriptions_controller.rb | app/controllers/subscriptions_controller.rb | class SubscriptionsController < ApplicationController
def new
@subscription = Subscription.new
end
def create
Subscription.create_and_request_confirmation(subscription_params)
redirect_to pending_subscriptions_path
end
def pending
end
def confirm
confirmation_token = params.require(:co... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/app/controllers/pages_controller.rb | app/controllers/pages_controller.rb | class PagesController < ApplicationController
end
| ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/app/controllers/application_controller.rb | app/controllers/application_controller.rb | 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
end
| ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/app/controllers/api/api_controller.rb | app/controllers/api/api_controller.rb | class Api::ApiController < ActionController::Base
protect_from_forgery with: :null_session
def self.disable_turbolinks_cookies
skip_before_action :set_request_method_cookie
end
disable_turbolinks_cookies
end
| ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/app/controllers/api/v1/access_tokens_controller.rb | app/controllers/api/v1/access_tokens_controller.rb | class Api::V1::AccessTokensController < Api::ApiController
def create
respond_to_json do
render json: { access_token: token_guardian.issue_token }, status: :created
end
end
private
def respond_to_json
assert_request_content_type Mime::JSON
respond_to { |format| format.json { yield } }
... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/app/models/subscription.rb | app/models/subscription.rb | class Subscription < ActiveRecord::Base
validates :email, uniqueness: true, presence: true
validates :confirmation_token, uniqueness: true, presence: true
validates_presence_of :start_on
scope :confirmation_overdue, -> { where("created_at < ?", 3.days.ago).where(confirmed: false) }
after_initialize :init_s... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/app/models/token_guardian.rb | app/models/token_guardian.rb | class TokenGuardian
attr_reader :encryptor, :params
def self.build(controller:)
# Borrow MessageEncryptor, thank you CookieJar.
encryptor = controller.request.cookie_jar.encrypted.instance_variable_get :@encryptor
TokenGuardian.new(encryptor: encryptor, params: controller.params)
end
def initiali... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/app/models/access_token.rb | app/models/access_token.rb | class AccessToken < ActiveRecord::Base
include HardenedToken
hardened_token
belongs_to :user
end
| ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/app/models/user.rb | app/models/user.rb | class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:confirmable, :lockable
has_many :access_to... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/app/models/concerns/hardened_token.rb | app/models/concerns/hardened_token.rb | module HardenedToken
extend ActiveSupport::Concern
LOCATOR_LENGTH = { bytes: 48.freeze, chars: 64.freeze }.freeze
SECRET_LENGTH = { bytes: 192.freeze, chars: 256.freeze }.freeze
def unencrypted
"#{locator}:#{secret}"
end
class_methods do
def hardened_token
attr_encrypted :secret, random_iv... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/app/mailers/application_mailer.rb | app/mailers/application_mailer.rb | class ApplicationMailer < ActionMailer::Base
layout 'mailer'
end
| ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/app/mailers/news_mailer.rb | app/mailers/news_mailer.rb | class NewsMailer < ApplicationMailer
def self.send_headlines(headlines:, to:)
headlines(headlines: headlines, to: to).deliver_now!
end
def headlines(headlines:, to:)
@headlines = headlines
mail to: to,
subject: headlines.blank? ? "No Headlines Today :-(" : "Today's Headlines"
end
end
| ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/app/mailers/subscription_mailer.rb | app/mailers/subscription_mailer.rb | class SubscriptionMailer < ApplicationMailer
def self.send_confirmation_request!(subscription)
confirmation_request(subscription).deliver_now!
end
def confirmation_request(subscription)
@subscription = subscription
mail to: subscription.email, subject: "Please confirm"
end
end
| ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/db/seeds.rb | db/seeds.rb | # 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... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/db/schema.rb | db/schema.rb | # encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative sou... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/db/migrate/20151024100339_create_access_tokens.rb | db/migrate/20151024100339_create_access_tokens.rb | class CreateAccessTokens < ActiveRecord::Migration
def change
create_table :access_tokens do |t|
t.string :locator, index: {unique: true}, null: false
t.text :encrypted_secret, null: false
t.belongs_to :user, index: true, foreign_key: true
t.timestamps null: false
end
end
end
| ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/db/migrate/20141221124118_devise_create_users.rb | db/migrate/20141221124118_devise_create_users.rb | class DeviseCreateUsers < ActiveRecord::Migration
def change
create_table(:users) do |t|
## Database authenticatable
t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""
## Recoverable
t.string :reset_password_token
t.... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/db/migrate/20150321163642_add_start_on_to_subscription.rb | db/migrate/20150321163642_add_start_on_to_subscription.rb | class AddStartOnToSubscription < ActiveRecord::Migration
def change
add_column :subscriptions, :start_on, :date
end
end
| ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/db/migrate/20141211174244_create_subscriptions.rb | db/migrate/20141211174244_create_subscriptions.rb | class CreateSubscriptions < ActiveRecord::Migration
def change
create_table :subscriptions do |t|
t.string :email, limit: 100, null: false
t.string :confirmation_token, limit: 100, null: false
t.boolean :confirmed, default: false, null: false
t.timestamps null: false
end
add_index... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/rails_helper.rb | spec/rails_helper.rb | # This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require 'spec_helper'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
# DO NOT Add additional requires below this line. Rails is not loaded until this point!
# INSTEAD...put requi... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/spec_helper.rb | spec/spec_helper.rb | # This file was generated by the `rails generate rspec:install` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause this
# file to always be loaded, without a need to explicitly require ... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/tasks/subscription_tasks_spec.rb | spec/tasks/subscription_tasks_spec.rb | require 'rails_helper'
# IMPORTANT: Add spec/support/tasks.rb to your project to load rake tasks.
RSpec.describe "Subscription tasks", :type => :task do
context "subscription:confirmation_overdue:delete" do
before do
# Freeze time as task is time-sensitive
travel_to Time.now
end
after { t... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/jobs/headline_scraper_job_spec.rb | spec/jobs/headline_scraper_job_spec.rb | require 'rails_helper'
RSpec.describe HeadlineScraperJob, :type => :job do
it "emails headlines scraped from given URL" do
url_to_scrape = "https://eliotsykes.github.io/rspec-rails-examples/"
recipient_email = "anchor@nightlynews.tld"
assert_performed_with(
job: HeadlineScraperJob,
a... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/support/job_helpers.rb | spec/support/job_helpers.rb | # Use Rails-provided test helper methods:
# 0. Check spec/support dir is auto-required in spec/rails_helper.rb.
#
# 1. Create a file like this one you're reading in spec/support/job_helpers.rb:
RSpec.configure do |config|
config.include ActiveJob::TestHelper, type: :job
end
# Suggested docs
# --------------
# http:... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/support/matchers.rb | spec/support/matchers.rb | # Setting up Custom Matchers:
# 0. Check spec/support dir is auto-required in spec/rails_helper.rb.
#
# 1. Create a file like this one you're reading in spec/support/matchers.rb:
Dir[Rails.root.join("spec/matchers/**/*.rb")].each { |f| require f }
RSpec.configure do |config|
config.include Matchers
end
# 2. Write... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/support/capybara.rb | spec/support/capybara.rb | # Installing Capybara:
# 0. Check spec/support dir is auto-required in spec/rails_helper.rb.
#
# 1. Add these to your Gemfile:
#
# group :development, :test do
# gem 'capybara'
# gem 'selenium-webdriver' # For Firefox
# # gem 'chromedriver-helper' # Install to use Chrome in feature specs
# end
#
# 2. Create a file ... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/support/vcr.rb | spec/support/vcr.rb | # Installing VCR:
# 0. Check spec/support dir is auto-required in spec/rails_helper.rb.
#
# 1. Add vcr and webmock gems to Gemfile:
#
# group :test do
# gem 'vcr'
# gem 'webmock'
# end
# 2. Create a file like this one you're reading in spec/support/vcr.rb
VCR.configure do |config|
config.cassette_library_dir = ... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/support/email_spec.rb | spec/support/email_spec.rb | # Installing email_spec:
# 0. Check spec/support dir is auto-required in spec/rails_helper.rb.
#
# 1. Add email_spec to Gemfile:
#
# group :test do
# gem 'email_spec'
# end
# 2. Create a file like this one you're reading in spec/support/email_spec.rb:
require 'email_spec'
RSpec.configure do |config|
config.inclu... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/support/capybara_driver_resolver.rb | spec/support/capybara_driver_resolver.rb | # 0. Check spec/support dir is auto-required in spec/rails_helper.rb.
#
# You probably don't need this config, its for setting up Capybara drivers
# with descriptive names related to the underlying browser's HTML5 support.
module CapybaraDriverResolver
FIREFOX_DRIVERS = [:selenium_billy, :selenium]
CHROME_DRIVER... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/support/json_helper.rb | spec/support/json_helper.rb | module JsonHelper
def json
(reparse_and_never_memoize_as_response_may_change = -> do
JSON.parse(response.body, symbolize_names: true)
end).call
end
def json_request_headers
{ 'Content-Type' => 'application/json', 'Accept' => 'application/json' }
end
end
RSpec.configure do |config|
config.i... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/support/database_cleaner.rb | spec/support/database_cleaner.rb | # Installing database_cleaner:
# 0. Check spec/support dir is auto-required in spec/rails_helper.rb.
#
# 1. Add database_cleaner to Gemfile:
#
# group :test do
# gem 'database_cleaner'
# end
# 2. IMPORTANT! Delete the "config.use_transactional_fixtures = ..." line
# in spec/rails_helper.rb (we're going to confi... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/support/factory_girl.rb | spec/support/factory_girl.rb | # Installing factory_girl:
# 0. Check spec/support dir is auto-required in spec/rails_helper.rb.
#
# 1. Add factory_girl_rails to Gemfile:
#
# group :development, :test do
# gem 'factory_girl_rails', '~> 4.5'
# end
# 2. Create a file like this one you're reading in spec/support/factory_girl.rb:
RSpec.configure do |c... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/support/shoulda_matchers.rb | spec/support/shoulda_matchers.rb | # Installing shoulda-matchers:
# 0. Check spec/support dir is auto-required in spec/rails_helper.rb.
#
# 1. Add shoulda-matchers to Gemfile:
#
# group :test do
# gem 'shoulda-matchers', '3.0.0.rc1'
# end
#
# 2. Create a file like this one you're reading in spec/support/shoulda_matchers.rb:
Shoulda::Matchers.configur... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/support/tasks.rb | spec/support/tasks.rb | # How to test Rake tasks:
# 0. Check spec/support dir is auto-required in spec/rails_helper.rb.
#
# 1. Create a file like this one you're reading in spec/support/tasks.rb:
require "rake"
RSpec.configure do |config|
config.before(:suite) do
Rails.application.load_tasks
end
end
| ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/support/time_helpers.rb | spec/support/time_helpers.rb | # Use Rails-provided test helper methods instead of Timecop:
# 0. Check spec/support dir is auto-required in spec/rails_helper.rb.
#
# 1. Create a file like this one you're reading in spec/support/time_helpers.rb:
RSpec.configure do |config|
config.include ActiveSupport::Testing::TimeHelpers
end
# Suggested docs
# ... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/support/puffing_billy.rb | spec/support/puffing_billy.rb | # Installing Puffing Billy:
# 0. Check spec/support dir is auto-required in spec/rails_helper.rb.
#
# 1. Puffing Billy depends on Capybara. Install Capybara as explained
# in spec/support/capybara.rb
#
# 2. Add puffing-billy to Gemfile:
#
# group :development, :test do
# gem 'puffing-billy'
# end
#
# 3. Create ... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/support/error_responses.rb | spec/support/error_responses.rb | module ErrorResponses
# See: https://github.com/rails/rails/pull/11289#issuecomment-118612393
def respond_without_detailed_exceptions
env_config = Rails.application.env_config
original_show_exceptions = env_config["action_dispatch.show_exceptions"]
original_show_detailed_exceptions = env_config["action... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/routing/subscriptions_routing_spec.rb | spec/routing/subscriptions_routing_spec.rb | require "rails_helper"
RSpec.describe "routes for Subscriptions", :type => :routing do
context "confirm_subscription route" do
it "should use the confirmation token as the identifier" do
subscription = Subscription.new(confirmation_token: "im-a-token-98765")
expect(:get => confirm_subscription_pa... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/helpers/application_helper_spec.rb | spec/helpers/application_helper_spec.rb | require 'rails_helper'
RSpec.describe ApplicationHelper, :type => :helper do
context "page_title attribute" do
it "has getter and setter" do
helper.page_title = "About Page Title"
expect(helper.page_title).to eq("About Page Title")
end
it "has sensible default" do
expect(helper... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/factories/users.rb | spec/factories/users.rb | FactoryGirl.define do
factory :user do
transient do
skip_confirmation true
end
sequence(:email) { |n| "user#{n}@example.tld" }
password "test password"
before(:create) do |user, evaluator|
user.skip_confirmation! if evaluator.skip_confirmation
end
end
end
| ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/factories/subscriptions.rb | spec/factories/subscriptions.rb | FactoryGirl.define do
factory :subscription do
sequence(:email) { |n| "subscriber#{n}@test.tld" }
confirmation_token { Subscription.generate_confirmation_token }
confirmed false
end
end
| ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/controllers/subscriptions_controller_spec.rb | spec/controllers/subscriptions_controller_spec.rb | require 'rails_helper'
RSpec.describe SubscriptionsController, :type => :controller do
context "GET new" do
it "assigns a blank subscription to the view" do
get :new
expect(assigns(:subscription)).to be_a_new(Subscription)
end
end
context "POST create" do
it "redirects to pending sub... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/models/subscription_spec.rb | spec/models/subscription_spec.rb | require 'rails_helper'
RSpec.describe Subscription, :type => :model do
context "db" do
context "indexes" do
it { should have_db_index(:email).unique(true) }
it { should have_db_index(:confirmation_token).unique(true) }
end
context "columns" do
it { should have_db_column(:email).of_typ... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/models/access_token_spec.rb | spec/models/access_token_spec.rb | require 'rails_helper'
describe AccessToken do
context '.create!' do
it 'generates locator and secret' do
access_token = AccessToken.create!
expect(access_token.locator).to match /\A[a-zA-Z0-9_-]{64}\z/
expect(access_token.secret).to match /\A[a-zA-Z0-9_-]{256}\z/
end
end
context '#un... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/models/user_spec.rb | spec/models/user_spec.rb | require 'rails_helper'
describe User do
context 'validations' do
it { should validate_presence_of :email }
it { should validate_presence_of :password }
it { should validate_confirmation_of :password }
it { should validate_uniqueness_of(:email).case_insensitive }
end
context 'associations' do
... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/api/v1/token_spec.rb | spec/api/v1/token_spec.rb | require 'rails_helper'
describe '/api/v1/token' do
context 'POST' do
context 'with correct credentials' do
it 'issues opaque (via encryption) and tamper-resistant (via signing) access token' do
user = create(:user)
parameters = { user: { email: user.email, password: user.password } }.to_... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/features/user_registers_spec.rb | spec/features/user_registers_spec.rb | require 'rails_helper'
feature "User registers" do
scenario "with valid details" do
visit "/"
click_link "Sign up"
expect(current_path).to eq(new_user_registration_path)
fill_in "Email", with: "tester@example.tld"
fill_in "Password", with: "test-password"
fill_in "Password confirmation", ... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/features/home_page_spec.rb | spec/features/home_page_spec.rb | require 'rails_helper'
feature "Home page" do
scenario "visit" do
visit "/"
expect(page).to have_title "Welcome to RSpec Rails Examples"
expect(page).to have_css "h1", text: "Welcome"
end
end
| ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/features/user_login_and_logout_spec.rb | spec/features/user_login_and_logout_spec.rb | require 'rails_helper'
feature "User logs in and logs out" do
# `js: true` spec metadata means this will run using the `:selenium`
# browser driver configured in spec/support/capybara.rb
scenario "with correct details", js: true do
create(:user, email: "someone@example.tld", password: "somepassword")
... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/features/share_page_spec.rb | spec/features/share_page_spec.rb | require 'rails_helper'
feature "Share page", js: true do
scenario "displays 3rd party widgets" do
visit "/share"
expect(page).to have_title "Share Our Stuff!"
expect(page).to have_css "h1", text: "Share Our Stuff!"
# This is the 3rd party widget
expect(page).to have_css "button", text: "Share t... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/features/subscribe_to_newsletter_spec.rb | spec/features/subscribe_to_newsletter_spec.rb | require 'rails_helper'
feature "Subscribe to newsletter" do
context "in browser with native date input", driver: driver_with(native_date_input: true) do
scenario "subscribes user to newsletter" do
visit_new_subscription
fill_in "Email", with: "buddy@example.tld"
fill_in "Start date", with: ... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/matchers/be_confirm_subscription_page.rb | spec/matchers/be_confirm_subscription_page.rb | module Matchers
def be_confirm_subscription_page(expected_subscription)
BeConfirmSubscriptionPage.new(expected_subscription)
end
class BeConfirmSubscriptionPage
include ::Rails.application.routes.url_helpers
attr_accessor :failure_message
def initialize(expected_subscription)
@expected_s... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/matchers/have_error_messages.rb | spec/matchers/have_error_messages.rb | module Matchers
def have_error_messages(*args)
HaveErrorMessages.new(*args)
end
# have_error_message can also be called for clarity
# when there is only one error message expected.
alias have_error_message have_error_messages
class HaveErrorMessages
attr_accessor :failure_message
def initia... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/matchers/be_pending_subscription_page.rb | spec/matchers/be_pending_subscription_page.rb | # It's important that the matcher is in a module and the module
# has an instance method that will be available to the specs.
# The module name here will need to match the module name
# in the configuration specified in spec/support/matchers.rb
module Matchers
# This instance method is what will be called in the spe... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/mailers/subscription_mailer_spec.rb | spec/mailers/subscription_mailer_spec.rb | require "rails_helper"
RSpec.describe SubscriptionMailer, :type => :mailer do
describe ".send_confirmation_request!(subscription)" do
before do
@subscription = Subscription.create!(
email: "subscriber@foo.tld",
confirmation_token: "this-is-a-confirmation-token"
)
end
it "ca... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/spec/mailers/news_mailer_spec.rb | spec/mailers/news_mailer_spec.rb | require "rails_helper"
RSpec.describe NewsMailer, :type => :mailer do
describe ".send_headlines(headlines:, to:)" do
it "has expected subject when there are headlines" do
mail = NewsMailer.send_headlines(
headlines: ["Scaremongering Headline: Be Fearful!"],
to: "newsguy@goodnews.tld... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/config/application.rb | config/application.rb | require File.expand_path('../boot', __FILE__)
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "sprockets/railtie"
# requi... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/config/environment.rb | config/environment.rb | # Load the Rails application.
require File.expand_path('../application', __FILE__)
# Initialize the Rails application.
Rails.application.initialize!
| ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/config/routes.rb | config/routes.rb | Rails.application.routes.draw do
root to: "pages#index"
get "share" => "pages#share"
devise_for :users, only: [:registrations, :sessions, :confirmations, :unlocks, :passwords]
resources :subscriptions, only: [:new, :create] do
get :pending, on: :collection
end
get "subscriptions/:confirmation_token/... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/config/boot.rb | config/boot.rb | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' # Set up gems listed in the Gemfile.
| ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/config/initializers/filter_parameter_logging.rb | config/initializers/filter_parameter_logging.rb | # Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file.
Rails.application.config.filter_parameters += [:password]
| ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/config/initializers/session_store.rb | config/initializers/session_store.rb | # Be sure to restart your server when you modify this file.
Rails.application.config.session_store :cookie_store, key: '_rspec-rails-examples_session'
| ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/config/initializers/devise.rb | config/initializers/devise.rb | # Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
Devise.setup do |config|
# The secret key used by Devise. Devise uses this key to generate
# random tokens. Changing this key will render invalid all existing
# confirmat... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/config/initializers/rescue_responses.rb | config/initializers/rescue_responses.rb | class UnauthorizedAccess < ActionController::ActionControllerError
end
class UnsupportedMediaType < ActionController::ActionControllerError
end
ActionDispatch::ExceptionWrapper.rescue_responses.merge!(
'UnauthorizedAccess' => :unauthorized,
'UnsupportedMediaType' => :unsupported_media_type
)
| ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/config/initializers/wrap_parameters.rb | config/initializers/wrap_parameters.rb | # Be sure to restart your server when you modify this file.
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters f... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/config/initializers/inflections.rb | config/initializers/inflections.rb | # Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflector.inflections(:en) do |inflec... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/config/initializers/cookies_serializer.rb | config/initializers/cookies_serializer.rb | # Be sure to restart your server when you modify this file.
Rails.application.config.action_dispatch.cookies_serializer = :json
| ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/config/initializers/assets.rb | config/initializers/assets.rb | # Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path
# Rails.application.config.assets.paths << Emoji.images_path
# Precompile additional ... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
eliotsykes/rspec-rails-examples | https://github.com/eliotsykes/rspec-rails-examples/blob/f6ba3d6f6f95e9430c3207d0d21e672de4a98359/config/initializers/backtrace_silencers.rb | config/initializers/backtrace_silencers.rb | # Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a probl... | ruby | MIT | f6ba3d6f6f95e9430c3207d0d21e672de4a98359 | 2026-01-04T15:57:41.510156Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.