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
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ sudo: false

bundler_args: ''

before_install:
- gem install bundler -v 1.12.3

before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### Changed

* [176](https://github.com/appfolio/ae_page_objects/pull/176) Limit exposed constants to _public_ API.
* [175](https://github.com/appfolio/ae_page_objects/issues/175) Use `BasicRouter` as default. Move Rails support to `ae_page_objects/rails`.
* [107](https://github.com/appfolio/ae_page_objects/issues/107) Replaced `Site` and `Document.site` with `AePageObjects.default_router` and `Document.router`
* [82](https://github.com/appfolio/ae_page_objects/pull/82) Removed Ruby 1.8.7 support
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source "https://rubygems.org"

gem "appraisal", "~> 0.5.1"
gem "appraisal", "~> 2.0"
gem "mocha", "= 0.13.3"
gem "selenium-webdriver", "~> 2.53.0"
gem 'gem-release', '0.7.4'
Expand Down
126 changes: 51 additions & 75 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ require 'appraisal'

require 'rake/testtask'

require 'pp'


Bundler::GemHelper.install_tasks

Expand All @@ -21,11 +19,11 @@ end

class SeleniumRunner

TestConfig = Struct.new(:rails_version, :gemfile)
TestConfig = Struct.new(:rails_version, :test_app_root, :gemfile)

def initialize(options = {})
@options = options
@matrix = read_matrix
@options = options
@matrix = read_matrix
end

def clean
Expand All @@ -37,27 +35,25 @@ class SeleniumRunner
test_app_directory = File.dirname(appraisal_file)

begin
Command.new("cd #{test_app_directory} && bundle check || bundle install").run
Command.new("cd #{test_app_directory} && rake appraisal:gemfiles").run
rescue Exception => e
run_command("cd #{test_app_directory} && bundle check || bundle install")
run_command("cd #{test_app_directory} && appraisal generate")
rescue => e
puts e.class
puts e.message
end
end
end

def install_all
@matrix.values.each do |test_configs|
test_configs.each do |test_config|
install_config(test_config)
end
@matrix.keys.each do |rails_version|
install_all_for(rails_version)
end
end

def install_all_for(rails_version)
@matrix[rails_version].each do |test_config|
install_config(test_config)
end
test_config = @matrix[rails_version].first
run_command("cd #{test_config.test_app_root} && bundle check || bundle install")
run_command("cd #{test_config.test_app_root} && appraisal install")
end

def run_all_tests
Expand All @@ -68,67 +64,28 @@ class SeleniumRunner
end

def run_all_tests_for(rails_version)
rails_versions = @matrix[rails_version]
if !rails_versions || rails_versions.empty?
gemfiles_for_rails_version = @matrix[rails_version]
if !gemfiles_for_rails_version || gemfiles_for_rails_version.empty?
puts "Tests for #{rails_version} can't run on #{RUBY_VERSION}"
return
end

rails_versions.each do |test_config|
run_test(test_config.gemfile, "test/test_apps/#{rails_version}", "bundle exec rake test:selenium")
gemfiles_for_rails_version.each do |test_config|
run_test(test_config, "bundle exec rake test:selenium")
end
end

private

def install_config(test_config)
appraisal = Appraisal::Appraisal.new("name", test_config.gemfile)

def appraisal.gemfile_path
@gemfile_path
end

appraisal.instance_variable_set(:@gemfile_path, test_config.gemfile)

if @options[:dry]
puts "Installing: #{test_config.gemfile}"
else
appraisal.install
end
end

# Appraisal::Command almost has what I need: a way to run things without Bundler/Ruby
# Env variables. The subclassing is to override the initializer to not modify the command.
class Command < Appraisal::Command
def initialize(command, gemfile = nil)
@original_env = {}
@gemfile = gemfile
@command = command
end
end

def run_test(gemfile, directory, command)
def run_test(test_config, command)
puts "---------------------",
'Test Config',
"Gemfile: #{gemfile}",
"Gemfile: #{test_config.gemfile}",
"Directory: #{test_config.test_app_root}",
"Command: '#{command}'",
"---------------------"

with_gemfile_symlink(directory, gemfile, "Gemfile") do
if !@options[:dry]
Command.new("cd #{directory} && #{command}", gemfile).run
end
end
end

def with_gemfile_symlink(directory, use_gemfile, app_gemfile)
run_command("cd #{directory} && ln -sf #{use_gemfile} #{app_gemfile}")
run_command("cd #{directory} && ln -sf #{use_gemfile}.lock #{app_gemfile}.lock")

yield

run_command("cd #{directory} && git checkout -- #{app_gemfile}")
run_command("rm -f #{directory}/#{app_gemfile}.lock")
run_command("cd #{test_config.test_app_root} && #{command}", test_config.gemfile)
end

def read_matrix
Expand All @@ -137,25 +94,37 @@ class SeleniumRunner
matrix = {}

Dir.glob(file_pattern).each do |file|
matches = file.match(%r{test/test_apps/(\d\.\d)/gemfiles/(.*ruby(\d\.\d\.\d)\.gemfile)})
matches = file.match(%r{(test/test_apps/(\d\.\d))/gemfiles/(.*ruby(\d\.\d\.\d)\.gemfile)})

gemfile_path = matches[0]
rails_version = matches[1]
gemfile = matches[2]
ruby_version = matches[3]
app_root = matches[1]
rails_version = matches[2]
gemfile = matches[3]
ruby_version = matches[4]

matrix[rails_version] ||= []
matrix[rails_version] << TestConfig.new(rails_version, File.expand_path("../#{gemfile_path}", __FILE__))
matrix[rails_version] << TestConfig.new(rails_version, app_root, File.expand_path("../#{gemfile_path}", __FILE__))
end

matrix
end

def run_command(command)
def run_command(command, gemfile = nil)
if gemfile
command = "BUNDLE_GEMFILE=#{gemfile} #{command}"
end

puts "Running '#{command}'"
return if @options[:dry]

specific_gemfile_env = Bundler.clean_env

if gemfile
specific_gemfile_env['BUNDLE_GEMFILE'] = gemfile
end

if ! @options[:dry]
`#{command}`
Bundler.send(:with_env, specific_gemfile_env) do
system(command)
raise unless $?.exitstatus == 0
end
end
Expand All @@ -178,12 +147,19 @@ namespace :test do
end

namespace :integration do
desc "Run unit test for ae_page_objects under appraisal environment"
desc "Run unit test for ae_page_objects under appraisal environment"
task :units do
system("bundle exec rake -s appraisal test:units")
system("appraisal rake test:units")
raise unless $?.exitstatus == 0
end

namespace :units do
task :install do
system("appraisal install")
raise unless $?.exitstatus == 0
end
end

namespace :selenium do
desc "Resolve and install dependencies for all test apps"
task :install do
Expand Down Expand Up @@ -220,14 +196,14 @@ namespace :test do
ci_install = nil
ci_task = nil

if ! (ENV['RAILS_VERSION'].nil? ^ ENV['UNITS'].nil?)
ci_install = ["appraisal:install", "test:integration:selenium:install"]
if !(ENV['RAILS_VERSION'].nil? ^ ENV['UNITS'].nil?)
ci_install = ["test:integration:units:install", "test:integration:selenium:install"]
ci_task = ['test:integration:units', 'test:integration:selenium']
elsif ENV['RAILS_VERSION']
ci_install = "test:integration:selenium:install"
ci_task = 'test:integration:selenium'
elsif ENV['UNITS']
ci_install = "appraisal:install"
ci_install = "test:integration:units:install"
ci_task = 'test:integration:units'
end

Expand Down
2 changes: 0 additions & 2 deletions ae_page_objects.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Gem::Specification.new do |s|
s.name = "ae_page_objects"
s.version = AePageObjects::VERSION

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.required_ruby_version = '>= 1.9.3'
s.authors = ["Donnie Tognazzini"]
s.description = "Capybara Page Objects pattern"
Expand All @@ -14,7 +13,6 @@ Gem::Specification.new do |s|
s.homepage = "http://github.com/appfolio/ae_page_objects"
s.licenses = ["MIT"]
s.require_paths = ["lib"]
s.rubygems_version = "1.8.24"
s.summary = "Capybara Page Objects pattern"

s.files = `git ls-files -- lib`.split("\n")
Expand Down
4 changes: 2 additions & 2 deletions gemfiles/capybara_2.1_ruby1.9.3.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source "https://rubygems.org"

gem "appraisal", "~> 0.5.1"
gem "appraisal", "~> 2.0"
gem "mocha", "= 0.13.3"
gem "selenium-webdriver", "~> 2.53.0"
gem "gem-release", "0.7.4"
Expand All @@ -11,4 +11,4 @@ gem "test-unit", "~> 3.0"
gem "mime-types", "< 3"
gem "capybara", "~> 2.1.0"

gemspec :path=>"../"
gemspec :path => "../"
4 changes: 2 additions & 2 deletions gemfiles/capybara_2.2_ruby2.2.5.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

source "https://rubygems.org"

gem "appraisal", "~> 0.5.1"
gem "appraisal", "~> 2.0"
gem "mocha", "= 0.13.3"
gem "selenium-webdriver", "~> 2.53.0"
gem "gem-release", "0.7.4"
gem "rake", "~> 11.0"
gem "test-unit", "~> 3.0"
gem "capybara", "~> 2.2.0"

gemspec :path=>"../"
gemspec :path => "../"
4 changes: 2 additions & 2 deletions gemfiles/capybara_2.3_ruby2.2.5.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

source "https://rubygems.org"

gem "appraisal", "~> 0.5.1"
gem "appraisal", "~> 2.0"
gem "mocha", "= 0.13.3"
gem "selenium-webdriver", "~> 2.53.0"
gem "gem-release", "0.7.4"
gem "rake", "~> 11.0"
gem "test-unit", "~> 3.0"
gem "capybara", "~> 2.3.0"

gemspec :path=>"../"
gemspec :path => "../"
4 changes: 2 additions & 2 deletions gemfiles/capybara_2.4_ruby2.2.5.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

source "https://rubygems.org"

gem "appraisal", "~> 0.5.1"
gem "appraisal", "~> 2.0"
gem "mocha", "= 0.13.3"
gem "selenium-webdriver", "~> 2.53.0"
gem "gem-release", "0.7.4"
gem "rake", "~> 11.0"
gem "test-unit", "~> 3.0"
gem "capybara", "~> 2.4.0"

gemspec :path=>"../"
gemspec :path => "../"
4 changes: 2 additions & 2 deletions gemfiles/capybara_2.5_ruby2.2.5.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

source "https://rubygems.org"

gem "appraisal", "~> 0.5.1"
gem "appraisal", "~> 2.0"
gem "mocha", "= 0.13.3"
gem "selenium-webdriver", "~> 2.53.0"
gem "gem-release", "0.7.4"
gem "rake", "~> 11.0"
gem "test-unit", "~> 3.0"
gem "capybara", "~> 2.5.0"

gemspec :path=>"../"
gemspec :path => "../"
4 changes: 2 additions & 2 deletions gemfiles/capybara_2.6_ruby2.2.5.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

source "https://rubygems.org"

gem "appraisal", "~> 0.5.1"
gem "appraisal", "~> 2.0"
gem "mocha", "= 0.13.3"
gem "selenium-webdriver", "~> 2.53.0"
gem "gem-release", "0.7.4"
gem "rake", "~> 11.0"
gem "test-unit", "~> 3.0"
gem "capybara", "~> 2.6.0"

gemspec :path=>"../"
gemspec :path => "../"
4 changes: 2 additions & 2 deletions gemfiles/capybara_2.7_ruby2.2.5.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

source "https://rubygems.org"

gem "appraisal", "~> 0.5.1"
gem "appraisal", "~> 2.0"
gem "mocha", "= 0.13.3"
gem "selenium-webdriver", "~> 2.53.0"
gem "gem-release", "0.7.4"
gem "rake", "~> 11.0"
gem "test-unit", "~> 3.0"
gem "capybara", "~> 2.7.0"

gemspec :path=>"../"
gemspec :path => "../"
Loading