Skip to content

Instantly share code, notes, and snippets.

@auser
Created January 9, 2009 18:01
Show Gist options
  • Save auser/45199 to your computer and use it in GitHub Desktop.
Save auser/45199 to your computer and use it in GitHub Desktop.
require "rubygems"
class Object
def returning(receiver)
yield receiver
receiver
end
end
module AnotherModule
def say_hello(obj)
puts "Hello from AnotherModule #{obj}"
end
end
class UserFlowsTest# < ActionController::IntegrationTest
def test_user_flow_from_signup_thru_first_trade
new_session do |parent|
hello_from_another_module parent
end
end
def new_session
returning self do |sess|
sess.extend(TestingDSL)
yield sess if block_given?
end
end
private
module TestingDSL
include AnotherModule
extend AnotherModule
def hello_from_another_module(obj)
say_hello obj
end
end
end
t = UserFlowsTest.new
t.new_session
t.test_user_flow_from_signup_thru_first_trade # => "Hello from AnotherModule #<UserFlowsTest:0x314304>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment