Skip to content

Commit

Permalink
RSpec 2 and 3 have the same message format on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Yurek committed Apr 30, 2015
1 parent 65b7776 commit afbb3af
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions spec/support/matchers/have_column.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@
column && column.default.to_s == @default.to_s
end

if RSpec::Version::STRING.to_i >= 3
failure_message do |columns|
"expected to find '#{column_name}', " +
"default '#{@default}' " +
"in #{columns.map { |column| [column.name, column.default] }}"
end
else
failure_message_for_should do |columns|
"expected to find '#{column_name}', " +
"default '#{@default}' " +
"in #{columns.map { |column| [column.name, column.default] }}"
failure_message_method =
if RSpec::Version::STRING.to_i >= 3
:failure_message
else
:failure_message_for_should
end

send(failure_message_method) do |columns|
"expected to find '#{column_name}', " +
"default '#{@default}' " +
"in #{columns.map { |column| [column.name, column.default] }}"
end
end

0 comments on commit afbb3af

Please sign in to comment.