Skip to content

Instantly share code, notes, and snippets.

View lucashungaro's full-sized avatar

Lucas Húngaro lucashungaro

View GitHub Profile

Keybase proof

I hereby claim:

  • I am lucashungaro on github.
  • I am lucashungaro (https://keybase.io/lucashungaro) on keybase.
  • I have a public key whose fingerprint is DBDB D15C 2767 6225 056B 63AC 956A BAD9 2CFE 2097

To claim this, I am signing this object:

@lucashungaro
lucashungaro / gist:06d1add1f39a57e05837
Created April 21, 2015 12:34
Microservices, RabbitMQ etc
https://speakerdeck.com/joshsz/rack-amqp-ditch-http-inside-soa
http://blog.carbonfive.com/2014/04/28/micromessaging-connecting-heroku-microservices-wredis-and-rabbitmq/
https://www.rabbitmq.com/tutorials/tutorial-six-ruby.html
http://highscalability.com/blog/2014/4/8/microservices-not-a-free-lunch.html
https://www.youtube.com/watch?v=vfs4sr1_o6s (Global Scaling at The New York Times Using RabbitMQ (from OSCON 2014))
context "a movie shelf" do
setup { @shelf = MovieShelf.new }
should "let the user store a movie" do
juno = Movie.new("Juno")
shelf.store juno
assert shelf.contains?(juno)
end
end
class Movie
attr_accessor :title
def initialize(title)
self.title = title
end
end
class MovieShelf
def initialize
class MovieShelf
def initialize
@movies = []
end
def store(movie)
@movies << movie
end
def contains?(movie)
it "should be successful" do
Account.expects(:new).with(:current_user => @user, :first_name => "Test", :last_name => "Test").returns(@account)
@account.expects(:login_method=).with(CONFIG::LOGIN::OpenID)
@account.expects(:has_email_and_password=).at_least_once
@account.expects(:has_openid=).twice
do_edit
response.should be_success
response.should render_template("edit")
end
it "has been modified a lot of times" do
Dependency.stubs(:a_method)
NoLongerADependency.stubs(:something).returns(false)
AnotherDependency.stubs(:nonexistent_method).returns(10)
MyClass.new.do_something
end
Mocha::Configuration.prevent(:stubbing_non_existent_method) #prevents stubbing of non-existent methods
Mocha::Configuration.prevent(:stubbing_method_unnecessarily) #prevents stubbing of unused methods
Mocha::Configuration.prevent(:stubbing_non_public_method) #prevents stubbing of non-public methods
Mocha::Configuration.prevent(:stubbing_method_on_non_mock_object) #prevents stubbing on concrete objects
# default - allows the condition
Mocha::Configuration.allow(condition)
# just emits a warning when the condition occurs
Mocha::Configuration.warn_when(condition)
# throws and error when the condition occurs
Mocha::Configuration.prevent(condition)