From f114485e22c17239f3d7be06eb3bc1abffbbfe4b Mon Sep 17 00:00:00 2001 From: Zog Date: Tue, 23 Jan 2018 13:35:26 +0100 Subject: Refs #5669 @1h; Set invariant values in the snapshots --- spec/support/snapshot_support.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'spec/support') diff --git a/spec/support/snapshot_support.rb b/spec/support/snapshot_support.rb index c37bb075c..b1ade5288 100644 --- a/spec/support/snapshot_support.rb +++ b/spec/support/snapshot_support.rb @@ -1,3 +1,27 @@ +module SnaphostSpecHelper + + module Methods + def set_invariant expr, val=nil + val ||= expr + chain = expr.split(".") + method = chain.pop + + before(:each) do + allow(eval(chain.join('.'))).to receive(method){ val } + end + end + end + + def self.included into + into.extend Methods + end +end + +RSpec.configure do |config| + config.include SnaphostSpecHelper, type: :view +end + + RSpec::Matchers.define :match_actions_links_snapshot do |name| match do |actual| @content = Capybara::Node::Simple.new(rendered).find('.page_header').native.inner_html -- cgit v1.2.3