public
Description: An open source social networking platform in Ruby on Rails
Homepage: http://dogfood.insoshi.com
Clone URL: git://github.com/insoshi/insoshi.git
insoshi / spec / models / preference_spec.rb
100644 55 lines (42 sloc) 1.425 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
require File.dirname(__FILE__) + '/../spec_helper'
 
describe Preference do
  
  describe "validations" do
    before(:each) do
      @preferences = Preference.new
    end
 
    it "should require email settings for email notifications" do
      @preferences.email_notifications = true
      @preferences.save.should be_false
      @preferences.errors_on(:domain).should_not be_empty
      @preferences.errors_on(:smtp_server).should_not be_empty
    end
 
    it "should require email settings for email verifications" do
      @preferences.email_verifications = true
      @preferences.save.should be_false
      @preferences.errors_on(:domain).should_not be_empty
      @preferences.errors_on(:smtp_server).should_not be_empty
    end
  end
 
  
  describe "booleans from fixtures" do
    
    before(:each) do
      @preferences = preferences(:one)
    end
    
    it "should have true email notifications" do
      @preferences.email_notifications?.should be_true
    end
    
    it "should have false email verifications" do
      @preferences.email_verifications?.should be_false
    end
  end
  
  describe "non-boolean attributes" do
    before(:each) do
      @preferences = Preference.new
    end
 
    it "should have an analytics field" do
      @preferences.should respond_to(:analytics)
    end
    
    it "should have a blank initial analytics" do
      @preferences.analytics.should be_blank
    end
  end
end