Sha256: ee8789d2bc601ec4538931e26e81ebf5fd25a270b99db01970247ee3418127df

Contents?: true

Size: 992 Bytes

Versions: 1

Compression:

Stored size: 992 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe C2::Informant::Locus do
  before(:all) do
    @locus = Fabricate(:locus, :class_name => 'User')
    @user = Fabricate(:user)
  end
  
  let(:locus) { @locus.reload }
  let(:user) { @user.reload }
  
  describe '#entry_label' do
    it 'should find an appropriate entry_label' do
      User.should_receive(:instance_methods).and_return(['c2_label'])
      locus.entry_label.should == 'c2_label'
    end
  
    it 'should return locus label if set' do
      locus.entry_label = 'this_label'
      locus.entry_label.should == 'this_label'
    end
    
    it 'should be returned in the entry_json' do
      locus.entry_label = 'c2_title'
      label = locus.entry_as_json(user)['c2_title']
      label.should == user.c2_title
    end
    
    it 'should return nil when json if no entry_label is found' do      
      label = locus.entry_as_json(user)[locus.entry_label]
      label.should be_nil
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
c2-0.1.5 spec/models/locus_spec.rb