Skip to content

Instantly share code, notes, and snippets.

@iamvery
iamvery / spleh
Last active December 25, 2015 12:39
master ● » be rake db:reset && be rspec
PG::ObjectInUse: ERROR: database "test_app_development" is being accessed by other users
DETAIL: There is 1 other session using the database.
: DROP DATABASE IF EXISTS "test_app_development"
/Users/jay/Github/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `exec'
/Users/jay/Github/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `block in execute'
/Users/jay/Github/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:434:in `block in log'
/Users/jay/.rvm/gems/ruby-2.0.0-p195/bundler/gems/rails-25649c7fd742/activesupport/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/Users/jay/Github/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:428:in `log'
/Users/jay/Github/rails/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:127:in `execute'
Loading development environment (Rails 4.0.0)
2.0.0-p247 :001 > email = 'Test@Example.com'
=> "Test@Example.com"
2.0.0-p247 :002 > u = User.new(email: email)
=> #<User id: nil, email: "Test@Example.com", encrypted_password: "", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, created_at: nil, updated_at: nil>
2.0.0-p247 :003 > email
=> "Test@Example.com"
2.0.0-p247 :004 > u.valid?
User Exists (0.1ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = 'test@example.com' LIMIT 1
=> false
Loading development environment (Rails 4.0.0)
2.0.0p247 :001 > email = 'Test@Example.com'
=> "Test@Example.com"
2.0.0p247 :002 > u = User.new(email: email)
=> #<User id: nil, email: "Test@Example.com", encrypted_password: "", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, created_at: nil, updated_at: nil>
2.0.0p247 :003 > email
=> "Test@Example.com"
2.0.0p247 :004 > u.valid?
User Exists (0.2ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = 'test@example.com' LIMIT 1
=> false
diff --git a/test/models/database_authenticatable_test.rb b/test/models/database_authenticatable_test.rb
index d8689ae..7fa0ef3 100644
--- a/test/models/database_authenticatable_test.rb
+++ b/test/models/database_authenticatable_test.rb
@@ -10,7 +10,7 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
assert_equal email, user.email
user.save!
- assert_equal email.downcase, user.email
+ assert_equal email, user.email
=> 1: <% binding.pry %>
[1] pry(#<#<Class:0x007ff5fa2ebe98>>)> t('test_html')
=> "<small>Thing</small>"
[2] pry(#<#<Class:0x007ff5fa2ebe98>>)> _.class
=> ActiveSupport::SafeBuffer
[3] pry(#<#<Class:0x007ff5fa2ebe98>>)> I18n.t('test_html')
=> "<small>Thing</small>"
[4] pry(#<#<Class:0x007ff5fa2ebe98>>)> _.class
=> String
%ul
%li
one
-#%li
two
%li
three
<ul>
<li>
@iamvery
iamvery / translating.txt
Last active December 25, 2015 23:29
Example of difference in `I18n.translate` and the `translate` view helper method
=> 1: - binding.pry
[1] pry(#<#<Class:0x007fbdab47caa0>>)> translate('test.html')
=> "<blink>flashy</blink>"
[2] pry(#<#<Class:0x007fbdab47caa0>>)> _.class
=> ActiveSupport::SafeBuffer
[4] pry(#<#<Class:0x007fbdab47caa0>>)> I18n.translate('test.html')
=> "<blink>flashy</blink>"
[5] pry(#<#<Class:0x007fbdab47caa0>>)> _.class
=> String
@iamvery
iamvery / test.rb
Last active December 26, 2015 05:09
def test1
value = 'done!'
yield
ensure
return(value)
end
def test2
value = 'done!'
yield
class Widget < ActiveRecord::Base
bigger_than_proc = lambda(size=10) do
where('size > ?', size)
end
scope :bigger_than, bigger_than_proc
end
Run options: --seed 56337
# Running tests:
EE
Finished tests in 0.143109s, 13.9754 tests/s, 0.0000 assertions/s.
1) Error:
LocationBasedMetaDataTest#test_joins_with_materials: