-
-
Save jasiek/1711082 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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