lib/shoulda/macros.rb in technicalpickles-shoulda-2.0.2 vs lib/shoulda/macros.rb in technicalpickles-shoulda-2.0.6
- old
+ new
@@ -9,11 +9,11 @@
# assertion, but supports more than just numeric values. See also
# should_not_change.
#
# Example:
#
- # context "Creating a post"
+ # context "Creating a post" do
# setup { Post.create }
# should_change "Post.count", :by => 1
# end
#
# As shown in this example, the <tt>:by</tt> option expects a numeric
@@ -24,12 +24,12 @@
# should_change "@post.title", :from => "old", :to => "new"
#
# Combinations of <tt>:by</tt>, <tt>:from</tt>, and <tt>:to</tt> are allowed:
#
# should_change "@post.title" # => assert the value changed in some way
- # should_change "@post.title" :from => "old" # => assert the value changed to anything other than "old"
- # should_change "@post.title" :to => "new" # => assert the value changed from anything other than "new"
+ # should_change "@post.title", :from => "old" # => assert the value changed to anything other than "old"
+ # should_change "@post.title", :to => "new" # => assert the value changed from anything other than "new"
def should_change(expression, options = {})
by, from, to = get_options!([options], :by, :from, :to)
stmt = "change #{expression.inspect}"
stmt << " from #{from.inspect}" if from
stmt << " to #{to.inspect}" if to
@@ -51,10 +51,10 @@
# of an expression that is run before and after the current setup block
# is run. This is the logical opposite of should_change.
#
# Example:
#
- # context "Updating a post"
+ # context "Updating a post" do
# setup { @post.update_attributes(:title => "new") }
# should_not_change "Post.count"
# end
def should_not_change(expression)
expression_eval = lambda { eval(expression) }