Class: RSpec::RailsApp::ArtifactFile::Matchers::HaveRailsArtifactFile
- Inherits:
-
Object
- Object
- RSpec::RailsApp::ArtifactFile::Matchers::HaveRailsArtifactFile
- Includes:
- Rails3::Assist::Artifact::FileName
- Defined in:
- lib/rails_app_spec/matchers/artifact/have_rails_artifact_file.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#artifact_name ⇒ Object
include ::Rails::Assist::Migration::FileName.
-
#artifact_type ⇒ Object
include ::Rails::Assist::Migration::FileName.
-
#folder ⇒ Object
Returns the value of attribute folder.
-
#name ⇒ Object
include ::Rails::Assist::Migration::FileName.
-
#view_ext ⇒ Object
Returns the value of attribute view_ext.
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(name, artifact_type = nil) ⇒ HaveRailsArtifactFile
constructor
A new instance of HaveRailsArtifactFile.
- #matches?(root_path, &block) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(name, artifact_type = nil) ⇒ HaveRailsArtifactFile
Returns a new instance of HaveRailsArtifactFile.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rails_app_spec/matchers/artifact/have_rails_artifact_file.rb', line 13 def initialize(name, artifact_type = nil) self.artifact_type = artifact_type extend "Rails3::Assist::Artifact::#{artifact_type.to_s.camelize}".constantize if name.kind_of? Hash = name self.folder = [:folder] self.action = [:action] self.view_ext = [:view_ext] self.artifact_type = :view return nil end self.artifact_name = name.to_s end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
11 12 13 |
# File 'lib/rails_app_spec/matchers/artifact/have_rails_artifact_file.rb', line 11 def action @action end |
#artifact_name ⇒ Object
include ::Rails::Assist::Migration::FileName
9 10 11 |
# File 'lib/rails_app_spec/matchers/artifact/have_rails_artifact_file.rb', line 9 def artifact_name @artifact_name end |
#artifact_type ⇒ Object
include ::Rails::Assist::Migration::FileName
9 10 11 |
# File 'lib/rails_app_spec/matchers/artifact/have_rails_artifact_file.rb', line 9 def artifact_type @artifact_type end |
#folder ⇒ Object
Returns the value of attribute folder.
11 12 13 |
# File 'lib/rails_app_spec/matchers/artifact/have_rails_artifact_file.rb', line 11 def folder @folder end |
#name ⇒ Object
include ::Rails::Assist::Migration::FileName
9 10 11 |
# File 'lib/rails_app_spec/matchers/artifact/have_rails_artifact_file.rb', line 9 def name @name end |
#view_ext ⇒ Object
Returns the value of attribute view_ext.
11 12 13 |
# File 'lib/rails_app_spec/matchers/artifact/have_rails_artifact_file.rb', line 11 def view_ext @view_ext end |
Instance Method Details
#failure_message ⇒ Object
52 53 54 |
# File 'lib/rails_app_spec/matchers/artifact/have_rails_artifact_file.rb', line 52 def "Expected the #{artifact_type} #{artifact_name} to exist, but it didn't" end |
#matches?(root_path, &block) ⇒ Boolean
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rails_app_spec/matchers/artifact/have_rails_artifact_file.rb', line 29 def matches?(root_path, &block) self.artifact_name = case artifact_type when :view find_view_method = "#{artifact_type}_file_name" File.(send find_view_method, folder, action, view_ext, :root_path => root_path) else find_existing_artifact_method = "existing_#{artifact_type}_file" if respond_to? find_existing_artifact_method send find_existing_artifact_method, artifact_name, artifact_type, :root_path => root_path else raise "The method ##{find_existing_artifact_method} to find the artifact was not available" end end # puts "artifact_name: #{artifact_name}" match = File.file? artifact_name if block && match yield File.read(artifact_name) end match end |
#negative_failure_message ⇒ Object
56 57 58 |
# File 'lib/rails_app_spec/matchers/artifact/have_rails_artifact_file.rb', line 56 def "Did not expect the #{artifact_type} #{artifact_name} to exist, but it did" end |