Files
2015-08-31 18:03:21 +02:00

43 lines
1.1 KiB
Ruby

shared_examples "it is success" do
it "has a 200 status code" do
action
expect(response.status).to eq(200)
end
it "is success" do
action
expect(response).to be_success
end
end
shared_examples "it assigns object" do
it "assigns object variable" do
action
expect(assigns(object_variable)).to eq(assigned_object_variable)
end
end
shared_examples "it assigns new object" do
it "assigns new object" do
action
expect(assigns(object_variable)).to be_a_new(object_class)
expect(assigns(object_variable)).not_to be_persisted
end
end
shared_examples "it assigns persisted object" do
it "assigns new object" do
action
expect(assigns(object_variable)).to be_a(object_class)
expect(assigns(object_variable)).to be_persisted
end
end
shared_examples "it is restricted" do
it "is expected to raise error" do
bypass_rescue
expect { action }.to raise_error(CanCan::AccessDenied)
end
it "is not success" do
action
expect(response).not_to be_success
end
end