Class: RSpec::RailsApp::Artifact::Matchers::HaveArtifacts
- Inherits:
-
RSpec::RubyContentMatcher
- Object
- RSpec::RubyContentMatcher
- RSpec::RailsApp::Artifact::Matchers::HaveArtifacts
- Extended by:
- RailsAssist::UseMacro
- Includes:
- Artifact::Matcher::Helper, ArtifactFile::Matcher::Helper
- Defined in:
- lib/rails_app_spec/matchers/artifact/have_artifacts.rb
Instance Attribute Summary collapse
-
#names ⇒ Object
readonly
Returns the value of attribute names.
Instance Method Summary collapse
-
#initialize(artifact_type, *names) ⇒ HaveArtifacts
constructor
A new instance of HaveArtifacts.
- #matches?(root_path, &block) ⇒ Boolean
Constructor Details
#initialize(artifact_type, *names) ⇒ HaveArtifacts
Returns a new instance of HaveArtifacts.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rails_app_spec/matchers/artifact/have_artifacts.rb', line 13 def initialize(artifact_type, *names) extend "RailsAssist::Artifact::#{artifact_type.to_s.camelize}".constantize @names = names parse_type artifact_type if artifact_type == :view handle_view artifact_type, names else super name end end |
Instance Attribute Details
#names ⇒ Object (readonly)
Returns the value of attribute names.
11 12 13 |
# File 'lib/rails_app_spec/matchers/artifact/have_artifacts.rb', line 11 def names @names end |
Instance Method Details
#matches?(root_path, &block) ⇒ Boolean
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rails_app_spec/matchers/artifact/have_artifacts.rb', line 24 def matches?(root_path, &block) @root_path = root_path begin labels = names.to_strings return false if labels.empty? labels.each do |name| parse_name name @artifact_found = find_artifact @artifact_name = name return false if !artifact_found return false if !File.file? artifact_found # check file content for class or subclass self.content = File.read(artifact_found) res = if artifact_type == :view true else super content end return false if !res end yield if block true rescue nil end end |