[83971] branches/gsoc11-statistics/stats-server

derek at macports.org derek at macports.org
Tue Sep 13 18:36:53 PDT 2011


Revision: 83971
          http://trac.macports.org/changeset/83971
Author:   derek at macports.org
Date:     2011-09-13 18:36:51 -0700 (Tue, 13 Sep 2011)
Log Message:
-----------
Added spec dir for rspec specifications.
Added models/user_spec.rb to test the User model

- Verify the presence of ActiveRecord associations
- Verify that User has a uuid present
- Verify that User has a valid uuid

Added Paths:
-----------
    branches/gsoc11-statistics/stats-server/spec/
    branches/gsoc11-statistics/stats-server/spec/models/
    branches/gsoc11-statistics/stats-server/spec/models/user_spec.rb

Added: branches/gsoc11-statistics/stats-server/spec/models/user_spec.rb
===================================================================
--- branches/gsoc11-statistics/stats-server/spec/models/user_spec.rb	                        (rev 0)
+++ branches/gsoc11-statistics/stats-server/spec/models/user_spec.rb	2011-09-14 01:36:51 UTC (rev 83971)
@@ -0,0 +1,31 @@
+require 'spec_helper'
+
+describe User do
+  before(:each) do
+    @user = User.new
+  end
+  
+  it "should have one os_statistic" do
+    @user.should have_one :os_statistic
+  end
+  
+  it "should have many ports" do
+    @user.should have_many :installed_ports
+  end
+  
+  it "should have a uuid present" do
+    @user.should be_invalid
+    @user.uuid = 'BD5C379F-F485-4C89-A3DB-20A3476116F1'
+    @user.should be_valid
+  end
+  
+  it "should only have a valid uuid" do
+    @user.uuid = 'ABC-INVALID-UUID'
+    @user.should be_invalid
+    @user.errors.on(:uuid).should == "uuid must be a valid universally unique identifier"
+            
+    # A valid UUID - generated with uuidgen
+    @user.uuid = 'BD5C379F-F485-4C89-A3DB-20A3476116F1'
+    @user.should be_valid
+  end
+end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20110913/e54941c8/attachment.html>


More information about the macports-changes mailing list