Skip to content

Instantly share code, notes, and snippets.

View windock's full-sized avatar

Andrew Shcheglov windock

View GitHub Profile
@jasonrudolph
jasonrudolph / about.md
Last active May 14, 2024 16:36
Programming Achievements: How to Level Up as a Developer
@tooky
tooky / card_creator.rb
Created July 6, 2012 20:52 — forked from gma/card_creator.rb
Moving response callbacks out of controller
class CardCreator < Struct.new(:listener)
def create(iteration, attributes)
card = iteration.cards.build(attributes)
if card.save
listener.created(card)
else
listener.create_failed(card)
end
end
end
@codenamev
codenamev / rspec_table_helpers.rb
Last active April 26, 2016 12:19
RSpec helper and Cucumber step to match table rows with Capybara
# Thanks to Henning Koch: https://makandracards.com/makandra/763-cucumber-step-to-match-table-rows-with-capybara
module ArrayMethods
def find_row(expected_row)
find_index do |row|
expected_row.all? do |expected_column|
first_column = row.find_index do |column|
content = column.content.gsub(/[\r\n\t]+/, ' ').gsub(/[ ]+/, ' ').strip
expected_content = expected_column.gsub(' ', ' ').strip
matching_parts = expected_content.split('*', -1).collect { |part| Regexp.escape(part) }
matching_expression = /\A#{matching_parts.join(".*")}\z/