This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module TableSupport | |
def column_names(table_selector = "table") | |
find(table_selector).all("th").map(&:text) | |
end | |
def values_for_column(column_name, table_selector = "table") | |
table = find(table_selector) | |
index = table.all("th").map(&:text).find_index(column_name) | |
expect(index).to be_present, "Unable to find column named: #{column_name}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
class PgEnumMigrator | |
def initialize(migration:, table:, column:, enum_name:, mapping:, new_default: nil, old_default: nil) | |
@migration = migration | |
@table = table | |
@column = column | |
@enum_name = enum_name | |
@mapping = mapping | |
@new_default = new_default |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
# app/models/concerns | |
module HasStringEnum | |
extend ActiveSupport::Concern | |
class_methods do | |
def string_enum(name, values, **options) | |
enum(name => values.zip(values).to_h, **options) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it "doesn't make further requests when the cache is warm" do | |
stub = stub_request(:get, "www.amazon.com") | |
Amazon::API.new.item_prices("id") | |
Amazon::API.new.item_prices("id") | |
# https://github.com/bblimke/webmock#setting-expectations-in-rspec-on-the-stub | |
expect(stub).to have_been_requested.once | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# spec/support/hit.rb | |
module HitSpec | |
def hit(*args, &block) | |
n = 100 | |
if args.last.is_a?(Hash) && args.last.key?(:n) | |
n = args.last.delete(:n) | |
end |
OlderNewer