Skip to content

Instantly share code, notes, and snippets.

@jasiek
Forked from LTe/gist:1710563
Created January 31, 2012 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasiek/1711082 to your computer and use it in GitHub Desktop.
Save jasiek/1711082 to your computer and use it in GitHub Desktop.
module M
def method
puts "hello"
end
end
def execute(current_module, &block)
Object.new.tap do |o|
o.extend(current_module)
o.instance_eval &block
end
end
execute(M) do
method
end
# moj case
RSpec::Matchers.define :set_has_subscribed_cookie do
include CookieSupport
match do |response|
parse_response_cookies(response).find do |cookie|
cookie[:name] == 'has_subscribed' && \
# 1 day should be more than enough tolerance.
Time.parse(cookie[:expires]) - Time.now <= 1.year + 1.day
end
end
failure_message_for_should do
"Should set a 'has_subscribed' cookie but doesn't"
end
failure_message_for_should_not do
"Should not set a 'has_subscribed' cookie but does"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment