Skip to content

Commit

Permalink
Add Rails 7 to the test matrix.
Browse files Browse the repository at this point in the history
  • Loading branch information
fnando committed Jan 14, 2022
1 parent a91b179 commit 704123d
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 62 deletions.
35 changes: 18 additions & 17 deletions .github/workflows/tests.yml → .github/workflows/ruby-tests.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
name: Tests
---
name: ruby-tests

on:
pull_request:
branches:
- main
pull_request_target:
push:
branches:
- main

schedule:
- cron: "0 10 * * *"
workflow_dispatch:
inputs: {}

jobs:
build:
name: Tests with Ruby ${{ matrix.ruby }} and ${{ matrix.gemfile }}
runs-on: "ubuntu-latest"
if: |
github.actor == 'dependabot[bot]' && github.event_name == 'pull_request_target' ||
github.actor != 'dependabot[bot]'
strategy:
fail-fast: false
matrix:
ruby: ["3.0.x", "2.7.x", "2.6.x", "2.5.x"]
ruby: ["2.7", "3.0", "3.1"]
gemfile:
- Gemfile
- gemfiles/rails6_1.gemfile
- gemfiles/rails6_0.gemfile
- gemfiles/7_0.gemfile
- gemfiles/6_1.gemfile
- gemfiles/6_0.gemfile

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2.4.0

- uses: actions/cache@v2
with:
path: vendor/bundle
key: >
${{ runner.os }}-${{ matrix.ruby }}-gems-${{ hashFiles(matrix.gemfile) }}
restore-keys: >
${{ runner.os }}-${{ matrix.ruby }}-gems-${{ hashFiles(matrix.gemfile) }}
${{ runner.os }}-${{ matrix.ruby }}-gems-${{
hashFiles(matrix.gemfile) }}
- name: Set up Ruby
uses: actions/setup-ruby@v1
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}

- name: Install gem dependencies
env:
RAILS_ENV: test
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
run: |
gem install bundler
Expand All @@ -51,7 +51,8 @@ jobs:
- name: Run Tests
env:
RAILS_ENV: test
PGHOST: localhost
PGUSER: postgres
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
run: |
bundle exec rake
25 changes: 1 addition & 24 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ inherit_gem:

AllCops:
TargetRubyVersion: 2.5
NewCops: enable
Exclude:
- bin/**/*
- gemfiles/**/*
Expand All @@ -13,29 +14,5 @@ AllCops:
- "*.gemspec"
- config.ru

Metrics/ClassLength:
Enabled: false

Layout/LineLength:
Max: 80

Metrics/MethodLength:
Enabled: false

Style/Alias:
EnforcedStyle: prefer_alias_method

Lint/RedundantCopDisableDirective:
Enabled: false

Metrics/AbcSize:
Enabled: false

Metrics/CyclomaticComplexity:
Enabled: false

Metrics/PerceivedComplexity:
Enabled: false

Naming/VariableNumber:
Enabled: false
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Browser

[![Tests](https://github.com/fnando/browser/workflows/Tests/badge.svg)](https://github.com/fnando/browser)
[![Code Climate](https://codeclimate.com/github/fnando/browser/badges/gpa.svg)](https://codeclimate.com/github/fnando/browser)
[![Tests](https://github.com/fnando/browser/workflows/ruby-tests/badge.svg)](https://github.com/fnando/browser)
[![Gem](https://img.shields.io/gem/v/browser.svg)](https://rubygems.org/gems/browser)
[![Gem](https://img.shields.io/gem/dt/browser.svg)](https://rubygems.org/gems/browser)

Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails6_0.gemfile → gemfiles/6_0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
source "https://rubygems.org"
gemspec path: ".."

gem "rails", "~> 6.0"
gem "rails", "~> 6.0.0"
2 changes: 1 addition & 1 deletion gemfiles/rails6_1.gemfile → gemfiles/6_1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
source "https://rubygems.org"
gemspec path: ".."

gem "rails", "~> 6.1"
gem "rails", "~> 6.1.0"
6 changes: 6 additions & 0 deletions gemfiles/7_0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

source "https://rubygems.org"
gemspec path: ".."

gem "rails", "~> 7.0.0"
2 changes: 1 addition & 1 deletion lib/browser/accept_language.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def quality

private def quality_value
qvalue = part[/;q=([\d.]+)/, 1]
qvalue = /\A0\.0?\z/.match?(qvalue) ? "0.0" : qvalue
qvalue = "0.0" if /\A0\.0?\z/.match?(qvalue)
qvalue = qvalue.squeeze(".") if qvalue
qvalue
end
Expand Down
6 changes: 3 additions & 3 deletions lib/browser/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def accept_language
end
end

alias_method :to_a, :meta
alias to_a meta

# Return meta representation as string.
def to_s
Expand Down Expand Up @@ -161,7 +161,7 @@ def sputnik?(expected_version = nil)
def yandex?(expected_version = nil)
Yandex.new(ua).match? && detect_version?(full_version, expected_version)
end
alias_method :yandex_browser?, :yandex?
alias yandex_browser? yandex?

# Detect if browser is UCBrowser.
def uc_browser?(expected_version = nil)
Expand All @@ -180,7 +180,7 @@ def micro_messenger?(expected_version = nil)
detect_version?(full_version, expected_version)
end

alias_method :wechat?, :micro_messenger?
alias wechat? micro_messenger?

def weibo?(expected_version = nil)
Weibo.new(ua).match? && detect_version?(full_version, expected_version)
Expand Down
18 changes: 9 additions & 9 deletions lib/browser/device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def unknown?
def ipod_touch?
id == :ipod_touch
end
alias_method :ipod?, :ipod_touch?
alias ipod? ipod_touch?

def iphone?
id == :iphone
Expand All @@ -105,12 +105,12 @@ def iphone?
def ps3?
id == :ps3
end
alias_method :playstation3?, :ps3?
alias playstation3? ps3?

def ps4?
id == :ps4
end
alias_method :playstation4?, :ps4?
alias playstation4? ps4?

def psp?
id == :psp
Expand All @@ -119,8 +119,8 @@ def psp?
def playstation_vita?
id == :psvita
end
alias_method :vita?, :playstation_vita?
alias_method :psp_vita?, :playstation_vita?
alias vita? playstation_vita?
alias psp_vita? playstation_vita?

def kindle?
id == :kindle || kindle_fire?
Expand All @@ -133,22 +133,22 @@ def kindle_fire?
def nintendo_wii?
id == :wii
end
alias_method :wii?, :nintendo_wii?
alias wii? nintendo_wii?

def nintendo_wiiu?
id == :wiiu
end
alias_method :wiiu?, :nintendo_wiiu?
alias wiiu? nintendo_wiiu?

def nintendo_switch?
id == :switch
end
alias_method :switch?, :nintendo_switch?
alias switch? nintendo_switch?

def blackberry_playbook?
id == :playbook
end
alias_method :playbook?, :blackberry_playbook?
alias playbook? blackberry_playbook?

def surface?
id == :surface
Expand Down
2 changes: 1 addition & 1 deletion lib/browser/meta/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def meta
end

def to_a
meta.to_s.squeeze(" ").split(" ")
meta.to_s.squeeze(" ").split
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/browser/platform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def ios_webview?
def android_app?
android? && ua.match?(/\bwv\b/)
end
alias_method :android_webview?, :android_app?
alias android_webview? android_app?

# http://msdn.microsoft.com/fr-FR/library/ms537503.aspx#PltToken
def windows_xp?
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
module Minitest
class Test
setup do
Browser::Bot.instance_variable_set("@detect_empty_ua", false)
Browser::Bot.instance_variable_set(:@detect_empty_ua, false)
end

def assert_deprecated(message, file, line, &block)
Expand Down
2 changes: 1 addition & 1 deletion test/unit/bots_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class BotsTest < Minitest::Test
end

test "adds custom bot matcher" do
Browser::Bot.matchers << ->(ua, _) { ua.match?(/some-script/) }
Browser::Bot.matchers << ->(ua, _) { ua.include?("some-script") }
browser = Browser.new("some-script")

assert browser.bot?
Expand Down

0 comments on commit 704123d

Please sign in to comment.