Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aguspe committed Jul 23, 2024
1 parent 2c41fcf commit 9eaf32c
Show file tree
Hide file tree
Showing 15 changed files with 117 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Rspec Selenium Test on Ubuntu
name: Selenium Tests on Ubuntu
on: [ pull_request ]

jobs:
build:
name: Selenium-Rspec pipeline
name: Selenium based frameworks pipeline
runs-on: ubuntu-latest

steps:
Expand All @@ -19,4 +19,4 @@ jobs:
run: bundle install

- name: Build and run system tests
run: rspec spec/system/selenium_rspec_spec.rb
run: rspec spec/system/selenium_spec.rb
22 changes: 22 additions & 0 deletions .github/workflows/watir.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Watir Test on Ubuntu
on: [ pull_request ]

jobs:
build:
name: Watir based frameworks pipeline
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1.0

- name: Install gems
run: bundle install

- name: Build and run system tests
run: rspec spec/system/watir_spec.rb
2 changes: 1 addition & 1 deletion spec/integration/commands/scaffolding_commands_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require_relative '../../../lib/generators/common_generator'
require_relative '../../../lib/commands/scaffolding_commands'
require_relative '../../../lib/scaffolding/scaffolding'
require_relative '../../spec_helper'
require_relative '../spec_helper'

describe ScaffoldingCommands do
let(:scaffold) { described_class }
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/commands/utility_commands_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require_relative '../../../lib/generators/common_generator'
require_relative '../../../lib/commands/utility_commands'
require_relative '../../../lib/scaffolding/scaffolding'
require_relative '../../spec_helper'
require_relative '../spec_helper'

describe UtilityCommands do
let(:utility) { described_class }
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/generators/actions_generator_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require_relative '../../../lib/generators/actions/actions_generator'
require_relative '../../spec_helper'
require_relative '../spec_helper'

describe ActionsGenerator do
shared_examples 'creates web automation framework' do |name|
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/generators/automation_generator_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require_relative '../../../lib/generators/automation/automation_generator'
require_relative '../../spec_helper'
require_relative '../spec_helper'

describe AutomationGenerator do
shared_examples 'creates web automation framework' do |name|
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/generators/common_generator_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require_relative '../../../lib/generators/common_generator'
require_relative '../../spec_helper'
require_relative '../spec_helper'

describe CommonGenerator do
shared_examples 'creates common files' do |name|
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/generators/cucumber_generator_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require_relative '../../../lib/generators/cucumber/cucumber_generator'
require_relative '../../spec_helper'
require_relative '../spec_helper'

describe CucumberGenerator do
shared_examples 'creates cucumber files' do |project_name, file_name|
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/generators/helpers_generator_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require_relative '../../../lib/generators/helper_generator'
require_relative '../../spec_helper'
require_relative '../spec_helper'

describe HelpersGenerator do
shared_examples 'creates common helpers' do |name|
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/generators/rspec_generator_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require_relative '../../../lib/generators/rspec/rspec_generator'
require_relative '../../spec_helper'
require_relative '../spec_helper'

describe RspecGenerator do
shared_examples 'creates factory files' do |project_name|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
module SettingsHelper
def create_settings(options)
automation = options[:automation]
visual = options[:visual]
framework = options[:framework]
{
automation:,
framework:,
name: "#{framework}_#{automation}#{'_visual' if visual}",
visual:
name: "#{framework}_#{automation}"
}
end
end
10 changes: 4 additions & 6 deletions spec/spec_helper.rb → spec/integration/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

require 'fileutils'
require 'rspec'
require_relative '../lib/generators/invoke_generators'
require_relative 'support/settings_helper'
require_relative '../../lib/generators/invoke_generators'
require_relative 'settings_helper'

AUTOMATION_TYPES = %w[android ios selenium watir cross_platform axe applitools].freeze
FRAMEWORKS = %w[cucumber rspec].freeze
Expand All @@ -23,10 +23,8 @@
config.after(:all) do
FRAMEWORKS.each do |framework|
AUTOMATION_TYPES.each do |automation|
[true, false].each do |visual|
settings = create_settings(framework:, automation:, visual:)
FileUtils.rm_rf(settings[:name])
end
settings = create_settings(framework:, automation:)
FileUtils.rm_rf(settings[:name])
end
end
end
Expand Down
15 changes: 0 additions & 15 deletions spec/system/selenium_rspec_spec.rb

This file was deleted.

40 changes: 40 additions & 0 deletions spec/system/selenium_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
require_relative '../../lib/ruby_raider'

FRAMEWORKS = %w[cucumber rspec].freeze

describe 'Selenium based frameworks' do
before do
FRAMEWORKS.each do |framework|
RubyRaider::Raider
.new.invoke(:new, nil, %W[selenium_#{framework} -p framework:#{framework} automation:selenium])
end
end

after do
FRAMEWORKS.each do |framework|
FileUtils.rm_rf("selenium_#{framework}")
end
end

shared_examples 'creates web automation framework' do |type|
it 'executes without errors' do
run_tests_with(type)
expect($stdout).not_to match(/StandardError/)
end
end

context 'with rspec' do
include_examples 'creates web automation framework', 'rspec'
end

context 'with cucumber' do
include_examples 'creates web automation framework', 'cucumber'
end

private

def run_tests_with(framework)
folder = framework == 'rspec' ? 'spec' : 'features'
system("cd selenium_#{framework} && bundle install && raider utility browser_options chrome headless && bundle exec #{framework} #{folder}")
end
end
39 changes: 39 additions & 0 deletions spec/system/watir_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
require_relative '../../lib/ruby_raider'

FRAMEWORKS = %w[cucumber rspec].freeze

describe 'Watir based frameworks' do
before do
FRAMEWORKS.each do |framework|
RubyRaider::Raider
.new.invoke(:new, nil, %W[watir_#{framework} -p framework:#{framework} automation:watir])
end
end

after do
FRAMEWORKS.each do |framework|
FileUtils.rm_rf("watir_#{framework}")
end
end

shared_examples 'creates web automation framework' do |type|
it 'executes without errors' do
run_tests_with(type)
expect($stdout).not_to match(/StandardError/)
end
end

context 'with rspec' do
include_examples 'creates web automation framework', 'rspec'
end

context 'with cucumber' do
include_examples 'creates web automation framework', 'cucumber'
end

private

def run_tests_with(framework)
system("cd selenium_#{framework} && bundle install && raider utility browser_options chrome headless && bundle exec #{framework}")
end
end

0 comments on commit 9eaf32c

Please sign in to comment.