Closed ghost closed 13 years ago
hi hemju, did you already try to look at https://github.com/caelum/restfulie-restbuy ?
Hi,
yes I already looked at the example. However, the example isn't really useful because it just shows how to test with the Restfulie client https://github.com/caelum/restfulie-restbuy/blob/master/spec/client_spec.rb . I want to test the raw response without any dependencies to restfulie. I want to parse the JSON/XML and check if it what I expected.
Nevertheless, nothing of this explains why tokamak isn't use to build the response. I am really stuck on this one, so any help would be appreciated.
looking into it now
Hi everyone,
I've tested with the following versions: rspec, rspec-rails 2.5.0 rails 3.0.7 restfulie 1.0.0 tokamak 1.1.2
Everything worked as expected (the body is there). Can you check the following git project? Notice that I have commited the gemfile.lock so it uses the exact same gem versions.
https://github.com/guilhermesilveira/restfulie-rspec-helmut
Regards
Yes, your project works, but there is a difference. You don't use tokamak files. Add index.tokamak to your clients view and nothing is returned.
Any progress on this issue?
looking at it. didnt find the cause yet.
the problem is somewhere within the compile method:
def compile(template)
"@content_type_helpers = @controller.hypertemplate_registry[self.response.content_type].helper; " +
"extend @content_type_helpers; " +
"extend Hypertemplate::Hook::Rails::Helpers; " +
"code_block = lambda { #{template.source} };" +
"builder = code_block.call; " +
"builder"
end
Builder is empty as code_block is nul for some weird reason. This means that the template invocation is returnin null instead of returning its content (the build or build_dsl method). Can you try helping me detecting the problem with build or build_dsl?
btw the problem is from rails 3.0.0 to rails 3.0.7 so it has been around all the time
Hey, I just debugged compile and I came to action_controller/test_case.rb where the result ActiveSupport::Notifications.subscribe("!render_template.action_view") was used. So this is a setting that the view intentionally isn't rendered. So I started googling and came across http://www.simonecarletti.com/blog/2011/04/rspec-rails-doesnt-render-rails-views-by-default/ which finally let me to the offical RSpec docu where it says that the view isn't rendered by default in controller specs, but you can turn it on with render_views
So this hasn't to do anything about tokamak, it is rspec. However, I would consider to add a note in the tokamak read me.
Couldnt be more thankful. Can you close the issue then?
I've added to the homepage: https://github.com/caelum/hypertemplate
Unfortunately we forked tokamak to be able to commit to the changes: https://github.com/abril/tokamak/pull/1
Regards
Yes, close the issue. Does this mean that restfulie uses hypertemplate and not tokamak?
Yep. We forked it to apply the missing patches (both dsls and others).
When the controller is executed normally, everything looks fine and I get a correct JSON/XML response. However, trying to do the same in RSPEC it looks like Restfulie isn't called at all. The controller action is called with the correct params and also gets the models, but the tokamak builder (view) isn't called.
CONTROLLER
SPEC
==> response code is 200, however, the body is empty. Headers are {"Content-Type"=>"application/json; charset=utf-8", "Cache-Control"=>"no-cache"}
I am pretty stuck with this. One idea would be that Restfulie isn't initialized correctly. I put a require in the spec_helper and didn't help either.