Class: RSpec::FileMatchers::GenerateMigration
- Inherits:
-
Object
- Object
- RSpec::FileMatchers::GenerateMigration
- Includes:
- Rails::Migration
- Defined in:
- lib/rspec_for_generators/matchers/file/generate_migration.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(name) ⇒ GenerateMigration
constructor
A new instance of GenerateMigration.
- #matches?(generator) ⇒ Boolean
- #negative_failure_message ⇒ Object
Methods included from Rails::Migration
#create_migration, #remove_migration, #remove_migrations
Methods included from Rails::App::Dirs
#app_dir, #config_dir, #controller_dir, #db_dir, #helper_dir, #initializer_dir, #javascript_dir, #locale_dir, #migration_dir, #model_dir, #stylesheet_dir, #view_dir
Constructor Details
#initialize(name) ⇒ GenerateMigration
Returns a new instance of GenerateMigration.
15 16 17 |
# File 'lib/rspec_for_generators/matchers/file/generate_migration.rb', line 15 def initialize(name) @name = name.to_s end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'lib/rspec_for_generators/matchers/file/generate_migration.rb', line 13 def name @name end |
Instance Method Details
#failure_message ⇒ Object
30 31 32 |
# File 'lib/rspec_for_generators/matchers/file/generate_migration.rb', line 30 def "Expected migration #{name} to have been generated, but it was not" end |
#matches?(generator) ⇒ Boolean
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rspec_for_generators/matchers/file/generate_migration.rb', line 19 def matches?(generator) expected = migration_file_name(name, generator) if block_given? && expected read = File.read(expected) ruby_content = read.extend(RSpec::RubyContent::Helpers) yield ruby_content else expected end end |
#negative_failure_message ⇒ Object
34 35 36 |
# File 'lib/rspec_for_generators/matchers/file/generate_migration.rb', line 34 def "Did not expect migration #{name} to have been generated, but it was" end |