Created
April 15, 2009 06:40
-
-
Save btakita/95652 to your computer and use it in GitHub Desktop.
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
module ActionController::Integration::Runner | |
# TODO: Make this a rails patch | |
def method_missing(sym, *args, &block) | |
reset! unless @integration_session | |
if @integration_session.respond_to?(sym) | |
returning @integration_session.__send__(sym, *args, &block) do | |
copy_session_variables! | |
end | |
else | |
super | |
end | |
end | |
end | |
class ActionController::IntegrationTest | |
class TestResultHack | |
def add_assertion | |
end | |
end | |
self.use_transactional_fixtures = false | |
self.use_instantiated_fixtures = true | |
# TODO: For some reason IntegrationTest does not use ActiveSupport::TestCase.fixture_path, but uses its own @fixture_path | |
def self.fixture_path | |
ActiveSupport::TestCase.fixture_path | |
end | |
def initialize(example_proxy, &implementation) | |
@_proxy = example_proxy | |
@_implementation = implementation | |
@_backtrace = caller | |
@_result = TestResultHack.new # This is a hack to fix an exception in Integration | |
end | |
end | |
module Spec | |
module Rails | |
module Example | |
class BaseWebratExampleGroup < ActionController::IntegrationTest | |
include Spec::Matchers | |
include Spec::Rails::Matchers | |
include Spec::Rails::Mocks | |
def current_path | |
end | |
end | |
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
class Spec::Rails::Example::SeleniumExampleGroup < Spec::Rails::Example::BaseWebratExampleGroup | |
class << self | |
def remove_cached_assets | |
system("rm -f #{RAILS_ROOT}/public/javascripts/all.js") | |
system("rm -f #{RAILS_ROOT}/public/stylesheets/all.css") | |
end | |
end | |
before(:suite) do | |
remove_cached_assets | |
system("mongrel_rails mongrel::start -p 3001 -e #{ENV["RAILS_ENV"]} -d") | |
Timeout.timeout(10) do | |
loop do | |
begin | |
TCPSocket.new("localhost", "3001") | |
rescue => e | |
retry | |
end | |
break | |
end | |
end | |
end | |
after(:each) do | |
visit(logout_path) | |
end | |
after(:suite) do | |
system("mongrel_rails mongrel::stop") | |
remove_cached_assets | |
end | |
def login_as(name_or_person) | |
returning(super) do | |
selenium.wait_for_page | |
end | |
end | |
def current_path | |
selenium.location.blank? ? "" : URI.parse(selenium.location).path | |
end | |
def current_dom | |
Nokogiri::HTML(response.body) | |
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
module Spec | |
module Rails | |
module Example | |
class WebratExampleGroup < BaseWebratExampleGroup | |
def current_path | |
current_url.blank? ? "" : URI.parse(current_url).path | |
end | |
end | |
end | |
end | |
end | |
Spec::Example::ExampleGroupFactory.register(:webrat, Spec::Rails::Example::WebratExampleGroup) | |
module Webrat | |
module Methods | |
delegate_to_session :current_scope | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment