Sha256: 9fe065d3ef247bb3f30df8b710cb0d7adbe7351525135753466fadc68ec78cef

Contents?: true

Size: 781 Bytes

Versions: 1

Compression:

Stored size: 781 Bytes

Contents

require 'spec_helper'
module Axel::Associations
  describe Base do
    let(:model) { User }
    let(:relation_name) { "personas" }
    let(:options) { {} }
    let(:instance) { User.new }
    subject { described_class.new model, relation_name, options }

    it "handles a read" do
      subject.handles_method?(:personas).should be_truthy
    end

    it "doesn't handle a write" do
      subject.handles_method?(:personas=).should be_falsey
    end

    it "runs a getter" do
      subject.should_receive(:getter).and_return nil
      subject.run_method(instance, :personas)
    end

    it "runs a getter" do
      expect { subject.run_method(instance, :personas=) }.to raise_error NoMethodError,
        "Could not find an association method for `personas='"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
axel-0.0.1 spec/lib/axel/associations/base_spec.rb