forked from bofh/fetsite
AutoCommit Mon Aug 31 18:03:21 CEST 2015
This commit is contained in:
42
spec/controllers/shared_examples/basic.rb
Normal file
42
spec/controllers/shared_examples/basic.rb
Normal file
@@ -0,0 +1,42 @@
|
||||
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
|
||||
Reference in New Issue
Block a user