Skip to content

Instantly share code, notes, and snippets.

@adzap
adzap / gist:7229
Created August 26, 2008 07:13 — forked from topfunky/gist:7224
/´¯/)
,/¯ /
/ /´¯/'¯¯'/´¯¯¯`·¸
/ / / / /¨¯\
('( ´ ´ ¯~/' ')
\ ' /
'' \ _ ·´
\ (
\ \
@adzap
adzap / valid.rb
Created October 11, 2012 05:12 — forked from notahat/valid.rb
Testing fail?
# I have a class that delegates functionality to a couple of objects that it
# constructs. I want to test this in isolation. I want to make sure that the
# objects are constructed with the right arguments. I also want to make sure
# that the results from the objects are handled correctly.
#
# I'm finding it hard to structure the code and test in a way that isn't
# cumbersome. What's below works, but it feels like a lot of stubbing and setup
# for something the should be simpler.
#
# Anyone got a better approach for this?
@adzap
adzap / valid.rb
Created October 11, 2012 05:25 — forked from notahat/valid.rb
Testing fail?
# I have a class that delegates functionality to a couple of objects that it
# constructs. I want to test this in isolation. I want to make sure that the
# objects are constructed with the right arguments. I also want to make sure
# that the results from the objects are handled correctly.
#
# I'm finding it hard to structure the code and test in a way that isn't
# cumbersome. What's below works, but it feels like a lot of stubbing and setup
# for something the should be simpler.
#
# Anyone got a better approach for this?
@adzap
adzap / valid.rb
Created October 12, 2012 00:39 — forked from cmaitchison/valid.rb
Testing fail?
# By leaning hard on the declarative nature of let(), you get to use
# a pattern where there is a single shared example whose
# expected result is defined at a lower level in the code.
# It is not really a pattern that is intuitive to everyone when
# they read this sort of code for the first time, so I am not about
# to claim it is better than other approaches, only different.
# There is no need for explicit tests to assert that the correct
# arguments are passed to the validators in this example, because
# if the arguments are not correct the doubles will not return the