ActiveModel::Attributes APIの attribute
メソッドを使用して値のcastを行う場合に、shoulda-matchersが提供するマッチャを使ってバリデーションのテストを行おうとすると
意図しない挙動によってテストが落ちてしまう。
class SampleForm
include ActiveModel::Model
include ActiveModel::Attributes
// index.js | |
const { App } = require('@slack/bolt') | |
const app = new App({ | |
token: process.env.SLACK_BOT_TOKEN, | |
signingSecret: process.env.SLACK_SIGNING_SECRET, | |
}) | |
exports.notifySlack = async (req, res) => { | |
const data = JSON.parse(Buffer.from(req.body['message']['data'], 'base64').toString()) |
[29] pry(main)> def monitor | |
[29] pry(main)* time = 0 | |
[29] pry(main)* loop do | |
[29] pry(main)* puts "#{time} 秒経ちました" | |
[29] pry(main)* unless Sidekiq::ProcessSet.new.first.present? | |
[29] pry(main)* puts 'heartbeatが揮発しました' | |
[29] pry(main)* break | |
[29] pry(main)* end | |
[29] pry(main)* puts Sidekiq::ProcessSet.new.first.inspect | |
[29] pry(main)* sleep 10 |
class Incrementer | |
@@class_variable = 0 | |
def self.call | |
@class_instance_variable = 0 | |
new.call | |
@class_instance_variable += 1 | |
puts 'class_instace_variable' | |
puts @class_instance_variable |
require 'pry-byebug' | |
# メソッドの引数の型を説明するコメントのフォーマットを揃えるためのスクリプト | |
# 下記のフォーマットに整形する | |
# `# @param param_name [type] description` | |
# rubyのファイルのみを対象にする | |
under_app_dir_filenames = Dir.glob('./app/*/**/**.rb') | |
under_app_dir_filenames.each do |name| |
require 'bundler/inline' | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'selenium-webdriver' | |
gem 'pry-byebug' | |
end | |
class Driver | |
require "selenium-webdriver" |
NameError: undefined local variable or method `view_context' for #<TestController:0x00007fd232cc0f40> | |
Did you mean? view_runtime> with backtrace: | |
# ./.bundle/gems/active_decorator-1.3.0/lib/active_decorator/monkey/action_controller/base/rescue_from.rb:10:in `rescue_with_handler' | |
# ./.bundle/gems/actionpack-5.2.3/lib/action_controller/metal/rescue.rb:25:in `rescue in process_action' | |
# ./.bundle/gems/actionpack-5.2.3/lib/action_controller/metal/rescue.rb:21:in `process_action' | |
# ./.bundle/gems/actionpack-5.2.3/lib/action_controller/metal/instrumentation.rb:34:in `block in process_action' | |
# ./.bundle/gems/activesupport-5.2.3/lib/active_support/notifications.rb:168:in `block in instrument' | |
# ./.bundle/gems/activesupport-5.2.3/lib/active_support/notifications/instrumenter.rb:23:in `instrument' | |
# ./.bundle/gems/activesupport-5.2.3/lib/active_support/notifications.rb:168:in `instrument' | |
# ./.bundle/gems/actionpack-5.2.3/lib/action_controller/metal/instrumentation.rb:32:in `process_action' |
class HogesController | |
before_action :set_hoge | |
before_action :redirect_to_home_path_if_request_invalid | |
def create | |
if @hoge.save(hoge_params) | |
# ok | |
else | |
render :new | |
end |
begin | |
require 'bundler/inline' | |
rescue LoadError | |
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler' | |
raise | |
end | |
gemfile(true) do | |
source 'https://rubygems.org' |