I am using Fabrication gem v-2.5.0 on Rails 2.3.16 but get the following errors when I run the unit test cases:
Below is the code snippet :
First case
Fabricate(:some_modal)
Fabrication::MisplacedFabricateError: # from /Users/user_xyz/.rvm/gems/ree-1.8.7- 2011.03@project/gems/fabrication-2.5.0/lib/fabrication.rb:51:in `Fabricate' from (irb):3
Second case
Fabricate(:some_other_modal)
SyntaxError: /Users/user_xyz/.rvm/gems/ree-1.8.7-2011.03@project/gems/fabrication-2.5.0/lib/fabrication/generator/active_record.rb:8: syntax error, unexpected ':', expecting ')' ...ttributes, without_protection: true)
Can someone please help me resolve these.
Modal Class :
class ErrorCode
attr_accessor :mappings
has_many :error_code_mappings
end
Fabricator :
Fabricator(:error_code) do
application_id 77
error_code_mappings(:count => 3) { |error_code, i| Fabricate.build(:error_code_mapping, :error_code => Fabricate.build(:error_code, :code => error_code.code + i))}
end
Unit test file:
require 'test_helper'
class ErrorCodeTest < ActiveSupport::TestCase
context "ErrorCode" do
setup do
@error_code = Fabricate.build(:error_code)
assert(@error_code.valid?)
end
should "have setter for mapping attribute" do
assert_respond_to(@error_code, :mappings=)
end
end