Restructuring spec tasks
This commit is contained in:
parent
ed6f7fc4a2
commit
bc34dc9ba0
68
Rakefile
68
Rakefile
|
@ -35,42 +35,52 @@ def remove_task(task_name)
|
||||||
Rake.application.remove_task(task_name)
|
Rake.application.remove_task(task_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_file_list
|
|
||||||
if ENV['TEST_MODE'] == "merb"
|
|
||||||
list = FileList['spec/**/*_spec.rb']
|
|
||||||
list = list.find_all do |file| !file.match("rails") end
|
|
||||||
return list
|
|
||||||
else
|
|
||||||
return FileList['spec/**/*_spec.rb']
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
remove_task "test"
|
remove_task "test"
|
||||||
remove_task "test_deps"
|
remove_task "test_deps"
|
||||||
|
|
||||||
desc "Run all specs in spec directory"
|
desc "Run API and Core specs"
|
||||||
Spec::Rake::SpecTask.new do |t|
|
Spec::Rake::SpecTask.new do |t|
|
||||||
t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
|
t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
|
||||||
t.spec_files = set_file_list
|
|
||||||
|
t.spec_files = FileList['spec/api/*_spec.rb'] + FileList['spec/webrat/core/*_spec.rb']
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Run all specs in spec directory with RCov"
|
namespace :spec do
|
||||||
Spec::Rake::SpecTask.new(:rcov) do |t|
|
desc "Run Rails specs"
|
||||||
t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
|
Spec::Rake::SpecTask.new(:rails) do |t|
|
||||||
t.spec_files = set_file_list
|
t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
|
||||||
t.rcov = true
|
t.spec_files = FileList['spec/webrat/rails/*_spec.rb']
|
||||||
t.rcov_opts = lambda do
|
end
|
||||||
IO.readlines(File.dirname(__FILE__) + "/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
|
|
||||||
|
desc "Run Merb specs"
|
||||||
|
Spec::Rake::SpecTask.new(:merb) do |t|
|
||||||
|
t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
|
||||||
|
t.spec_files = FileList['spec/webrat/merb/*_spec.rb']
|
||||||
|
end
|
||||||
|
|
||||||
|
desc "Run Mechanize specs"
|
||||||
|
Spec::Rake::SpecTask.new(:mechanize) do |t|
|
||||||
|
t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
|
||||||
|
t.spec_files = FileList['spec/webrat/mechanize/*_spec.rb']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# desc "Run all specs in spec directory with RCov"
|
||||||
require 'spec/rake/verify_rcov'
|
# Spec::Rake::SpecTask.new(:rcov) do |t|
|
||||||
RCov::VerifyTask.new(:verify_rcov => :rcov) do |t|
|
# t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
|
||||||
t.threshold = 96.2 # Make sure you have rcov 0.7 or higher!
|
# t.spec_files = set_file_list
|
||||||
end
|
# t.rcov = true
|
||||||
|
# t.rcov_opts = lambda do
|
||||||
remove_task "default"
|
# IO.readlines(File.dirname(__FILE__) + "/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
|
||||||
task :default do
|
# end
|
||||||
Rake::Task["verify_rcov"].invoke
|
# end
|
||||||
end
|
#
|
||||||
|
# require 'spec/rake/verify_rcov'
|
||||||
|
# RCov::VerifyTask.new(:verify_rcov => :rcov) do |t|
|
||||||
|
# t.threshold = 96.2 # Make sure you have rcov 0.7 or higher!
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
# remove_task "default"
|
||||||
|
# task :default do
|
||||||
|
# Rake::Task["verify_rcov"].invoke
|
||||||
|
# end
|
|
@ -1,12 +1,17 @@
|
||||||
|
require "rubygems"
|
||||||
|
|
||||||
module Webrat
|
module Webrat
|
||||||
VERSION = '0.2.2'
|
VERSION = '0.2.2'
|
||||||
|
|
||||||
def self.root
|
def self.root
|
||||||
defined?(RAILS_ROOT) ? RAILS_ROOT : Merb.root
|
defined?(RAILS_ROOT) ? RAILS_ROOT : Merb.root
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
require "rubygems"
|
require File.dirname(__FILE__) + "/webrat/core_extensions/blank"
|
||||||
|
require File.dirname(__FILE__) + "/webrat/core_extensions/hash_with_indifferent_access"
|
||||||
|
require File.dirname(__FILE__) + "/webrat/core_extensions/nil_to_param"
|
||||||
require File.dirname(__FILE__) + "/webrat/core"
|
require File.dirname(__FILE__) + "/webrat/core"
|
||||||
require File.dirname(__FILE__) + "/webrat/rails" if defined?(RAILS_ENV)
|
|
||||||
require File.dirname(__FILE__) + "/webrat/merb" if defined?(Merb)
|
require File.dirname(__FILE__) + "/webrat/rails" if defined?(RAILS_ENV)
|
||||||
|
require File.dirname(__FILE__) + "/webrat/merb" if defined?(Merb)
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
class Object
|
||||||
|
# An object is blank if it's false, empty, or a whitespace string.
|
||||||
|
# For example, "", " ", +nil+, [], and {} are blank.
|
||||||
|
#
|
||||||
|
# This simplifies
|
||||||
|
#
|
||||||
|
# if !address.nil? && !address.empty?
|
||||||
|
#
|
||||||
|
# to
|
||||||
|
#
|
||||||
|
# if !address.blank?
|
||||||
|
def blank?
|
||||||
|
respond_to?(:empty?) ? empty? : !self
|
||||||
|
end
|
||||||
|
|
||||||
|
# An object is present if it's not blank.
|
||||||
|
def present?
|
||||||
|
!blank?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class NilClass #:nodoc:
|
||||||
|
def blank?
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class FalseClass #:nodoc:
|
||||||
|
def blank?
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class TrueClass #:nodoc:
|
||||||
|
def blank?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class Array #:nodoc:
|
||||||
|
alias_method :blank?, :empty?
|
||||||
|
end
|
||||||
|
|
||||||
|
class Hash #:nodoc:
|
||||||
|
alias_method :blank?, :empty?
|
||||||
|
end
|
||||||
|
|
||||||
|
class String #:nodoc:
|
||||||
|
def blank?
|
||||||
|
self !~ /\S/
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class Numeric #:nodoc:
|
||||||
|
def blank?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
|
@ -122,4 +122,10 @@ class HashWithIndifferentAccess < Hash
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Hash
|
||||||
|
def with_indifferent_access
|
||||||
|
hash = HashWithIndifferentAccess.new(self)
|
||||||
|
hash.default = self.default
|
||||||
|
hash
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
class NilClass
|
||||||
|
def to_param
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,12 +0,0 @@
|
||||||
class Hash
|
|
||||||
def with_indifferent_access
|
|
||||||
hash = HashWithIndifferentAccess.new(self)
|
|
||||||
hash.default = self.default
|
|
||||||
hash
|
|
||||||
end
|
|
||||||
end
|
|
||||||
class NilClass
|
|
||||||
def to_param
|
|
||||||
nil
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -6,15 +6,9 @@ require "spec/interop/test"
|
||||||
begin require "redgreen" unless ENV['TM_CURRENT_LINE']; rescue LoadError; end
|
begin require "redgreen" unless ENV['TM_CURRENT_LINE']; rescue LoadError; end
|
||||||
|
|
||||||
require File.expand_path(File.dirname(__FILE__) + "/../lib/webrat")
|
require File.expand_path(File.dirname(__FILE__) + "/../lib/webrat")
|
||||||
require File.dirname(__FILE__) + "/fakes/test_session"
|
require File.expand_path(File.dirname(__FILE__) + "/fakes/test_session")
|
||||||
|
require File.expand_path(File.dirname(__FILE__) + "/../lib/webrat/merb/param_parser")
|
||||||
if ["rails","merb"].include?(ENV["TEST_MODE"])
|
require File.expand_path(File.dirname(__FILE__) + "/../lib/webrat/merb/url_encoded_pair_parser")
|
||||||
require File.join(File.dirname(__FILE__), "webrat", "#{ENV["TEST_MODE"]}", "helper.rb")
|
|
||||||
else
|
|
||||||
puts "Assuming test mode is Rails... for Merb set TEST_MODE=merb and rerun."
|
|
||||||
ENV["TEST_MODE"] = 'rails'
|
|
||||||
require File.join(File.dirname(__FILE__), "webrat", "#{ENV["TEST_MODE"]}", "helper.rb")
|
|
||||||
end
|
|
||||||
|
|
||||||
Spec::Runner.configure do |config|
|
Spec::Runner.configure do |config|
|
||||||
# Nothing to configure yet
|
# Nothing to configure yet
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
||||||
unless ENV["TEST_MODE"] == "merb" #TODO - Rob
|
require File.expand_path(File.dirname(__FILE__) + '/helper')
|
||||||
|
|
||||||
describe "attaches_file" do
|
describe "attaches_file" do
|
||||||
before do
|
before do
|
||||||
@session = Webrat::TestSession.new
|
@session = Webrat::TestSession.new
|
||||||
|
@ -69,5 +70,4 @@ describe "attaches_file" do
|
||||||
@session.attaches_file "Picture", @filename, "image/png"
|
@session.attaches_file "Picture", @filename, "image/png"
|
||||||
@session.clicks_button
|
@session.clicks_button
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
|
@ -1,4 +1,5 @@
|
||||||
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
||||||
|
require File.expand_path(File.dirname(__FILE__) + '/helper')
|
||||||
|
|
||||||
describe Webrat::RailsSession do
|
describe Webrat::RailsSession do
|
||||||
it "should require a Rails Integration session to be initialized" do
|
it "should require a Rails Integration session to be initialized" do
|
||||||
|
|
Loading…
Reference in New Issue