codeplant/simple-navigation

When running a view rspec spec variable isn't loaded on navigation file

Closed this issue · 6 comments

I'm reallly sorry if this problem doesn't concern with this gem.

If I have some view spec that check a link inside a navigation, the variable isn't loaded.
Suppose I have:

    before(:each) do
        assign(:var, var)
    end

    it "should display link" do
        render
        expect(rendered).to have_link("Link" , edit_page_path(var))
    end

Partial

<%= render_navigation(context: :admin) %>

config/admin_navigation.rb

SimpleNavigation::Configuration.run do |navigation|
    navigation.items do |p|
           p.item :edit, "Page", edit_page_path(@var)
    end
end

What happens is that @var is always nil on admin_navigation.rb file, although is loaded on the partial. And when I ran into a development or production enviroment works perfectly.

I really appreciate any help.

Hi, could you try to call render partial: 'folder/partial_name' instead of just render ?

I created a new app with RSpec and Capybara and tried your spec, got an error, tried with :partial and it worked :)

@fltiago any luck with your issue?

@simonc thanks for your help, I will try today and give you some feedback. Thanks.

@fltiago can I close this issue? In the end it seems to be related to your specs, right?

Right, I didn't have time to test your advice, but you can close this issue and happen the same issue I investigate more and post here. I really appreciate your time and help. 😄

No problem :)