Sha256: 81f0674d6051df0a01e5f56a5785207ec1affcd3cf2d75ae93304a6f12b5ce9e

Contents?: true

Size: 1.19 KB

Versions: 28

Compression:

Stored size: 1.19 KB

Contents

require 'spec_helper'

describe Shoulda::Matchers::ActiveRecord::HaveReadonlyAttributeMatcher do
  context "an attribute that cannot be set after being saved" do
    before do
      define_model :example, :attr => :string do
        attr_readonly :attr
      end
      @model = Example.new
    end

    it "should accept being read-only" do
      @model.should have_readonly_attribute(:attr)
    end
  end

  context "an attribute not included in the readonly set" do
    before do
      define_model :example, :attr => :string, :other => :string do
        attr_readonly :other
      end
      @model = Example.new
    end

    it "should not accept being read-only" do
      @model.should_not have_readonly_attribute(:attr)
    end
  end

  context "an attribute on a class with no readonly attributes" do
    before do
      define_model :example, :attr => :string
      @model = Example.new
    end

    it "should not accept being read-only" do
      @model.should_not have_readonly_attribute(:attr)
    end

    it "should assign a failure message" do
      matcher = have_readonly_attribute(:attr)
      matcher.matches?(@model).should == false
      matcher.failure_message.should_not be_nil
    end
  end
end

Version data entries

28 entries across 20 versions & 4 rubygems

Version Path
challah-1.0.0.beta vendor/bundle/gems/shoulda-matchers-1.4.2/spec/shoulda/active_record/have_readonly_attributes_matcher_spec.rb
challah-0.9.1.beta.3 vendor/bundle/gems/shoulda-matchers-1.4.2/spec/shoulda/active_record/have_readonly_attributes_matcher_spec.rb
devise_sociable-0.1.0 vendor/bundle/gems/shoulda-matchers-1.4.2/spec/shoulda/active_record/have_readonly_attributes_matcher_spec.rb
challah-0.9.1.beta vendor/bundle/gems/shoulda-matchers-1.4.2/spec/shoulda/active_record/have_readonly_attributes_matcher_spec.rb
challah-0.9.0 vendor/bundle/gems/shoulda-matchers-1.4.2/spec/shoulda/active_record/have_readonly_attributes_matcher_spec.rb
shoulda-matchers-1.4.2 spec/shoulda/active_record/have_readonly_attributes_matcher_spec.rb
challah-rolls-0.2.0 vendor/bundle/gems/shoulda-matchers-1.4.1/spec/shoulda/active_record/have_readonly_attributes_matcher_spec.rb
challah-rolls-0.2.0 vendor/bundle/gems/shoulda-matchers-1.3.0/spec/shoulda/active_record/have_readonly_attributes_matcher_spec.rb
challah-rolls-0.2.0 vendor/bundle/gems/shoulda-matchers-1.2.0/spec/shoulda/active_record/have_readonly_attributes_matcher_spec.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.3/vendor/bundle/gems/shoulda-matchers-1.4.1/spec/shoulda/active_record/have_readonly_attributes_matcher_spec.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.0.pre/vendor/bundle/gems/shoulda-matchers-1.2.0/spec/shoulda/active_record/have_readonly_attributes_matcher_spec.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.3/vendor/bundle/gems/shoulda-matchers-1.3.0/spec/shoulda/active_record/have_readonly_attributes_matcher_spec.rb
challah-0.8.3 vendor/bundle/gems/shoulda-matchers-1.3.0/spec/shoulda/active_record/have_readonly_attributes_matcher_spec.rb
challah-0.8.3 vendor/bundle/gems/shoulda-matchers-1.4.1/spec/shoulda/active_record/have_readonly_attributes_matcher_spec.rb
shoulda-matchers-1.4.1 spec/shoulda/active_record/have_readonly_attributes_matcher_spec.rb
shoulda-matchers-1.4.0 spec/shoulda/active_record/have_readonly_attributes_matcher_spec.rb
challah-0.8.1 vendor/bundle/gems/shoulda-matchers-1.3.0/spec/shoulda/active_record/have_readonly_attributes_matcher_spec.rb
challah-rolls-0.1.0 vendor/bundle/gems/challah-0.8.0.pre/vendor/bundle/gems/shoulda-matchers-1.2.0/spec/shoulda/active_record/have_readonly_attributes_matcher_spec.rb
challah-rolls-0.1.0 vendor/bundle/gems/shoulda-matchers-1.2.0/spec/shoulda/active_record/have_readonly_attributes_matcher_spec.rb
challah-rolls-0.1.0 vendor/bundle/gems/shoulda-matchers-1.3.0/spec/shoulda/active_record/have_readonly_attributes_matcher_spec.rb