Skip to content

Instantly share code, notes, and snippets.

@iiwo
Created August 23, 2019 22:59
Show Gist options
  • Save iiwo/6eccfc417adb0509595f9d2c4db6427f to your computer and use it in GitHub Desktop.
Save iiwo/6eccfc417adb0509595f9d2c4db6427f to your computer and use it in GitHub Desktop.
rails_5_1.rb
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem 'rails', '~> 5.1.7'
gem "sqlite3"
end
require "active_record"
require "minitest/autorun"
require "logger"
# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
create_table :utility_statements, force: true do |t|
t.integer :kwh
end
end
class UtilityStatement < ActiveRecord::Base
validates :kwh, numericality: { greater_than_or_equal_to: 0, only_integer: true }
end
class BugTest < Minitest::Test
def test_association_stuff
statement = UtilityStatement.new(kwh: 123.0)
assert_equal statement.valid?, true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment