Class: RSpec::RailsApp::File::Matchers::HaveRailsFile
- Inherits:
-
Object
- Object
- RSpec::RailsApp::File::Matchers::HaveRailsFile
- Includes:
- Rails::Assist::App, Rails::Assist::BaseHelper::FileName, Rails::Assist::Migration::FileName, Rails::Migration::Assist::ClassMethods
- Defined in:
- lib/rails_app_spec/matchers/file/have_rails_file.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#artifact_name ⇒ Object
Returns the value of attribute artifact_name.
-
#artifact_type ⇒ Object
Returns the value of attribute artifact_type.
-
#folder ⇒ Object
Returns the value of attribute folder.
-
#name ⇒ Object
Returns the value of attribute name.
-
#view_ext ⇒ Object
Returns the value of attribute view_ext.
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(name, artifact_type = nil) ⇒ HaveRailsFile
constructor
A new instance of HaveRailsFile.
- #matches?(generator, &block) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(name, artifact_type = nil) ⇒ HaveRailsFile
Returns a new instance of HaveRailsFile.
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rails_app_spec/matchers/file/have_rails_file.rb', line 14 def initialize(name, artifact_type = nil) self.artifact_type = artifact_type 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.
12 13 14 |
# File 'lib/rails_app_spec/matchers/file/have_rails_file.rb', line 12 def action @action end |
#artifact_name ⇒ Object
Returns the value of attribute artifact_name.
10 11 12 |
# File 'lib/rails_app_spec/matchers/file/have_rails_file.rb', line 10 def artifact_name @artifact_name end |
#artifact_type ⇒ Object
Returns the value of attribute artifact_type.
10 11 12 |
# File 'lib/rails_app_spec/matchers/file/have_rails_file.rb', line 10 def artifact_type @artifact_type end |
#folder ⇒ Object
Returns the value of attribute folder.
12 13 14 |
# File 'lib/rails_app_spec/matchers/file/have_rails_file.rb', line 12 def folder @folder end |
#name ⇒ Object
Returns the value of attribute name.
10 11 12 |
# File 'lib/rails_app_spec/matchers/file/have_rails_file.rb', line 10 def name @name end |
#view_ext ⇒ Object
Returns the value of attribute view_ext.
12 13 14 |
# File 'lib/rails_app_spec/matchers/file/have_rails_file.rb', line 12 def view_ext @view_ext end |
Instance Method Details
#failure_message ⇒ Object
46 47 48 |
# File 'lib/rails_app_spec/matchers/file/have_rails_file.rb', line 46 def "Expected the #{artifact_type} #{artifact_name} to exist, but it didn't" end |
#matches?(generator, &block) ⇒ Boolean
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rails_app_spec/matchers/file/have_rails_file.rb', line 28 def matches?(generator, &block) self.artifact_name = case artifact_type when :view File.(send :"#{artifact_type}_file_name", folder, action, view_ext) else found_file = send :existing_file_name, artifact_name, artifact_type if respond_to? :existing_file_name # send :"#{artifact_type}_file_name", artifact_name 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
50 51 52 |
# File 'lib/rails_app_spec/matchers/file/have_rails_file.rb', line 50 def "Did not expect the #{artifact_type} #{artifact_name} to exist, but it did" end |