Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

666 B
Raw Blame
# frozen_string_literal: true

RSpec.shared_context "model contract" do
  shared_examples_for "is not writable" do
    before do
      instance.model.attributes = { attribute => value }
    end

    it "explains the not writable error" do
      instance.validate
      expect(instance.errors.details[attribute])
        .to contain_exactly({ error: :error_readonly })
    end
  end

  shared_examples_for "is writable" do
    before do
      instance.model.attributes = { attribute => value }
    end

    it "is writable" do
      instance.validate

      expect(instance.errors.details[attribute])
        .not_to include(error: :error_readonly)
    end
  end
end