0

I'm using Mongoid. I have an object :

class Employee
  include Mongoid::Document

    field :name_first,      type: String
    field :name_last,       type: String
    field   :name_other,        type: Array,    default: []
    field :title,                   type: String
    field :education,           type: Hash,     default: {}
    field :languages,           type: Array,    default: []
    field :phone,                   type: Hash,     default: {}
    field :address,             type: Hash,     default: {}
    field :email,                   type: Array,    default: []
    field :url,                     type: Array,    default: []
    field :history,             type: Array,    default: []
    field :profile,             type: String
    field :social_media,    type: Hash,     default: {}
    field :last_contact,    type: Time
    field :signed_up,           type: Date

    belongs_to :user
    belongs_to :practice
end

And, I'm trying to use Fabrication, and having problems. Gem installed fine. In /spec/fabricators/employee_fabricator.rb I have

Fabricator :employee do

end

And in my_controller_spec.rb I have :

describe CasesController do

    describe "viewing cases" do
    before(:each) do
        Fabricate(:employee)
    end

    it "allows viewing the cases index page" do
        get 'index'
        response.should_not be_success
    end
    end
end

When I run 'rspec spec' in Terminal, I get :

Failures:

  1) CasesController viewing cases allows viewing the cases index page
     Failure/Error: Fabricate(:employee)
     ArgumentError:
       wrong number of arguments (2 for 1)

What's going on here? I've tried various permutations, some of which throw other errors, but nothing runs. Without calling the Fabricate(:employee) line, it runs as expected, but so far there are only empty tests...

Dan Donaldson
  • 1,061
  • 1
  • 8
  • 21

1 Answers1

0

I encountered the same problem while using active record.

I found that version 2.6 of Fabrication gem passes a second attribute to the active_record/base.rb initializer: {:without_protection=>true}

This change seems to be in Rails 3.2 (I'm on 3.0). The new parameter started being passed by Fabrication gem in version 2.0.2, so I've downgraded the fabrication gem in my gem file to 2.0.1 until we upgrade Rails to 3.2

So, basically, my suggestion is to either downgrade Fabrication gem to 2.0.1 or upgrade Rails to 3.2

Eric Parshall
  • 731
  • 9
  • 15