Skip to content

Instantly share code, notes, and snippets.

@jeremyf
Created February 18, 2014 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeremyf/9073937 to your computer and use it in GitHub Desktop.
Save jeremyf/9073937 to your computer and use it in GitHub Desktop.
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