taza 0.8.0 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +7 -0
- data/Manifest.txt +14 -0
- data/{README.txt → README} +0 -0
- data/README.textile +1 -0
- data/VERSION.yml +4 -0
- data/generators/flow/templates/flow.rb.erb +2 -5
- data/generators/page/templates/functional_page_spec.rb.erb +1 -1
- data/generators/partial/partial_generator.rb +57 -0
- data/generators/partial/templates/partial.rb.erb +7 -0
- data/generators/site/site_generator.rb +1 -0
- data/lib/app_generators/taza/taza_generator.rb +12 -16
- data/lib/app_generators/taza/templates/rakefile.rb.erb +7 -0
- data/lib/extensions/array.rb +10 -0
- data/lib/extensions/hash.rb +5 -0
- data/lib/extensions/object.rb +24 -0
- data/lib/extensions/string.rb +11 -0
- data/lib/taza.rb +7 -24
- data/lib/taza/browser.rb +9 -16
- data/lib/taza/entity.rb +34 -0
- data/lib/taza/fixture.rb +66 -0
- data/lib/taza/flow.rb +10 -15
- data/lib/taza/page.rb +13 -8
- data/lib/taza/settings.rb +17 -6
- data/lib/taza/site.rb +25 -19
- data/lib/taza/tasks.rb +42 -26
- data/spec/array_spec.rb +16 -0
- data/spec/browser_spec.rb +14 -28
- data/spec/entity_spec.rb +9 -0
- data/spec/fixture_spec.rb +34 -0
- data/spec/fixtures_spec.rb +21 -0
- data/spec/flow_generator_spec.rb +0 -20
- data/spec/hash_spec.rb +12 -0
- data/spec/object_spec.rb +29 -0
- data/spec/page_generator_spec.rb +0 -1
- data/spec/page_spec.rb +14 -0
- data/spec/partial_generator_spec.rb +38 -0
- data/spec/project_generator_spec.rb +6 -1
- data/spec/sandbox/fixtures/examples.yml +8 -0
- data/spec/sandbox/fixtures/users.yml +2 -0
- data/spec/sandbox/flows/batman.rb +4 -1
- data/spec/sandbox/pages/foo/partials/partial_the_reckoning.rb +2 -0
- data/spec/settings_spec.rb +5 -5
- data/spec/site_generator_spec.rb +5 -1
- data/spec/site_spec.rb +19 -29
- data/spec/spec_helper.rb +12 -4
- data/spec/string_spec.rb +7 -0
- data/spec/taza_tasks_spec.rb +17 -1
- metadata +59 -45
- data/Rakefile +0 -125
- data/lib/taza/browsers/ie_watir.rb +0 -8
- data/lib/taza/browsers/safari_watir.rb +0 -8
- data/spec/platform/osx/browser_spec.rb +0 -14
- data/spec/platform/windows/browser_spec.rb +0 -14
- data/spec/unit_helper_spec.rb +0 -14
data/History.txt
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
=== 0.8.2 / 2009-01-11
|
2
|
+
|
3
|
+
* Added Partials
|
4
|
+
* Added Preliminary Fixture Support
|
5
|
+
* Fixed horrible infinite loop bug in Filters
|
6
|
+
* Added Configurability to a Taza projects Rakefile
|
7
|
+
|
1
8
|
=== 0.8.0 / 2008-11-23
|
2
9
|
|
3
10
|
Taza is a web application testing framework meant to be used with browsed-based testing libraries like WATIR or Selenium
|
data/Manifest.txt
CHANGED
@@ -8,6 +8,8 @@ generators/flow/templates/flow.rb.erb
|
|
8
8
|
generators/page/page_generator.rb
|
9
9
|
generators/page/templates/functional_page_spec.rb.erb
|
10
10
|
generators/page/templates/page.rb.erb
|
11
|
+
generators/partial/partial_generator.rb
|
12
|
+
generators/partial/templates/partial.rb.erb
|
11
13
|
generators/site/site_generator.rb
|
12
14
|
generators/site/templates/site.rb.erb
|
13
15
|
generators/site/templates/site.yml.erb
|
@@ -15,7 +17,13 @@ lib/app_generators/taza/taza_generator.rb
|
|
15
17
|
lib/app_generators/taza/templates/config.yml.erb
|
16
18
|
lib/app_generators/taza/templates/rakefile.rb.erb
|
17
19
|
lib/app_generators/taza/templates/spec_helper.rb.erb
|
20
|
+
lib/extensions/object.rb
|
21
|
+
lib/extensions/string.rb
|
22
|
+
lib/extensions/hash.rb
|
23
|
+
lib/extensions/array.rb
|
18
24
|
lib/taza.rb
|
25
|
+
lib/taza/fixture.rb
|
26
|
+
lib/taza/entity.rb
|
19
27
|
lib/taza/browser.rb
|
20
28
|
lib/taza/browsers/ie_watir.rb
|
21
29
|
lib/taza/browsers/safari_watir.rb
|
@@ -25,9 +33,14 @@ lib/taza/settings.rb
|
|
25
33
|
lib/taza/site.rb
|
26
34
|
lib/taza/tasks.rb
|
27
35
|
spec/browser_spec.rb
|
36
|
+
spec/entity_spec.rb
|
28
37
|
spec/flow_generator_spec.rb
|
38
|
+
spec/fixture_spec.rb
|
39
|
+
spec/fixtures_spec.rb
|
40
|
+
spec/object_spec.rb
|
29
41
|
spec/page_generator_spec.rb
|
30
42
|
spec/page_spec.rb
|
43
|
+
spec/partial_generator_spec.rb
|
31
44
|
spec/platform/osx/browser_spec.rb
|
32
45
|
spec/platform/windows/browser_spec.rb
|
33
46
|
spec/project_generator_spec.rb
|
@@ -37,6 +50,7 @@ spec/sandbox/config/site_name.yml
|
|
37
50
|
spec/sandbox/flows/batman.rb
|
38
51
|
spec/sandbox/flows/robin.rb
|
39
52
|
spec/sandbox/pages/foo/bar.rb
|
53
|
+
spec/sandbox/pages/foo/partials/partial_the_reckoning.rb
|
40
54
|
spec/settings_spec.rb
|
41
55
|
spec/site_generator_spec.rb
|
42
56
|
spec/site_spec.rb
|
data/{README.txt → README}
RENAMED
File without changes
|
data/README.textile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
"Taza Wiki":http://github.com/scudco/taza/wikis
|
data/VERSION.yml
ADDED
@@ -1,11 +1,8 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require 'taza/flow'
|
3
2
|
|
4
3
|
module <%= site_name.camelize %>
|
5
|
-
class <%=
|
6
|
-
|
7
|
-
|
8
|
-
def run(params={})
|
4
|
+
class <%= site_name.camelize %> < ::Taza::Site
|
5
|
+
def <%= name.underscore %>_flow(params={})
|
9
6
|
|
10
7
|
end
|
11
8
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rubigen'
|
3
|
+
require 'activesupport'
|
4
|
+
|
5
|
+
class PartialGenerator < RubiGen::Base
|
6
|
+
default_options :author => nil
|
7
|
+
attr_reader :site_name,:name
|
8
|
+
|
9
|
+
def initialize(runtime_args, runtime_options = {})
|
10
|
+
super
|
11
|
+
usage if args.size != 2
|
12
|
+
@name = args.shift
|
13
|
+
@site_name=args.shift
|
14
|
+
check_if_site_exists
|
15
|
+
extract_options
|
16
|
+
end
|
17
|
+
|
18
|
+
def check_if_site_exists
|
19
|
+
unless File.directory?(File.join(destination_root,'lib','sites',site_name.underscore))
|
20
|
+
$stderr.puts "******No such site #{site_name} exists.******"
|
21
|
+
usage
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def manifest
|
26
|
+
record do |m|
|
27
|
+
m.template "partial.rb.erb", File.join('lib','sites', site_name.underscore, "pages", "partials", "#{name.underscore}.rb")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
protected
|
32
|
+
def banner
|
33
|
+
<<-EOS
|
34
|
+
Creates a taza partial for a given taza site, site you are making a partial for must exist first.
|
35
|
+
|
36
|
+
USAGE: #{$0} #{spec.name} partial_name site_name
|
37
|
+
EOS
|
38
|
+
end
|
39
|
+
|
40
|
+
def add_options!(opts)
|
41
|
+
# opts.separator ''
|
42
|
+
# opts.separator 'Options:'
|
43
|
+
# For each option below, place the default
|
44
|
+
# at the top of the file next to "default_options"
|
45
|
+
# opts.on("-a", "--author=\"Your Name\"", String,
|
46
|
+
# "Some comment about this option",
|
47
|
+
# "Default: none") { |options[:author]| }
|
48
|
+
# opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
|
49
|
+
end
|
50
|
+
|
51
|
+
def extract_options
|
52
|
+
# for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
|
53
|
+
# Templates can access these value via the attr_reader-generated methods, but not the
|
54
|
+
# raw instance variable value.
|
55
|
+
# @author = options[:author]
|
56
|
+
end
|
57
|
+
end
|
@@ -20,6 +20,7 @@ class SiteGenerator < RubiGen::Base
|
|
20
20
|
m.directory File.join(site_path,"#{name.underscore}")
|
21
21
|
m.directory File.join(site_path,("#{name.underscore}"),"flows")
|
22
22
|
m.directory File.join(site_path,("#{name.underscore}"),"pages")
|
23
|
+
m.directory File.join(site_path,("#{name.underscore}"),"pages","partials")
|
23
24
|
m.directory File.join('spec','functional',name.underscore)
|
24
25
|
m.template "site.yml.erb", File.join('config',"#{name.underscore}.yml")
|
25
26
|
end
|
@@ -17,29 +17,25 @@ class TazaGenerator < RubiGen::Base
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def manifest
|
20
|
-
record do |m|
|
21
|
-
|
22
|
-
|
23
|
-
BASEDIRS.each { |path| m.directory path }
|
24
|
-
m.directory File.join('lib','sites')
|
25
|
-
m.directory File.join('lib','flows')
|
26
|
-
m.directory File.join('spec','functional')
|
27
|
-
m.directory File.join('spec','integration')
|
28
|
-
|
20
|
+
record do |m|
|
21
|
+
create_directories(m)
|
29
22
|
m.template "rakefile.rb.erb", "rakefile"
|
30
23
|
m.template "config.yml.erb", File.join("config","config.yml")
|
31
24
|
m.template "spec_helper.rb.erb", File.join("spec","spec_helper.rb")
|
32
|
-
|
33
|
-
# Create stubs
|
34
|
-
# m.template_copy_each ["template.rb", "template2.rb"]
|
35
|
-
# m.file "file", "some_file_copied"
|
36
|
-
# m.file_copy_each ["path/to/file", "path/to/file2"]
|
37
|
-
|
38
25
|
m.dependency "install_rubigen_scripts", [destination_root, 'taza'],
|
39
26
|
:shebang => options[:shebang], :collision => :force
|
40
27
|
end
|
41
28
|
end
|
42
29
|
|
30
|
+
def create_directories(m)
|
31
|
+
BASEDIRS.each { |path| m.directory path }
|
32
|
+
m.directory File.join('lib','sites')
|
33
|
+
m.directory File.join('lib','flows')
|
34
|
+
m.directory File.join('spec','functional')
|
35
|
+
m.directory File.join('spec','integration')
|
36
|
+
m.directory File.join('spec','story')
|
37
|
+
end
|
38
|
+
|
43
39
|
protected
|
44
40
|
def banner
|
45
41
|
<<-EOS
|
@@ -73,4 +69,4 @@ EOS
|
|
73
69
|
script
|
74
70
|
spec
|
75
71
|
)
|
76
|
-
end
|
72
|
+
end
|
@@ -1,3 +1,10 @@
|
|
1
1
|
<%= "#Generated at #{Time.now}" %>
|
2
2
|
require 'rubygems'
|
3
3
|
require 'taza/tasks'
|
4
|
+
|
5
|
+
Taza::Rake::Tasks.new do |t|
|
6
|
+
file_hole = "artifacts/#{Time.now.to_i}"
|
7
|
+
t.spec_opts = ["--format html:#{file_hole}/index.html",
|
8
|
+
"--format p",
|
9
|
+
"--format failing_examples:#{file_hole}/failing_examples.txt"]
|
10
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class Array
|
2
|
+
# Returns true if the two arrays elements are equal ignoring order
|
3
|
+
# Example:
|
4
|
+
# [1,2].equivalent([2,1]) # => true
|
5
|
+
# [1,2,3].equivalent([2,1]) # => false
|
6
|
+
def equivalent?(other_array)
|
7
|
+
merged_array = self & other_array
|
8
|
+
merged_array.size == self.size && merged_array.size == other_array.size
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# instance_exec comes with >1.8.7 thankfully
|
2
|
+
if VERSION <= '1.8.6'
|
3
|
+
class Object
|
4
|
+
module InstanceExecHelper; end
|
5
|
+
include InstanceExecHelper
|
6
|
+
# instance_exec method evaluates a block of code relative to the specified object, with parameters whom come from outside the object.
|
7
|
+
def instance_exec(*args, &block)
|
8
|
+
begin
|
9
|
+
old_critical, Thread.critical = Thread.critical, true
|
10
|
+
n = 0
|
11
|
+
n += 1 while respond_to?(mname="__instance_exec#{n}")
|
12
|
+
InstanceExecHelper.module_eval{ define_method(mname, &block) }
|
13
|
+
ensure
|
14
|
+
Thread.critical = old_critical
|
15
|
+
end
|
16
|
+
begin
|
17
|
+
ret = send(mname, *args)
|
18
|
+
ensure
|
19
|
+
InstanceExecHelper.module_eval{ remove_method(mname) } rescue nil
|
20
|
+
end
|
21
|
+
ret
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/taza.rb
CHANGED
@@ -3,9 +3,15 @@ require 'taza/site'
|
|
3
3
|
require 'taza/browser'
|
4
4
|
require 'taza/settings'
|
5
5
|
require 'taza/flow'
|
6
|
+
require 'taza/entity'
|
7
|
+
require 'taza/fixture'
|
8
|
+
require 'extensions/object'
|
9
|
+
require 'extensions/string'
|
10
|
+
require 'extensions/hash'
|
11
|
+
require 'extensions/array'
|
6
12
|
|
7
13
|
module Taza
|
8
|
-
VERSION = '0.8.
|
14
|
+
VERSION = '0.8.1'
|
9
15
|
|
10
16
|
def self.windows?
|
11
17
|
PLATFORM.include?("mswin")
|
@@ -27,26 +33,3 @@ module ForwardInitialization
|
|
27
33
|
end
|
28
34
|
end
|
29
35
|
|
30
|
-
# instance_exec comes with >1.8.7 thankfully
|
31
|
-
if VERSION <= '1.8.6'
|
32
|
-
class Object
|
33
|
-
module InstanceExecHelper; end
|
34
|
-
include InstanceExecHelper
|
35
|
-
def instance_exec(*args, &block)
|
36
|
-
begin
|
37
|
-
old_critical, Thread.critical = Thread.critical, true
|
38
|
-
n = 0
|
39
|
-
n += 1 while respond_to?(mname="__instance_exec#{n}")
|
40
|
-
InstanceExecHelper.module_eval{ define_method(mname, &block) }
|
41
|
-
ensure
|
42
|
-
Thread.critical = old_critical
|
43
|
-
end
|
44
|
-
begin
|
45
|
-
ret = send(mname, *args)
|
46
|
-
ensure
|
47
|
-
InstanceExecHelper.module_eval{ remove_method(mname) } rescue nil
|
48
|
-
end
|
49
|
-
ret
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
data/lib/taza/browser.rb
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
require 'taza/browsers/ie_watir'
|
2
|
-
require 'taza/browsers/safari_watir'
|
3
|
-
|
4
1
|
module Taza
|
5
2
|
class Browser
|
6
3
|
|
@@ -12,29 +9,25 @@ module Taza
|
|
12
9
|
def self.create(params={})
|
13
10
|
self.send("create_#{params[:driver]}".to_sym,params)
|
14
11
|
end
|
15
|
-
|
12
|
+
|
13
|
+
def self.browser_class(params)
|
14
|
+
self.send("#{params[:driver]}_#{params[:browser]}".to_sym)
|
15
|
+
end
|
16
16
|
|
17
17
|
private
|
18
18
|
|
19
19
|
def self.create_watir(params)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
watir
|
20
|
+
require 'watir'
|
21
|
+
Watir::Browser.default = params[:browser].to_s
|
22
|
+
Watir::Browser.new
|
24
23
|
end
|
25
24
|
|
26
25
|
def self.create_selenium(params)
|
27
26
|
require 'selenium'
|
28
27
|
Selenium::SeleniumDriver.new(params[:server_ip],params[:server_port],'*' + params[:browser].to_s,params[:timeout])
|
29
28
|
end
|
30
|
-
|
31
|
-
def self.create_watir_firefox
|
32
|
-
require 'firewatir'
|
33
|
-
FireWatir::Firefox.new()
|
34
|
-
end
|
35
|
-
|
29
|
+
|
36
30
|
end
|
31
|
+
|
37
32
|
end
|
38
33
|
|
39
|
-
class BrowserUnsupportedError < StandardError
|
40
|
-
end
|
data/lib/taza/entity.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
module Taza
|
2
|
+
class Entity
|
3
|
+
#Creates a entity, pass in a hash to be methodized and the fixture to look up other fixtures (not entirely happy with this abstraction)
|
4
|
+
def initialize(hash,fixture)
|
5
|
+
@hash = hash
|
6
|
+
@fixture = fixture
|
7
|
+
define_methods_for_hash_keys
|
8
|
+
end
|
9
|
+
|
10
|
+
#This method converts hash keys into methods onto the entity
|
11
|
+
def define_methods_for_hash_keys
|
12
|
+
@hash.keys.each do |key|
|
13
|
+
create_method(key) do
|
14
|
+
get_value_for_entry(key)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
#This method will lookup another fixture if a pluralized fixture exists otherwise return the value in the hash
|
20
|
+
def get_value_for_entry(key) # :nodoc:
|
21
|
+
if @fixture.pluralized_fixture_exists?(key)
|
22
|
+
@fixture.get_fixture_entity(key.pluralize_to_sym,@hash[key])
|
23
|
+
else
|
24
|
+
@hash[key]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
def create_method(name, &block) # :nodoc:
|
30
|
+
self.class.send(:define_method, name, &block)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
data/lib/taza/fixture.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
module Taza
|
2
|
+
class Fixture # :nodoc:
|
3
|
+
|
4
|
+
def initialize # :nodoc:
|
5
|
+
@fixtures = {}
|
6
|
+
end
|
7
|
+
|
8
|
+
def load_all # :nodoc:
|
9
|
+
Dir.glob(fixtures_pattern) do |file|
|
10
|
+
entitized_fixture = {}
|
11
|
+
YAML.load_file(file).each do |key, value|
|
12
|
+
entitized_fixture[key] = value.convert_hash_keys_to_methods(self)
|
13
|
+
end
|
14
|
+
@fixtures[File.basename(file,'.yml').to_sym] = entitized_fixture
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def fixture_names # :nodoc:
|
19
|
+
@fixtures.keys
|
20
|
+
end
|
21
|
+
|
22
|
+
def get_fixture_entity(fixture_file_key,entity_key) # :nodoc:
|
23
|
+
@fixtures[fixture_file_key][entity_key]
|
24
|
+
end
|
25
|
+
|
26
|
+
def pluralized_fixture_exists?(singularized_fixture_name) # :nodoc:
|
27
|
+
fixture_names.include?(singularized_fixture_name.pluralize_to_sym)
|
28
|
+
end
|
29
|
+
|
30
|
+
def fixtures_pattern # :nodoc:
|
31
|
+
File.join(base_path, 'fixtures','*.yml')
|
32
|
+
end
|
33
|
+
|
34
|
+
def base_path # :nodoc:
|
35
|
+
File.join('.','spec')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# The module that will mixin methods based on the fixture files in your 'spec/fixtures'
|
40
|
+
#
|
41
|
+
# Example:
|
42
|
+
# describe "something" do
|
43
|
+
# it "should test something" do
|
44
|
+
# users(:jane_smith).first_name.should eql("jane")
|
45
|
+
# end
|
46
|
+
# end
|
47
|
+
#
|
48
|
+
# where there is a spec/fixtures/users.yml file containing a entry of:
|
49
|
+
# jane_smith:
|
50
|
+
# first_name: jane
|
51
|
+
# last_name: smith
|
52
|
+
module Fixtures
|
53
|
+
def Fixtures.included(other_module) # :nodoc:
|
54
|
+
fixture = Fixture.new
|
55
|
+
fixture.load_all
|
56
|
+
fixture.fixture_names.each do |fixture_name|
|
57
|
+
self.class_eval do
|
58
|
+
define_method(fixture_name) do |entity_key|
|
59
|
+
fixture.get_fixture_entity(fixture_name,entity_key.to_s)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|