taza 0.8.0 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/History.txt +7 -0
  2. data/Manifest.txt +14 -0
  3. data/{README.txt → README} +0 -0
  4. data/README.textile +1 -0
  5. data/VERSION.yml +4 -0
  6. data/generators/flow/templates/flow.rb.erb +2 -5
  7. data/generators/page/templates/functional_page_spec.rb.erb +1 -1
  8. data/generators/partial/partial_generator.rb +57 -0
  9. data/generators/partial/templates/partial.rb.erb +7 -0
  10. data/generators/site/site_generator.rb +1 -0
  11. data/lib/app_generators/taza/taza_generator.rb +12 -16
  12. data/lib/app_generators/taza/templates/rakefile.rb.erb +7 -0
  13. data/lib/extensions/array.rb +10 -0
  14. data/lib/extensions/hash.rb +5 -0
  15. data/lib/extensions/object.rb +24 -0
  16. data/lib/extensions/string.rb +11 -0
  17. data/lib/taza.rb +7 -24
  18. data/lib/taza/browser.rb +9 -16
  19. data/lib/taza/entity.rb +34 -0
  20. data/lib/taza/fixture.rb +66 -0
  21. data/lib/taza/flow.rb +10 -15
  22. data/lib/taza/page.rb +13 -8
  23. data/lib/taza/settings.rb +17 -6
  24. data/lib/taza/site.rb +25 -19
  25. data/lib/taza/tasks.rb +42 -26
  26. data/spec/array_spec.rb +16 -0
  27. data/spec/browser_spec.rb +14 -28
  28. data/spec/entity_spec.rb +9 -0
  29. data/spec/fixture_spec.rb +34 -0
  30. data/spec/fixtures_spec.rb +21 -0
  31. data/spec/flow_generator_spec.rb +0 -20
  32. data/spec/hash_spec.rb +12 -0
  33. data/spec/object_spec.rb +29 -0
  34. data/spec/page_generator_spec.rb +0 -1
  35. data/spec/page_spec.rb +14 -0
  36. data/spec/partial_generator_spec.rb +38 -0
  37. data/spec/project_generator_spec.rb +6 -1
  38. data/spec/sandbox/fixtures/examples.yml +8 -0
  39. data/spec/sandbox/fixtures/users.yml +2 -0
  40. data/spec/sandbox/flows/batman.rb +4 -1
  41. data/spec/sandbox/pages/foo/partials/partial_the_reckoning.rb +2 -0
  42. data/spec/settings_spec.rb +5 -5
  43. data/spec/site_generator_spec.rb +5 -1
  44. data/spec/site_spec.rb +19 -29
  45. data/spec/spec_helper.rb +12 -4
  46. data/spec/string_spec.rb +7 -0
  47. data/spec/taza_tasks_spec.rb +17 -1
  48. metadata +59 -45
  49. data/Rakefile +0 -125
  50. data/lib/taza/browsers/ie_watir.rb +0 -8
  51. data/lib/taza/browsers/safari_watir.rb +0 -8
  52. data/spec/platform/osx/browser_spec.rb +0 -14
  53. data/spec/platform/windows/browser_spec.rb +0 -14
  54. data/spec/unit_helper_spec.rb +0 -14
@@ -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
@@ -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
File without changes
@@ -0,0 +1 @@
1
+ "Taza Wiki":http://github.com/scudco/taza/wikis
@@ -0,0 +1,4 @@
1
+ ---
2
+ major: 0
3
+ patch: 2
4
+ minor: 8
@@ -1,11 +1,8 @@
1
1
  require 'rubygems'
2
- require 'taza/flow'
3
2
 
4
3
  module <%= site_name.camelize %>
5
- class <%= name.camelize %> < ::Taza::Flow
6
- alias :<%= site_name.underscore %> :site
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
@@ -1,7 +1,7 @@
1
1
  require 'spec/spec_helper'
2
2
  require '<%= site_name.underscore %>'
3
3
 
4
- describe "<%= name.camelize %>" do
4
+ describe "<%= name.camelize %>Page" do
5
5
  it "should fail because you haven't written any tests yet" do
6
6
  false.should be_true
7
7
  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
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+
3
+ module <%= site_name.camelize %>
4
+ class <%= name.camelize %> < ::Taza::Page
5
+
6
+ end
7
+ 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
- # Ensure appropriate folder(s) exists
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,5 @@
1
+ class Hash
2
+ def convert_hash_keys_to_methods(fixture) # :nodoc:
3
+ Taza::Entity.new(self,fixture)
4
+ end
5
+ 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
@@ -0,0 +1,11 @@
1
+ require 'rubygems'
2
+ require 'activesupport'
3
+
4
+ class String
5
+ # pluralizes a string and turns it into a symbol
6
+ # Example:
7
+ # "apple".pluralize_to_sym # => :apples
8
+ def pluralize_to_sym
9
+ self.pluralize.to_sym
10
+ end
11
+ end
@@ -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.0'
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
@@ -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
- method = "create_watir_#{params[:browser]}"
21
- raise BrowserUnsupportedError unless self.respond_to?(method)
22
- watir = self.send(method)
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
@@ -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
@@ -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