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
| require "bundler/inline" | |
| gemfile do | |
| source 'https://rubygems.org' | |
| gem "rspec", "~> 3.10" | |
| end | |
| require "rspec/autorun" | |
| RSpec.configure do |config| |
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
| class Whereable | |
| def initialize(where:, model: Item, ranking_conditions: [], valid: true, data_source: nil) | |
| @model = model | |
| @where = where | |
| @data_source = data_source | |
| @ranking_conditions = ranking_conditions | |
| @valid = valid | |
| end | |
| def valid? |
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
| # I heard Whereables were having a moment. | |
| # | |
| # More on the real version of this feature here: | |
| # https://community.wanikani.com/t/kamesame-a-fast-feature-rich-japanese-memorization-webapp/31319/1575?u=searls | |
| # | |
| # Below is simplified but basic usage: | |
| # | |
| # SearchesStuff.new.call("arigatou") # finds ありがとう | |
| # SearchesStuff.new.call("にほんご") # finds 日本語 | |
| # SearchesStuff.new.call("探して") # finds 探す |
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
| $ time bin/rails test | |
| Run options: --seed 6029 | |
| # Running: | |
| ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. | |
| Finished in 22.966130s, 20.7697 runs/s, 19.7682 assertions/s. | |
| 477 runs, 454 assertions, 0 failures, 0 errors, 0 skips | |
| Coverage report generated for Minitest to /Users/justin/code/testdouble/present/coverage. 2793 / 3633 LOC (76.88%) covered. |
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
| class ActiveSupport::TestCase | |
| def self.test_data_source(source) | |
| case source | |
| when :test_data | |
| setup do | |
| TestData.load | |
| RefreshesMaterializedViews.new.call | |
| end | |
| teardown do |
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
| class ActiveSupport::TestCase | |
| def setup | |
| $rails_test_def_setup = true | |
| end | |
| setup do | |
| $rails_test_setup_do = true | |
| end | |
| def teardown |
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
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"> | |
| <array> | |
| <dict> | |
| <key>Activate</key> | |
| <string>Normal</string> | |
| <key>CreationDate</key> | |
| <real>640009344.41797602</real> | |
| <key>Macros</key> |
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
| version: 2 | |
| jobs: | |
| build: | |
| docker: | |
| - image: cimg/ruby:3.0.1-browsers | |
| environment: | |
| PAGER: cat # https://stackoverflow.com/questions/53055044/rails-rake-dbstructureload-times-out-on-circleci-2-0 | |
| SKIP_SCHEMA_DUMP: true # pg_dump: error: server version: 13.2; pg_dump version: 12.6 | |
| CYPRESS_RAILS_CYPRESS_OPTS: "--record --key ace11e57-d9d5-443d-8882-b2ecf0488a6d" |
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
| require "test_helper" | |
| class AttestationTest < ActiveSupport::TestCase | |
| def test_validate_not_already_attested | |
| user = User.new | |
| Attestation.create!(user: user, date: Date.civil(2021, 2, 28)) | |
| assert_validation :already_attested, Attestation.new(user: user, date: Date.civil(2021, 2, 16)) | |
| assert_validation :already_attested, Attestation.new(user: user, date: Date.civil(2021, 2, 28)) | |
| refute_validation :already_attested, Attestation.new(user: user, date: Date.civil(2021, 3, 15)) |
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
| -- This all starts with some functions and a *materialized* postgres view that unnests several | |
| -- arrays of strings of definitions into flattened rows that are easier to search. Fun fact: | |
| -- you can even create indexes on materialized views' columns! They'll refresh whenever the view | |
| -- is refreshed (which in my case is every time that we pull new dictionary data from WaniKani or JMDICT | |
| -- This function will take an array of strings and convert all the double-width alphanumeric characters | |
| -- and normalize them as half-width. That way a search query can be massaged from "OK" to "ok" easily | |
| CREATE OR REPLACE FUNCTION array_hankakufy_romaji(character varying[]) | |
| RETURNS character varying[] | |
| AS |