Ruby/Rails/Rspec keywords
Rspec
- xdescribe
- shared_examples
- expect { }.to raise_error
- it_behaves_like
- create_list
- raise_error
- expect_any_instance_of
- have_key
- be_nil
- be_successful
- include
- shared_context
Rake
- task
- TaskArguments.new
- Task[].execute
Rails
- ”«-SQL” block
- around_action/before_action
ActiveRecord
- .connection.execute
- .update!
- .find_by
- .pluck
Ruby
- raise/rescue
- .to_i
- .uniq
- .present?
- .nil?
- .blank?
- .to_h
- .deep_symbolize_keys
- .map(&:func)
- .map(&:to_sym)
- .merge
- .with_indifferent_access
def print_phrase(&block)
block.call
end
# the methods in ruby can take only one block
print_phrase { puts "Hello from block!" }
def print_phrase(amount, &block)
amount.times.each do |x|
yield
end
end
def print_phrase
puts yield
end
print_phrase { "Example phrase" }