Skip to content

Instantly share code, notes, and snippets.

test
snippet
Sorter::DiligenceSearch testing the entire stack should return all search results sorted
Failure/Error: sorter.sort.should == [SearchIndex.first]
expected: [#<SearchIndex id: 60, city_hall_id: nil, institution_id: nil, searchable_id: 51, searchable_type: "City", name: "city", model_weight: 1, rank_a: "sao paulo", rank_b: "sp", rank_c: nil, created_at: "2013-02-06 16:53:17", updated_at: "2013-02-06 16:53:17", active: nil, branch_id: nil>]
got: [#<SearchIndex id: 72, city_hall_id: 1, institution_id: 1, searchable_id: 1, searchable_type: "Diligence", name: "diligencia", model_weight: 1, rank_a: "1 00000001 guia g 00000001 10/2011 nao recolhimento...", rank_b: "filial centro 74215432000318 74.215.432/0003-18 000...", rank_c: "problema de pagamento de guia", created_at: "2013-02-06 16:54:02", updated_at: "2013-02-06 16:54:02", active: true, branch_id: 1>] (using ==)
Diff:
@@ -1,2 +1,2 @@
-[#<SearchIndex id: 60, city_hall_id: nil, institution_id: nil, searchable_id: 51,
Associations
should belong to diligence (FAILED - 1)
should belong to issqn_monthly_survey (FAILED - 2)
should have many fiscal_action_problems (FAILED - 3)
should have many fiscal_actions (FAILED - 4)
Validations
Failures:
1) ProblemIssqnMonthlySurvey Validations
# model/order.rb
class Order
def items_format_type
items.group_by{ |order_item| order_item.item.format.type }.keys
end
end
# lib/order_resource.rb
class OrderResource
class OrdersController < ApplicationController
def confirm
order = OrderResource.confirm(params)
redirect_to payment_on_external_service_url(order.number)
end
end
class Order
def final_message
if items.any?{ |item| item == :paper }
@marcomoura
marcomoura / spec_examples.rb
Created January 27, 2012 15:05 — forked from endeepak/spec_examples.rb
rspec-best-practices-and-tips
#http://eggsonbread.com/2010/03/28/my-rspec-best-practices-and-tips/
describe User do
subject { user }
let(:user) { User.new }
context "when name empty" do
it { should_not be_valid }
specify { user.save.should be_false }
end
@marcomoura
marcomoura / poker.feature
Created December 15, 2010 15:25
poker.feature
# language: pt
# features/poker.feature
Funcionalidade: Detectar jogada de Poker
Para jogar poker
E com um baralho com um naipe apenas
Como um jogador
Eu quero ver as possíveis combinações
Cenario: Royal flush
# lib/game.rb
class Game
def initialize()
@royal_flush = %w(dez valete dama reis as)
@straight_flush = %w(quatro cinco seis sete oito)
end
def cards(*card)
@marcomoura
marcomoura / dicionario.feature
Created December 1, 2010 12:42
Kata feito no CodingDojo na CN usando Ruby+BDD
# language: pt
# features/dicionario.feature
# @author Marco Moura <email at marcomoura.com>
# @author Luciana Mendes <super.luci at gmail.com>
# @author Rafael Salomao <rafaelgavazzi at gmail.com>
# @author Patricia Carvalho <patfcarv at gmail.com>
# @author Carlos Eduardo <kaddxxi at gmail.com>
Funcionalidade: Dicionary Replace
#@author Rafael Salomao <rafaelgavazzi at gmail.com>
#@author Natalia Marcondes < natalia.marcondes at gmail.com>
#@author Marco Moura <email at marcomoura.com>
#@author Luciana Mendes <super.luci at gmail.com>
#@author Carlos Eduardo <kaddxxi at gmail.com>
#@author Patricia Carvalho <patfcarv at gmail.com>
class Dinostratus:
@staticmethod