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
| RSpec.configure do |config| | |
| config.before(:suite) do | |
| DatabaseCleaner.clean_with(:truncation) | |
| end | |
| config.before(:each) do | |
| DatabaseCleaner.strategy = :transaction | |
| end | |
| config.before(:each, js: true) 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
| irb --simple-prompt | |
| >> a = [1,2,3] | |
| => [1, 2, 3] | |
| >> a.select {|e| e >= 2} | |
| => [2, 3] | |
| >> a.detect {|e| e >= 2} | |
| => 2 |
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 'active_record' | |
| ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: 'db.sqlite3') | |
| ActiveRecord::Schema.define do | |
| create_table :users, force: true do |t| | |
| end | |
| end | |
| class ActiveRecord::Base |
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 'active_record' | |
| require 'minitest/autorun' | |
| ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: 'db.sqlite3') | |
| ActiveRecord::Schema.define do | |
| create_table :users, force: true do |t| | |
| t.references :company, index: true | |
| 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
| class DeviseCreateUsers < ActiveRecord::Migration | |
| def migrate(direction) | |
| super | |
| # Create a default user | |
| User.create!(email: 'admin@example.com', password: 'password', password_confirmation: 'password') if direction == :up | |
| end | |
| def change | |
| create_table(:users) do |t| | |
| ## Database authenticatable |
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 'minitest/autorun' | |
| BOOLEAN_MAPPINGS = { | |
| 'true' => true, | |
| 'false' => false | |
| } | |
| def typecast_hash_values(hash) | |
| hash.each do |k, old_value| | |
| if (new_value = BOOLEAN_MAPPINGS.fetch(old_value, old_value)) != old_value |
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
| /usr/local/opt/rbenv/versions/2.1.0/lib/ruby/2.1.0/bigdecimal/util.rb:18: [BUG] Segmentation fault at 0x00000000000000 | ETA: 00:04:13 | |
| ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin13.0] | |
| -- Crash Report log information -------------------------------------------- | |
| See Crash Report log file under the one of following: | |
| * ~/Library/Logs/CrashReporter | |
| * /Library/Logs/CrashReporter | |
| * ~/Library/Logs/DiagnosticReports | |
| * /Library/Logs/DiagnosticReports | |
| for more details. |
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
| STEP_DECORATORS_MAPPING = { | |
| step1: Decorator1, | |
| step2: Decorator2 | |
| } | |
| step = :step1 | |
| STEP_DECORATORS_MAPPING[step].new(...) |
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
| x = '123' | |
| x[0, x.length] = 'aa' # x.replace('aa') |
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
| RSpec.configure do |config| | |
| config.before do | |
| Category.subclasses.each do |c| | |
| c.instance_variable_set(:@instance, nil) | |
| end | |
| Category.instance_variable_set(:@instances, nil) | |
| end | |
| end |
OlderNewer