scudco-taza 0.8.4 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,10 @@
1
+ === 0.8.5
2
+
3
+ * Fixed Fixtures bugs
4
+ * Fixture entities can be accessed like hashes(foo[:bar])
5
+ * Functional tests are now 'isolation' tests
6
+ * Added Page-Module feature
7
+
1
8
  === 0.8.4
2
9
 
3
10
  * Added one to many relationship in fixtures
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
+ :patch: 5
2
3
  :major: 0
3
4
  :minor: 8
4
- :patch: 4
@@ -25,7 +25,7 @@ class PageGenerator < RubiGen::Base
25
25
  def manifest
26
26
  record do |m|
27
27
  m.template "page.rb.erb", File.join('lib','sites', site_name.underscore, "pages", "#{name.underscore}_page.rb")
28
- m.template "functional_page_spec.rb.erb", File.join('spec','functional',site_name.underscore,"#{name.underscore}_page_spec.rb")
28
+ m.template "functional_page_spec.rb.erb", File.join('spec','isolation',site_name.underscore,"#{name.underscore}_page_spec.rb")
29
29
  end
30
30
  end
31
31
 
@@ -21,7 +21,7 @@ class SiteGenerator < RubiGen::Base
21
21
  m.directory File.join(site_path,("#{name.underscore}"),"flows")
22
22
  m.directory File.join(site_path,("#{name.underscore}"),"pages")
23
23
  m.directory File.join(site_path,("#{name.underscore}"),"pages","partials")
24
- m.directory File.join('spec','functional',name.underscore)
24
+ m.directory File.join('spec','isolation',name.underscore)
25
25
  m.template "site.yml.erb", File.join('config',"#{name.underscore}.yml")
26
26
  end
27
27
  end
@@ -31,7 +31,7 @@ class TazaGenerator < RubiGen::Base
31
31
  BASEDIRS.each { |path| m.directory path }
32
32
  m.directory File.join('lib','sites')
33
33
  m.directory File.join('lib','flows')
34
- m.directory File.join('spec','functional')
34
+ m.directory File.join('spec','isolation')
35
35
  m.directory File.join('spec','integration')
36
36
  m.directory File.join('spec','story')
37
37
  end
@@ -1,6 +1,10 @@
1
1
  # instance_exec comes with >1.8.7 thankfully
2
2
  if VERSION <= '1.8.6'
3
3
  class Object
4
+ def metaclass
5
+ class << self; self; end
6
+ end
7
+
4
8
  module InstanceExecHelper; end
5
9
  include InstanceExecHelper
6
10
  # instance_exec method evaluates a block of code relative to the specified object, with parameters whom come from outside the object.
@@ -22,3 +26,8 @@ if VERSION <= '1.8.6'
22
26
  end
23
27
  end
24
28
  end
29
+ class Object
30
+ def metaclass
31
+ class << self; self; end
32
+ end
33
+ end
data/lib/taza.rb CHANGED
@@ -4,23 +4,12 @@ require 'taza/browser'
4
4
  require 'taza/settings'
5
5
  require 'taza/flow'
6
6
  require 'taza/entity'
7
- require 'taza/fixture'
7
+ require 'taza/fixtures'
8
8
  require 'extensions/object'
9
9
  require 'extensions/string'
10
10
  require 'extensions/hash'
11
11
  require 'extensions/array'
12
12
 
13
- module Taza
14
- VERSION = '0.8.1'
15
-
16
- def self.windows?
17
- PLATFORM.include?("mswin")
18
- end
19
- def self.osx?
20
- PLATFORM.include?("darwin")
21
- end
22
- end
23
-
24
13
  module ForwardInitialization
25
14
  module ClassMethods
26
15
  def new(*args,&block)
data/lib/taza/entity.rb CHANGED
@@ -19,12 +19,25 @@ module Taza
19
19
 
20
20
  #This method will lookup another fixture if a pluralized fixture exists otherwise return the value in the hash
21
21
  def get_value_for_entry(key) # :nodoc:
22
- if @fixture.fixture_exists?(key)
22
+ if @fixture.nil?
23
+ create_entity_if_value_is_hash(key)
24
+ elsif @fixture.fixture_exists?(key)
23
25
  @fixture.specific_fixture_entities(key.to_sym, @hash[key])
24
26
  elsif @fixture.pluralized_fixture_exists?(key)
25
- @fixture.get_fixture_entity(key.pluralize_to_sym,@hash[key])
27
+ @fixture.get_fixture_entity(key.pluralize.to_sym,@hash[key])
26
28
  else
27
- @hash[key]
29
+ create_entity_if_value_is_hash(key)
30
+ end
31
+ end
32
+ alias :[] :get_value_for_entry
33
+
34
+ def create_entity_if_value_is_hash(key)
35
+ if (@fixture.nil? && @hash[key].is_a?(Hash))
36
+ Entity.new(@hash[key], nil)
37
+ elsif (!@fixture.nil? && @hash[key].is_a?(Hash))
38
+ Entity.new(@hash[key], @fixture)
39
+ else
40
+ @hash[key]
28
41
  end
29
42
  end
30
43
 
data/lib/taza/fixture.rb CHANGED
@@ -1,17 +1,30 @@
1
1
  require 'find'
2
- require "erb"
2
+ require 'erb'
3
+ require 'extensions/hash'
4
+ require 'taza/entity'
3
5
 
4
6
  module Taza
7
+ # The module that will mixin methods based on the fixture files in your 'spec/fixtures'
8
+ #
9
+ # Example:
10
+ # describe "something" do
11
+ # it "should test something" do
12
+ # users(:jane_smith).first_name.should eql("jane")
13
+ # end
14
+ # end
15
+ #
16
+ # where there is a spec/fixtures/users.yml file containing a entry of:
17
+ # jane_smith:
18
+ # first_name: jane
19
+ # last_name: smith
5
20
  class Fixture # :nodoc:
6
21
 
7
22
  def initialize # :nodoc:
8
23
  @fixtures = {}
9
24
  end
10
25
 
11
- def load_all(fixtures_pattern) # :nodoc:
12
- index_of_fixtures = fixtures_pattern.index("fixtures")
13
- truncated_pattern = fixtures_pattern[index_of_fixtures..-1]
14
- Dir.glob(File.join(base_path,truncated_pattern)) do |file|
26
+ def load_fixtures_from(dir) # :nodoc:
27
+ Dir.glob(File.join(dir,'*.yml')) do |file|
15
28
  templatized_fixture=ERB.new(File.read(file))
16
29
  entitized_fixture = {}
17
30
  YAML.load(templatized_fixture.result()).each do |key, value|
@@ -34,7 +47,7 @@ module Taza
34
47
  end
35
48
 
36
49
  def pluralized_fixture_exists?(singularized_fixture_name) # :nodoc:
37
- fixture_exists?(singularized_fixture_name.pluralize_to_sym)
50
+ fixture_exists?(singularized_fixture_name.pluralize.to_sym)
38
51
  end
39
52
 
40
53
  def specific_fixture_entities(fixture_key, select_array)
@@ -46,43 +59,10 @@ module Taza
46
59
  fixture_names.include?(fixture_name.to_sym)
47
60
  end
48
61
 
49
- def base_path # :nodoc:
50
- File.join('.','spec')
62
+ def self.base_path # :nodoc:
63
+ File.join('.','spec','fixtures','')
51
64
  end
52
65
  end
53
66
 
54
- # The module that will mixin methods based on the fixture files in your 'spec/fixtures'
55
- #
56
- # Example:
57
- # describe "something" do
58
- # it "should test something" do
59
- # users(:jane_smith).first_name.should eql("jane")
60
- # end
61
- # end
62
- #
63
- # where there is a spec/fixtures/users.yml file containing a entry of:
64
- # jane_smith:
65
- # first_name: jane
66
- # last_name: smith
67
- dirs = Dir.glob(File.join(Fixture.new.base_path,"**","**")).select {|d| File.directory?(d) }
68
- dirs[0,0] = File.join(Fixture.new.base_path,"fixtures")
69
- dirs.each do |mod|
70
- base_module = mod == dirs[0] ? "" : "Fixtures::"
71
- self.class_eval <<-EOS
72
- module #{base_module}#{mod.split('/')[-1].camelize}
73
- def self.included(other_module)
74
- fixture = Fixture.new
75
- fixture.load_all(File.join("#{mod}","*.yml"))
76
- fixture.fixture_names.each do |fixture_name|
77
- self.class_eval do
78
- define_method(fixture_name) do |entity_key|
79
- fixture.get_fixture_entity(fixture_name,entity_key.to_s)
80
- end
81
- end
82
- end
83
- end
84
- end
85
- EOS
86
- end
87
67
  end
88
68
 
@@ -0,0 +1,24 @@
1
+ require 'taza/fixture'
2
+
3
+ module Taza
4
+ dirs = Dir.glob(File.join(Fixture.base_path,'*/'))
5
+ dirs.unshift Fixture.base_path
6
+ dirs.each do |dir|
7
+ mod = dir.sub(Fixture.base_path,File.join(File.basename(Fixture.base_path),'')).camelize.sub(/::$/,'')
8
+ self.class_eval <<-EOS
9
+ module #{mod}
10
+ def self.included(other_module)
11
+ fixture = Fixture.new
12
+ fixture.load_fixtures_from('#{dir}')
13
+ fixture.fixture_names.each do |fixture_name|
14
+ self.class_eval do
15
+ define_method(fixture_name) do |entity_key|
16
+ fixture.get_fixture_entity(fixture_name,entity_key.to_s)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ EOS
23
+ end
24
+ end
data/lib/taza/page.rb CHANGED
@@ -32,7 +32,12 @@ module Taza
32
32
  # end
33
33
  # homepage.foo.click
34
34
  def self.element(name,&block)
35
- self.elements[name] = block
35
+ if !@module.nil?
36
+ self.elements[@module] = Hash.new if self.elements[@module].nil?
37
+ self.elements[@module] = self.elements[@module].merge({ name => block })
38
+ else
39
+ self.elements[name] = block
40
+ end
36
41
  end
37
42
 
38
43
  # A filter for elemenet(s) on a page
@@ -64,20 +69,33 @@ module Taza
64
69
  end
65
70
  end
66
71
 
67
- def initialize
68
- add_element_methods
72
+ def self.page_module(name,&block)
73
+ @module = name
74
+ yield(block)
75
+ @module = nil
76
+ end
77
+
78
+ def initialize(page_module = nil)
79
+ add_element_methods(page_module)
69
80
  @active_filters = []
70
81
  end
71
82
 
72
- def add_element_methods # :nodoc:
83
+ def add_element_methods(page_module = nil) # :nodoc:
73
84
  self.class.elements.each do |element_name,element_block|
74
- filters = self.class.filters[element_name] + self.class.filters[:all]
75
- add_element_method(:filters => filters, :element_name => element_name, :element_block => element_block)
85
+ if (element_block.is_a?(Hash) && !page_module.nil? && page_module==element_name)
86
+ element_block.each do |key,value|
87
+ filters = self.class.filters[element_name] + self.class.filters[:all]
88
+ add_element_method(:filters => filters, :element_name => key, :element_block => value)
89
+ end
90
+ else
91
+ filters = self.class.filters[element_name] + self.class.filters[:all]
92
+ add_element_method(:filters => filters, :element_name => element_name, :element_block => element_block)
93
+ end
76
94
  end
77
95
  end
78
96
 
79
97
  def add_element_method(params) # :nodoc:
80
- self.class.class_eval do
98
+ metaclass.class_eval do
81
99
  define_method(params[:element_name]) do |*args|
82
100
  check_filters(params)
83
101
  self.instance_exec(*args,&params[:element_block])
data/lib/taza/site.rb CHANGED
@@ -93,8 +93,8 @@ module Taza
93
93
  page_name = File.basename(file,'.rb')
94
94
  page_class = "#{@module_name}::#{page_name.camelize}"
95
95
  self.class.class_eval <<-EOS
96
- def #{page_name}
97
- page = '#{page_class}'.constantize.new
96
+ def #{page_name}(page_module = nil)
97
+ page = '#{page_class}'.constantize.new(page_module)
98
98
  page.browser = @browser
99
99
  yield page if block_given?
100
100
  page
data/lib/taza/tasks.rb CHANGED
@@ -31,19 +31,24 @@ module Taza
31
31
  end
32
32
  end
33
33
  end
34
+
34
35
  def recurse_to_create_rake_tasks(dir)
35
36
  basename = File.basename(dir)
36
- define_spec_task(basename,File.join(dir,"**","*_spec.rb"))
37
- namespace basename do
38
- Dir.glob(File.join(dir,"*_spec.rb")).each do |spec_file|
39
- spec_name = File.basename(spec_file,'_spec.rb')
40
- define_spec_task(spec_name,spec_file)
41
- end
42
- Dir.glob(File.join(dir,"*/")).each do |sub_dir|
43
- recurse_to_create_rake_tasks(sub_dir)
37
+ spec_pattern = File.join(dir,"**","*_spec.rb")
38
+ if (not Dir.glob(spec_pattern).empty?)
39
+ define_spec_task(basename,spec_pattern)
40
+ namespace basename do
41
+ Dir.glob(File.join(dir,"*_spec.rb")).each do |spec_file|
42
+ spec_name = File.basename(spec_file,'_spec.rb')
43
+ define_spec_task(spec_name,spec_file)
44
+ end
45
+ Dir.glob(File.join(dir,"*/")).each do |sub_dir|
46
+ recurse_to_create_rake_tasks(sub_dir)
47
+ end
44
48
  end
45
49
  end
46
50
  end
51
+
47
52
  end
48
53
  end
49
54
  end
data/spec/array_spec.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'spec/spec_helper'
2
+ require 'extensions/array'
2
3
 
3
4
  describe 'Array Extensions' do
4
5
  it "should know if elements are not equivilent to a subset of those elements" do
@@ -13,4 +14,4 @@ describe 'Array Extensions' do
13
14
  it "should know it is equivalent if the different orders" do
14
15
  [1,2,3].should be_equivalent([2,1,3])
15
16
  end
16
- end
17
+ end
data/spec/entity_spec.rb CHANGED
@@ -1,9 +1,19 @@
1
1
  require 'spec/spec_helper'
2
- require 'taza'
2
+ require 'taza/entity'
3
3
 
4
4
  describe Taza::Entity do
5
5
  it "should add methods for hash string keys" do
6
6
  entity = Taza::Entity.new({'apple' => 'pie'},nil)
7
7
  entity.should respond_to(:apple)
8
8
  end
9
- end
9
+
10
+ it "should be accessible like a hash(foo[:bar])" do
11
+ entity = Taza::Entity.new({:apple => 'pie'},nil)
12
+ entity[:apple].should eql('pie')
13
+ end
14
+
15
+ it "should be able to define methods for multiple levels" do
16
+ entity = Taza::Entity.new({:fruits => {:apple => 'pie'} },nil)
17
+ entity.fruits.apple.should eql('pie')
18
+ end
19
+ end
data/spec/fixture_spec.rb CHANGED
@@ -1,56 +1,48 @@
1
1
  require 'spec/spec_helper'
2
- require 'taza'
2
+ require 'taza/fixture'
3
+ require 'extensions/array'
3
4
 
4
5
  describe Taza::Fixture do
5
-
6
+ before :each do
7
+ @base_path = File.join('.','spec','sandbox','fixtures','')
8
+ end
9
+
6
10
  it "should be able to load entries from fixtures" do
7
- Taza::Fixture.any_instance.stubs(:base_path).returns('./spec/sandbox')
8
11
  fixture = Taza::Fixture.new
9
- fixture.load_all(File.join('fixtures','*.yml'))
12
+ fixture.load_fixtures_from(@base_path)
10
13
  example = fixture.get_fixture_entity(:examples,'first_example')
11
14
  example.name.should eql("first")
12
15
  example.price.should eql(1)
13
16
  end
14
17
 
15
- it "should use the spec folder as the base path" do
16
- Taza::Fixture.new.base_path.should eql('./spec')
18
+ it "should use the spec fixtures folder as the base path" do
19
+ Taza::Fixture.base_path.should eql('./spec/fixtures/')
17
20
  end
18
21
 
19
22
  it "should know if a pluralized fixture of that name exists" do
20
- Taza::Fixture.any_instance.stubs(:base_path).returns('./spec/sandbox')
21
23
  fixture = Taza::Fixture.new
22
- fixture.load_all(File.join('fixtures','*.yml'))
24
+ fixture.load_fixtures_from(@base_path)
23
25
  fixture.pluralized_fixture_exists?('example').should be_true
24
26
  fixture.pluralized_fixture_exists?('boo').should be_false
25
27
  end
26
28
 
27
29
  it "should be able to get all fixtures loaded excluding sub-folder fixtures" do
28
- Taza::Fixture.any_instance.stubs(:base_path).returns('./spec/sandbox')
29
30
  fixture = Taza::Fixture.new
30
- fixture.load_all(File.join('fixtures','*.yml'))
31
+ fixture.load_fixtures_from(@base_path)
31
32
  fixture.fixture_names.should be_equivalent([:examples,:users,:foos])
32
33
  end
33
34
 
34
- it "should be able to get all fixtures loaded including sub-folder fixtures" do
35
- Taza::Fixture.any_instance.stubs(:base_path).returns('./spec/sandbox')
36
- fixture = Taza::Fixture.new
37
- fixture.load_all(File.join('fixtures','**','*.yml'))
38
- fixture.fixture_names.should be_equivalent([:examples,:users,:foos,:bars])
39
- end
40
-
41
35
  it "should be able to get specific fixture entities" do
42
- Taza::Fixture.any_instance.stubs(:base_path).returns('./spec/sandbox')
43
36
  fixture = Taza::Fixture.new
44
- fixture.load_all(File.join('fixtures','*.yml'))
37
+ fixture.load_fixtures_from(@base_path)
45
38
  examples = fixture.specific_fixture_entities(:examples, ['third_example'])
46
39
  examples.length.should eql(1)
47
40
  examples['third_example'].name.should eql('third')
48
41
  end
49
42
 
50
43
  it "should not modified the fixtures when you get specific entities off a fixture" do
51
- Taza::Fixture.any_instance.stubs(:base_path).returns('./spec/sandbox')
52
44
  fixture = Taza::Fixture.new
53
- fixture.load_all(File.join('fixtures','*.yml'))
45
+ fixture.load_fixtures_from(@base_path)
54
46
  previous_count = fixture.get_fixture(:examples).length
55
47
  examples = fixture.specific_fixture_entities(:examples, ['third_example'])
56
48
  fixture.get_fixture(:examples).length.should eql(previous_count)
@@ -1,38 +1,47 @@
1
1
  require 'spec/spec_helper'
2
2
  require 'taza/fixture'
3
3
 
4
- describe Taza::Fixtures do
5
- Taza::Fixture.any_instance.stubs(:base_path).returns('./spec/sandbox')
4
+ describe "Taza::Fixtures" do
5
+ Taza::Fixture.stubs(:base_path).returns('./spec/sandbox/fixtures/')
6
+ require 'taza/fixtures'
6
7
  include Taza::Fixtures
7
8
 
8
- it "should be able to look up a fixture entity off fixture_methods module" do
9
- examples(:first_example).name.should eql('first')
10
- end
11
-
12
- it "should still raise method missing error" do
13
- lambda{zomgwtf(:first_example)}.should raise_error(NoMethodError)
14
- end
9
+ # it "should be able to look up a fixture entity off fixture_methods module" do
10
+ # examples(:first_example).name.should eql('first')
11
+ # end
12
+ #
13
+ # it "should still raise method missing error" do
14
+ # lambda{zomgwtf(:first_example)}.should raise_error(NoMethodError)
15
+ # end
16
+ #
17
+ # #TODO: this test tests what is in entity's instance eval not happy with it being here
18
+ # it "should be able to look up a fixture entity off fixture_methods module" do
19
+ # examples(:first_example).user.name.should eql(users(:shatner).name)
20
+ # end
21
+ #
22
+ # it "should be able to resolve one to many relationships" do
23
+ # foos(:gap).examples.length.should eql(2)
24
+ # end
25
+ #
26
+ # it "should be able to get one to many entities" do
27
+ # foos(:gap).examples['first_example'].name.should eql('first')
28
+ # foos(:gap).examples['second_example'].name.should eql('second')
29
+ # end
30
+ #
31
+ # it "should not be able to access fixtures in sub-folders if not included" do
32
+ # lambda{bars(:foo)}.should raise_error(NoMethodError)
33
+ # end
34
+ #
35
+ # it "should template fixture files" do
36
+ # users(:shatner).age.should eql(66)
37
+ # end
38
+ #
39
+ # it "should be able to get one to many entities for hash[key] style" do
40
+ # foos(:gap)['examples']['first_example']['name'].should eql('first')
41
+ # end
15
42
 
16
- #TODO: this test tests what is in entity's instance eval not happy with it being here
17
- it "should be able to look up a fixture entity off fixture_methods module" do
18
- examples(:first_example).user.name.should eql(users(:shatner).name)
19
- end
20
-
21
- it "should be able to resolve one to many relationships" do
22
- foos(:gap).examples.length.should eql(2)
23
- end
24
-
25
- it "should be able to get one to many entities" do
26
- foos(:gap).examples['first_example'].name.should eql('first')
27
- foos(:gap).examples['second_example'].name.should eql('second')
28
- end
29
-
30
- it "should not be able to access fixtures in sub-folders if not included" do
31
- lambda{bars(:foo)}.should raise_error(NoMethodError)
32
- end
33
-
34
- it "should template fixture files" do
35
- users(:shatner).age.should eql(66)
43
+ it "should be able to access multiple levels inside fixtures" do
44
+ examples(:forth_example).something.user('shatner').name.should eql('William Shatner')
36
45
  end
37
46
 
38
47
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec/spec_helper'
2
2
  require 'rubygems'
3
3
  require 'fileutils'
4
- require 'taza'
4
+ require 'taza/site'
5
5
 
6
6
  class Taza::Site
7
7
  def flows
data/spec/hash_spec.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  require 'spec/spec_helper'
2
+ require 'taza/entity'
3
+ require 'extensions/hash'
2
4
 
5
+ # This is too tightly coupled to Taza::Entity
3
6
  describe 'Hash Extensions' do
4
7
  it "should add methods for hash keys to some instance" do
5
8
  entity = {'apple' => 'pie'}.convert_hash_keys_to_methods(nil)
@@ -9,4 +12,4 @@ describe 'Hash Extensions' do
9
12
  entity = {'apple' => 'pie'}.convert_hash_keys_to_methods(nil)
10
13
  entity.should_not be_a_instance_of(Hash)
11
14
  end
12
- end
15
+ end
@@ -1,7 +1,7 @@
1
1
  require 'spec/spec_helper'
2
2
  require 'rubygems'
3
3
  require 'fileutils'
4
- require 'taza'
4
+ require 'taza/page'
5
5
 
6
6
  describe "Page Generation" do
7
7
  include RubiGen::GeneratorTestHelper
@@ -34,7 +34,7 @@ describe "Page Generation" do
34
34
 
35
35
  it "should generate a page spec that can be required" do
36
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')
37
+ page_functional_spec = File.join(PROJECT_FOLDER,'spec','isolation',@site_class.to_s.underscore,'check_out_page_spec.rb')
38
38
  system("ruby -c #{page_functional_spec} > #{null_device}").should be_true
39
39
  end
40
40
 
@@ -0,0 +1,104 @@
1
+ require 'spec/spec_helper'
2
+ require 'taza/page'
3
+
4
+ describe "Taza Page Module" do
5
+
6
+ class PageWithModule < ::Taza::Page
7
+
8
+ page_module :module do
9
+ element(:module_element) { browser }
10
+ end
11
+
12
+ end
13
+
14
+ it "should execute elements in the context of their page module" do
15
+ page = PageWithModule.new(:module)
16
+ page.browser = :something
17
+ page.module_element.should eql(:something)
18
+ end
19
+
20
+ class AnotherPageWithModule < ::Taza::Page
21
+
22
+ page_module :other_module do
23
+ element(:another_module_element) { browser }
24
+ end
25
+
26
+ end
27
+
28
+
29
+ it "should not execute elements that belong to a page module but accessed without it" do
30
+ lambda { AnotherPageWithModule.new.another_module_element }.should raise_error(NoMethodError)
31
+ end
32
+
33
+ it "should execute elements in the context of their page module when accessed with it" do
34
+ page = AnotherPageWithModule.new(:other_module)
35
+ page.browser = :another_thing
36
+ page.another_module_element.should eql(:another_thing)
37
+ end
38
+
39
+
40
+ class TestPageWithModules < ::Taza::Page
41
+
42
+ page_module :module_one do
43
+ element(:some_module_element) { :something }
44
+ end
45
+
46
+ page_module :module_two do
47
+ element(:some_module_element) { :nothing }
48
+ end
49
+
50
+ end
51
+
52
+ it "should execute elements with the same name but different page modules" do
53
+ module_one = TestPageWithModules.new(:module_one)
54
+ module_two = TestPageWithModules.new(:module_two)
55
+ module_one.some_module_element.should eql(:something)
56
+ module_two.some_module_element.should eql(:nothing)
57
+ end
58
+
59
+ class PageWithMultipleModuleElements < ::Taza::Page
60
+
61
+ page_module :module do
62
+ element(:module_element) { :something }
63
+ element(:another_module_element) { :nothing }
64
+ end
65
+
66
+ end
67
+
68
+ it "should execute elements with the same name but different page modules" do
69
+ page_module = PageWithMultipleModuleElements.new(:module)
70
+ page_module.module_element.should eql(:something)
71
+ page_module.another_module_element.should eql(:nothing)
72
+ end
73
+
74
+ class PageWithFilterAndModule < ::Taza::Page
75
+ page_module :module do
76
+ element(:sample_element) {:something}
77
+ end
78
+ filter :sample_filter, :module
79
+ def sample_filter
80
+ true
81
+ end
82
+ end
83
+
84
+ it "should execute filters for page modules" do
85
+ page = PageWithFilterAndModule.new(:module)
86
+ page.sample_element.should eql(:something)
87
+ end
88
+
89
+ class PageWithFalseFilterAndModule < ::Taza::Page
90
+ page_module :module do
91
+ element(:sample_element) {:something}
92
+ end
93
+ filter :false_filter, :module
94
+ def false_filter
95
+ false
96
+ end
97
+ end
98
+
99
+ it "should raise an error for page-module filters that return false" do
100
+ page = PageWithFalseFilterAndModule.new(:module)
101
+ lambda { page.sample_element }.should raise_error(Taza::FilterError)
102
+ end
103
+
104
+ end
@@ -1,7 +1,7 @@
1
1
  require 'spec/spec_helper'
2
2
  require 'rubygems'
3
3
  require 'fileutils'
4
- require 'taza'
4
+ require 'taza/page'
5
5
 
6
6
  describe "Partial Generation" do
7
7
  include RubiGen::GeneratorTestHelper
@@ -2,7 +2,6 @@ require 'spec/spec_helper'
2
2
  require 'rubygems'
3
3
  require 'rake'
4
4
  require 'fileutils'
5
- require 'taza'
6
5
 
7
6
  describe "Project Generator" do
8
7
  include RubiGen::GeneratorTestHelper
@@ -10,3 +10,6 @@ third_example:
10
10
  name: third
11
11
  price: 3
12
12
  user: shatner
13
+ forth_example:
14
+ something:
15
+ user: shatner
@@ -0,0 +1,10 @@
1
+ class Baz < Taza::Page
2
+ page_module :another_module do
3
+ element(:some_element) { :another_some_element_value }
4
+ end
5
+
6
+ filter :bay, :another_module
7
+ def bay
8
+ true
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ class Baz < Taza::Page
2
+ page_module :module do
3
+ element(:some_element) { :some_element_value }
4
+ element(:other_element) { :other_element_value }
5
+ end
6
+
7
+ filter :boo, :module
8
+ def boo
9
+ true
10
+ end
11
+ end
@@ -1,88 +1,89 @@
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
1
+ require 'spec/spec_helper'
2
+ require 'rubygems'
3
+ require 'taza/settings'
4
+ require 'taza/site'
5
+
6
+ describe Taza::Settings do
7
+
8
+ before :all do
9
+ @site_name = 'SiteName'
10
+ end
11
+
12
+ before :each do
13
+ ENV['TAZA_ENV'] = 'isolation'
14
+ ENV['BROWSER'] = nil
15
+ ENV['DRIVER'] = nil
16
+ end
17
+
18
+ it "should use environment variable for browser settings" do
19
+ Taza::Settings.stubs(:path).returns("spec/sandbox")
20
+ ENV['BROWSER'] = 'foo'
21
+ Taza::Settings.config(@site_name)[:browser].should eql(:foo)
22
+ end
23
+
24
+ it "should provide default values if no config file or environment settings provided" do
25
+ Taza::Settings.stubs(:path).returns("spec/sandbox")
26
+ Taza::Settings.config(@site_name)[:driver].should eql(:selenium)
27
+ Taza::Settings.config(@site_name)[:browser].should eql(:firefox)
28
+ end
29
+
30
+ it "should use environment variable for driver settings" do
31
+ Taza::Settings.stubs(:path).returns("spec/sandbox")
32
+ ENV['DRIVER'] = 'bar'
33
+ Taza::Settings.config(@site_name)[:driver].should eql(:bar)
34
+ end
35
+
36
+ it "should be able to load the site yml" do
37
+ Taza::Settings.stubs(:path).returns("spec/sandbox")
38
+ Taza::Settings.config("SiteName")[:url].should eql('http://google.com')
39
+ end
40
+
41
+ it "should be able to load a alternate site url" do
42
+ ENV['TAZA_ENV'] = 'clown_shoes'
43
+ Taza::Settings.stubs(:path).returns("spec/sandbox")
44
+ Taza::Settings.config("SiteName")[:url].should eql('http://clownshoes.com')
45
+ end
46
+
47
+ it "should use the config file's variable for browser settings if no environment variable is set" do
48
+ Taza::Settings.expects(:config_file).returns({:browser => :fu})
49
+ Taza::Settings.stubs(:path).returns("spec/sandbox")
50
+ Taza::Settings.config(@site_name)[:browser].should eql(:fu)
51
+ end
52
+
53
+ it "should use the ENV variables if specfied instead of config files" do
54
+ ENV['BROWSER'] = 'opera'
55
+ Taza::Settings.expects(:config_file).returns({:browser => :fu})
56
+ Taza::Settings.stubs(:path).returns("spec/sandbox")
57
+ Taza::Settings.config(@site_name)[:browser].should eql(:opera)
58
+ end
59
+
60
+ it "should use the correct config file to set defaults" do
61
+ Taza::Settings.stubs(:path).returns("spec/sandbox")
62
+ Taza::Settings.stubs(:config_file_path).returns('spec/sandbox/config.yml')
63
+ end
64
+
65
+ it "should raise error for a config file that doesnot exist" do
66
+ Taza::Settings.stubs(:path).returns('spec/sandbox/file_not_exists.yml')
67
+ lambda {Taza::Settings.config}.should raise_error
68
+ end
69
+
70
+ it "should path point at root directory" do
71
+ Taza::Settings.path.should eql('.')
72
+ end
73
+
74
+ it "should use the config file's variable for driver settings if no environment variable is set" do
75
+ Taza::Settings.stubs(:path).returns("spec/sandbox")
76
+ Taza::Settings.stubs(:config_file).returns({:driver => :fun})
77
+ Taza::Settings.config(@site_name)[:driver].should eql(:fun)
78
+ end
79
+
80
+ class SiteName < Taza::Site
81
+
82
+ end
83
+
84
+ it "a site should be able to load its settings" do
85
+ Taza::Settings.stubs(:path).returns("spec/sandbox")
86
+ SiteName.settings[:url].should eql('http://google.com')
87
+ end
88
+
89
+ end
@@ -1,15 +1,17 @@
1
- require 'spec/spec_helper'
2
- require 'taza/fixture'
3
-
4
- describe "Site Specific Fixtures" do
5
- include Taza::Fixtures::FooSite
6
-
7
- it "should be able to access fixtures in sub-folders" do
8
- bars(:foo).name.should eql("foo")
9
- end
10
-
11
- it "should not be able to access non-site-specific fixtures" do
12
- lambda{foos(:gap)}.should raise_error(NoMethodError)
13
- end
14
-
15
- end
1
+ require 'spec/spec_helper'
2
+ require 'taza/fixture'
3
+
4
+ describe "Site Specific Fixtures" do
5
+ Taza::Fixture.stubs(:base_path).returns(File.join('.','spec','sandbox','fixtures',''))
6
+ require 'taza/fixtures'
7
+ include Taza::Fixtures::FooSite
8
+
9
+ it "should be able to access fixtures in sub-folders" do
10
+ bars(:foo).name.should eql("foo")
11
+ end
12
+
13
+ it "should not be able to access non-site-specific fixtures" do
14
+ lambda{foos(:gap)}.should raise_error(NoMethodError)
15
+ end
16
+
17
+ end
@@ -1,7 +1,6 @@
1
1
  require 'spec/spec_helper'
2
2
  require 'rubygems'
3
3
  require 'fileutils'
4
- require 'taza'
5
4
 
6
5
  describe "Site Generation" do
7
6
  include RubiGen::GeneratorTestHelper
@@ -39,9 +38,9 @@ describe "Site Generation" do
39
38
  File.directory?(File.join(@site_folder,"pages","partials")).should be_true
40
39
  end
41
40
 
42
- it "should generate a folder for a sites functional tests" do
41
+ it "should generate a folder for a sites isolation tests" do
43
42
  run_generator('site', [@site_name], generator_sources)
44
- File.directory?(File.join(PROJECT_FOLDER,'spec','functional','wikipedia_foo')).should be_true
43
+ File.directory?(File.join(PROJECT_FOLDER,'spec','isolation','wikipedia_foo')).should be_true
45
44
  end
46
45
 
47
46
  it "generated site that uses the block given in new" do
data/spec/site_spec.rb CHANGED
@@ -1,6 +1,10 @@
1
1
  require 'spec/spec_helper'
2
2
  require 'rubygems'
3
- require 'taza'
3
+ require 'taza/site'
4
+ require 'taza/settings'
5
+ require 'taza/browser'
6
+ require 'taza/page'
7
+ require 'taza/flow'
4
8
 
5
9
  describe Taza::Site do
6
10
 
@@ -226,4 +230,23 @@ describe Taza::Site do
226
230
  browser
227
231
  end
228
232
 
233
+ it "should yield an instance of page class that can access page-module specific elements" do
234
+ f = Foo.new(:browser => stub_browser)
235
+ barzor = nil
236
+ f.baz(:module) do |baz|
237
+ barzor = baz
238
+ end
239
+ barzor.should be_an_instance_of(Baz)
240
+ barzor.some_element.should eql(:some_element_value)
241
+ end
242
+
243
+ it "should raise an error when accessing an element taht belongs to another module" do
244
+ f = Foo.new(:browser => stub_browser)
245
+ barzor = nil
246
+ f.baz(:another_module) do |baz|
247
+ barzor = baz
248
+ end
249
+ lambda{barzor.other_element}.should raise_error(NoMethodError)
250
+ end
251
+
229
252
  end
data/spec/string_spec.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'spec/spec_helper'
2
+ require 'extensions/string'
2
3
 
3
4
  describe "string extensions" do
4
5
  it "should pluralize and to sym a string" do
@@ -1,7 +1,6 @@
1
1
  require 'spec/spec_helper'
2
2
  require 'rubygems'
3
3
  require 'fileutils'
4
- require 'taza'
5
4
 
6
5
  describe "Taza project generator script" do
7
6
 
@@ -13,13 +13,18 @@ describe "Taza Tasks" do
13
13
 
14
14
  before :each do
15
15
  Dir.stubs(:taglob).returns([])
16
- Dir.expects(:glob).with('./spec/*/').returns(['./spec/functional/'])
16
+ Dir.expects(:glob).with('./spec/*/').returns(['./spec/functional/','./spec/mocks/'])
17
17
  Dir.expects(:glob).with('./spec/functional/*/').returns(['./spec/functional/foo/'])
18
18
  Dir.expects(:glob).with('./spec/functional/*_spec.rb').returns([])
19
19
  Dir.expects(:glob).with('./spec/functional/foo/*/').returns(['./spec/functional/foo/page/'])
20
20
  Dir.expects(:glob).with('./spec/functional/foo/*_spec.rb').returns([])
21
21
  Dir.expects(:glob).with('./spec/functional/foo/page/*/').returns([])
22
22
  Dir.expects(:glob).with('./spec/functional/foo/page/*_spec.rb').returns(['./spec/functional/foo/page/bar_spec.rb'])
23
+
24
+ Dir.expects(:glob).with('./spec/functional/**/*_spec.rb').returns(['./spec/functional/foo/page/bar_spec.rb'])
25
+ Dir.expects(:glob).with('./spec/functional/foo/**/*_spec.rb').returns(['./spec/functional/foo/page/bar_spec.rb'])
26
+ Dir.expects(:glob).with('./spec/functional/foo/page/**/*_spec.rb').returns(['./spec/functional/foo/page/bar_spec.rb'])
27
+ Dir.expects(:glob).with('./spec/mocks/**/*_spec.rb').returns([])
23
28
  load @file_name
24
29
  Taza::Rake::Tasks.new
25
30
  end
@@ -40,6 +45,10 @@ describe "Taza Tasks" do
40
45
  tasks.include?("spec:functional:foo:page:bar").should be_true
41
46
  end
42
47
 
48
+ it "should not create rake spec tasks for folders that donot contain specs in their sub-tree" do
49
+ tasks.include?("spec:mocks").should be_false
50
+ end
51
+
43
52
  def tasks
44
53
  @rake.tasks.collect{|task| task.name }
45
54
  end
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
4
+ version: 0.8.5
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: 2009-02-16 00:00:00 -08:00
12
+ date: 2009-03-05 00:00:00 -08:00
13
13
  default_executable: taza
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -112,6 +112,7 @@ files:
112
112
  - lib/taza/browser.rb
113
113
  - lib/taza/entity.rb
114
114
  - lib/taza/fixture.rb
115
+ - lib/taza/fixtures.rb
115
116
  - lib/taza/flow.rb
116
117
  - lib/taza/page.rb
117
118
  - lib/taza/settings.rb
@@ -127,6 +128,7 @@ files:
127
128
  - spec/hash_spec.rb
128
129
  - spec/object_spec.rb
129
130
  - spec/page_generator_spec.rb
131
+ - spec/page_module_spec.rb
130
132
  - spec/page_spec.rb
131
133
  - spec/partial_generator_spec.rb
132
134
  - spec/project_generator_spec.rb
@@ -147,6 +149,8 @@ files:
147
149
  - spec/sandbox/pages
148
150
  - spec/sandbox/pages/foo
149
151
  - spec/sandbox/pages/foo/bar.rb
152
+ - spec/sandbox/pages/foo/bay.rb
153
+ - spec/sandbox/pages/foo/baz.rb
150
154
  - spec/sandbox/pages/foo/partials
151
155
  - spec/sandbox/pages/foo/partials/partial_the_reckoning.rb
152
156
  - spec/settings_spec.rb
@@ -156,7 +160,6 @@ files:
156
160
  - spec/spec_helper.rb
157
161
  - spec/string_spec.rb
158
162
  - spec/taza_bin_spec.rb
159
- - spec/taza_spec.rb
160
163
  - spec/taza_tasks_spec.rb
161
164
  - README
162
165
  has_rdoc: true
data/spec/taza_spec.rb DELETED
@@ -1,12 +0,0 @@
1
- require 'spec/spec_helper'
2
- require 'rubygems'
3
-
4
- describe "Taza GIVE ME 100% COVERAGE LOL" do
5
- it "should cover the windows method" do
6
- Taza.windows?
7
- end
8
-
9
- it "should cover the osx method" do
10
- Taza.osx?
11
- end
12
- end