cavalle/steak — Issue #50: problem with getJSON and render json
Author: lpsBetty
Created: 2012-02-06 19:19:07+00:00
State: open

hi, i am using
steak (2.0.0)
capybara (>= 1.0.0)
rspec-rails (>= 2.5.0)

and want to test if the right object appears, my test:

scenario 'Tvshow index' do
Tvshow.create!(:name => 'Chuck', :upcoming => true)
visit homepage
within('#tvshows') do
page.should have_content('Chuck')
end
save_and_open_page
within('#upcoming') do
page.should have_content('Chuck')
end
end

i have a controller with:

respond_to :html, :json

def index
@tvshows = Tvshow.all

respond_with @tvshows do |format|
format.json { render :json => json }
end
end

and in my application.js is the following code:

$.getJSON("/", {tvshow_ids: tvshows}, function(data) {
create_html(data);
});

when i start de rails server it works, but when i run the test nothing happens! the #upcoming doesn't change and i've found that nothing happens in the getJSON function (only in the test, in development it works just fine!)