scudco-taza 0.8.1 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +3 -1
- data/VERSION.yml +1 -1
- data/generators/page/templates/functional_page_spec.rb.erb +1 -1
- data/lib/app_generators/taza/templates/rakefile.rb.erb +7 -0
- data/lib/taza/browser.rb +20 -3
- data/lib/taza/page.rb +13 -8
- data/lib/taza/tasks.rb +37 -33
- data/spec/browser_spec.rb +0 -5
- data/spec/page_spec.rb +14 -0
- data/spec/project_generator_spec.rb +6 -0
- data/spec/taza_tasks_spec.rb +2 -0
- metadata +3 -3
data/History.txt
CHANGED
data/VERSION.yml
CHANGED
@@ -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
|
data/lib/taza/browser.rb
CHANGED
@@ -17,9 +17,10 @@ module Taza
|
|
17
17
|
private
|
18
18
|
|
19
19
|
def self.create_watir(params)
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
method = "watir_#{params[:browser]}"
|
21
|
+
raise BrowserUnsupportedError unless self.respond_to?(method)
|
22
|
+
watir = self.send(method).new
|
23
|
+
watir
|
23
24
|
end
|
24
25
|
|
25
26
|
def self.create_selenium(params)
|
@@ -27,7 +28,23 @@ module Taza
|
|
27
28
|
Selenium::SeleniumDriver.new(params[:server_ip],params[:server_port],'*' + params[:browser].to_s,params[:timeout])
|
28
29
|
end
|
29
30
|
|
31
|
+
def self.watir_firefox
|
32
|
+
require 'firewatir'
|
33
|
+
FireWatir::Firefox
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.watir_safari
|
37
|
+
require 'safariwatir'
|
38
|
+
Watir::Safari
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.watir_ie
|
42
|
+
require 'watir'
|
43
|
+
Watir::IE
|
44
|
+
end
|
30
45
|
end
|
31
46
|
|
47
|
+
# We don't know how to create the browser you asked for
|
48
|
+
class BrowserUnsupportedError < StandardError; end
|
32
49
|
end
|
33
50
|
|
data/lib/taza/page.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
module Taza
|
2
2
|
# An abstraction of a web page, place the elements you care about accessing in here as well as specify the filters that apply when trying to access the element.
|
3
|
-
#
|
3
|
+
#
|
4
4
|
# Example:
|
5
5
|
# require 'taza'
|
6
6
|
# class HomePage < Taza::Page
|
7
7
|
# element(:foo) {browser.element_by_xpath('some xpath')}
|
8
|
-
# filter :title_given, :foo
|
9
|
-
#
|
8
|
+
# filter :title_given, :foo
|
9
|
+
#
|
10
10
|
# def title_given
|
11
11
|
# browser.title.nil?
|
12
12
|
# end
|
13
13
|
# end
|
14
|
-
#
|
14
|
+
#
|
15
15
|
# homepage.foo will return the element specified in the block if the filter returned true
|
16
16
|
class Page
|
17
17
|
attr_accessor :browser
|
@@ -39,12 +39,12 @@ module Taza
|
|
39
39
|
# Example:
|
40
40
|
# class HomePage < Taza::Page
|
41
41
|
# element(:foo) {browser.element_by_xpath('some xpath')}
|
42
|
-
# filter :title_given, :foo
|
42
|
+
# filter :title_given, :foo
|
43
43
|
# #a filter will apply to all elements if none are specified
|
44
44
|
# filter :some_filter
|
45
45
|
# #a filter will also apply to all elements if the symbol :all is given
|
46
46
|
# filter :another_filter, :all
|
47
|
-
#
|
47
|
+
#
|
48
48
|
# def some_filter
|
49
49
|
# true
|
50
50
|
# end
|
@@ -66,6 +66,7 @@ module Taza
|
|
66
66
|
|
67
67
|
def initialize
|
68
68
|
add_element_methods
|
69
|
+
@active_filters = []
|
69
70
|
end
|
70
71
|
|
71
72
|
def add_element_methods # :nodoc:
|
@@ -83,10 +84,14 @@ module Taza
|
|
83
84
|
end
|
84
85
|
end
|
85
86
|
end
|
86
|
-
|
87
|
+
|
87
88
|
def check_filters(params) # :nodoc:
|
88
89
|
params[:filters].each do |filter_method|
|
89
|
-
|
90
|
+
unless @active_filters.include?(filter_method)
|
91
|
+
@active_filters << filter_method
|
92
|
+
raise FilterError, "#{filter_method} returned false for #{params[:element_name]}" unless send(filter_method)
|
93
|
+
@active_filters.delete(filter_method)
|
94
|
+
end
|
90
95
|
end
|
91
96
|
end
|
92
97
|
end
|
data/lib/taza/tasks.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'rake/testtask'
|
3
1
|
require 'rubygems'
|
2
|
+
require 'rake'
|
4
3
|
require 'taglob/rake/tasks'
|
5
4
|
require 'spec/rake/spectask'
|
6
5
|
|
@@ -8,41 +7,46 @@ def tags
|
|
8
7
|
ENV['TAGS']
|
9
8
|
end
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
FileUtils.mkdir_p(dir_name) unless File.directory?(dir_name)
|
16
|
-
["--format","html:#{file_name}","--format","p"]
|
17
|
-
end
|
10
|
+
module Taza
|
11
|
+
module Rake
|
12
|
+
class Tasks
|
13
|
+
attr_accessor :spec_opts
|
18
14
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
24
|
-
desc "Run all integration specs"
|
25
|
-
Spec::Rake::SpecTask.new :integration do |t|
|
26
|
-
t.spec_files = Dir.taglob('spec/integration/**/*_spec.rb',tags)
|
27
|
-
t.spec_opts << format_options("integration/all")
|
28
|
-
end
|
15
|
+
def initialize
|
16
|
+
yield self if block_given?
|
17
|
+
define
|
18
|
+
end
|
29
19
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
t.spec_files = Dir.taglob("#{dir}**/*_spec.rb",tags)
|
36
|
-
t.spec_opts << format_options("functional/#{site_name}/all")
|
20
|
+
def define_spec_task(name,glob_path)
|
21
|
+
Spec::Rake::SpecTask.new name do |t|
|
22
|
+
t.spec_files = Dir.taglob(glob_path,tags)
|
23
|
+
t.spec_opts << spec_opts
|
24
|
+
end
|
37
25
|
end
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
26
|
+
|
27
|
+
def define
|
28
|
+
namespace :spec do
|
29
|
+
desc "Run all functional specs"
|
30
|
+
define_spec_task(:functional,'spec/functional/**/*_spec.rb')
|
31
|
+
desc "Run all integration specs"
|
32
|
+
define_spec_task(:integration,'spec/integration/**/*_spec.rb')
|
33
|
+
|
34
|
+
namespace :functional do
|
35
|
+
Dir.glob('./spec/functional/*/').each do |dir|
|
36
|
+
site_name = File.basename(dir)
|
37
|
+
desc "Run all functional specs for #{site_name}"
|
38
|
+
define_spec_task(site_name,"#{dir}**/*_spec.rb")
|
39
|
+
|
40
|
+
namespace site_name do
|
41
|
+
Dir.glob("./spec/functional/#{site_name}/*_spec.rb").each do |page_spec_file|
|
42
|
+
page_name = File.basename(page_spec_file,'_spec.rb')
|
43
|
+
define_spec_task(page_name,page_spec_file)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
45
48
|
end
|
49
|
+
|
46
50
|
end
|
47
51
|
end
|
48
52
|
end
|
data/spec/browser_spec.rb
CHANGED
@@ -16,11 +16,6 @@ describe Taza::Browser do
|
|
16
16
|
ENV['TIMEOUT'] = nil
|
17
17
|
end
|
18
18
|
|
19
|
-
module Watir
|
20
|
-
class Safari
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
19
|
it "should raise unknown browser error for unsupported watir browsers" do
|
25
20
|
lambda { Taza::Browser.create(:browser => :foo_browser_9000,:driver => :watir) }.should raise_error(StandardError)
|
26
21
|
end
|
data/spec/page_spec.rb
CHANGED
@@ -11,6 +11,20 @@ describe Taza::Page do
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
class RecursiveFilterExample < Taza::Page
|
15
|
+
element(:foo) {}
|
16
|
+
filter :sample_filter
|
17
|
+
def sample_filter
|
18
|
+
foo
|
19
|
+
true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should not enter a infinite loop if you call a filtered element inside of a filter" do
|
24
|
+
page = RecursiveFilterExample.new
|
25
|
+
lambda { page.foo }.should_not raise_error
|
26
|
+
end
|
27
|
+
|
14
28
|
it "should execute an element's block with the params provided for its method" do
|
15
29
|
Taza::Page.element(:boo){|baz| baz}
|
16
30
|
Taza::Page.new.boo("rofl").should == "rofl"
|
@@ -9,6 +9,7 @@ describe "Project Generator" do
|
|
9
9
|
|
10
10
|
before :all do
|
11
11
|
@spec_helper = File.join(TMP_ROOT,PROJECT_NAME,'spec','spec_helper.rb')
|
12
|
+
@rakefile = File.join(TMP_ROOT,PROJECT_NAME,'rakefile')
|
12
13
|
end
|
13
14
|
|
14
15
|
before :each do
|
@@ -24,6 +25,11 @@ describe "Project Generator" do
|
|
24
25
|
system("ruby -c #{@spec_helper} > #{null_device}").should be_true
|
25
26
|
end
|
26
27
|
|
28
|
+
it "should generate a rakefile that can be required" do
|
29
|
+
run_generator('taza', [APP_ROOT], generator_sources)
|
30
|
+
system("ruby -c #{@spec_helper} > #{null_device}").should be_true
|
31
|
+
end
|
32
|
+
|
27
33
|
it "spec helper should set the TAZA_ENV variable if it is not provided" do
|
28
34
|
ENV['TAZA_ENV'] = nil
|
29
35
|
run_generator('taza', [APP_ROOT], generator_sources)
|
data/spec/taza_tasks_spec.rb
CHANGED
@@ -23,6 +23,7 @@ describe "Taza Tasks" do
|
|
23
23
|
Dir.stubs(:glob).with('./spec/functional/*/').returns(['./spec/functional/foo/'])
|
24
24
|
Dir.stubs(:glob).with('./spec/functional/foo/*_spec.rb').returns([])
|
25
25
|
load @file_name
|
26
|
+
Taza::Rake::Tasks.new
|
26
27
|
tasks.include?("spec:functional:foo").should be_true
|
27
28
|
end
|
28
29
|
|
@@ -30,6 +31,7 @@ describe "Taza Tasks" do
|
|
30
31
|
Dir.expects(:glob).with('./spec/functional/*/').returns(['./spec/functional/foo/'])
|
31
32
|
Dir.expects(:glob).with('./spec/functional/foo/*_spec.rb').returns(['./spec/functional/foo/page_spec.rb'])
|
32
33
|
load @file_name
|
34
|
+
Taza::Rake::Tasks.new
|
33
35
|
tasks.include?("spec:functional:foo:page").should be_true
|
34
36
|
end
|
35
37
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scudco-taza
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Anderson
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-01-26 00:00:00 -08:00
|
13
13
|
default_executable: taza
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -46,7 +46,7 @@ dependencies:
|
|
46
46
|
requirements:
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 1.1.
|
49
|
+
version: 1.1.12
|
50
50
|
version:
|
51
51
|
- !ruby/object:Gem::Dependency
|
52
52
|
name: rubigen
|