Class: RSpec::RailsApp::Artifact::Matchers::HaveArtifact
- Inherits:
-
RSpec::RubyContentMatcher
- Object
- RSpec::RubyContentMatcher
- RSpec::RailsApp::Artifact::Matchers::HaveArtifact
- Extended by:
- RailsAssist::UseMacro
- Includes:
- Artifact::Matcher::Helper
- Defined in:
- lib/rails_app_spec/matchers/artifact/have_artifact.rb
Instance Method Summary collapse
-
#initialize(name, artifact_type) ⇒ HaveArtifact
constructor
A new instance of HaveArtifact.
- #matches?(root_path, &block) ⇒ Boolean
Constructor Details
#initialize(name, artifact_type) ⇒ HaveArtifact
Returns a new instance of HaveArtifact.
11 12 13 14 15 16 17 |
# File 'lib/rails_app_spec/matchers/artifact/have_artifact.rb', line 11 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 |
Instance Method Details
#matches?(root_path, &block) ⇒ Boolean
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rails_app_spec/matchers/artifact/have_artifact.rb', line 19 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 |