11require " ./spec_helper"
22
33Mocks .create_mock Post do
4- mock self .all(query), :inherited
5- mock self .find(id), :inherited
6- mock save(), :inherited
7- mock destroy(), :inherited
4+ mock self .all(query)
5+ mock self .find(id)
6+ mock save()
7+ mock destroy()
88end
99
1010describe PostController ::Index do
@@ -15,8 +15,8 @@ describe PostController::Index do
1515 allow(Post ).to receive(self .all(" ORDER BY created_at DESC" )).and_return([sample_post])
1616
1717 request = HTTP ::Request .new(" GET" , " /posts" )
18- io, context = create_context(request)
19- response = PostController ::Index .instance.call(context) as String
18+ io, context = create_context(request)
19+ response = PostController ::Index .instance.call(context).as( String )
2020 response.should contain " sample post"
2121 end
2222
@@ -30,9 +30,9 @@ describe PostController::Show do
3030 allow(Post ).to receive(self .find(" 1" )).and_return(sample_post)
3131
3232 request = HTTP ::Request .new(" GET" , " /posts/1" )
33- io, context = create_context(request)
33+ io, context = create_context(request)
3434 context.params[" id" ] = " 1"
35- response = PostController ::Show .instance.call(context) as String
35+ response = PostController ::Show .instance.call(context).as( String )
3636 response.should contain " sample post"
3737 end
3838
@@ -42,9 +42,9 @@ describe PostController::New do
4242
4343 it " displays form to create a new post when authorized" do
4444 request = HTTP ::Request .new(" GET" , " /posts/new" )
45- io, context = create_context(request)
45+ io, context = create_context(request)
4646 context.session[" authorized" ] = " true"
47- response = PostController ::New .instance.call(context) as String
47+ response = PostController ::New .instance.call(context).as( String )
4848 response.should contain " <h1>New Post</h1>"
4949 end
5050
@@ -54,7 +54,7 @@ describe PostController::Create do
5454
5555 it " creates a new post when authorized" do
5656 request = HTTP ::Request .new(" POST" , " /posts/create" )
57- io, context = create_context(request)
57+ io, context = create_context(request)
5858 context.session[" authorized" ] = " true"
5959 context.params[" name" ] = " new post"
6060 context.params[" body" ] = " new post body"
@@ -78,10 +78,10 @@ describe PostController::Edit do
7878 allow(Post ).to receive(self .find(" 1" )).and_return(sample_post)
7979
8080 request = HTTP ::Request .new(" GET" , " /posts/1/edit" )
81- io, context = create_context(request)
81+ io, context = create_context(request)
8282 context.session[" authorized" ] = " true"
8383 context.params[" id" ] = " 1"
84- response = PostController ::Edit .instance.call(context) as String
84+ response = PostController ::Edit .instance.call(context).as( String )
8585 response.should contain " <h1>Edit Post</h1>"
8686 end
8787
0 commit comments