Skip to content

Instantly share code, notes, and snippets.

View romanlehnert's full-sized avatar

Roman Lehnert romanlehnert

  • Munich, Germany
View GitHub Profile
@romanlehnert
romanlehnert / test.rb
Created April 13, 2016 10:10
Wrong reference of embedded document at after_save cb
require 'mongoid'
require 'rspec'
Mongoid.configure.connect_to('mongoid_test')
class Syncer
def self.perform(address); end
end
class Customer
@romanlehnert
romanlehnert / credit_transfers.rb
Last active October 20, 2015 08:47
Receive transactions
Bankster::Client.credit_transfer(
bic: "HYVEDEMM417",
iban: "DE83763123456780253100",
name: "Max Mustermann",
purpose: "Miete",
amount: 3700,
currency: "EUR",
eref: "my-end-to-end-id"
)
@romanlehnert
romanlehnert / json.snippets
Last active August 29, 2015 14:23
json schema snippets for vim (utilizing snipmate)
snippet khv
"${1}": {
${2}
}
snippet kv
"${1}": "${2}"
snippet s
"${1}": {
module Attributify
def attributify(key, unprocessed=params[key])
if unprocessed.is_a? Hash
specific_params = {}
unprocessed.each do |k,v|
if (v.is_a?(Hash) && !k.to_s.match(/_attributes$/)) or (v.is_a?(Array) && !k.to_s.match(/_ids$/))
# Nested, so suffix with '_attributes'
specific_params["#{k}_attributes".to_sym] = attributify(key, v)
@romanlehnert
romanlehnert / gist:b9b8584abf766b28c844
Last active August 29, 2015 14:16
Matcher pattern
invoice = Invoice.last
invoice.load_order_matches.with_score_gt(70) # <= LoadOrderMatchesCollection
best_match = invoice.load_order_matches.best # <= LoadOrderMatch
best_match.score # <= 97
best_match.invoice # <= Invoice
best_match.load_order # <= LoadOrder
best_match.similarities # <= [ amount: 500 ]
class Invoice
extend Matchability
@romanlehnert
romanlehnert / gist:eab4eb8658b7334d4003
Created February 17, 2015 11:50
make capybara wait for text to disappear
# have_content calls has_content? that is aliased by has_text?
#
# It checks, if the page has the text. when the text is not present,
# it waits until the capybara timout to let the text appear.
#
# When our frontendcode should remove the content muffins, we could
# test it like this way:
it 'does not have content xyz after clicking the magic button' do
find('a.magic_button').click
1.upto(100) do |i|
if i % 5 == 0 and i % 3 == 0
puts "FizzBuzz"
elsif i % 5 == 0
puts "Buzz"
elsif i % 3 == 0
puts "Fizz"
else
puts i
end
@romanlehnert
romanlehnert / phrase.rb
Created June 10, 2014 08:31
Phrase exclusion and skipping of verification
# This is part of a "locale" model, we use.
#
# @name contains the handle of the locale, e.g. "de-AT", or "da-DK".
# this way, we exclude a key in phrase. It works perfect.
def exclude_key_in_phrase(key)
HTTParty.post('https://phraseapp.com/api/v1/translations/store.json',
query: {
auth_token: Phrase.auth_token,
def self.with_latest_document
joins(" INNER JOIN
contract_documents AS joined_contract_documents
ON contracts.id = joined_contract_documents.contract_id
INNER JOIN
(
SELECT max(created_at) AS created_at, contract_id, id, status
FROM contract_documents
WHERE status IN ('uploaded', 'approved')
GROUP BY contract_id

Goals of a bug report

The single goal of a bug report is to fix the bug. Chances for that are higher, when the report is clear, reproduceable and follows a fixed structure. Keep in mind, that not only developers need to understand a bug, but also the product owner and testers who may not have such a deep technical knowhow. Customers and other stakeholders have to talk about the bug. A software tester has to be able to reproduce it, and a developer is in charge to fix it. The following description is a "best practice" for reporting a bug.

Contents of a bug report

  1. Title
  2. Steps to reproduce
  3. Current result
  4. Expected result
  5. Environment