Created
July 11, 2011 18:45
-
-
Save MarkBennett/1076500 to your computer and use it in GitHub Desktop.
RSpec matcher for table indexes
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
| # Playlist.should be_indexed_on([:name]) | |
| RSpec::Matchers.define :be_indexed_on do |expected| | |
| match do |actual| | |
| indexes = ActiveRecord::Base.connection.indexes(actual.table_name) | |
| expected.map!(&:to_s) | |
| indexes.map { |index| index.columns.map(&:to_s) }.include?(expected) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment