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...