mirror of
https://github.com/TracksApp/tracks.git
synced 2026-03-14 08:26:16 +01:00
Next step in upgrading Tracks to Rails 2.2. Some highlights:
* Ran rake rails:update * Added old actionwebservice framework * Updated RSpec and RSpec-Rails * Removed asset_packager plugin (not compatible, Scott no longer maintaining), and replaced with bundle_fu. See the bundle_fu README for more info. * Hacks to UJS and ARTS plugins, which are no longer supported. Probably should move off both UJS and RJS. * Hack to flashobject_helper plugin (upgrade to Rails 2.2-compatible version if/when it comes out.) * Hack to skinny-spec plugin, for Rails 2.2 compatibility. Should check for official release. * Hacks to resource_feeder plugin, for Rails 2.2 compatibility. Should check for official release (not likely) or move off it. * Addressed some deprecation warnings. More to come. * My mobile mime type hackery is no longer necessary with new Rails features. Yay! * Updated environment.rb.tmpl with changes TODO: * Restore view specs marked pending * Fix failing integration tests. * Try selenium tests. * Investigate OpenID support. * Address deprecation warnings. * Consider moving parts of environment.rb to initializers * Address annoying config.gem warning about highline gem
This commit is contained in:
parent
6d11ebd1b0
commit
35ae5fc431
394 changed files with 15184 additions and 9936 deletions
4
stories/all.rb
Normal file
4
stories/all.rb
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
dir = File.dirname(__FILE__)
|
||||
Dir[File.expand_path("#{dir}/**/*.rb")].uniq.each do |file|
|
||||
require file
|
||||
end
|
||||
|
|
@ -1,136 +1,3 @@
|
|||
ENV["RAILS_ENV"] = "test"
|
||||
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
|
||||
$:.unshift File.join(File.dirname(__FILE__), *%w[.. vendor plugings rspec lib])
|
||||
require 'test_help'
|
||||
require 'test/unit/testresult'
|
||||
require 'spec'
|
||||
require 'spec/rails'
|
||||
require 'spec/story'
|
||||
require 'webrat/selenium'
|
||||
require 'action_controller/test_process'
|
||||
|
||||
module Spec
|
||||
module Story
|
||||
class StepGroup
|
||||
def include_steps_for(name)
|
||||
require File.expand_path(File.dirname(__FILE__) + "/steps/#{name}")
|
||||
step_matchers = rspec_story_steps[name.to_sym]
|
||||
warn "WARNING: 0 step matchers found for include_steps_for(:#{name}). Are you missing an include?" if step_matchers.empty?
|
||||
self << step_matchers
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Test::Unit.run = true
|
||||
|
||||
class SeleniumRailsStory < Test::Unit::TestCase
|
||||
include Spec::Matchers
|
||||
include Spec::Rails::Matchers
|
||||
|
||||
def initialize #:nodoc:
|
||||
# TODO - eliminate this hack, which is here to stop
|
||||
# Rails Stories from dumping the example summary.
|
||||
Spec::Runner::Options.class_eval do
|
||||
def examples_should_be_run?
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
@_result = Test::Unit::TestResult.new
|
||||
end
|
||||
|
||||
def should_see(text_or_regexp)
|
||||
if text_or_regexp.is_a?(Regexp)
|
||||
response.should have_tag("*", text_or_regexp)
|
||||
else
|
||||
response.should have_tag("*", /#{Regexp.escape(text_or_regexp)}/i)
|
||||
end
|
||||
end
|
||||
|
||||
def should_not_see(text_or_regexp)
|
||||
if text_or_regexp.is_a?(Regexp)
|
||||
response.should_not have_tag("*", text_or_regexp)
|
||||
else
|
||||
response.should_not have_tag("*", /#{Regexp.escape(text_or_regexp)}/i)
|
||||
end
|
||||
end
|
||||
|
||||
def response
|
||||
webrat_session.response_body
|
||||
end
|
||||
|
||||
def logged_in_as(user)
|
||||
visits("/selenium_helper/login?as=#{user.login}")
|
||||
end
|
||||
|
||||
def selenium
|
||||
SeleniumDriverManager.instance.running_selenium_driver
|
||||
end
|
||||
|
||||
def badge_count_should_show(count)
|
||||
response.should have_tag('#badge_count', count.to_s)
|
||||
end
|
||||
|
||||
def method_missing(name, *args)
|
||||
if webrat_session.respond_to?(name)
|
||||
webrat_session.send(name, *args)
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def webrat_session
|
||||
@webrat_session ||= begin
|
||||
Webrat::SeleniumSession.new(SeleniumDriverManager.instance.running_selenium_driver)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class DatabaseResetListener
|
||||
include Singleton
|
||||
|
||||
def scenario_started(*args)
|
||||
if defined?(ActiveRecord::Base)
|
||||
connection = ActiveRecord::Base.connection
|
||||
%w[users].each do |table|
|
||||
connection.execute "DELETE FROM #{table}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def method_missing sym, *args, &block
|
||||
# ignore all messages you don't care about
|
||||
end
|
||||
end
|
||||
|
||||
class CookieResetListener
|
||||
include Singleton
|
||||
|
||||
def scenario_started(*args)
|
||||
%w[tracks_login auth_token _session_id].each do |cookie_name|
|
||||
SeleniumDriverManager.instance.running_selenium_driver.get_eval("window.document.cookie = '#{cookie_name}=;expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/';")
|
||||
end
|
||||
end
|
||||
|
||||
def method_missing sym, *args, &block
|
||||
# ignore all messages you don't care about
|
||||
end
|
||||
end
|
||||
|
||||
class Spec::Story::Runner::ScenarioRunner
|
||||
def initialize
|
||||
@listeners = [DatabaseResetListener.instance, CookieResetListener.instance]
|
||||
end
|
||||
end
|
||||
|
||||
class Spec::Story::GivenScenario
|
||||
def perform(instance, name = nil)
|
||||
scenario = Spec::Story::Runner::StoryRunner.scenario_from_current_story @name
|
||||
runner = Spec::Story::Runner::ScenarioRunner.new
|
||||
runner.instance_variable_set(:@listeners,[])
|
||||
runner.run(scenario, instance)
|
||||
end
|
||||
end
|
||||
require 'spec/rails/story_adapter'
|
||||
Loading…
Add table
Add a link
Reference in a new issue