[rspec-devel] [ rspec-Bugs-8027 ] should_change works but should_not_change appears not to.

noreply at rubyforge.org noreply at rubyforge.org
Sat Jan 20 13:46:50 EST 2007


Bugs item #8027, was opened at 2007-01-20 10:46
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=8027&group_id=797

Category: None
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: steve ross (cwd)
Assigned to: Nobody (None)
Summary: should_change works but should_not_change appears not to.

Initial Comment:
Rspec v. 0.8.0 (trunk)

Given the code:

context "Given a Bug (in general)" do
  specify "Should be able to add a valid record" do
    lambda { Bug.create(:title => 'a valid bug', :description => 'a valid description') }.should_change(Bug, :count).by(1)
  end
  
  specify "Should not be able to add an invalid record" do
    lambda { Bug.create(:description => 'a valid description') }.should_not_change(Bug, :count).by(1)
  end
end

The result is:

1)
'Given a Bug (in general) Should not be able to add an invalid record' FAILED
count should have been changed by 1, but was changed by 0
./spec/models/bug_spec.rb:18:

Model code, bug.rb, is:

class Bug < ActiveRecord::Base
  validates_presence_of :title
end


----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=8027&group_id=797


More information about the rspec-devel mailing list