Sha256: 6483eeca2f18ebdba01d4779e3129e5884a9706fa0841830989550b4ae16ef68

Contents?: true

Size: 937 Bytes

Versions: 11

Compression:

Stored size: 937 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

11 entries across 11 versions & 1 rubygems

Version Path
remarkable_activerecord-3.1.7 lib/remarkable_activerecord/matchers/have_readonly_attributes_matcher.rb
remarkable_activerecord-3.1.8 lib/remarkable_activerecord/matchers/have_readonly_attributes_matcher.rb
remarkable_activerecord-3.0.10 lib/remarkable_activerecord/matchers/have_readonly_attributes_matcher.rb
remarkable_activerecord-3.1.3 lib/remarkable_activerecord/matchers/have_readonly_attributes_matcher.rb
remarkable_activerecord-3.1.2 lib/remarkable_activerecord/matchers/have_readonly_attributes_matcher.rb
remarkable_activerecord-3.1.4 lib/remarkable_activerecord/matchers/have_readonly_attributes_matcher.rb
remarkable_activerecord-3.1.1 lib/remarkable_activerecord/matchers/have_readonly_attributes_matcher.rb
remarkable_activerecord-3.0.9 lib/remarkable_activerecord/matchers/have_readonly_attributes_matcher.rb
remarkable_activerecord-3.1.0 lib/remarkable_activerecord/matchers/have_readonly_attributes_matcher.rb
remarkable_activerecord-3.1.5 lib/remarkable_activerecord/matchers/have_readonly_attributes_matcher.rb
remarkable_activerecord-3.1.6 lib/remarkable_activerecord/matchers/have_readonly_attributes_matcher.rb