I remember that for having my rspec test to passe, I had to add this
line in the config/initializers/mime_types.rb file :
Mime::Type.register ''text/html'', :fbml
Also, in my routing specs, changing lines like
params_from(:post, "/model").should == {:controller =>
"model", :action => "create"}
params_from(:get, "/model/1/edit").should == {:controller =>
"model", :action => "edit", :id => "1"}
by something like :
params_from(:post, "/model/create").should == {:controller =>
"model", :action => "create"}
params_from(:get, "/model/edit/1").should == {:controller =>
"model", :action => "edit", :id => "1"}
Facebooker rewrite rules because of the POST http verb matter.
But take care of this, I just made this to keep moving and having my
specs to pass. I don''t know if it''s the best way to do. I may
have
broke something else. I was planning to work better on this in the
comming weeks.
If someone has a better way to do, let us know ! ;-)
HTH,
--
St?phane Akkaoui
http://www.sociabliz.com [fr]
http://www.imeuble.info [fr]
Le 16 oct. 08 ? 09:26, Zhao Lu a ?crit :
> Hi,
>
> I''m having some problem with a rspec test for facebook and I hope
> someone may be able to help me out.
>
> I wrote a very simple test for facebook_users_controller_spec:
>
> require File.expand_path(File.dirname(__FILE__) +
''/../spec_helper'')
> include Facebooker::Rails::TestHelpers
>
> describe FacebookUsersController do
> describe "FBML requests" do
> describe "#new" do
> it "should succeed" do
> facebook_get :new
> response.should be_success
> end
> end
> end
> end
>
> and to make the test pass I have in facebook_users_controller:
>
> class FacebookUsersController < ApplicationController
> def new
> respond_to do |format|
> pp format
> format.html{}
> format.fbml { head ok }
> end
> end
> end
>
>
> The pp format in the controller gives:
>
> #<ActionController::MimeResponds::Responder:0x7f8eb8f77af8
> @controller> #<FacebookUsersController:0x7f8eb90a3d00
> @_cookies={},
> @_flash={},
> @_headers={"cookie"=>[],
"Cache-Control"=>"no-cache"},
> @_params> {"format"=>"fbml",
> "fb_sig_time"=>1224027111.45693,
> "fb_sig"=>"ec765b71ae523c19003bd24755da0013",
> "action"=>"new",
> "fb_sig_in_canvas"=>"1",
> "fb_sig_session_key"=>"facebook_session_key",
> "canvas"=>true,
> "controller"=>"facebook_users",
> "fb_sig_expires"=>"0",
> "fb_sig_added"=>"1",
> "fb_sig_user"=>"1234"},
> wrong number of arguments (1 for 0)
> /home/zlu/work/gifttophone/app/controllers/
> facebook_users_controller.rb:4:in
> `new''
>
> I''m not sure about the wrong number of arguments error, which
happens
> on line "pp format". The error goes away if I comment out that
line.
> But desert is having trouble with fbml being the mime type. As far as
> I can tell, the _params hash, which has an underscore and don''t
know
> why, has "format" set to "xml".
>
> This is the error:
>
> TEST_FAILED% should succeed time=0.390875 message=Constant Mime::FBML
> from mime/fbml.rb not found
> Constant FBML from fbml.rb not found
> location=/home/zlu/work/gifttophone/config/../vendor/desert/lib/
> desert/rails/dependencies.rb:56:in
> `look_for_constant_in_parent_module''
>
>
> 1)
> NameError in ''FacebookUsersController FBML requests#new should
> succeed''
> Constant Mime::FBML from mime/fbml.rb not found
> Constant FBML from fbml.rb not found
> /home/zlu/work/gifttophone/config/../vendor/desert/lib/desert/rails/
> dependencies.rb:56:in
> `look_for_constant_in_parent_module''
> /home/zlu/work/gifttophone/config/../vendor/desert/lib/desert/rails/
> dependencies.rb:13:in
> `load_missing_constant''
> /home/zlu/work/gifttophone/app/controllers/
> facebook_users_controller.rb:5:in
> `new''
> /home/zlu/work/gifttophone/app/controllers/
> facebook_users_controller.rb:3:in
> `new''
> /home/zlu/work/gifttophone/vendor/plugins/user/lib/
> user_based_security.rb:13:in
> `perform_action_without_filters''
> /home/zlu/work/gifttophone/vendor/plugins/pivotal_core_bundle/lib/
> rails_core_extensions/url_writer_retardase_inhibitor.rb:22:in
> `inhibit_retardase''
> /home/zlu/work/gifttophone/vendor/plugins/pivotal_core_bundle/lib/
> rails_core_extensions/url_writer_retardase_inhibitor.rb:22:in
> `inhibit_retardase''
> /home/zlu/work/gifttophone/vendor/plugins/pivotal_core_bundle/lib/
> rails_core_extensions/url_writer_retardase_inhibitor.rb:22:in
> `inhibit_retardase''
> /home/zlu/work/gifttophone/vendor/plugins/user/lib/store_location.rb:
> 23:in
> `store_location''
> /home/zlu/work/gifttophone/vendor/plugins/user/lib/current_user.rb:
> 49:in
> `perform_action''
> /home/zlu/work/gifttophone/vendor/plugins/facebooker/lib/facebooker/
> rails/test_helpers.rb:34:in
> `send''
> /home/zlu/work/gifttophone/vendor/plugins/facebooker/lib/facebooker/
> rails/test_helpers.rb:34:in
> `facebook_verb''
> /home/zlu/work/gifttophone/vendor/plugins/facebooker/lib/facebooker/
> rails/test_helpers.rb:15:in
> `facebook_get''
> /home/zlu/work/gifttophone/spec/controllers/
> facebook_users_controller_spec.rb:8:
>
> Finished in 0.630094 seconds
>
> Any idea would be appreciated.
>
> --
> Zhao
> _______________________________________________
> Facebooker-talk mailing list
> Facebooker-talk at rubyforge.org
> http://rubyforge.org/mailman/listinfo/facebooker-talk