Created
June 21, 2012 15:38
-
-
Save rinaldifonseca/2966489 to your computer and use it in GitHub Desktop.
Dashboard Presenter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DashboardPresenter < ClassicPresenter::Base | |
def navigation | |
if context.controller_name == 'vendors' | |
context.render 'shared/dashboard/vendor_navigation' | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe DashboardPresenter do | |
let(:context) { mock } #se neste caso vc quer apenas verificar o render, entao pode ser apenas um mock | |
subject { described_class.new(nil, context) } | |
it 'should render navigation' do | |
subject.context.should_receive(:render).with('shared/dashboard/vendor_navigation') | |
subject.navigation | |
end | |
end | |
#output | |
F | |
Failures: | |
1) DashboardPresenter should render navigation | |
Failure/Error: subject.context.should_receive(:render).with('shared/dashboard/vendor_navigation') | |
(nil).render("shared/dashboard/vendor_navigation") | |
expected: 1 time | |
received: 0 times | |
# ./spec/presenters/dashboard_presenter_spec.rb:8:in `block (2 levels) in <top (required)>' | |
Finished in 0.01114 seconds | |
1 example, 1 failure | |
Failed examples: | |
rspec ./spec/presenters/dashboard_presenter_spec.rb:7 # DashboardPresenter should render navigation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% present DashboardPresenter do |presenter| %> #vc nao precisa passar o controler name pois ele ja esta acessivel a partir de context | |
<%= presenter.navigation %> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment