Q:

Unable to use ActiveModel::MassAssignmentSecurity

I am trying to use some functionality in ActiveModel but I'm having trouble making everything work. I've included my class file and the test I'm running.
The test is failing with:
': undefined method `attr_accessible
I really don't know why, since MassAssignmentSecurity will bring that in and it is in fact running. I've also tried to include all of ActiveModel as well but that's doesn't work either. It doesn't seem to matter if I use include or extend to bring in the MassAssignmentSecurity.
If I pass in some attributes in my test to exercise "assign_attributes" in the initialize, that fails as well. I'm fairly new to rails, so I'm hoping I'm just missing something really simple.
TIA.
Using rails 3.2.12

my_class.rb
class MyClass
  include ActiveModel::MassAssignmentSecurity
  include ActiveModel::Validations
  include ActiveModel::Conversion
  extend ActiveModel::Naming
  extend ActiveSupport::Callbacks

  attr_accessible :persisted, :creds

  def initialize(attributes = nil, options = {})
    @persisted = false

    assign_attributes(attributes, options) if attributes

   yield self if block_given?
  end
end

my_class_spec.rb
require 'spec_helper'

describe MyClass do
  before do
    @testcase = MyClass.new
  end
  subject { @testcase }

  it_should_behave_like "ActiveModel"

  it { MyClass.should include(ActiveModel::MassAssignmentSecurity) }

  it { should respond_to(:persisted) }
end

support/active_model.rb
shared_examples_for "ActiveModel" do
  include ActiveModel::Lint::Tests

  # to_s is to support ruby-1.9
  ActiveModel::Lint::Tests.public_instance_methods.map{|m| m.to_s}.grep(/^test/).each do |m|
    example m.gsub('_',' ') do
      send m
    end
   end

  def model
    subject
  end
 end

A:

Yikes! What a mess I was yesterday. Might as well answer my own question since I figured out my issues.

attr_accessible in MassAssignmentSecurity does not work like it does with ActiveRecord. It does not create getters and setters. You still have to use attr_accessor if you those created.
assign_attributes is a connivence function that someone wrote to wrap around mass_assignment_sanitizer and isn't something baked into in MassAssignment Security. An example implementation is below:

def assign_attributes(values, options = {})
  sanitize_for_mass_assignment(values, options[:as]).each do |k, v|
    send("#{k}=", v)
  end
end

