Class: RSpec::FileMatchers::GenerateFile
- Inherits:
-
Object
- Object
- RSpec::FileMatchers::GenerateFile
- Defined in:
- lib/rspec_for_generators/matchers/file/generate_file.rb
Instance Attribute Summary collapse
-
#relative_path ⇒ Object
Returns the value of attribute relative_path.
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(relative_path, type = nil) ⇒ GenerateFile
constructor
A new instance of GenerateFile.
- #matches?(generator, &block) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(relative_path, type = nil) ⇒ GenerateFile
Returns a new instance of GenerateFile.
12 13 14 |
# File 'lib/rspec_for_generators/matchers/file/generate_file.rb', line 12 def initialize(relative_path, type = nil) @relative_path = relative_rails_file(relative_path, type) end |
Instance Attribute Details
#relative_path ⇒ Object
Returns the value of attribute relative_path.
10 11 12 |
# File 'lib/rspec_for_generators/matchers/file/generate_file.rb', line 10 def relative_path @relative_path end |
Instance Method Details
#failure_message ⇒ Object
28 29 30 |
# File 'lib/rspec_for_generators/matchers/file/generate_file.rb', line 28 def "Expected file #{relative_path} to have been generated, but it was not" end |
#matches?(generator, &block) ⇒ Boolean
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rspec_for_generators/matchers/file/generate_file.rb', line 16 def matches?(generator, &block) file = File.(relative_path, generator.class.destination_root) file_exists = File.exists?(file) if block && file_exists read = File.read(file) ruby_content = read.extend(RSpec::RubyContent::Helpers) yield ruby_content else file_exists end end |
#negative_failure_message ⇒ Object
32 33 34 |
# File 'lib/rspec_for_generators/matchers/file/generate_file.rb', line 32 def "Did not expected file #{relative_path} to have been generated, but it was" end |