scudco-taza 0.8.1
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 +44 -0
- data/Manifest.txt +61 -0
- data/README +79 -0
- data/README.textile +1 -0
- data/VERSION.yml +4 -0
- data/bin/taza +17 -0
- data/generators/flow/flow_generator.rb +57 -0
- data/generators/flow/templates/flow.rb.erb +9 -0
- data/generators/page/page_generator.rb +58 -0
- data/generators/page/templates/functional_page_spec.rb.erb +8 -0
- data/generators/page/templates/page.rb.erb +8 -0
- data/generators/partial/partial_generator.rb +57 -0
- data/generators/partial/templates/partial.rb.erb +7 -0
- data/generators/site/site_generator.rb +56 -0
- data/generators/site/templates/site.rb.erb +10 -0
- data/generators/site/templates/site.yml.erb +3 -0
- data/lib/app_generators/taza/taza_generator.rb +72 -0
- data/lib/app_generators/taza/templates/config.yml.erb +3 -0
- data/lib/app_generators/taza/templates/rakefile.rb.erb +3 -0
- data/lib/app_generators/taza/templates/spec_helper.rb.erb +11 -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/browser.rb +33 -0
- data/lib/taza/entity.rb +34 -0
- data/lib/taza/fixture.rb +66 -0
- data/lib/taza/flow.rb +40 -0
- data/lib/taza/page.rb +95 -0
- data/lib/taza/settings.rb +47 -0
- data/lib/taza/site.rb +145 -0
- data/lib/taza/tasks.rb +50 -0
- data/lib/taza.rb +35 -0
- data/spec/array_spec.rb +16 -0
- data/spec/browser_spec.rb +63 -0
- 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 +50 -0
- data/spec/hash_spec.rb +12 -0
- data/spec/object_spec.rb +29 -0
- data/spec/page_generator_spec.rb +56 -0
- data/spec/page_spec.rb +82 -0
- data/spec/partial_generator_spec.rb +38 -0
- data/spec/project_generator_spec.rb +41 -0
- data/spec/sandbox/config/config.yml +1 -0
- data/spec/sandbox/config/site_name.yml +5 -0
- data/spec/sandbox/config.yml +3 -0
- data/spec/sandbox/fixtures/examples.yml +8 -0
- data/spec/sandbox/fixtures/users.yml +2 -0
- data/spec/sandbox/flows/batman.rb +5 -0
- data/spec/sandbox/flows/robin.rb +4 -0
- data/spec/sandbox/pages/foo/bar.rb +9 -0
- data/spec/sandbox/pages/foo/partials/partial_the_reckoning.rb +2 -0
- data/spec/settings_spec.rb +88 -0
- data/spec/site_generator_spec.rb +57 -0
- data/spec/site_spec.rb +229 -0
- data/spec/spec_helper.rb +57 -0
- data/spec/string_spec.rb +7 -0
- data/spec/taza_bin_spec.rb +14 -0
- data/spec/taza_spec.rb +12 -0
- data/spec/taza_tasks_spec.rb +41 -0
- metadata +181 -0
data/spec/hash_spec.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
|
3
|
+
describe 'Hash Extensions' do
|
4
|
+
it "should add methods for hash keys to some instance" do
|
5
|
+
entity = {'apple' => 'pie'}.convert_hash_keys_to_methods(nil)
|
6
|
+
entity.should respond_to(:apple)
|
7
|
+
end
|
8
|
+
it "should not add the methods to a hash" do
|
9
|
+
entity = {'apple' => 'pie'}.convert_hash_keys_to_methods(nil)
|
10
|
+
entity.should_not be_a_instance_of(Hash)
|
11
|
+
end
|
12
|
+
end
|
data/spec/object_spec.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
|
3
|
+
describe "Object" do
|
4
|
+
before :all do
|
5
|
+
@orig_version = VERSION
|
6
|
+
Object.send :remove_const, :VERSION
|
7
|
+
Object.const_set :VERSION, "1.8.6"
|
8
|
+
load 'lib/extensions/object.rb'
|
9
|
+
end
|
10
|
+
|
11
|
+
after :all do
|
12
|
+
Object.send :remove_const, :VERSION
|
13
|
+
Object.const_set :VERSION, @orig_version
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should execute blocks with args in instance context" do
|
17
|
+
str = "string"
|
18
|
+
|
19
|
+
class << str
|
20
|
+
def my_singleton_method(arg)
|
21
|
+
arg
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
block = Proc.new { |arg| my_singleton_method(arg) }
|
26
|
+
|
27
|
+
str.instance_exec("foo",&block).should == "foo"
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'taza'
|
5
|
+
|
6
|
+
describe "Page Generation" do
|
7
|
+
include RubiGen::GeneratorTestHelper
|
8
|
+
include Helpers::Generator
|
9
|
+
include Helpers::Taza
|
10
|
+
|
11
|
+
before :all do
|
12
|
+
@page_name = "CheckOut"
|
13
|
+
end
|
14
|
+
|
15
|
+
before :each do
|
16
|
+
run_generator('taza', [APP_ROOT], generator_sources)
|
17
|
+
@site_class = generate_site('Gap')
|
18
|
+
end
|
19
|
+
|
20
|
+
after :each do
|
21
|
+
bare_teardown
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should give you usage if you do not give two arguments" do
|
25
|
+
PageGenerator.any_instance.expects(:usage)
|
26
|
+
lambda { run_generator('page', [@page_name], generator_sources) }.should raise_error
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should give you usage if you give a site that does not exist" do
|
30
|
+
PageGenerator.any_instance.expects(:usage)
|
31
|
+
$stderr.expects(:puts).with(regexp_matches(/NoSuchSite/))
|
32
|
+
lambda { run_generator('page', [@page_name,"NoSuchSite"], generator_sources) }.should raise_error
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should generate a page spec that can be required" do
|
36
|
+
run_generator('page', [@page_name,@site_class.to_s], generator_sources)
|
37
|
+
page_functional_spec = File.join(PROJECT_FOLDER,'spec','functional',@site_class.to_s.underscore,'check_out_page_spec.rb')
|
38
|
+
system("ruby -c #{page_functional_spec} > #{null_device}").should be_true
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should be able to access the generated page from the site" do
|
42
|
+
run_generator('page', [@page_name,@site_class.to_s], generator_sources)
|
43
|
+
stub_settings
|
44
|
+
stub_browser
|
45
|
+
@site_class.new.check_out_page
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should be able to access the generated page for its site" do
|
49
|
+
stub_browser
|
50
|
+
stub_settings
|
51
|
+
new_site_class = generate_site('Pag')
|
52
|
+
run_generator('page', [@page_name,@site_class.to_s], generator_sources)
|
53
|
+
run_generator('page', [@page_name,new_site_class.to_s], generator_sources)
|
54
|
+
new_site_class.new.check_out_page.class.should_not eql(@site_class.new.check_out_page.class)
|
55
|
+
end
|
56
|
+
end
|
data/spec/page_spec.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
require 'taza/page'
|
3
|
+
|
4
|
+
describe Taza::Page do
|
5
|
+
|
6
|
+
class ElementAndFilterContextExample < Taza::Page
|
7
|
+
element(:sample_element) {browser}
|
8
|
+
filter:sample_filter, :sample_element
|
9
|
+
def sample_filter
|
10
|
+
browser
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should execute an element's block with the params provided for its method" do
|
15
|
+
Taza::Page.element(:boo){|baz| baz}
|
16
|
+
Taza::Page.new.boo("rofl").should == "rofl"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should execute elements and filters in the context of the page instance" do
|
20
|
+
page = ElementAndFilterContextExample.new
|
21
|
+
page.browser = :something
|
22
|
+
page.sample_element.should eql(:something)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should add a filter to the classes filters" do
|
26
|
+
ElementAndFilterContextExample.filters.size.should eql(1)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should store the block given to the element method in a method with the name of the parameter" do
|
30
|
+
Taza::Page.element(:foo) do
|
31
|
+
"bar"
|
32
|
+
end
|
33
|
+
Taza::Page.new.foo.should == "bar"
|
34
|
+
end
|
35
|
+
|
36
|
+
class FilterAllElements < Taza::Page
|
37
|
+
element(:foo) {}
|
38
|
+
element(:apple) {}
|
39
|
+
filter :false_filter
|
40
|
+
|
41
|
+
def false_filter
|
42
|
+
false
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should filter all elements if element argument is not provided" do
|
47
|
+
lambda { FilterAllElements.new.apple }.should raise_error(Taza::FilterError)
|
48
|
+
lambda { FilterAllElements.new.foo }.should raise_error(Taza::FilterError)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should have empty elements on a new class" do
|
52
|
+
foo = Class::new(superclass=Taza::Page)
|
53
|
+
foo.elements.should_not be_nil
|
54
|
+
foo.elements.should be_empty
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should have empty filters on a new class" do
|
58
|
+
foo = Class::new(superclass=Taza::Page)
|
59
|
+
foo.filters.should_not be_nil
|
60
|
+
foo.filters.should be_empty
|
61
|
+
end
|
62
|
+
|
63
|
+
class FilterAnElement < Taza::Page
|
64
|
+
attr_accessor :called_element_method
|
65
|
+
element(:false_item) { @called_element_method = true}
|
66
|
+
filter :false_filter, :false_item
|
67
|
+
|
68
|
+
def false_filter
|
69
|
+
false
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should raise a error if an elements is called and its filter returns false" do
|
74
|
+
lambda { FilterAnElement.new.false_item }.should raise_error(Taza::FilterError)
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should not call element block if filters fail" do
|
78
|
+
page = FilterAnElement.new
|
79
|
+
lambda { page.false_item }.should raise_error
|
80
|
+
page.called_element_method.should_not be_true
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'taza'
|
5
|
+
|
6
|
+
describe "Partial Generation" do
|
7
|
+
include RubiGen::GeneratorTestHelper
|
8
|
+
include Helpers::Generator
|
9
|
+
include Helpers::Taza
|
10
|
+
|
11
|
+
before :all do
|
12
|
+
@site_name = "Foo"
|
13
|
+
@site_folder = File.join(PROJECT_FOLDER,'lib','sites',"gap")
|
14
|
+
@site_file = File.join(PROJECT_FOLDER,'lib','sites',"gap.rb")
|
15
|
+
@partial_name = "Header"
|
16
|
+
end
|
17
|
+
|
18
|
+
before :each do
|
19
|
+
run_generator('taza', [APP_ROOT], generator_sources)
|
20
|
+
@site_class = generate_site(@site_name)
|
21
|
+
end
|
22
|
+
|
23
|
+
after :each do
|
24
|
+
bare_teardown
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should give you usage if you do not give two arguments" do
|
28
|
+
PartialGenerator.any_instance.expects(:usage)
|
29
|
+
lambda { run_generator('partial', [@partial_name], generator_sources) }.should raise_error
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should give you usage if you give a site that does not exist" do
|
33
|
+
PartialGenerator.any_instance.expects(:usage)
|
34
|
+
$stderr.expects(:puts).with(regexp_matches(/NoSuchSite/))
|
35
|
+
lambda { run_generator('partial', [@partial_name,"NoSuchSite"], generator_sources) }.should raise_error
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rake'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'taza'
|
6
|
+
|
7
|
+
describe "Project Generator" do
|
8
|
+
include RubiGen::GeneratorTestHelper
|
9
|
+
|
10
|
+
before :all do
|
11
|
+
@spec_helper = File.join(TMP_ROOT,PROJECT_NAME,'spec','spec_helper.rb')
|
12
|
+
end
|
13
|
+
|
14
|
+
before :each do
|
15
|
+
bare_setup
|
16
|
+
end
|
17
|
+
|
18
|
+
after :each do
|
19
|
+
bare_teardown
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should generate a spec helper that can be required" do
|
23
|
+
run_generator('taza', [APP_ROOT], generator_sources)
|
24
|
+
system("ruby -c #{@spec_helper} > #{null_device}").should be_true
|
25
|
+
end
|
26
|
+
|
27
|
+
it "spec helper should set the TAZA_ENV variable if it is not provided" do
|
28
|
+
ENV['TAZA_ENV'] = nil
|
29
|
+
run_generator('taza', [APP_ROOT], generator_sources)
|
30
|
+
load @spec_helper
|
31
|
+
ENV['TAZA_ENV'].should eql("isolation")
|
32
|
+
end
|
33
|
+
|
34
|
+
it "spec helper should not override the TAZA_ENV variable if was provided" do
|
35
|
+
ENV['TAZA_ENV'] = 'orange pie? is there such a thing?'
|
36
|
+
run_generator('taza', [APP_ROOT], generator_sources)
|
37
|
+
load @spec_helper
|
38
|
+
ENV['TAZA_ENV'].should eql('orange pie? is there such a thing?')
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
:nothing: :something
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'taza'
|
4
|
+
|
5
|
+
describe Taza::Settings do
|
6
|
+
|
7
|
+
before :all do
|
8
|
+
@site_name = 'SiteName'
|
9
|
+
end
|
10
|
+
|
11
|
+
before :each do
|
12
|
+
ENV['TAZA_ENV'] = 'isolation'
|
13
|
+
ENV['BROWSER'] = nil
|
14
|
+
ENV['DRIVER'] = nil
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should use environment variable for browser settings" do
|
18
|
+
Taza::Settings.stubs(:path).returns("spec/sandbox")
|
19
|
+
ENV['BROWSER'] = 'foo'
|
20
|
+
Taza::Settings.config(@site_name)[:browser].should eql(:foo)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should provide default values if no config file or environment settings provided" do
|
24
|
+
Taza::Settings.stubs(:path).returns("spec/sandbox")
|
25
|
+
Taza::Settings.config(@site_name)[:driver].should eql(:selenium)
|
26
|
+
Taza::Settings.config(@site_name)[:browser].should eql(:firefox)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should use environment variable for driver settings" do
|
30
|
+
Taza::Settings.stubs(:path).returns("spec/sandbox")
|
31
|
+
ENV['DRIVER'] = 'bar'
|
32
|
+
Taza::Settings.config(@site_name)[:driver].should eql(:bar)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should be able to load the site yml" do
|
36
|
+
Taza::Settings.stubs(:path).returns("spec/sandbox")
|
37
|
+
Taza::Settings.config("SiteName")[:url].should eql('http://google.com')
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should be able to load a alternate site url" do
|
41
|
+
ENV['TAZA_ENV'] = 'clown_shoes'
|
42
|
+
Taza::Settings.stubs(:path).returns("spec/sandbox")
|
43
|
+
Taza::Settings.config("SiteName")[:url].should eql('http://clownshoes.com')
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should use the config file's variable for browser settings if no environment variable is set" do
|
47
|
+
Taza::Settings.expects(:config_file).returns({:browser => :fu})
|
48
|
+
Taza::Settings.stubs(:path).returns("spec/sandbox")
|
49
|
+
Taza::Settings.config(@site_name)[:browser].should eql(:fu)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should use the ENV variables if specfied instead of config files" do
|
53
|
+
ENV['BROWSER'] = 'opera'
|
54
|
+
Taza::Settings.expects(:config_file).returns({:browser => :fu})
|
55
|
+
Taza::Settings.stubs(:path).returns("spec/sandbox")
|
56
|
+
Taza::Settings.config(@site_name)[:browser].should eql(:opera)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should use the correct config file to set defaults" do
|
60
|
+
Taza::Settings.stubs(:path).returns("spec/sandbox")
|
61
|
+
Taza::Settings.stubs(:config_file_path).returns('spec/sandbox/config.yml')
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should raise error for a config file that doesnot exist" do
|
65
|
+
Taza::Settings.stubs(:path).returns('spec/sandbox/file_not_exists.yml')
|
66
|
+
lambda {Taza::Settings.config}.should raise_error
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should path point at root directory" do
|
70
|
+
Taza::Settings.path.should eql('.')
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should use the config file's variable for driver settings if no environment variable is set" do
|
74
|
+
Taza::Settings.stubs(:path).returns("spec/sandbox")
|
75
|
+
Taza::Settings.stubs(:config_file).returns({:driver => :fun})
|
76
|
+
Taza::Settings.config(@site_name)[:driver].should eql(:fun)
|
77
|
+
end
|
78
|
+
|
79
|
+
class SiteName < Taza::Site
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
it "a site should be able to load its settings" do
|
84
|
+
Taza::Settings.stubs(:path).returns("spec/sandbox")
|
85
|
+
SiteName.settings[:url].should eql('http://google.com')
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'taza'
|
5
|
+
|
6
|
+
describe "Site Generation" do
|
7
|
+
include RubiGen::GeneratorTestHelper
|
8
|
+
include Helpers::Generator
|
9
|
+
include Helpers::Taza
|
10
|
+
|
11
|
+
before :all do
|
12
|
+
@spec_helper = File.join(TMP_ROOT,PROJECT_NAME,'spec','spec_helper.rb')
|
13
|
+
@site_name = "WikipediaFoo"
|
14
|
+
@site_file = File.join(PROJECT_FOLDER,'lib','sites' , "wikipedia_foo.rb")
|
15
|
+
@site_folder = File.join(PROJECT_FOLDER,'lib','sites' , "wikipedia_foo")
|
16
|
+
end
|
17
|
+
|
18
|
+
before :each do
|
19
|
+
bare_setup
|
20
|
+
run_generator('taza', [APP_ROOT], generator_sources)
|
21
|
+
end
|
22
|
+
|
23
|
+
after :each do
|
24
|
+
bare_teardown
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should generate configuration file for a site" do
|
28
|
+
run_generator('site', [@site_name], generator_sources)
|
29
|
+
File.exists?(File.join(PROJECT_FOLDER,'config','wikipedia_foo.yml')).should be_true
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should generate a site path for pages" do
|
33
|
+
run_generator('site', [@site_name], generator_sources)
|
34
|
+
File.directory?(@site_folder).should be_true
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should generate a partials folder under pages" do
|
38
|
+
run_generator('site', [@site_name], generator_sources)
|
39
|
+
File.directory?(File.join(@site_folder,"pages","partials")).should be_true
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should generate a folder for a sites functional tests" do
|
43
|
+
run_generator('site', [@site_name], generator_sources)
|
44
|
+
File.directory?(File.join(PROJECT_FOLDER,'spec','functional','wikipedia_foo')).should be_true
|
45
|
+
end
|
46
|
+
|
47
|
+
it "generated site that uses the block given in new" do
|
48
|
+
@site_class = generate_site(@site_name)
|
49
|
+
stub_settings
|
50
|
+
stub_browser
|
51
|
+
foo = nil
|
52
|
+
@site_class.new {|site| foo = site}
|
53
|
+
foo.should_not be_nil
|
54
|
+
foo.should be_a_kind_of(Taza::Site)
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|