- Languages are
:en
and:ja
and:fr
, where:en
is the default. - It is path-based, like
/ja/articles
is for Index of Article model. - Allow access without the locale parameter in the path like
http://example.com/articles
- in which case the locale parameter
I18n.locale
should be set according to the browser's request, falling back to:en
- in which case the locale parameter
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 ModuleWasFounds | |
class InconsistencyInWasFoundError < StandardError # ModuleWasFounds::InconsistencyInWasFoundError | |
## Error in inconsistency in ModuleWasFound#was_found? and ModuleWasFound#was_created? | |
end | |
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
# Returns the String for the caller information | |
# | |
# @example To display the location of the last caller in the *_test.rb file. | |
# assert abc, sprintf("(%s): abc=%s", _get_caller_info_message, abc.inspect) # defined in test_helper.rb | |
# | |
# @example displays the exact line where an error occurs | |
# assert false, _get_caller_info_message(bind_offset: -1, prefix: true)+" Error occurs exactly at this line." | |
# | |
# @param bind_offset: [Integer, NilClass] offset for caller_locations (used for displaying the caller routine). In default (=nil), the last location in *_test.rb (such as, inside a block). If this is 0, it is useful in the case where this method is called in a test library method that is called from an original test routine. Therefore, specify "-1" to get the information of the caller itself (Second example above). | |
# @param fmt: [String] sprintf format. It must contain %s (for path) and %d (or %s) (for line number) in this order. |
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
# -*- coding: utf-8 -*- | |
require 'w3c_validators' | |
# Module to deal with W3C Validator | |
# | |
# == Usage | |
# | |
# Put this file in one of your library-load paths in the test environment. | |
# Then, in /test/test_helper.rb |
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 "tempfile" | |
# TeeIO to "tee" (or splice) an IO | |
# | |
# Basically this overwrites IO#write . | |
# | |
# Note this does not capture IO#syswrite | |
# | |
# The main part but {TeeIO.suppress_io} is taken from | |
# {https://stackoverflow.com/a/9439298/3577922} |
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
gem "minitest" | |
require 'minitest/autorun' | |
require 'tempfile' | |
# In general, each test method should generate its own temporary files. | |
# With the following code, the temporary files will be automatically deleted | |
# at the end of the processing, even if their IOs have been alraedy closed | |
# and only the filename (path) were utilised during processing. | |
class TestUnitMyLibrary < MiniTest::Test |
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 'optparse' | |
require 'optparse/time' # if Time is used. | |
#require 'ostruct' | |
require 'pp' | |
# This example file for using Ruby optparse is based on the original example | |
# code in Github, specifically, commit number f2b8318, or roughly for Ruby 3.1.2. | |
# https://github.com/ruby/optparse | |
# I have added several sections and modified some parts, as well as annotated | |
# the code extensively with my comments. |
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
<head> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> | |
</head> | |
<body> | |
<a href="https://jsfiddle.net/masa_alpin/z1sjekvt/35/">jsfiddle</a> | |
<!-- country-town working with town hidden mostly4 --> | |
<!-- country-town dynamic dropdown menu. Town menu hidden first. It'll appear, but including optgroup country name, with tidied-up code. --> | |
<form action="/persons" accept-charset="UTF-8" method="post"> |
NewerOlder