role_model/spec/roles_spec.rb

53 lines
1.6 KiB
Ruby
Raw Permalink Normal View History

2010-05-29 13:20:59 +02:00
require 'spec_helper'
describe RoleModel::Roles do
let(:model_instance) { Class.new.new }
let(:array) { [:foo, :bar] }
subject { RoleModel::Roles.new(model_instance, array) }
before(:each) do
model_instance.stub(:roles=)
end
2010-05-29 13:20:59 +02:00
2017-06-20 16:02:07 -07:00
it { subject.model_instance.should equal(model_instance) }
2010-05-29 13:20:59 +02:00
it { should include(:foo, :bar) }
it { should respond_to(:each) }
2010-05-29 13:20:59 +02:00
describe "#<<" do
it "should add the given element to the model_instance.roles by re-assigning all roles" do
model_instance.should_receive(:roles=).with(array_including(:foo, :bar, :baz))
2010-05-29 13:20:59 +02:00
subject << :baz
end
end
describe "#add" do
it "should add the given element to the model_instance.roles by re-assigning all roles" do
model_instance.should_receive(:roles=).with(array_including(:foo, :bar, :baz))
subject.add(:baz)
end
end
describe "#merge" do
it "should add the given enum to the model_instance.roles by re-assigning all roles" do
model_instance.should_receive(:roles=).with(array_including(:foo, :bar, :baz, :quux))
subject.merge([:baz, :quux])
end
end
describe "#delete" do
it "should delete the given element to the model_instance.roles by re-assigning all roles" do
model_instance.should_receive(:roles=).with(subject)
subject.delete :foo
subject.should_not include(:foo)
end
end
describe "#subtract" do
it "should remove the given enum to the model_instance.roles by re-assigning all roles" do
model_instance.should_receive(:roles=).with(subject)
subject.subtract([:foo, :bar])
2017-06-20 16:02:07 -07:00
expect(subject.size).to be 0
end
end
2010-05-29 13:20:59 +02:00
end