Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A set of specs for defining how the amend group membership form will behave
describe GroupMembershipForm do
let(:group) { Group.new }
let(:group_id) { 'abc:123'}
let(:person) { Person.new }
let(:member_id) { 'abc:456'}
let(:params) {
{
# These are the parameters that are generated in the existing form.
"group_id" => group_id
"members_attributes" =>
{
"0"=>{"id"=>member_id, "_destroy"=>""},
}
}
}
subject { GroupMembership.new(params) }
before(:each) do
Group.should_receive(:find).with(group_id).and_return(group)
Person.should_receive(:find).with(member_id).and_return(person)
end
context '#save' do
it 'should append the member to the group' do
group.should_receive(:add_member).with(person)
subject.save
end
end
context 'validation' do
it 'should require a group_id'
it 'should require a title'
it 'should require a description'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.