Sha256: 06fabd3a3a780fa5a00365ea6dd78018194c8a47caef99937a8b6a6b6c403598

Contents?: true

Size: 1.26 KB

Versions: 8

Compression:

Stored size: 1.26 KB

Contents

require 'spec_helper'

describe Profile do
  subject { Factory(:profile) }

  it { should belong_to(:school) }

  describe "school validation" do
    context "there exists a few audiences, including educator" do
      before do
        @doctor_audience  = Factory :audience, :name => "Doctor"
        @educator_audience = Factory :audience, :name => "Educator"
      end

      context "A profile is created with a non-educators audience and without a school;" do
        it "should be a valid profile" do
          @profile = Factory :profile, :audience => @doctor_audience
          @profile.valid?.should be_true
        end
      end

      context "A profile is created with a educators audience;" do
        context "the profile does not have a school associated with it;" do
          it "should not be a valid profile" do
            lambda{ Factory :profile, :audience => @educator_audience, :school => nil }.should raise_error
          end
        end
  
        context "the profile does have a school associated with it;" do
          it "should be a valid profile" do
            @profile = Factory :profile, :audience => @educator_audience, :school => Factory(:school)
            @profile.valid?.should be_true
          end
        end
      end
    end 
  end #describe 
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
scidea-schools-1.1 spec/models/profile_spec.rb
scidea-schools-1.0.6 spec/models/profile_spec.rb
scidea-schools-1.0.5 spec/models/profile_spec.rb
scidea-schools-1.0.4 spec/models/profile_spec.rb
scidea-schools-1.0.3 spec/models/profile_spec.rb
scidea-schools-1.0.2 spec/models/profile_spec.rb
scidea-schools-1.0.1 spec/models/profile_spec.rb
scidea-schools-1.0.0 spec/models/profile_spec.rb