Created
October 19, 2009 19:05
-
-
Save iain/213636 to your computer and use it in GitHub Desktop.
Weird RSpec issue
This file contains 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
1) | |
'User should get all active users' FAILED | |
expected any? to return false, got true | |
./spec/models/user_spec.rb:26: |
This file contains 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
# == Schema Information | |
# | |
# Table name: users | |
# | |
# id :integer not null, primary key | |
# active :boolean | |
# created_at :datetime | |
# updated_at :datetime | |
# | |
class User < ActiveRecord::Base | |
named_scope :active, :conditions => { :active => true } | |
end |
This file contains 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
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') | |
Factory.define :active_user, :class => "User" do |f| | |
f.active true | |
end | |
Factory.define :inactive_user, :class => "User" do |f| | |
f.active false | |
end | |
describe User do | |
it "should get all active users" do | |
active = Factory(:active_user) | |
inactive = Factory(:inactive_user) | |
subject = User.active | |
subject.should be_all(&:active) | |
inverse = User.all - subject | |
inverse.none?(&:active).should be_true | |
inverse.any?(&:active).should be_false | |
# inverse.should be_none(&:active) | |
inverse.should_not be_any(&:active) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment