Sha256: 5b6156f032bdf6619816701ee5e1fa74808c08f98cd67e81d5ef12748ab6f9d3

Contents?: true

Size: 907 Bytes

Versions: 13

Compression:

Stored size: 907 Bytes

Contents

module Remarkable
  module ActiveRecord
    module Matchers
      class HaveReadonlyAttributesMatcher < Remarkable::ActiveRecord::Base #:nodoc:
        arguments :collection => :attributes, :as => :attribute
        collection_assertions :is_readonly?

        private

          def is_readonly?
            readonly = subject_class.readonly_attributes || []
            return readonly.include?(@attribute.to_s), :actual => readonly.to_a.inspect
          end
      end

      # Ensures that the attribute cannot be changed once the record has been
      # created.
      #
      # == Examples
      #
      #   it { should have_readonly_attributes(:password, :admin_flag) }
      #
      def have_readonly_attributes(*attributes, &block)
        HaveReadonlyAttributesMatcher.new(*attributes, &block).spec(self)
      end
      alias :have_readonly_attribute :have_readonly_attributes

    end
  end
end

Version data entries

13 entries across 13 versions & 5 rubygems

Version Path
specstar-remarkable-0.0.0 lib/remarkable/active_record/matchers/have_readonly_attributes_matcher.rb
maksar-remarkable_activerecord-4.0.0.alpha6 lib/remarkable/active_record/matchers/have_readonly_attributes_matcher.rb
schubert-remarkable_activerecord-4.0.0.alpha4 lib/remarkable/active_record/matchers/have_readonly_attributes_matcher.rb
benhutton-remarkable_activerecord-4.0.0.alpha6 lib/remarkable/active_record/matchers/have_readonly_attributes_matcher.rb
remarkable_activerecord-4.0.0.alpha4 lib/remarkable/active_record/matchers/have_readonly_attributes_matcher.rb
remarkable_activerecord-4.0.0.alpha3 lib/remarkable/active_record/matchers/have_readonly_attributes_matcher.rb
remarkable_activerecord-4.0.0.alpha2 lib/remarkable/active_record/matchers/have_readonly_attributes_matcher.rb
remarkable_activerecord-4.0.0.alpha1 lib/remarkable_activerecord/matchers/have_readonly_attributes_matcher.rb
remarkable_activerecord-3.1.13 lib/remarkable_activerecord/matchers/have_readonly_attributes_matcher.rb
remarkable_activerecord-3.1.12 lib/remarkable_activerecord/matchers/have_readonly_attributes_matcher.rb
remarkable_activerecord-3.1.11 lib/remarkable_activerecord/matchers/have_readonly_attributes_matcher.rb
remarkable_activerecord-3.1.10 lib/remarkable_activerecord/matchers/have_readonly_attributes_matcher.rb
remarkable_activerecord-3.1.9 lib/remarkable_activerecord/matchers/have_readonly_attributes_matcher.rb