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 |
|---|---|---|---|---|---|---|---|---|
varvet/pundit | https://github.com/varvet/pundit/blob/3488802b2f218ba26562e91186655297c95eb6da/spec/support/models/artificial_blog.rb | spec/support/models/artificial_blog.rb | # frozen_string_literal: true
class ArtificialBlog < Blog
def self.policy_class
BlogPolicy
end
end
| ruby | MIT | 3488802b2f218ba26562e91186655297c95eb6da | 2026-01-04T15:38:58.048292Z | false |
varvet/pundit | https://github.com/varvet/pundit/blob/3488802b2f218ba26562e91186655297c95eb6da/spec/support/models/customer/post.rb | spec/support/models/customer/post.rb | # frozen_string_literal: true
module Customer
class Post < ::Post
extend ActiveModel::Naming
def self.policy_class
PostPolicy
end
end
end
| ruby | MIT | 3488802b2f218ba26562e91186655297c95eb6da | 2026-01-04T15:38:58.048292Z | false |
varvet/pundit | https://github.com/varvet/pundit/blob/3488802b2f218ba26562e91186655297c95eb6da/spec/support/models/project_one_two_three/avatar_four_five_six.rb | spec/support/models/project_one_two_three/avatar_four_five_six.rb | # frozen_string_literal: true
module ProjectOneTwoThree
class AvatarFourFiveSix
extend ActiveModel::Naming
end
end
| ruby | MIT | 3488802b2f218ba26562e91186655297c95eb6da | 2026-01-04T15:38:58.048292Z | false |
varvet/pundit | https://github.com/varvet/pundit/blob/3488802b2f218ba26562e91186655297c95eb6da/spec/support/models/project_one_two_three/tag_four_five_six.rb | spec/support/models/project_one_two_three/tag_four_five_six.rb | # frozen_string_literal: true
module ProjectOneTwoThree
class TagFourFiveSix
def initialize(user)
@user = user
end
attr_reader(:user)
end
end
| ruby | MIT | 3488802b2f218ba26562e91186655297c95eb6da | 2026-01-04T15:38:58.048292Z | false |
varvet/pundit | https://github.com/varvet/pundit/blob/3488802b2f218ba26562e91186655297c95eb6da/spec/support/lib/custom_cache.rb | spec/support/lib/custom_cache.rb | # frozen_string_literal: true
class CustomCache
def initialize
@store = {}
end
def to_h
@store
end
def [](key)
@store[key]
end
def []=(key, value)
@store[key] = value
end
end
| ruby | MIT | 3488802b2f218ba26562e91186655297c95eb6da | 2026-01-04T15:38:58.048292Z | false |
varvet/pundit | https://github.com/varvet/pundit/blob/3488802b2f218ba26562e91186655297c95eb6da/spec/support/lib/instance_tracking.rb | spec/support/lib/instance_tracking.rb | # frozen_string_literal: true
module InstanceTracking
module ClassMethods
def instances
@instances || 0
end
attr_writer :instances
end
def self.prepended(other)
other.extend(ClassMethods)
end
def initialize(*args, **kwargs, &block)
self.class.instances += 1
super(*args, **kwa... | ruby | MIT | 3488802b2f218ba26562e91186655297c95eb6da | 2026-01-04T15:38:58.048292Z | false |
varvet/pundit | https://github.com/varvet/pundit/blob/3488802b2f218ba26562e91186655297c95eb6da/spec/support/lib/controller.rb | spec/support/lib/controller.rb | # frozen_string_literal: true
class Controller
attr_accessor :current_user
attr_reader :action_name, :params
class View
def initialize(controller)
@controller = controller
end
attr_reader :controller
end
class << self
def helper(mod)
View.include(mod)
end
def helper_me... | ruby | MIT | 3488802b2f218ba26562e91186655297c95eb6da | 2026-01-04T15:38:58.048292Z | false |
varvet/pundit | https://github.com/varvet/pundit/blob/3488802b2f218ba26562e91186655297c95eb6da/spec/policies/post_policy_spec.rb | spec/policies/post_policy_spec.rb | # frozen_string_literal: true
require "spec_helper"
RSpec.describe PostPolicy do
let(:user) { double }
let(:own_post) { double(user: user) }
let(:other_post) { double(user: double) }
subject { described_class }
permissions :update?, :show? do
it "is successful when all permissions match" do
shoul... | ruby | MIT | 3488802b2f218ba26562e91186655297c95eb6da | 2026-01-04T15:38:58.048292Z | false |
varvet/pundit | https://github.com/varvet/pundit/blob/3488802b2f218ba26562e91186655297c95eb6da/spec/pundit/helper_spec.rb | spec/pundit/helper_spec.rb | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Pundit::Helper do
let(:user) { double }
let(:controller) { Controller.new(user, "update", double) }
let(:view) { Controller::View.new(controller) }
describe "#policy_scope" do
it "doesn't flip pundit_policy_scoped?" do
scoped = view... | ruby | MIT | 3488802b2f218ba26562e91186655297c95eb6da | 2026-01-04T15:38:58.048292Z | false |
varvet/pundit | https://github.com/varvet/pundit/blob/3488802b2f218ba26562e91186655297c95eb6da/lib/pundit.rb | lib/pundit.rb | # frozen_string_literal: true
require "active_support"
require "pundit/version"
require "pundit/error"
require "pundit/policy_finder"
require "pundit/context"
require "pundit/authorization"
require "pundit/helper"
require "pundit/cache_store"
require "pundit/cache_store/null_store"
require "pundit/cache_store/legacy_... | ruby | MIT | 3488802b2f218ba26562e91186655297c95eb6da | 2026-01-04T15:38:58.048292Z | false |
varvet/pundit | https://github.com/varvet/pundit/blob/3488802b2f218ba26562e91186655297c95eb6da/lib/generators/rspec/policy_generator.rb | lib/generators/rspec/policy_generator.rb | # frozen_string_literal: true
# @private
module Rspec
# @private
module Generators
# @private
class PolicyGenerator < ::Rails::Generators::NamedBase
source_root File.expand_path("templates", __dir__)
def create_policy_spec
template "policy_spec.rb.tt", File.join("spec/policies", class_... | ruby | MIT | 3488802b2f218ba26562e91186655297c95eb6da | 2026-01-04T15:38:58.048292Z | false |
varvet/pundit | https://github.com/varvet/pundit/blob/3488802b2f218ba26562e91186655297c95eb6da/lib/generators/pundit/install/install_generator.rb | lib/generators/pundit/install/install_generator.rb | # frozen_string_literal: true
module Pundit
# @private
module Generators
# @private
class InstallGenerator < ::Rails::Generators::Base
source_root File.expand_path("templates", __dir__)
def copy_application_policy
template "application_policy.rb.tt", "app/policies/application_policy.rb... | ruby | MIT | 3488802b2f218ba26562e91186655297c95eb6da | 2026-01-04T15:38:58.048292Z | false |
varvet/pundit | https://github.com/varvet/pundit/blob/3488802b2f218ba26562e91186655297c95eb6da/lib/generators/pundit/policy/policy_generator.rb | lib/generators/pundit/policy/policy_generator.rb | # frozen_string_literal: true
module Pundit
# @private
module Generators
# @private
class PolicyGenerator < ::Rails::Generators::NamedBase
source_root File.expand_path("templates", __dir__)
def create_policy
template "policy.rb.tt", File.join("app/policies", class_path, "#{file_name}_p... | ruby | MIT | 3488802b2f218ba26562e91186655297c95eb6da | 2026-01-04T15:38:58.048292Z | false |
varvet/pundit | https://github.com/varvet/pundit/blob/3488802b2f218ba26562e91186655297c95eb6da/lib/generators/test_unit/policy_generator.rb | lib/generators/test_unit/policy_generator.rb | # frozen_string_literal: true
# @private
module TestUnit
# @private
module Generators
# @private
class PolicyGenerator < ::Rails::Generators::NamedBase
source_root File.expand_path("templates", __dir__)
def create_policy_test
template "policy_test.rb.tt", File.join("test/policies", cla... | ruby | MIT | 3488802b2f218ba26562e91186655297c95eb6da | 2026-01-04T15:38:58.048292Z | false |
varvet/pundit | https://github.com/varvet/pundit/blob/3488802b2f218ba26562e91186655297c95eb6da/lib/pundit/cache_store.rb | lib/pundit/cache_store.rb | # frozen_string_literal: true
module Pundit
# Namespace for cache store implementations.
#
# Cache stores are used to cache policy lookups, so you get the same policy
# instance for the same record.
# @since v2.3.2
module CacheStore
# @!group Cache Store Interface
# @!method fetch(user:, record:, ... | ruby | MIT | 3488802b2f218ba26562e91186655297c95eb6da | 2026-01-04T15:38:58.048292Z | false |
varvet/pundit | https://github.com/varvet/pundit/blob/3488802b2f218ba26562e91186655297c95eb6da/lib/pundit/version.rb | lib/pundit/version.rb | # frozen_string_literal: true
module Pundit
# The current version of Pundit.
VERSION = "2.5.2"
end
| ruby | MIT | 3488802b2f218ba26562e91186655297c95eb6da | 2026-01-04T15:38:58.048292Z | false |
varvet/pundit | https://github.com/varvet/pundit/blob/3488802b2f218ba26562e91186655297c95eb6da/lib/pundit/railtie.rb | lib/pundit/railtie.rb | # frozen_string_literal: true
module Pundit
# @since v2.5.0
class Railtie < Rails::Railtie
if Rails.version.to_f >= 8.0
initializer "pundit.stats_directories" do
require "rails/code_statistics"
if Rails.root.join("app/policies").directory?
Rails::CodeStatistics.register_directo... | ruby | MIT | 3488802b2f218ba26562e91186655297c95eb6da | 2026-01-04T15:38:58.048292Z | false |
varvet/pundit | https://github.com/varvet/pundit/blob/3488802b2f218ba26562e91186655297c95eb6da/lib/pundit/rspec.rb | lib/pundit/rspec.rb | # frozen_string_literal: true
require "pundit"
# Array#to_sentence
require "active_support/core_ext/array/conversions"
module Pundit
# Namespace for Pundit's RSpec integration.
# @since v0.1.0
module RSpec
# Namespace for Pundit's RSpec matchers.
module Matchers
extend ::RSpec::Matchers::DSL
... | ruby | MIT | 3488802b2f218ba26562e91186655297c95eb6da | 2026-01-04T15:38:58.048292Z | false |
varvet/pundit | https://github.com/varvet/pundit/blob/3488802b2f218ba26562e91186655297c95eb6da/lib/pundit/helper.rb | lib/pundit/helper.rb | # frozen_string_literal: true
module Pundit
# Rails view helpers, to allow a slightly different view-specific
# implementation of the methods in {Pundit::Authorization}.
#
# @api private
# @since v1.0.0
module Helper
# @see Pundit::Authorization#pundit_policy_scope
# @since v1.0.0
def policy_sc... | ruby | MIT | 3488802b2f218ba26562e91186655297c95eb6da | 2026-01-04T15:38:58.048292Z | false |
varvet/pundit | https://github.com/varvet/pundit/blob/3488802b2f218ba26562e91186655297c95eb6da/lib/pundit/policy_finder.rb | lib/pundit/policy_finder.rb | # frozen_string_literal: true
# String#safe_constantize, String#demodulize, String#underscore, String#camelize
require "active_support/core_ext/string/inflections"
module Pundit
# Finds policy and scope classes for given object.
# @since v0.1.0
# @api public
# @example
# user = User.find(params[:id])
# ... | ruby | MIT | 3488802b2f218ba26562e91186655297c95eb6da | 2026-01-04T15:38:58.048292Z | false |
varvet/pundit | https://github.com/varvet/pundit/blob/3488802b2f218ba26562e91186655297c95eb6da/lib/pundit/context.rb | lib/pundit/context.rb | # frozen_string_literal: true
module Pundit
# {Pundit::Context} is intended to be created once per request and user, and
# it is then used to perform authorization checks throughout the request.
#
# @example Using Sinatra
# helpers do
# def current_user = ...
#
# def pundit
# @pundit ... | ruby | MIT | 3488802b2f218ba26562e91186655297c95eb6da | 2026-01-04T15:38:58.048292Z | false |
varvet/pundit | https://github.com/varvet/pundit/blob/3488802b2f218ba26562e91186655297c95eb6da/lib/pundit/authorization.rb | lib/pundit/authorization.rb | # frozen_string_literal: true
module Pundit
# Pundit DSL to include in your controllers to provide authorization helpers.
#
# @example
# class ApplicationController < ActionController::Base
# include Pundit::Authorization
# end
# @see #pundit
# @api public
# @since v2.2.0
module Authorizati... | ruby | MIT | 3488802b2f218ba26562e91186655297c95eb6da | 2026-01-04T15:38:58.048292Z | false |
varvet/pundit | https://github.com/varvet/pundit/blob/3488802b2f218ba26562e91186655297c95eb6da/lib/pundit/error.rb | lib/pundit/error.rb | # frozen_string_literal: true
module Pundit
# @api private
# @since v1.0.0
# To avoid name clashes with common Error naming when mixing in Pundit,
# keep it here with compact class style definition.
class Error < StandardError; end
# Error that will be raised when authorization has failed
# @since v0.1.... | ruby | MIT | 3488802b2f218ba26562e91186655297c95eb6da | 2026-01-04T15:38:58.048292Z | false |
varvet/pundit | https://github.com/varvet/pundit/blob/3488802b2f218ba26562e91186655297c95eb6da/lib/pundit/cache_store/null_store.rb | lib/pundit/cache_store/null_store.rb | # frozen_string_literal: true
module Pundit
module CacheStore
# A cache store that does not cache anything.
#
# Use `NullStore.instance` to get the singleton instance, it is thread-safe.
#
# @see Pundit::Context#initialize
# @api private
# @since v2.3.2
class NullStore
@instance... | ruby | MIT | 3488802b2f218ba26562e91186655297c95eb6da | 2026-01-04T15:38:58.048292Z | false |
varvet/pundit | https://github.com/varvet/pundit/blob/3488802b2f218ba26562e91186655297c95eb6da/lib/pundit/cache_store/legacy_store.rb | lib/pundit/cache_store/legacy_store.rb | # frozen_string_literal: true
module Pundit
module CacheStore
# A cache store that uses only the record as a cache key, and ignores the user.
#
# The original cache mechanism used by Pundit.
#
# @api private
# @since v2.3.2
class LegacyStore
# @since v2.3.2
def initialize(hash... | ruby | MIT | 3488802b2f218ba26562e91186655297c95eb6da | 2026-01-04T15:38:58.048292Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/features/support/env.rb | features/support/env.rb | require "aruba/cucumber"
| ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/features/support/bourbon_support.rb | features/support/bourbon_support.rb | module BourbonSupport
def install_bourbon(path = nil)
if path
run_simple("bundle exec bourbon install --path '#{path}'")
else
run_simple("bundle exec bourbon install")
end
end
def bourbon_path(prefix, path)
if prefix
File.join(prefix, 'bourbon', path)
else
File.join('b... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/features/step_definitions/bourbon_steps.rb | features/step_definitions/bourbon_steps.rb | Given /^bourbon is already installed$/ do
install_bourbon
end
Given /^I install bourbon to "([^"]*)"$/ do |path|
end
Then /^the sass directories(?: with "([^"]+)" prefix)? should have been generated$/ do |prefix|
sass_directories = [
"bourbon/helpers",
"bourbon/library",
"bourbon/settings",
"bourb... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/spec_helper.rb | spec/spec_helper.rb | $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require "rspec"
require "bourbon"
require "aruba/api"
require "css_parser"
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
RSpec.configure do |config|
config.include SassSupport
con... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/support/parser_support.rb | spec/support/parser_support.rb | module ParserSupport
def self.parser
@parser ||= CssParser::Parser.new
end
def self.parse_file(identifier)
parser.load_file!("tmp/#{identifier}.css")
end
def self.show_contents(identifier)
css_file_contents = File.open("tmp/#{identifier}.css").read
css_file_contents.each_line do |line|
... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/support/sass_support.rb | spec/support/sass_support.rb | module SassSupport
def generate_css
FileUtils.mkdir("tmp")
`sass -I . spec/fixtures:tmp --update --precision=5 --sourcemap=none`
end
def clean_up
FileUtils.rm_rf("tmp")
end
end
| ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/support/matchers/have_rule.rb | spec/support/matchers/have_rule.rb | RSpec::Matchers.define :have_rule do |expected|
match do |selector|
@rules = rules_from_selector(selector)
@rules.include? expected
end
failure_message do |selector|
if @rules.empty?
%{no CSS for selector #{selector} were found}
else
rules = @rules.join("; ")
%{Expected selector... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/support/matchers/have_value.rb | spec/support/matchers/have_value.rb | RSpec::Matchers.define :have_value do |expected|
match do |variable|
selector_class = variable.sub("$", ".")
@value_attribute = ParserSupport.parser.find_by_selector(selector_class)[0]
unless @value_attribute.nil?
actual_value = @value_attribute.split(":")[1].strip.sub(";", "")
actual_value =... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/support/matchers/have_ruleset.rb | spec/support/matchers/have_ruleset.rb | RSpec::Matchers.define :have_ruleset do |expected|
match do |selector|
@ruleset = rules_from_selector(selector)
@ruleset.join("; ") == expected
end
failure_message do |selector|
if @ruleset.empty?
%{no CSS for selector #{selector} were found}
else
ruleset = @ruleset.join("; ")
%... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/validators/contains_spec.rb | spec/bourbon/validators/contains_spec.rb | require "spec_helper"
describe "contains" do
before(:all) do
ParserSupport.parse_file("validators/contains")
end
context "called on array with single item" do
it "contains item" do
expect(".single").to have_rule("color: #fff")
end
it "doesn't contain missing item" do
expect(".single... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/validators/is_length_spec.rb | spec/bourbon/validators/is_length_spec.rb | require "spec_helper"
describe "is-length" do
before(:all) do
ParserSupport.parse_file("validators/is-length")
end
context "checks if unitless integer can be represented as a length" do
it "returns false" do
expect(".integer").not_to have_rule("color: #fff")
end
end
context "checks if px ... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/validators/is_number_spec.rb | spec/bourbon/validators/is_number_spec.rb | require "spec_helper"
describe "is-number" do
before(:all) do
ParserSupport.parse_file("validators/is-number")
end
context "called with integer" do
it "is a number" do
expect(".integer").to have_rule("line-height: 1")
end
end
context "called with px" do
it "is a number" do
expec... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/validators/is_size_spec.rb | spec/bourbon/validators/is_size_spec.rb | require "spec_helper"
describe "is-size" do
before(:all) do
ParserSupport.parse_file("validators/is-size")
end
context "called with integer" do
it "is not a size" do
expect(".integer").to_not have_rule("margin-top: 1")
end
end
context "called with px" do
it "is a size" do
expect... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/library/padding_spec.rb | spec/bourbon/library/padding_spec.rb | require "spec_helper"
describe "padding" do
before(:all) do
ParserSupport.parse_file("library/padding")
end
context "called with one size" do
it "applies same width to all sides" do
rule = "padding: 1px"
expect(".padding-all").to have_rule(rule)
end
end
context "called with two siz... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/library/text_inputs_spec.rb | spec/bourbon/library/text_inputs_spec.rb | require "spec_helper"
describe "text-inputs" do
before(:all) do
ParserSupport.parse_file("library/text-inputs")
@inputs_list = %w(
[type='color']
[type='date']
[type='datetime']
[type='datetime-local']
[type='email']
[type='month']
[type='number']
[type='passw... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/library/margin_spec.rb | spec/bourbon/library/margin_spec.rb | require "spec_helper"
describe "margin" do
before(:all) do
ParserSupport.parse_file("library/margin")
end
context "called with one size" do
it "applies same width to all sides" do
rule = "margin: 1px"
expect(".margin-all").to have_rule(rule)
end
end
context "called with two sizes" ... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/library/tint_spec.rb | spec/bourbon/library/tint_spec.rb | require "spec_helper"
describe "tint" do
before(:all) do
ParserSupport.parse_file("library/tint")
end
context "called on white" do
it "still returns white" do
expect(".tint-white").to have_rule("color: white")
end
end
context "called on black" do
it "tints black" do
expect(".tin... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/library/font_face_spec_2.rb | spec/bourbon/library/font_face_spec_2.rb | require "spec_helper"
describe "font-face" do
before(:all) do
ParserSupport.parse_file("library/font-face-5")
end
context "called with additional CSS rules" do
it "outputs defaults with additional content" do
ruleset = 'font-family: "calibre"; ' +
'src: url("fonts/calibre.woff2") f... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/library/ellipsis_spec.rb | spec/bourbon/library/ellipsis_spec.rb | require "spec_helper"
describe "ellipsis" do
before(:all) do
ParserSupport.parse_file("library/ellipsis")
end
context "called on element" do
it "adds ellipsis" do
ruleset = "display: inline-block; " +
"max-width: 100%; " +
"overflow: hidden; " +
"tex... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/library/size_spec.rb | spec/bourbon/library/size_spec.rb | require "spec_helper"
describe "size" do
before(:all) do
ParserSupport.parse_file("library/size")
end
context "called with one size" do
it "applies same width to both height and width" do
rule = "height: 10px; width: 10px;"
expect(".size-implicit").to have_ruleset(rule)
end
end
con... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/library/clearfix_spec.rb | spec/bourbon/library/clearfix_spec.rb | require "spec_helper"
describe "clearfix" do
before(:all) do
ParserSupport.parse_file("library/clearfix")
end
context "called on element" do
it "adds clearfix" do
input = ".clearfix::after"
ruleset = "clear: both; " +
'content: ""; ' +
"display: block;"
... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/library/hide_text_spec.rb | spec/bourbon/library/hide_text_spec.rb | require "spec_helper"
describe "hide-text" do
before(:all) do
ParserSupport.parse_file("library/hide-text")
end
context "called on element" do
it "adds hide-text" do
ruleset = "overflow: hidden; " +
"text-indent: 101%; " +
"white-space: nowrap;"
expect(".hide... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/library/prefixer_spec.rb | spec/bourbon/library/prefixer_spec.rb | require "spec_helper"
describe "prefixer" do
before(:all) do
ParserSupport.parse_file("library/prefixer")
end
context "called with no prefixes" do
it "outputs the spec" do
rule = "appearance: none;"
expect(".prefix").to have_ruleset(rule)
end
end
context "called with one prefix" do... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/library/shade_spec.rb | spec/bourbon/library/shade_spec.rb | require "spec_helper"
describe "shade" do
before(:all) do
ParserSupport.parse_file("library/shade")
end
context "called on white" do
it "shades white" do
expect(".shade-white").to have_rule("color: #404040")
end
end
context "called on black" do
it "still returns black" do
expect... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/library/font_face_spec_3.rb | spec/bourbon/library/font_face_spec_3.rb | require "spec_helper"
describe "font-face" do
before(:all) do
ParserSupport.parse_file("library/font-face-3")
end
context "called with defaults" do
it "outputs defaults" do
ruleset = 'font-family: "pitch";' +
'src: font-url("/fonts/pitch.woff2") format("woff2");'
expect("@fo... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/library/position_spec.rb | spec/bourbon/library/position_spec.rb | require "spec_helper"
describe "position" do
before(:all) do
ParserSupport.parse_file("library/position")
end
context "called with one size" do
it "applies same width to all sides" do
ruleset = "position: fixed; " +
"top: 1em; " +
"right: 1em; " +
"b... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/library/hide_visually_spec.rb | spec/bourbon/library/hide_visually_spec.rb | require "spec_helper"
describe "hide-visually" do
before(:all) do
ParserSupport.parse_file("library/hide-visually")
end
context "called on element" do
it "adds properties to hide the element" do
ruleset = "border: 0; " +
"clip: rect(1px, 1px, 1px, 1px); " +
"clip-pa... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/library/contrast_switch_spec.rb | spec/bourbon/library/contrast_switch_spec.rb | require "spec_helper"
describe "contrast-switch" do
before(:all) do
ParserSupport.parse_file("library/contrast-switch")
end
context "called with a light base color" do
it "outputs the dark color" do
rule = "color: #000;"
expect(".contrast-switch-light-base").to have_ruleset(rule)
end
... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/library/border_radius_spec.rb | spec/bourbon/library/border_radius_spec.rb | require "spec_helper"
describe "border-radius" do
before(:all) do
ParserSupport.parse_file("library/border-radius")
end
context "called with one argument" do
it "applies to correct sides" do
top = "border-top-left-radius: 1em; " +
"border-top-right-radius: 1em;"
left = "border-bo... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/library/border_color_spec.rb | spec/bourbon/library/border_color_spec.rb | require "spec_helper"
describe "border-color" do
before(:all) do
ParserSupport.parse_file("library/border-color")
end
context "called with one color" do
it "applies same color to all sides" do
rule = "border-color: #f00"
expect(".border-color-all").to have_rule(rule)
end
end
contex... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/library/buttons_spec.rb | spec/bourbon/library/buttons_spec.rb | require "spec_helper"
describe "buttons" do
before(:all) do
ParserSupport.parse_file("library/buttons")
@buttons_list = %w(
button
[type='button']
[type='reset']
[type='submit']
)
end
context "expands plain buttons" do
it "finds selectors" do
list = @buttons_list.j... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/library/font_stacks_spec.rb | spec/bourbon/library/font_stacks_spec.rb | require "spec_helper"
describe "font-stacks" do
before(:all) do
ParserSupport.parse_file("library/font-stacks")
end
context "stacks used in variable" do
it "output stacks" do
helvetica = '"Helvetica Neue", "Helvetica", "Arial", sans-serif'
lucida_grande = '"Lucida Grande", "Lucida Sans Unico... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/library/overflow_wrap_spec.rb | spec/bourbon/library/overflow_wrap_spec.rb | require "spec_helper"
describe "overflow-wrap" do
before(:all) do
ParserSupport.parse_file("library/overflow-wrap")
end
context "called on element" do
it "adds overflow-wrap and word-wrap" do
input = ".overflow-wrap"
ruleset = "word-wrap: break-word; " +
"overflow-wrap: break... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/library/triangle_spec.rb | spec/bourbon/library/triangle_spec.rb | require "spec_helper"
describe "triangle" do
before(:all) do
ParserSupport.parse_file("library/triangle")
end
context "called with defaults" do
it "outputs the properties" do
ruleset = "border-style: solid; " +
"height: 0; " +
"width: 0; " +
"border-... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/library/border_width_spec.rb | spec/bourbon/library/border_width_spec.rb | require "spec_helper"
describe "border-width" do
before(:all) do
ParserSupport.parse_file("library/border-width")
end
context "called with one color" do
it "applies same width to all sides" do
rule = "border-width: 1px"
expect(".border-width-all").to have_rule(rule)
end
end
context... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/library/border_style_spec.rb | spec/bourbon/library/border_style_spec.rb | require "spec_helper"
describe "border-style" do
before(:all) do
ParserSupport.parse_file("library/border-style")
end
context "called with one style" do
it "applies same style to all sides" do
rule = "border-style: solid"
expect(".border-style-all").to have_rule(rule)
end
end
conte... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/library/strip_unit_spec.rb | spec/bourbon/library/strip_unit_spec.rb | require "spec_helper"
describe "strip-unit" do
before(:all) do
ParserSupport.parse_file("library/strip-unit")
end
context "called with px" do
it "strips units" do
expect(".px").to have_rule("width: 10")
end
end
context "called with em" do
it "strips units" do
expect(".em").to ha... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/library/font_face_spec_1.rb | spec/bourbon/library/font_face_spec_1.rb | require "spec_helper"
describe "font-face" do
before(:all) do
ParserSupport.parse_file("library/font-face-1")
end
context "called with defaults" do
it "outputs defaults" do
ruleset = 'font-family: "source-sans-pro"; ' +
'src: url("/fonts/source-sans-pro/source-sans-pro-regular.woff... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/library/modular_scale_spec.rb | spec/bourbon/library/modular_scale_spec.rb | require "spec_helper"
describe "modular-scale" do
before(:all) do
ParserSupport.parse_file("library/modular-scale")
end
context "called with arguments (1, $value: 2em)" do
it "outputs double the first value from the default scale" do
expect(".one-base-two").to have_rule("font-size: 2.5em")
end... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/utilities/compact_shorthand_spec.rb | spec/bourbon/utilities/compact_shorthand_spec.rb | require "spec_helper"
describe "compact-shorthand" do
before(:all) do
ParserSupport.parse_file("utilities/compact-shorthand")
end
context "compact-shorthand" do
it "returns four values unaltered" do
expect(".four-values-a").to have_rule("padding: 10px 20px 30px 40px")
end
it "returns four... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/utilities/font_source_declaration_spec.rb | spec/bourbon/utilities/font_source_declaration_spec.rb | require "spec_helper"
describe "font-source-declaration" do
before(:all) do
ParserSupport.parse_file("utilities/font-source-declaration")
end
context "called with pipeline" do
it "returns pipeline path" do
rule = 'src: font-url("b.woff2") format("woff2"), ' +
'font-url("b.woff") forma... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/utilities/fetch_bourbon_setting_spec.rb | spec/bourbon/utilities/fetch_bourbon_setting_spec.rb | require "spec_helper"
describe "fetch-bourbon-setting" do
before(:all) do
ParserSupport.parse_file("utilities/fetch-bourbon-setting")
end
context "fetches the modular-scale-base setting" do
it "and returns the default value" do
expect(".test-1").to have_rule("content: 1em")
end
end
contex... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/utilities/unpack_spec.rb | spec/bourbon/utilities/unpack_spec.rb | require "spec_helper"
describe "unpack" do
before(:all) do
ParserSupport.parse_file("utilities/unpack")
end
context "single" do
it "unpacks four identical measurements" do
expect(".single").to have_rule("padding: 10px 10px 10px 10px")
end
end
context "double" do
it "unpacks identical ... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/utilities/lightness_spec.rb | spec/bourbon/utilities/lightness_spec.rb | require "spec_helper"
describe "lightness" do
before(:all) do
ParserSupport.parse_file("utilities/lightness")
end
context "called on black" do
it "outputs a number between 0 and 1 to indicate lightness" do
rule = "content: 0;"
expect(".lightness-black").to have_ruleset(rule)
end
end
... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/utilities/gamma_spec.rb | spec/bourbon/utilities/gamma_spec.rb | require "spec_helper"
describe "gamma" do
before(:all) do
ParserSupport.parse_file("utilities/gamma")
end
context "called on a color channel" do
it "outputs a gamma value between 0 and 1" do
rule = "content: 0.12168;"
expect(".gamma").to have_ruleset(rule)
end
end
context "called o... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/utilities/assign_inputs_spec.rb | spec/bourbon/utilities/assign_inputs_spec.rb | require "spec_helper"
describe "assign-inputs" do
before(:all) do
ParserSupport.parse_file("utilities/assign-inputs")
@text_inputs_list = [
"[type='password']",
"[type='text']",
"textarea"
]
end
context "expands plain text inputs" do
it "finds selectors" do
@text_inputs_l... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/utilities/contrast_ratio_spec.rb | spec/bourbon/utilities/contrast_ratio_spec.rb | require "spec_helper"
describe "contrast-ratio" do
before(:all) do
ParserSupport.parse_file("utilities/contrast-ratio")
end
context "calculates between white and black" do
it "outputs the contrast ratio" do
rule = "content: 21;"
expect(".contrast-ratio-black").to have_ruleset(rule)
end
... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/spec/bourbon/utilities/directional_property_spec.rb | spec/bourbon/utilities/directional_property_spec.rb | require "spec_helper"
describe "directional-property" do
before(:all) do
ParserSupport.parse_file("utilities/directional-property")
end
context "directional-property" do
it "returns property and values with four distinct lengths" do
expect(".border-all").to have_rule("border-width: 2px 5px 8px 12p... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/lib/bourbon.rb | lib/bourbon.rb | require "bourbon/generator"
module Bourbon
if defined?(Rails) && defined?(Rails::Engine)
class Engine < ::Rails::Engine
initializer "bourbon.paths", group: :all do |app|
app.config.assets.paths << File.expand_path("../core", __dir__)
end
end
else
begin
require "sass"
Sas... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/lib/bourbon/version.rb | lib/bourbon/version.rb | module Bourbon
VERSION = "7.3.0".freeze
end
| ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/bourbon | https://github.com/thoughtbot/bourbon/blob/1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8/lib/bourbon/generator.rb | lib/bourbon/generator.rb | require "bourbon/version"
require "fileutils"
require "thor"
require "pathname"
module Bourbon
class Generator < Thor
map ["-v", "--version"] => :version
desc "install", "Install Bourbon into your project"
method_options :path => :string, :force => :boolean
def install
if bourbon_files_already... | ruby | MIT | 1cd55ce9c0f1785ddecc617b3ba6a40a0c61b7b8 | 2026-01-04T15:38:44.363157Z | false |
thoughtbot/factory_bot | https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/.github/REPRODUCTION_SCRIPT.rb | .github/REPRODUCTION_SCRIPT.rb | require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "factory_bot", "~> 6.0"
gem "activerecord"
gem "sqlite3"
end
require "active_record"
require "factory_bot"
require "minitest/autorun"
require "logger"
ActiveRecord::Ba... | ruby | MIT | 5115775355323252da65f323f6c10b91f2130d48 | 2026-01-04T15:39:01.421901Z | false |
thoughtbot/factory_bot | https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/features/support/env.rb | features/support/env.rb | PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), "..", ".."))
require "simplecov" if RUBY_ENGINE == "ruby"
$: << File.join(PROJECT_ROOT, "lib")
require "active_record"
require "factory_bot"
require "aruba/cucumber"
| ruby | MIT | 5115775355323252da65f323f6c10b91f2130d48 | 2026-01-04T15:39:01.421901Z | false |
thoughtbot/factory_bot | https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/features/support/factories.rb | features/support/factories.rb | ActiveRecord::Base.establish_connection(
adapter: "sqlite3",
database: ":memory:"
)
class CreateSchema < ActiveRecord::Migration[5.0]
def self.up
create_table :categories, force: true do |t|
t.string :name
end
end
end
CreateSchema.suppress_messages { CreateSchema.migrate(:up) }
class Category <... | ruby | MIT | 5115775355323252da65f323f6c10b91f2130d48 | 2026-01-04T15:39:01.421901Z | false |
thoughtbot/factory_bot | https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/features/step_definitions/factory_bot_steps.rb | features/step_definitions/factory_bot_steps.rb | module FactoryBotDefinitionsHelper
def append_file_to_factory_bot_definitions_path(path_to_file)
FactoryBot.definition_file_paths ||= []
FactoryBot.definition_file_paths << path_to_file
end
end
World(FactoryBotDefinitionsHelper)
When(/^"([^"]*)" is added to FactoryBot's file definitions path$/) do |file_n... | ruby | MIT | 5115775355323252da65f323f6c10b91f2130d48 | 2026-01-04T15:39:01.421901Z | false |
thoughtbot/factory_bot | https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/features/step_definitions/database_steps.rb | features/step_definitions/database_steps.rb | Then(/^I should find the following for the last category:$/) do |table|
table.hashes.first.each do |key, value|
expect(Category.last.attributes[key].to_s).to eq value
end
end
Before do
Category.delete_all
end
| ruby | MIT | 5115775355323252da65f323f6c10b91f2130d48 | 2026-01-04T15:39:01.421901Z | false |
thoughtbot/factory_bot | https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/factory_bot_spec.rb | spec/factory_bot_spec.rb | describe FactoryBot do
it "finds a registered strategy" do
FactoryBot.register_strategy(:strategy_name, :strategy_class)
expect(FactoryBot.strategy_by_name(:strategy_name))
.to eq :strategy_class
end
describe ".use_parent_strategy" do
it "is true by default" do
expect(FactoryBot.use_paren... | ruby | MIT | 5115775355323252da65f323f6c10b91f2130d48 | 2026-01-04T15:39:01.421901Z | false |
thoughtbot/factory_bot | https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/spec_helper.rb | spec/spec_helper.rb | # Set timeout when setting sequences
require "rspec"
require "rspec/its"
require "simplecov" if RUBY_ENGINE == "ruby"
require "factory_bot"
FactoryBot.sequence_setting_timeout = 0.5
if RUBY_ENGINE == "jruby"
# Workaround for issue in I18n/JRuby combo.
# See https://github.com/jruby/jruby/issues/6547 and
# htt... | ruby | MIT | 5115775355323252da65f323f6c10b91f2130d48 | 2026-01-04T15:39:01.421901Z | false |
thoughtbot/factory_bot | https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/support/macros/deprecation.rb | spec/support/macros/deprecation.rb | require "active_support"
RSpec.configure do |config|
config.around :example, silence_deprecation: true do |example|
with_temporary_assignment(FactoryBot::Deprecation, :silenced, true) do
example.run
end
end
end
| ruby | MIT | 5115775355323252da65f323f6c10b91f2130d48 | 2026-01-04T15:39:01.421901Z | false |
thoughtbot/factory_bot | https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/support/macros/temporary_assignment.rb | spec/support/macros/temporary_assignment.rb | module TemporaryAssignment
def with_temporary_assignment(assignee, attribute, temporary_value)
original_value = assignee.public_send(attribute)
attribute_setter = "#{attribute}="
assignee.public_send(attribute_setter, temporary_value)
yield
ensure
assignee.public_send(attribute_setter, original_... | ruby | MIT | 5115775355323252da65f323f6c10b91f2130d48 | 2026-01-04T15:39:01.421901Z | false |
thoughtbot/factory_bot | https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/support/macros/define_constant.rb | spec/support/macros/define_constant.rb | require "active_record"
module DefineConstantMacros
def define_class(path, base = Object, &block)
const = stub_const(path, Class.new(base))
const.class_eval(&block) if block
const
end
def define_model(name, columns = {}, &block)
model = define_class(name, ActiveRecord::Base, &block)
create_t... | ruby | MIT | 5115775355323252da65f323f6c10b91f2130d48 | 2026-01-04T15:39:01.421901Z | false |
thoughtbot/factory_bot | https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/support/shared_examples/strategy.rb | spec/support/shared_examples/strategy.rb | shared_examples_for "strategy without association support" do
let(:factory) { double("associate_factory") }
let(:attribute) { FactoryBot::Attribute::Association.new(:user, :user, {}) }
def association_named(name, overrides)
runner = FactoryBot::FactoryRunner.new(name, :build, [overrides])
subject.associa... | ruby | MIT | 5115775355323252da65f323f6c10b91f2130d48 | 2026-01-04T15:39:01.421901Z | false |
thoughtbot/factory_bot | https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/support/matchers/callback.rb | spec/support/matchers/callback.rb | RSpec::Matchers.define :have_callback do |callback_name|
match do |instance|
instance.callbacks.include?(FactoryBot::Callback.new(callback_name, @block))
end
chain :with_block do |block|
@block = block
end
end
| ruby | MIT | 5115775355323252da65f323f6c10b91f2130d48 | 2026-01-04T15:39:01.421901Z | false |
thoughtbot/factory_bot | https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/support/matchers/be_about_now.rb | spec/support/matchers/be_about_now.rb | RSpec::Matchers.define :be_about_now do
match do |actual|
expect(actual).to be_within(2.seconds).of(Time.now)
end
end
| ruby | MIT | 5115775355323252da65f323f6c10b91f2130d48 | 2026-01-04T15:39:01.421901Z | false |
thoughtbot/factory_bot | https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/support/matchers/declaration.rb | spec/support/matchers/declaration.rb | module DeclarationMatchers
def have_dynamic_declaration(name)
DeclarationMatcher.new(:dynamic).named(name)
end
def have_association_declaration(name)
DeclarationMatcher.new(:association).named(name)
end
def have_implicit_declaration(name)
DeclarationMatcher.new(:implicit).named(name)
end
cl... | ruby | MIT | 5115775355323252da65f323f6c10b91f2130d48 | 2026-01-04T15:39:01.421901Z | false |
thoughtbot/factory_bot | https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/support/matchers/raise_did_you_mean_error.rb | spec/support/matchers/raise_did_you_mean_error.rb | RSpec::Matchers.define :raise_did_you_mean_error do
supports_block_expectations
match do |actual|
# detailed_message introduced in Ruby 3.2 for cleaner integration with
# did_you_mean. See https://bugs.ruby-lang.org/issues/18564
matcher = if KeyError.method_defined?(:detailed_message)
raise_error... | ruby | MIT | 5115775355323252da65f323f6c10b91f2130d48 | 2026-01-04T15:39:01.421901Z | false |
thoughtbot/factory_bot | https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/support/matchers/trait.rb | spec/support/matchers/trait.rb | RSpec::Matchers.define :have_trait do |trait_name|
match do |instance|
instance.defined_traits.any? do |trait|
trait.name == trait_name.to_s && trait.send(:block) == @block
end
end
chain :with_block do |block|
@block = block
end
end
| ruby | MIT | 5115775355323252da65f323f6c10b91f2130d48 | 2026-01-04T15:39:01.421901Z | false |
thoughtbot/factory_bot | https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/support/matchers/delegate.rb | spec/support/matchers/delegate.rb | RSpec::Matchers.define :delegate do |delegated_method|
chain :to do |target_method|
@target_method = target_method
end
chain :as do |method_on_target|
@method_on_target = method_on_target
end
chain :with_arguments do |args|
@args = args
end
match do |instance|
@instance = instance
@... | ruby | MIT | 5115775355323252da65f323f6c10b91f2130d48 | 2026-01-04T15:39:01.421901Z | false |
thoughtbot/factory_bot | https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/support/containers/test_log.rb | spec/support/containers/test_log.rb | require "forwardable"
##
# Designed for tests to log output for later evaluation
#
module TestLog
class << self
extend Forwardable
def_delegators :log_array, :<<, :[], :size, :first, :last
def_delegators :log_array, :map, :in?, :include?, :inspect
def all
Thread.current[:my_thread_safe_test_l... | ruby | MIT | 5115775355323252da65f323f6c10b91f2130d48 | 2026-01-04T15:39:01.421901Z | false |
thoughtbot/factory_bot | https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/callbacks_spec.rb | spec/acceptance/callbacks_spec.rb | describe "callbacks" do
before do
define_model("User", first_name: :string, last_name: :string)
end
context "with strategy callbacks" do
before do
FactoryBot.define do
factory :user_with_callbacks, class: :user do
after(:stub) { |user| user.first_name = "Stubby" }
after(... | ruby | MIT | 5115775355323252da65f323f6c10b91f2130d48 | 2026-01-04T15:39:01.421901Z | false |
thoughtbot/factory_bot | https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/build_spec.rb | spec/acceptance/build_spec.rb | describe "a built instance" do
include FactoryBot::Syntax::Methods
before do
define_model("User")
define_model("Post", user_id: :integer) do
belongs_to :user
end
FactoryBot.define do
factory :user
factory :post do
user
end
end
end
subject { build(:post) }... | ruby | MIT | 5115775355323252da65f323f6c10b91f2130d48 | 2026-01-04T15:39:01.421901Z | false |
thoughtbot/factory_bot | https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/keyed_by_class_spec.rb | spec/acceptance/keyed_by_class_spec.rb | describe "finding factories keyed by class instead of symbol" do
before do
define_model("User") do
attr_accessor :name, :email
end
FactoryBot.define do
factory :user
end
end
it "doesn't find the factory" do
expect { FactoryBot.create(User) }.to(
raise_error(KeyError, /Facto... | ruby | MIT | 5115775355323252da65f323f6c10b91f2130d48 | 2026-01-04T15:39:01.421901Z | false |
thoughtbot/factory_bot | https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/nested_attributes_spec.rb | spec/acceptance/nested_attributes_spec.rb | describe "association assignment from nested attributes" do
before do
define_model("Post", title: :string) do
has_many :comments
accepts_nested_attributes_for :comments
end
define_model("Comment", post_id: :integer, body: :text) do
belongs_to :post
end
FactoryBot.define do
... | ruby | MIT | 5115775355323252da65f323f6c10b91f2130d48 | 2026-01-04T15:39:01.421901Z | false |
thoughtbot/factory_bot | https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/stub_spec.rb | spec/acceptance/stub_spec.rb | describe "a stubbed instance" do
include FactoryBot::Syntax::Methods
before do
define_model("User")
define_model("Post", user_id: :integer) do
belongs_to :user
end
FactoryBot.define do
factory :user
factory :post do
user
end
end
end
subject { build_stubbe... | ruby | MIT | 5115775355323252da65f323f6c10b91f2130d48 | 2026-01-04T15:39:01.421901Z | false |
thoughtbot/factory_bot | https://github.com/thoughtbot/factory_bot/blob/5115775355323252da65f323f6c10b91f2130d48/spec/acceptance/attributes_from_instance_spec.rb | spec/acceptance/attributes_from_instance_spec.rb | describe "calling methods on the model instance" do
before do
define_model("User", age: :integer, age_copy: :integer) do
def age
read_attribute(:age) || 18
end
end
FactoryBot.define do
factory :user do
age_copy { age }
end
end
end
context "without the attr... | ruby | MIT | 5115775355323252da65f323f6c10b91f2130d48 | 2026-01-04T15:39:01.421901Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.