Class: RSpec::FileMatchers::GenerateFile
- Inherits:
-
Object
- Object
- RSpec::FileMatchers::GenerateFile
- Defined in:
- lib/rspec_for_generators/matchers/file/generate_file.rb
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.
11 12 13 |
# File 'lib/rspec_for_generators/matchers/file/generate_file.rb', line 11 def initialize(relative_path, type = nil) @relative_path = relative_rails_file relative_path, type end |
Instance Method Details
#failure_message ⇒ Object
27 28 29 |
# File 'lib/rspec_for_generators/matchers/file/generate_file.rb', line 27 def "Expected file #{@relative_path} to have been generated, but it was not" end |
#matches?(generator, &block) ⇒ Boolean
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rspec_for_generators/matchers/file/generate_file.rb', line 15 def matches?(generator, &block) @expected = File.(@relative_path, generator.class.destination_root) ex = File.exists?(@expected) if block && ex read = File.read(@expected) ruby_content = read.extend(RSpec::RubyContent::Helpers) yield ruby_content else ex end end |
#negative_failure_message ⇒ Object
31 32 33 |
# File 'lib/rspec_for_generators/matchers/file/generate_file.rb', line 31 def "Did not expected file #{@relative_path} to have been generated, but it was" end |