spec/page_module_spec.rb in taza-0.8.5 vs spec/page_module_spec.rb in taza-0.8.6

- old
+ new

@@ -99,6 +99,67 @@ it "should raise an error for page-module filters that return false" do page = PageWithFalseFilterAndModule.new(:module) lambda { page.sample_element }.should raise_error(Taza::FilterError) end + class PageWithFilterAndModuleElements < ::Taza::Page + page_module :module do + element(:sample_element) {:something} + end + page_module_filter :sample_filter, :module, :sample_element + def sample_filter + false + end + end + + it "should execute filters for elements inside page modules" do + page = PageWithFilterAndModuleElements.new(:module) + lambda { page.sample_element }.should raise_error(Taza::FilterError) + end + + class PageWithFiltersAndModuleElements < ::Taza::Page + page_module :module do + element(:sample_element) {:something} + element(:another_sample_element) {:something} + end + page_module_filter :sample_filter, :module + def sample_filter + true + end + page_module_filter :another_sample_filter, :module, :sample_element + def another_sample_filter + false + end + end + + it "should execute filters for specific and all elements inside page modules" do + page = PageWithFiltersAndModuleElements.new(:module) + lambda { page.sample_element }.should raise_error(Taza::FilterError) + page.another_sample_element.should eql(:something) + end + + class PageWithFiltersAndModulesAndElements < ::Taza::Page + page_module :foo_module do + element(:sample_element) {:something} + end + page_module_filter :foo_filter, :foo_module + def foo_filter + true + end + page_module :bar_module do + element(:sample_element) {:nothing} + end + page_module_filter :bar_filter, :bar_module + def bar_filter + false + end + end + + it "should execute page module filters for identical element names appropriately" do + foo = PageWithFiltersAndModulesAndElements.new(:foo_module) + foo.sample_element.should eql(:something) + bar = PageWithFiltersAndModulesAndElements.new(:bar_module) + lambda { bar.sample_element }.should raise_error(Taza::FilterError) + end + + end