Skip to content

Instantly share code, notes, and snippets.

@mkempe
Created July 18, 2012 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkempe/3135487 to your computer and use it in GitHub Desktop.
Save mkempe/3135487 to your computer and use it in GitHub Desktop.
Testing rspec views with capybara
# encoding: utf-8
module RSpec
module Support
module Views
module CapybaraExtensions
def rendered
Capybara.string(@rendered)
end
def within(selector)
yield rendered.find(selector)
end
end
end
end
end
# encoding: utf-8
require 'spec_helper'
describe 'page/foo.html.haml' do
include RSpec::Support::Views::CapybaraExtensions
before do
render
end
it 'has a header' do
rendered.find('h1').should have_content('Foo')
end
end