Created
March 5, 2009 00:21
-
-
Save technicalpickles/74108 to your computer and use it in GitHub Desktop.
vim syntax highlighting for shoulda using rails.vim. place rails.vim in ~/.vim/macros/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| RAILS_ROOT = 'zomg' | |
| class Logger | |
| def initialize(*args) | |
| end | |
| def info(*args) | |
| end | |
| end | |
| module Rails | |
| def self.logger | |
| Logger.new('zomg') | |
| end | |
| end | |
| require 'ruby-debug' | |
| require 'active_record' | |
| require 'action_controller' | |
| require 'action_view' | |
| require 'action_mailer' | |
| require 'shoulda' | |
| def module_methods(some_module) | |
| some_module.instance_methods.select do |method| | |
| method =~ /^(should|assert)/ | |
| end.join(' ') | |
| end | |
| puts <<-EOL | |
| if RailsFileType() =~# '^test' | |
| syn keyword rubyShouldaKeywords #{module_methods(Shoulda::ClassMethods)} | |
| syn keyword rubyShouldaAsserts #{module_methods(Shoulda::Assertions)} | |
| syn keyword rubyShouldaMacros #{module_methods(Shoulda::Macros)} | |
| syn keyword rubyShouldaActionControllerMacros #{module_methods(Shoulda::ActionController::Macros)} | |
| syn keyword rubyShouldaActionMailerAsserts #{module_methods(Shoulda::ActionMailer::Assertions)} | |
| syn keyword rubyShouldaActionViewMacros #{module_methods(Shoulda::ActionView::Macros)} | |
| syn keyword rubyShouldaActiveRecordAsserts #{module_methods(Shoulda::ActiveRecord::Assertions)} | |
| syn keyword rubyShouldaActiveRecordMacros #{module_methods(Shoulda::ActiveRecord::Macros)} | |
| hi def link rubyShouldaKeywords rubyRailsTestMethod | |
| hi def link rubyShouldaAsserts rubyRailsTestMethod | |
| hi def link rubyShouldaMacros rubyRailsTestMethod | |
| hi def link rubyShouldaActionControllerMacros rubyRailsTestMethod | |
| hi def link rubyShouldaActionMailerAsserts rubyRailsTestMethod | |
| hi def link rubyShouldaActionViewMacros rubyRailsTestMethod | |
| hi def link rubyShouldaActiveRecordAsserts rubyRailsTestMethod | |
| hi def link rubyShouldaActiveRecordMacros rubyRailsTestMethod | |
| endif | |
| EOL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if RailsFileType() =~# '^test' | |
| syn keyword rubyShouldaKeywords should_eventually should | |
| syn keyword rubyShouldaAsserts assert_contains assert_same_elements assert_accepts assert_rejects assert_does_not_contain | |
| syn keyword rubyShouldaMacros should_not_change should_change | |
| syn keyword rubyShouldaActionControllerMacros should_set_the_flash_to should_respond_with_content_type should_assign_to should_render_without_layout should_render_template should_respond_with should_route should_filter_params should_return_from_session should_not_assign_to should_not_set_the_flash should_render_with_layout should_set_session should_redirect_to | |
| syn keyword rubyShouldaActionMailerAsserts assert_sent_email assert_did_not_send_email | |
| syn keyword rubyShouldaActionViewMacros should_render_a_form should_render_page_with_metadata | |
| syn keyword rubyShouldaActiveRecordAsserts assert_valid assert_bad_value assert_save assert_good_value | |
| syn keyword rubyShouldaActiveRecordMacros should_allow_values_for should_validate_numericality_of should_have_index should_protect_attributes should_ensure_length_is should_have_instance_methods should_validate_uniqueness_of should_have_one should_have_named_scope should_have_indices should_not_allow_mass_assignment_of should_have_class_methods should_require_attributes should_ensure_length_in_range should_have_many should_require_acceptance_of should_not_allow_values_for should_have_db_column should_allow_mass_assignment_of should_ensure_length_at_least should_belong_to should_validate_presence_of should_only_allow_numeric_values_for should_validate_acceptance_of should_have_readonly_attributes should_ensure_value_in_range should_have_db_columns should_require_unique_attributes should_have_and_belong_to_many | |
| hi def link rubyShouldaKeywords rubyRailsTestMethod | |
| hi def link rubyShouldaAsserts rubyRailsTestMethod | |
| hi def link rubyShouldaMacros rubyRailsTestMethod | |
| hi def link rubyShouldaActionControllerMacros rubyRailsTestMethod | |
| hi def link rubyShouldaActionMailerAsserts rubyRailsTestMethod | |
| hi def link rubyShouldaActionViewMacros rubyRailsTestMethod | |
| hi def link rubyShouldaActiveRecordAsserts rubyRailsTestMethod | |
| hi def link rubyShouldaActiveRecordMacros rubyRailsTestMethod | |
| endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment