Sha256: e08a935fe7014dc2469a6286c09ec8ddee81a18483d3dd8e86e20e086a92379a
Contents?: true
Size: 1.59 KB
Versions: 3
Compression:
Stored size: 1.59 KB
Contents
# Combines artifact file exist check with class check! module RSpec::RailsApp::Artifact module Matchers class HaveArtifact < RSpec::RubyContentMatcher extend RailsAssist::UseMacro use_helpers :file include Artifact::Matcher::Helper def initialize(name, artifact_type) extend "RailsAssist::Artifact::#{artifact_type.to_s.camelize}".constantize parse_name name parse_type artifact_type super name if artifact_type != :view end def matches?(root_path, &block) @root_path = root_path begin artifact_found = find_artifact return nil if !artifact_found # check file content for class or subclass @content = File.read(artifact_found) if artifact_type == :view yield content if block return true end super content, &block rescue false end end end def have_artifact(relative, type = nil) HaveArtifact.new(relative, type) end alias_method :contain_artifact, :have_artifact (::RailsAssist.artifacts - [:view]).each do |name| class_eval %{ def have_#{name} relative have_artifact relative, :#{name} end alias_method :contain_#{name}, :have_#{name} } end def have_view folder, action=nil, view_ext=nil arg = {:folder => folder, :action => action, :view_ext => view_ext} have_artifact arg, :view end alias_method :contain_view, :have_view end end
Version data entries
3 entries across 3 versions & 1 rubygems