Sha256: d7ccff3af3c44b38bf131f8cc07cd3eb50047a32f3f388c9beb11651e67c583b

Contents?: true

Size: 682 Bytes

Versions: 1

Compression:

Stored size: 682 Bytes

Contents

require 'spec_helper'

describe DataMapper::Matchers::HaveOne do
  context '#should' do
    it 'passes if association exists' do
      lambda { expect(Book).to have_one :foreword}.should_pass
    end

    it 'fails if association does not exist' do
      expect { expect(Author).to have_one :book}.to fail_with "expected to have one book"
    end
  end

  context '#should_not' do
    it 'fails if association exists' do
      expect { expect(Book).not_to have_one :foreword}.to fail_with "expected not to have one foreword"
    end
  end

  context 'instance of model' do
    it 'should pass' do
      lambda { expect(Book.new).to have_one :foreword}.should_pass
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dm-rspec-0.3.0 spec/dm/matchers/have_one_spec.rb