2013-07-12 01:48:23 +00:00
|
|
|
require 'minitest_helper'
|
|
|
|
require 'impressionist/setup_association'
|
|
|
|
|
|
|
|
module Impressionist
|
|
|
|
describe SetupAssociation do
|
|
|
|
|
|
|
|
let(:mock) { Minitest::Mock.new }
|
|
|
|
let(:set_up) { SetupAssociation.new(mock) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
# expects attr_accessible to return true
|
2015-04-22 05:38:10 +00:00
|
|
|
# and pass 12 arguments
|
2013-07-12 01:48:23 +00:00
|
|
|
mock.
|
|
|
|
expect(:attr_accessible, true) do |args|
|
2015-04-22 05:38:10 +00:00
|
|
|
args.size == 12
|
2013-07-12 01:48:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "attr_accessible" do
|
|
|
|
|
|
|
|
it "includes" do
|
|
|
|
set_up.stub :toggle, true do
|
|
|
|
set_up.include_attr_acc?.must_equal true
|
|
|
|
|
|
|
|
mock.verify
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "belongs_to" do
|
|
|
|
|
|
|
|
it "active_record" do
|
|
|
|
mock.expect(:belongs_to, true, [Symbol, Hash])
|
|
|
|
set_up.define_belongs_to.must_equal true
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "#set" do
|
|
|
|
|
|
|
|
it "sets an association" do
|
|
|
|
def set_up.include_attr_acc?; true; end
|
|
|
|
|
|
|
|
set_up.stub(:define_belongs_to, true) {
|
2013-09-06 22:07:47 +00:00
|
|
|
set_up.set.must_equal true
|
2013-07-12 01:48:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2013-09-02 01:23:52 +00:00
|
|
|
# returns done if thruthy
|
2013-07-12 01:48:23 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
end
|