Skip to content

Commit

Permalink
removed next_release and regression dirs and replaced with applicatio…
Browse files Browse the repository at this point in the history
…n_tests
  • Loading branch information
drewolson committed May 23, 2008
1 parent d79f292 commit f054301
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 94 deletions.
2 changes: 0 additions & 2 deletions Manifest.txt
Expand Up @@ -26,7 +26,6 @@ lib/test_sweet.rb
lib/test_sweet/filter_error.rb
lib/test_sweet/page.rb
lib/test_sweet/site.rb
lib/test_sweet/tag.rb
lib/test_sweet/tag_filter.rb
test/config/foo_site/default.yaml
test/config/foo_site/foo.yaml
Expand All @@ -37,5 +36,4 @@ test/tag_files/tag_file_a_b.rb
test/tag_files/tag_file_b.rb
test/test_page.rb
test/test_site.rb
test/test_tag.rb
test/test_tag_filter.rb
1 change: 1 addition & 0 deletions Rakefile
Expand Up @@ -11,6 +11,7 @@ Hoe.new('test_sweet', TestSweet::VERSION) do |p|
p.extra_deps << ['rspec', '>= 1.1.3']
p.extra_deps << ['block-chainable', '>= 0.0.3']
p.extra_deps << ['ci_reporter', '>= 1.5.1']
p.extra_deps << ['activesupport', '>= 2.0.2']
end

# vim: syntax=Ruby
15 changes: 13 additions & 2 deletions lib/sweet_generator/files/application.rb
Expand Up @@ -11,9 +11,17 @@ def start_browser
# browser being created as a Struct
self.browser = Struct.new(:url).new(environment['url'])

# browser being created as a Watir::IE instance
# self.browser = Watir::IE.new
# examples below for starting Selenium and Watir. Both depend on the url
# field being set in your site config/default.yaml to the base url of the
# site.

# example of browser being created as a Watir::IE instance
# self.browser = Watir::IE.new

# example of browser being created as a Selenium firefox instance
# self.browser = Selenium::SeleniumDriver.new("localhost", 4444, "*chrome", environment['url'], 30000)

# open the browser at your start page
start_page
end

Expand All @@ -22,6 +30,9 @@ def start_browser
def start_page
# browser being redirected to start page using Watir
# browser.start(environment['url'])

# browser being redirected to start page using selenium
# browser.open('/')
end
end
end
Expand Down
93 changes: 22 additions & 71 deletions lib/sweet_generator/files/rakefile.rb
Expand Up @@ -7,102 +7,53 @@
require 'fileutils'
require 'test_sweet/tag_filter'

desc 'Run current release functional tests'
task :test => ['test:release']

desc 'Run current release functional specs'
task :spec => ['spec:release']
desc 'Run unit tests'
Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = FileList['test/**/test*.rb']
t.verbose = true
end

namespace :test do
desc 'Run current release functional tests'
Rake::TestTask.new(:release) do |t|
desc 'Run application tests'
Rake::TestTask.new(:application) do |t|
app = ENV['app']
tags = ENV['tag']

file_pattern = "next_release/**/#{app+'/**/' if app}test*.rb"

if tags
tags = tags.split(',')
t.test_files = TestSweet::TagFilter.filter(file_pattern,tags)
else
t.test_files = FileList[file_pattern]
end

t.verbose = true
end

desc 'Run regression functional tests'
Rake::TestTask.new(:regression) do |t|
app = ENV['app']
release = ENV['release']
tags = ENV['tag']

file_pattern = "regression/**/#{release+'/**/' if release}#{app+'/**/' if app}test*.rb"

file_pattern = "application_tests/**/#{app+'/**/' if app}test*.rb"

if tags
tags = tags.split(',')
t.test_files = TestSweet::TagFilter.filter(file_pattern,tags)
else
t.test_files = FileList[file_pattern]
end

t.verbose = true
end
end

desc 'Run lib specs'
Spec::Rake::SpecTask.new do |t|
t.warning = true
t.spec_files = FileList['spec/**/*spec.rb']
end

namespace :spec do
desc 'Run current release functional specs'
Spec::Rake::SpecTask.new(:release) do |t|
desc 'Run application specs'
Spec::Rake::SpecTask.new(:application) do |t|
app = ENV['app']
tags = ENV['tag']

file_pattern = "next_release/**/#{app+'/**/' if app}*spec.rb"

if tags
tags = tags.split(',')
t.spec_files = TestSweet::TagFilter.filter(file_pattern,tags)
else
t.spec_files = FileList[file_pattern]
end

t.verbose = true
end

desc 'Run regression functional specs'
Spec::Rake::SpecTask.new(:regression) do |t|
app = ENV['app']
release = ENV['release']
tags = ENV['tag']

file_pattern = "regression/**/#{release+'/**/' if release}#{app+'/**/' if app}*spec.rb"

file_pattern = "application_tests/**/#{app+'/**/' if app}*spec.rb"

if tags
tags = tags.split(',')
t.spec_files = TestSweet::TagFilter.filter(file_pattern,tags)
else
t.spec_files = FileList[file_pattern]
end

t.verbose = true
end
end

desc 'Move tests from next_release into regression'
task :branch do
unless ENV['version']
puts 'Please specifiy a version for the branch'
else
version = ENV['version'].gsub(".","_")
if File.exist?("regression/#{version}")
puts "Branch version #{ENV['version']} already exists"
else
puts 'Creating new branch in regression...'
FileUtils.mkdir("regression/#{version}")
puts 'Moving files from next_release to new branch...'
FileUtils.cp_r("next_release/.","regression/#{version}")
puts 'Cleaning next_release...'
FileUtils.rm_r(Dir.glob("next_release/*"))
puts 'Complete!'
end
end
end
2 changes: 1 addition & 1 deletion lib/sweet_generator/script/destroyers/site.rb
Expand Up @@ -24,7 +24,7 @@ def destroy
remove_file site_file
end

['pages','config','flows'].each do |dir|
['pages','config','flows','application_tests'].each do |dir|
remove_dir File.join(file_dir,'..','..',dir,Inflector.underscore(@name))
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/sweet_generator/script/destroyers/spec.rb
Expand Up @@ -17,7 +17,7 @@ def initialize(*args)
def destroy
file_dir = File.expand_path(File.dirname(__FILE__))

spec_dir = File.join(file_dir,'..','..','next_release',@site)
spec_dir = File.join(file_dir,'..','..','application_tests',@site)

unless File.exist? spec_dir
raise ArgumentError, 'the specified site does not exist'
Expand Down
4 changes: 2 additions & 2 deletions lib/sweet_generator/script/destroyers/test.rb
Expand Up @@ -17,13 +17,13 @@ def initialize(*args)
def destroy
file_dir = File.expand_path(File.dirname(__FILE__))

test_dir = File.join(file_dir,'..','..','next_release',@site)
test_dir = File.join(file_dir,'..','..','application_tests',@site)

unless File.exist? test_dir
raise ArgumentError, 'the specified site does not exist'
end

test_file = File.join(test_dir,"test_#{Inflector.underscore(name)}.rb")
test_file = File.join(test_dir,"test_#{Inflector.underscore(@name)}.rb")

unless File.exist? test_file
raise ArgumentError, 'the specified test does not exist'
Expand Down
2 changes: 1 addition & 1 deletion lib/sweet_generator/script/generators/site.rb
Expand Up @@ -35,7 +35,7 @@ def generate
class #{Inflector.camelize(@name)} < TestSweet::Site; end
EOS

['pages','flows','config','next_release'].each do |dir|
['pages','flows','config','application_tests'].each do |dir|
site_dir = File.join(file_dir,'..','..',dir,"#{Inflector.underscore(@name)}")

unless File.exist? site_dir
Expand Down
2 changes: 1 addition & 1 deletion lib/sweet_generator/script/generators/spec.rb
Expand Up @@ -17,7 +17,7 @@ def initialize(*args)
def generate
file_dir = File.expand_path(File.dirname(__FILE__))

spec_dir = File.join(file_dir,'..','..','next_release',@site)
spec_dir = File.join(file_dir,'..','..','application_tests',@site)

unless File.exist? spec_dir
raise ArgumentError, 'the specified site does not exist'
Expand Down
2 changes: 1 addition & 1 deletion lib/sweet_generator/script/generators/test.rb
Expand Up @@ -17,7 +17,7 @@ def initialize(*args)
def generate
file_dir = File.expand_path(File.dirname(__FILE__))

test_dir = File.join(file_dir,'..','..','next_release',@site)
test_dir = File.join(file_dir,'..','..','application_tests',@site)

unless File.exist? test_dir
raise ArgumentError, 'the specified site does not exist'
Expand Down
7 changes: 4 additions & 3 deletions lib/sweet_generator/sweet_generator.rb
Expand Up @@ -5,15 +5,16 @@ class SweetGenerator
CURRENT_DIR = File.expand_path('.')

APP_SKELETON = %w(
application_tests
config
flows
lib
next_release
log
pages
regression
script
sites
log
spec
test
tmp
)

Expand Down
16 changes: 7 additions & 9 deletions lib/test_sweet/page.rb
Expand Up @@ -32,15 +32,13 @@ def self.filters
def initialize
# build methods for elements
self.class.elements.each do |element,block|
self.class.class_eval do
define_method("__#{element}_block",&block)

define_method(element) do |*args|
if (self.class.filters[:all].to_a + self.class.filters[element].to_a).all?{|filter| instance_eval(&filter)}
self.send("__#{element}_block",*args)
else
raise FilterError, "All filters for #{element} did not return true"
end
self.class.send(:define_method,"__#{element}_block",&block)

self.class.send(:define_method,element) do |*args|
if (self.class.filters[:all].to_a + self.class.filters[element].to_a).all?{|filter| instance_eval(&filter)}
self.send("__#{element}_block",*args)
else
raise FilterError, "All filters for #{element} did not return true"
end
end
end
Expand Down

0 comments on commit f054301

Please sign in to comment.