mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-17 07:40:12 +01:00
Added Rspec and Webrat plugins and started porting Selenium on Rails tests to Rspec Plain Text Stories driving Webrat driving Selenium.
This commit is contained in:
parent
0600756bbf
commit
0f7d6f7a1d
602 changed files with 47788 additions and 29 deletions
14
vendor/plugins/rspec-rails/lib/spec/rails/extensions/action_controller/base.rb
vendored
Executable file
14
vendor/plugins/rspec-rails/lib/spec/rails/extensions/action_controller/base.rb
vendored
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
module ActionController
|
||||
class Base
|
||||
class << self
|
||||
def set_view_path(path)
|
||||
[:append_view_path, :view_paths=, :template_root=].each do |method|
|
||||
if respond_to?(method)
|
||||
return send(method, path)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
21
vendor/plugins/rspec-rails/lib/spec/rails/extensions/action_controller/rescue.rb
vendored
Normal file
21
vendor/plugins/rspec-rails/lib/spec/rails/extensions/action_controller/rescue.rb
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
module ActionController
|
||||
module Rescue
|
||||
def use_rails_error_handling!
|
||||
@use_rails_error_handling = true
|
||||
end
|
||||
|
||||
def use_rails_error_handling?
|
||||
@use_rails_error_handling ||= false
|
||||
end
|
||||
|
||||
protected
|
||||
def rescue_action_with_fast_errors(exception)
|
||||
if use_rails_error_handling?
|
||||
rescue_action_without_fast_errors exception
|
||||
else
|
||||
raise exception
|
||||
end
|
||||
end
|
||||
alias_method_chain :rescue_action, :fast_errors
|
||||
end
|
||||
end
|
||||
11
vendor/plugins/rspec-rails/lib/spec/rails/extensions/action_controller/test_response.rb
vendored
Normal file
11
vendor/plugins/rspec-rails/lib/spec/rails/extensions/action_controller/test_response.rb
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
module ActionController #:nodoc:
|
||||
class TestResponse #:nodoc:
|
||||
attr_writer :controller_path
|
||||
|
||||
def capture(name)
|
||||
template.instance_variable_get "@content_for_#{name.to_s}"
|
||||
end
|
||||
alias [] capture
|
||||
|
||||
end
|
||||
end
|
||||
27
vendor/plugins/rspec-rails/lib/spec/rails/extensions/action_view/base.rb
vendored
Normal file
27
vendor/plugins/rspec-rails/lib/spec/rails/extensions/action_view/base.rb
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
module ActionView #:nodoc:
|
||||
class Base #:nodoc:
|
||||
include Spec::Rails::Example::RenderObserver
|
||||
cattr_accessor :base_view_path
|
||||
def render_partial(partial_path, local_assigns = nil, deprecated_local_assigns = nil) #:nodoc:
|
||||
if partial_path.is_a?(String)
|
||||
unless partial_path.include?("/")
|
||||
unless self.class.base_view_path.nil?
|
||||
partial_path = "#{self.class.base_view_path}/#{partial_path}"
|
||||
end
|
||||
end
|
||||
end
|
||||
super(partial_path, local_assigns, deprecated_local_assigns)
|
||||
end
|
||||
|
||||
alias_method :orig_render, :render
|
||||
def render(options = {}, old_local_assigns = {}, &block)
|
||||
if expect_render_mock_proxy.send(:__mock_proxy).send(:find_matching_expectation, :render, options)
|
||||
expect_render_mock_proxy.render(options)
|
||||
else
|
||||
unless expect_render_mock_proxy.send(:__mock_proxy).send(:find_matching_method_stub, :render, options)
|
||||
orig_render(options, old_local_assigns, &block)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
30
vendor/plugins/rspec-rails/lib/spec/rails/extensions/active_record/base.rb
vendored
Normal file
30
vendor/plugins/rspec-rails/lib/spec/rails/extensions/active_record/base.rb
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
if defined?(ActiveRecord::Base)
|
||||
module ActiveRecord #:nodoc:
|
||||
class Base
|
||||
|
||||
(class << self; self; end).class_eval do
|
||||
# Extension for <tt>should have</tt> on AR Model classes
|
||||
#
|
||||
# ModelClass.should have(:no).records
|
||||
# ModelClass.should have(1).record
|
||||
# ModelClass.should have(n).records
|
||||
def records
|
||||
find(:all)
|
||||
end
|
||||
alias :record :records
|
||||
end
|
||||
|
||||
# Extension for <tt>should have</tt> on AR Model instances
|
||||
#
|
||||
# model.should have(:no).errors_on(:attribute)
|
||||
# model.should have(1).error_on(:attribute)
|
||||
# model.should have(n).errors_on(:attribute)
|
||||
def errors_on(attribute)
|
||||
self.valid?
|
||||
[self.errors.on(attribute)].flatten.compact
|
||||
end
|
||||
alias :error_on :errors_on
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
5
vendor/plugins/rspec-rails/lib/spec/rails/extensions/object.rb
vendored
Normal file
5
vendor/plugins/rspec-rails/lib/spec/rails/extensions/object.rb
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class Object # :nodoc:
|
||||
def self.path2class(klassname)
|
||||
klassname.split('::').inject(Object) { |k,n| k.const_get n }
|
||||
end
|
||||
end
|
||||
71
vendor/plugins/rspec-rails/lib/spec/rails/extensions/spec/example/configuration.rb
vendored
Executable file
71
vendor/plugins/rspec-rails/lib/spec/rails/extensions/spec/example/configuration.rb
vendored
Executable file
|
|
@ -0,0 +1,71 @@
|
|||
require 'spec/example/configuration'
|
||||
begin
|
||||
module Spec
|
||||
module Example
|
||||
class Configuration
|
||||
# Rails 1.2.3 does a copy of the @inheritable_attributes to the subclass when the subclass is
|
||||
# created. This causes an ordering issue when setting state on Configuration because the data is
|
||||
# already copied.
|
||||
# Iterating over EXAMPLE_GROUP_CLASSES causes the base ExampleGroup classes to have their
|
||||
# @inheritable_attributes updated.
|
||||
# TODO: BT - When we no longer support Rails 1.2.3, we can remove this functionality
|
||||
EXAMPLE_GROUP_CLASSES = [
|
||||
::Test::Unit::TestCase,
|
||||
::Spec::Rails::Example::RailsExampleGroup,
|
||||
::Spec::Rails::Example::FunctionalExampleGroup,
|
||||
::Spec::Rails::Example::ControllerExampleGroup,
|
||||
::Spec::Rails::Example::ViewExampleGroup,
|
||||
::Spec::Rails::Example::HelperExampleGroup,
|
||||
::Spec::Rails::Example::ModelExampleGroup
|
||||
]
|
||||
# All of this is ActiveRecord related and makes no sense if it's not used by the app
|
||||
if defined?(ActiveRecord::Base)
|
||||
def initialize
|
||||
super
|
||||
self.fixture_path = RAILS_ROOT + '/spec/fixtures'
|
||||
end
|
||||
|
||||
def use_transactional_fixtures
|
||||
Test::Unit::TestCase.use_transactional_fixtures
|
||||
end
|
||||
def use_transactional_fixtures=(value)
|
||||
EXAMPLE_GROUP_CLASSES.each do |example_group|
|
||||
example_group.use_transactional_fixtures = value
|
||||
end
|
||||
end
|
||||
|
||||
def use_instantiated_fixtures
|
||||
Test::Unit::TestCase.use_instantiated_fixtures
|
||||
end
|
||||
def use_instantiated_fixtures=(value)
|
||||
EXAMPLE_GROUP_CLASSES.each do |example_group|
|
||||
example_group.use_instantiated_fixtures = value
|
||||
end
|
||||
end
|
||||
|
||||
def fixture_path
|
||||
Test::Unit::TestCase.fixture_path
|
||||
end
|
||||
def fixture_path=(path)
|
||||
EXAMPLE_GROUP_CLASSES.each do |example_group|
|
||||
example_group.fixture_path = path
|
||||
end
|
||||
end
|
||||
|
||||
def global_fixtures
|
||||
::Test::Unit::TestCase.fixture_table_names
|
||||
end
|
||||
def global_fixtures=(fixtures)
|
||||
EXAMPLE_GROUP_CLASSES.each do |example_group|
|
||||
example_group.fixtures(*fixtures)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
rescue Exception => e
|
||||
puts e.message
|
||||
puts e.backtrace
|
||||
raise e
|
||||
end
|
||||
21
vendor/plugins/rspec-rails/lib/spec/rails/extensions/spec/matchers/have.rb
vendored
Normal file
21
vendor/plugins/rspec-rails/lib/spec/rails/extensions/spec/matchers/have.rb
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
require 'spec/matchers/have'
|
||||
|
||||
module Spec #:nodoc:
|
||||
module Matchers #:nodoc:
|
||||
class Have #:nodoc:
|
||||
alias_method :__original_failure_message, :failure_message
|
||||
def failure_message
|
||||
return "expected #{relativities[@relativity]}#{@expected} errors on :#{@args[0]}, got #{@actual}" if @collection_name == :errors_on
|
||||
return "expected #{relativities[@relativity]}#{@expected} error on :#{@args[0]}, got #{@actual}" if @collection_name == :error_on
|
||||
return __original_failure_message
|
||||
end
|
||||
|
||||
alias_method :__original_description, :description
|
||||
def description
|
||||
return "should have #{relativities[@relativity]}#{@expected} errors on :#{@args[0]}" if @collection_name == :errors_on
|
||||
return "should have #{relativities[@relativity]}#{@expected} error on :#{@args[0]}" if @collection_name == :error_on
|
||||
return __original_description
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue