Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
Update history
Browse files Browse the repository at this point in the history
- also split out module declarations in ar_be_valid
  for consistency.
  • Loading branch information
dchelimsky committed Jan 12, 2010
1 parent b3f9b23 commit 9446fef
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 18 deletions.
6 changes: 6 additions & 0 deletions History.rdoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
=== Version 1.3.1 / 2010-01-12

* bug fix
* ensure that Spec::Rails module is defined (Jack Chen and Ryan Bigg).
Closes #939.

=== Version 1.3.0 / 2010-01-11

* enhancements
Expand Down
4 changes: 1 addition & 3 deletions lib/spec/rails/matchers.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
dir = File.dirname(__FILE__)

module Spec
module Rails
# Spec::Rails::Expectations::Matchers provides several expectation matchers
Expand Down Expand Up @@ -31,4 +29,4 @@ module Matchers
require 'spec/rails/matchers/include_text'
require 'spec/rails/matchers/redirect_to'
require 'spec/rails/matchers/route_to'
require 'spec/rails/matchers/render_template'
require 'spec/rails/matchers/render_template'
34 changes: 19 additions & 15 deletions lib/spec/rails/matchers/ar_be_valid.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
if defined?(ActiveRecord::Base)
module Spec::Rails::Matchers
# :call-seq:
# response.should be_valid
# response.should_not be_valid
def be_valid
::Spec::Matchers::Matcher.new :be_valid do
match do |actual|
actual.valid?
end
module Spec
module Rails
module Matchers
# :call-seq:
# response.should be_valid
# response.should_not be_valid
def be_valid
::Spec::Matchers::Matcher.new :be_valid do
match do |actual|
actual.valid?
end

failure_message_for_should do |actual|
if actual.respond_to?(:errors) && ActiveRecord::Errors === actual.errors
"Expected #{actual.inspect} to be valid, but it was not\nErrors: " + actual.errors.full_messages.join(", ")
else
"Expected #{actual.inspect} to be valid"
failure_message_for_should do |actual|
if actual.respond_to?(:errors) && ActiveRecord::Errors === actual.errors
"Expected #{actual.inspect} to be valid, but it was not\nErrors: " + actual.errors.full_messages.join(", ")
else
"Expected #{actual.inspect} to be valid"
end
end
end
end

end
end

end
end

0 comments on commit 9446fef

Please sign in to comment.