cavalle / steak

DISCONTINUED - The delicious combination of RSpec and Capybara for Acceptance BDD
MIT License
763 stars 32 forks source link

problem with getJSON and render json #50

Closed bettysteger closed 12 years ago

bettysteger commented 12 years ago

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!)

cavalle commented 12 years ago

You probably need to learn capybara and how to configure selenium or any driver that supports js. I suggest starting by reading capybara docs and, if you can't find a solution, asking in its mailing list.

You should only open issues in github if you know for sure that there's some bug in a specific library.

bettysteger commented 12 years ago

thanks for your help, and sorry for my overhasty question!

for your information i changed the following:

in spec_helper.rb

config.use_transactional_fixtures = false

and in the test

  scenario 'Tvshow index', :js => true do