Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ae_page_objects.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Gem::Specification.new do |s|

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Donnie Tognazzini"]
s.date = "2013-06-12"
s.date = "2013-07-02"
s.description = "Capybara Page Objects pattern"
s.email = ["engineering@appfolio.com"]

Expand Down
2 changes: 1 addition & 1 deletion gemfiles/3.0.gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
ae_page_objects (0.1.3)
ae_page_objects (0.1.3.rl2)
activesupport (~> 3.0)
capybara (~> 1.1)
nokogiri (~> 1.5.9)
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/3.1.gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
ae_page_objects (0.1.3)
ae_page_objects (0.1.3.rl2)
activesupport (~> 3.0)
capybara (~> 1.1)
nokogiri (~> 1.5.9)
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/3.2.gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
ae_page_objects (0.1.3)
ae_page_objects (0.1.3.rl2)
activesupport (~> 3.0)
capybara (~> 1.1)
nokogiri (~> 1.5.9)
Expand Down
8 changes: 1 addition & 7 deletions lib/ae_page_objects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@
require 'active_support/core_ext/hash/keys'
require 'active_support/core_ext/object/try'
require 'active_support/core_ext/class'
require 'active_support/dependencies'
require 'active_support/core_ext/module/introspection'

require 'ae_page_objects/version'

module AePageObjects
autoload :Universe, 'ae_page_objects/core/universe'
autoload :ConstantResolver, 'ae_page_objects/core/constant_resolver'
autoload :DependenciesHook, 'ae_page_objects/core/dependencies_hook'
autoload :Installable, 'ae_page_objects/core/installable'
autoload :Configuration, 'ae_page_objects/core/configuration'
autoload :Singleton, 'ae_page_objects/core/singleton'
autoload :Application, 'ae_page_objects/core/application'
autoload :ApplicationRouter, 'ae_page_objects/core/application_router'
Expand Down Expand Up @@ -44,8 +40,6 @@ module Concerns
autoload :Checkbox, 'ae_page_objects/elements/checkbox'
end

ActiveSupport::Dependencies.extend AePageObjects::DependenciesHook




Expand Down
44 changes: 5 additions & 39 deletions lib/ae_page_objects/core/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,11 @@ class Application
class << self
private :new

attr_accessor :called_from

delegate :initialize!, :to => :instance
delegate :config, :to => :instance
delegate :initialize!, :router=, :to => :instance

def inherited(application_class)
super

application_class.called_from = begin
call_stack = caller.map { |p| p.sub(/:\d+.*/, '') }
File.dirname(call_stack.detect { |p| p !~ %r[railties[\w.-]*/lib/rails|rack[\w.-]*/lib/rack] })
end

application_class.universe.send(:include, Universe)
application_class.universe.page_objects_application_class = application_class
end
Expand All @@ -39,44 +31,18 @@ def from(from_mod)
end
end

delegate :universe, :to => 'self.class'
attr_writer :router

delegate :paths, :to => :config
delegate :router, :to => :config
delegate :universe, :to => 'self.class'

delegate :path_recognizes_url?, :to => :router
delegate :generate_path, :to => :router

def config
@config ||= Configuration.new(self)
def router
@router ||= ApplicationRouter.new
end

def initialize!
ActiveSupport::Dependencies.autoload_paths.unshift(*paths)
eager_load!
end

def resolve_constant(from_mod, const_name)
resolver = ConstantResolver.new(self, from_mod, const_name)

resolved = nil
paths.each do |path|
break if resolved = resolver.load_constant_from_path(path)
end
resolved
end

private

def eager_load!
paths.each do |path|
matcher = /\A#{Regexp.escape(path)}\/(.*)\.rb\Z/

Dir.glob("#{path}/**/*.rb").sort.each do |file|
dependency_name = file.sub(matcher, '\1')
require_dependency dependency_name
end
end
end
end
end
15 changes: 0 additions & 15 deletions lib/ae_page_objects/core/configuration.rb

This file was deleted.

38 changes: 0 additions & 38 deletions lib/ae_page_objects/core/constant_resolver.rb

This file was deleted.

7 changes: 0 additions & 7 deletions lib/ae_page_objects/core/dependencies_hook.rb

This file was deleted.

2 changes: 1 addition & 1 deletion lib/ae_page_objects/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module AePageObjects
VERSION = '0.1.3'.freeze
VERSION = '0.1.3.rl2'.freeze
end
4 changes: 2 additions & 2 deletions test/test_apps/3.0/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ../../..
specs:
ae_page_objects (0.1.3)
ae_page_objects (0.1.3.rl2)
activesupport (~> 3.0)
capybara (~> 1.1)
nokogiri (~> 1.5.9)
Expand Down Expand Up @@ -64,7 +64,7 @@ GEM
mime-types (1.22)
mocha (0.13.3)
metaclass (~> 0.0.1)
multi_json (1.7.6)
multi_json (1.7.7)
nokogiri (1.5.9)
polyglot (0.3.3)
rack (1.2.8)
Expand Down
2 changes: 1 addition & 1 deletion test/test_apps/3.1/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ../../..
specs:
ae_page_objects (0.1.3)
ae_page_objects (0.1.3.rl2)
activesupport (~> 3.0)
capybara (~> 1.1)
nokogiri (~> 1.5.9)
Expand Down
2 changes: 1 addition & 1 deletion test/test_apps/3.2/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ../../..
specs:
ae_page_objects (0.1.3)
ae_page_objects (0.1.3.rl2)
activesupport (~> 3.0)
capybara (~> 1.1)
nokogiri (~> 1.5.9)
Expand Down
10 changes: 4 additions & 6 deletions test/test_apps/shared/test/page_objects.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
require 'ae_page_objects'

module TestApp
module PageObjects
class Application < ::AePageObjects::Application
ActiveSupport::Dependencies.autoload_paths << "test"

# TODO - add something to config.paths to ensure it works
end
module PageObjects
class Application < ::AePageObjects::Application
end
end

TestApp::PageObjects::Application.initialize!
PageObjects::Application.initialize!
100 changes: 49 additions & 51 deletions test/test_apps/shared/test/page_objects/authors/new_page.rb
Original file line number Diff line number Diff line change
@@ -1,56 +1,54 @@
module TestApp
module PageObjects
module Authors
class NewPage < ::AePageObjects::Document

path :new_author

form_for "author" do
element :first_name
element :last_name

collection :books,
:name => "books_attributes",
:locator => "#author_books",
:row_xpath => ".//*[contains(@class, 'some-books-fool')]//*[contains(@class,'row') and not(contains(@style,'display'))]" do
element :title
end
module PageObjects
module Authors
class NewPage < ::AePageObjects::Document

path :new_author

form_for "author" do
element :first_name
element :last_name

collection :books,
:name => "books_attributes",
:locator => "#author_books",
:row_xpath => ".//*[contains(@class, 'some-books-fool')]//*[contains(@class,'row') and not(contains(@style,'display'))]" do
element :title
end
end

class Rating < ::AePageObjects::Element
element :star, :locator => ".star"

def show_star
find(".show_star").click
end

class Rating < ::AePageObjects::Element
element :star, :locator => ".star"

def show_star
find(".show_star").click
end

def hide_star
find(".hide_star").click
end

def remove_star
find(".remove_star").click
end

def hide_star
find(".hide_star").click
end

def remove_star
find(".remove_star").click
end
element :missing, :locator => "#does_not_exist"
element :rating, :is => Rating, :locator => "#rating"
element :nested_rating, :name => "nested_rating_attributes", :locator => "#rating" do
element :star, :locator => ".star"
def show_star
find(".show_star").click
end
def hide_star
find(".hide_star").click
end
def remove_star
find(".remove_star").click
end
end

element :missing, :locator => "#does_not_exist"

element :rating, :is => Rating, :locator => "#rating"

element :nested_rating, :name => "nested_rating_attributes", :locator => "#rating" do
element :star, :locator => ".star"

def show_star
find(".show_star").click
end

def hide_star
find(".hide_star").click
end

def remove_star
find(".remove_star").click
end
end
end
Expand Down
Loading