require 'rails_helper'

RSpec.describe Derivation, :type => :model do
  subject(:derivation) { build(:derivation) }

  describe "#has_value?" do
    context "when a Derivation has derivation fields" do
      it "returns true" do
        derivation.finals << build(:word_part)
        expect(derivation.has_value?).to be(true)
      end
    end

    context "when a Derivation has no derivation fields or note" do
      it "returns false" do
        derivation.note = ""
        expect(derivation.has_value?).to be(false)
      end
    end
  end

  describe "#has_analysis?" do
    context "when a Derivation has derivation fields" do
      it "returns true" do
        derivation.finals << build(:word_part)
        expect(derivation.has_analysis?).to be(true)
      end
    end

    context "when a Derivation has no derivation fields" do
      it "returns false" do
        expect(derivation.has_analysis?).to be(false)
      end
    end
  end
end
