From d853ab38c4f0bcc5262508a3a97789ec9da486d6 Mon Sep 17 00:00:00 2001 From: Pere Joan Martorell Calaf Date: Thu, 16 Mar 2023 11:01:50 +0100 Subject: [PATCH 1/9] Fix Gemfile.lock platforms --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2ea47e7..c3c1c4f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -43,7 +43,7 @@ GEM unicode-display_width (2.1.0) PLATFORMS - arm64-darwin-21 + ruby DEPENDENCIES app_rail-steps! From 6cce8b63f5c9e1cf67d181651386b7ff35745e9f Mon Sep 17 00:00:00 2001 From: Pere Joan Martorell Calaf Date: Thu, 16 Mar 2023 11:11:56 +0100 Subject: [PATCH 2/9] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e11c3d7..a12bba8 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Or install it yourself as: require 'app_rail/steps' ... -#inside your module/class include the displayable modile +#inside your module/class include the displayable module include AppRail::Steps::Displayable ... From 134db521c73f11993dab3777e72095c11fac3d22 Mon Sep 17 00:00:00 2001 From: Pere Joan Martorell Calaf Date: Thu, 16 Mar 2023 11:31:55 +0100 Subject: [PATCH 3/9] Add Github Actions workflow to run rspec and rubocop --- .github/workflows/main.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..9af359e --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,31 @@ +name: Ruby + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.2.0 + - name: Setup cache key and directory for gems cache + uses: actions/cache@v2 + with: + path: vendor/bundle + key: ${{ runner.os }}-gems-v2-${{ hashFiles('**/Gemfile.lock') }} + restore-keys: | + ${{ runner.os }}-gems-v2 + - name: Bundle install + run: | + gem install bundler + bundle config path vendor/bundle + bundle install --jobs 4 --retry 3 --without production + - name: RSpec + run: bundle exec rake spec + - name: Rubocop + run: bundle exec rake rubocop + From 0d09d3c8a9f65ff5d43e091848e6dee3036a30a3 Mon Sep 17 00:00:00 2001 From: Pere Joan Martorell Calaf Date: Thu, 16 Mar 2023 12:01:08 +0100 Subject: [PATCH 4/9] Fix rubocop offense: Gemspec/RequiredRubyVersion: required_ruby_version and TargetRubyVersion (2.6, which may be specified in .rubocop.yml) should be equal --- .rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index e3462a7..8d1fdd3 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,5 @@ AllCops: - TargetRubyVersion: 2.6 + TargetRubyVersion: 2.7 Style/StringLiterals: Enabled: true From 10c2a286b218dc19b329257425e9a8ed23d8e43c Mon Sep 17 00:00:00 2001 From: Pere Joan Martorell Calaf Date: Thu, 16 Mar 2023 12:06:35 +0100 Subject: [PATCH 5/9] Add rubocop-rspec gem --- .rubocop.yml | 3 +++ Gemfile | 1 + Gemfile.lock | 3 +++ 3 files changed, 7 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 8d1fdd3..69fa8b2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,6 @@ +require: + - rubocop-rspec + AllCops: TargetRubyVersion: 2.7 diff --git a/Gemfile b/Gemfile index 988fabf..ff9534a 100644 --- a/Gemfile +++ b/Gemfile @@ -10,3 +10,4 @@ gem "rake", "~> 13.0" gem "rspec", "~> 3.0" gem "rubocop", "~> 1.21" +gem "rubocop-rspec", "~> 2.11.1" diff --git a/Gemfile.lock b/Gemfile.lock index c3c1c4f..d021598 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -39,6 +39,8 @@ GEM unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.17.0) parser (>= 3.1.1.0) + rubocop-rspec (2.11.1) + rubocop (~> 1.19) ruby-progressbar (1.11.0) unicode-display_width (2.1.0) @@ -50,6 +52,7 @@ DEPENDENCIES rake (~> 13.0) rspec (~> 3.0) rubocop (~> 1.21) + rubocop-rspec (~> 2.11.1) BUNDLED WITH 2.3.5 From 0efb0d09f4665470f917b1ec725bbd29b2e3c1bb Mon Sep 17 00:00:00 2001 From: Pere Joan Martorell Calaf Date: Thu, 16 Mar 2023 12:07:38 +0100 Subject: [PATCH 6/9] Fix rubocop offenses --- spec/app_rail/steps/background_location/region_spec.rb | 3 ++- spec/app_rail/steps/charts/dashboard_spec.rb | 3 ++- spec/app_rail/steps/core/list_spec.rb | 4 ++-- spec/app_rail/steps/core/stack_spec.rb | 3 ++- spec/app_rail/steps/core_forms/form_spec.rb | 4 +++- spec/app_rail/steps/core_forms/question_spec.rb | 3 ++- spec/app_rail/steps/grid/grid_spec.rb | 3 ++- spec/app_rail/steps/maps/confirm_location_spec.rb | 3 ++- spec/app_rail/steps/maps/map_spec.rb | 3 ++- 9 files changed, 19 insertions(+), 10 deletions(-) diff --git a/spec/app_rail/steps/background_location/region_spec.rb b/spec/app_rail/steps/background_location/region_spec.rb index 2e638f2..6eac1b0 100644 --- a/spec/app_rail/steps/background_location/region_spec.rb +++ b/spec/app_rail/steps/background_location/region_spec.rb @@ -1,11 +1,12 @@ # frozen_string_literal: true RSpec.describe AppRail::Steps::BackgroundLocation::Region do + subject { test_struct.new(id) } + let(:test_struct) { Struct.new(:id) { include AppRail::Steps::Displayable } } let(:test_class) { Class.new { include AppRail::Steps::Displayable } } let(:id) { 1 } - subject { test_struct.new(id) } describe "#region" do context "required" do let(:result) { subject.ar_background_location_region(id: "home", latitude: 51.2, longitude: -0.5) } diff --git a/spec/app_rail/steps/charts/dashboard_spec.rb b/spec/app_rail/steps/charts/dashboard_spec.rb index d58fb35..0becbab 100644 --- a/spec/app_rail/steps/charts/dashboard_spec.rb +++ b/spec/app_rail/steps/charts/dashboard_spec.rb @@ -1,11 +1,12 @@ # frozen_string_literal: true RSpec.describe AppRail::Steps::Charts::Dashboard do + subject { test_struct.new(id) } + let(:test_struct) { Struct.new(:id) { include AppRail::Steps::Displayable } } let(:test_class) { Class.new { include AppRail::Steps::Displayable } } let(:id) { 1 } - subject { test_struct.new(id) } describe "#ar_charts_dashboard_statistic" do context "required" do let(:result) { subject.ar_charts_dashboard_statistic(id: 1, title: "London", text: "10,000,000") } diff --git a/spec/app_rail/steps/core/list_spec.rb b/spec/app_rail/steps/core/list_spec.rb index e088d3b..adaf680 100644 --- a/spec/app_rail/steps/core/list_spec.rb +++ b/spec/app_rail/steps/core/list_spec.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true RSpec.describe AppRail::Steps::Core::List do + subject { test_struct.new(id) } + let(:test_struct) { Struct.new(:id) { include AppRail::Steps::Displayable } } let(:test_class) { Class.new { include AppRail::Steps::Displayable } } let(:id) { 1 } - subject { test_struct.new(id) } - describe "#ar_core_list_item" do context "text" do let(:result) { subject.ar_core_list_item(text: "London") } diff --git a/spec/app_rail/steps/core/stack_spec.rb b/spec/app_rail/steps/core/stack_spec.rb index a0f579b..83b113e 100644 --- a/spec/app_rail/steps/core/stack_spec.rb +++ b/spec/app_rail/steps/core/stack_spec.rb @@ -1,11 +1,12 @@ # frozen_string_literal: true RSpec.describe AppRail::Steps::Core::Stack do + subject { test_struct.new(id) } + let(:test_struct) { Struct.new(:id) { include AppRail::Steps::Displayable } } let(:test_class) { Class.new { include AppRail::Steps::Displayable } } let(:id) { 1 } - subject { test_struct.new(id) } describe "#ar_core_stack_text" do context "text and label" do let(:result) { subject.ar_core_stack_text(text: "London", label: "City") } diff --git a/spec/app_rail/steps/core_forms/form_spec.rb b/spec/app_rail/steps/core_forms/form_spec.rb index 8537006..87cca32 100644 --- a/spec/app_rail/steps/core_forms/form_spec.rb +++ b/spec/app_rail/steps/core_forms/form_spec.rb @@ -1,11 +1,12 @@ # frozen_string_literal: true RSpec.describe AppRail::Steps::CoreForms::Form do + subject { test_struct.new(id) } + let(:test_struct) { Struct.new(:id) { include AppRail::Steps::Displayable } } let(:test_class) { Class.new { include AppRail::Steps::Displayable } } let(:id) { 1 } - subject { test_struct.new(id) } describe "#ar_core_forms_form_section" do let(:result) { subject.ar_core_forms_form_section(label: "Personal Information", id: 1) } @@ -84,6 +85,7 @@ describe "#ar_core_forms_form_time" do let(:result) { subject.ar_core_forms_form_time(label: "Start Time", id: 1, optional: true) } + it { expect(result[:id]).to eq 1 } it { expect(result[:item_type]).to eq :time } it { expect(result[:label]).to eq "Start Time" } diff --git a/spec/app_rail/steps/core_forms/question_spec.rb b/spec/app_rail/steps/core_forms/question_spec.rb index 4ede229..92a1e3b 100644 --- a/spec/app_rail/steps/core_forms/question_spec.rb +++ b/spec/app_rail/steps/core_forms/question_spec.rb @@ -1,11 +1,12 @@ # frozen_string_literal: true RSpec.describe AppRail::Steps::CoreForms::Question do + subject { test_struct.new(id) } + let(:test_struct) { Struct.new(:id) { include AppRail::Steps::Displayable } } let(:test_class) { Class.new { include AppRail::Steps::Displayable } } let(:id) { 1 } - subject { test_struct.new(id) } describe "#ar_core_forms_form_multiple_selection" do let(:multiple_section_options) do [{ text: "Alcohol Free", isPreSelected: true }, { text: "Sunrise Yoga", isPreSelected: false }] diff --git a/spec/app_rail/steps/grid/grid_spec.rb b/spec/app_rail/steps/grid/grid_spec.rb index 9baeca2..9d87ac7 100644 --- a/spec/app_rail/steps/grid/grid_spec.rb +++ b/spec/app_rail/steps/grid/grid_spec.rb @@ -1,11 +1,12 @@ # frozen_string_literal: true RSpec.describe AppRail::Steps::Grid::Grid do + subject { test_struct.new(id) } + let(:test_struct) { Struct.new(:id) { include AppRail::Steps::Displayable } } let(:test_class) { Class.new { include AppRail::Steps::Displayable } } let(:id) { 1 } - subject { test_struct.new(id) } describe "#ar_styled_content_grid_large_section" do let(:result) { subject.ar_styled_content_grid_large_section(id: 0, text: "Mountains") } diff --git a/spec/app_rail/steps/maps/confirm_location_spec.rb b/spec/app_rail/steps/maps/confirm_location_spec.rb index 0ce2b10..0a8abc0 100644 --- a/spec/app_rail/steps/maps/confirm_location_spec.rb +++ b/spec/app_rail/steps/maps/confirm_location_spec.rb @@ -1,11 +1,12 @@ # frozen_string_literal: true RSpec.describe AppRail::Steps::Maps::ConfirmLocation do + subject { test_struct.new(id) } + let(:test_struct) { Struct.new(:id) { include AppRail::Steps::Displayable } } let(:test_class) { Class.new { include AppRail::Steps::Displayable } } let(:id) { 1 } - subject { test_struct.new(id) } describe "#ar_maps_map_item" do context "text" do let(:result) { subject.ar_maps_confirm_location(text: "London", latitude: 51.5, longitude: 0.51) } diff --git a/spec/app_rail/steps/maps/map_spec.rb b/spec/app_rail/steps/maps/map_spec.rb index 8c2258a..5b947cc 100644 --- a/spec/app_rail/steps/maps/map_spec.rb +++ b/spec/app_rail/steps/maps/map_spec.rb @@ -1,11 +1,12 @@ # frozen_string_literal: true RSpec.describe AppRail::Steps::Maps::Map do + subject { test_struct.new(id) } + let(:test_struct) { Struct.new(:id) { include AppRail::Steps::Displayable } } let(:test_class) { Class.new { include AppRail::Steps::Displayable } } let(:id) { 1 } - subject { test_struct.new(id) } describe "#ar_maps_map_item" do context "text" do let(:result) { subject.ar_maps_map_item(text: "London", latitude: 51.5, longitude: 0.51) } From 82df73f2d1eba884b07ee1c809ae58d445f43a4b Mon Sep 17 00:00:00 2001 From: Pere Joan Martorell Calaf Date: Thu, 16 Mar 2023 12:14:25 +0100 Subject: [PATCH 7/9] Upgrade rubocop and rubocop-rspec gems --- Gemfile | 4 ++-- Gemfile.lock | 35 ++++++++++++++++++++--------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/Gemfile b/Gemfile index ff9534a..a01a28d 100644 --- a/Gemfile +++ b/Gemfile @@ -9,5 +9,5 @@ gem "rake", "~> 13.0" gem "rspec", "~> 3.0" -gem "rubocop", "~> 1.21" -gem "rubocop-rspec", "~> 2.11.1" +gem "rubocop", "~> 1.48.1" +gem "rubocop-rspec", "~> 2.19.0" diff --git a/Gemfile.lock b/Gemfile.lock index d021598..d89ab52 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,12 +8,13 @@ GEM specs: ast (2.4.2) diff-lcs (1.5.0) + json (2.6.3) parallel (1.22.1) - parser (3.1.2.0) + parser (3.2.1.1) ast (~> 2.4.1) rainbow (3.1.1) rake (13.0.6) - regexp_parser (2.3.0) + regexp_parser (2.7.0) rexml (3.2.5) rspec (3.11.0) rspec-core (~> 3.11.0) @@ -28,21 +29,25 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) rspec-support (3.11.0) - rubocop (1.27.0) + rubocop (1.48.1) + json (~> 2.3) parallel (~> 1.10) - parser (>= 3.1.0.0) + parser (>= 3.2.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) - rexml - rubocop-ast (>= 1.16.0, < 2.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.26.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.17.0) - parser (>= 3.1.1.0) - rubocop-rspec (2.11.1) - rubocop (~> 1.19) - ruby-progressbar (1.11.0) - unicode-display_width (2.1.0) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.27.0) + parser (>= 3.2.1.0) + rubocop-capybara (2.17.1) + rubocop (~> 1.41) + rubocop-rspec (2.19.0) + rubocop (~> 1.33) + rubocop-capybara (~> 2.17) + ruby-progressbar (1.13.0) + unicode-display_width (2.4.2) PLATFORMS ruby @@ -51,8 +56,8 @@ DEPENDENCIES app_rail-steps! rake (~> 13.0) rspec (~> 3.0) - rubocop (~> 1.21) - rubocop-rspec (~> 2.11.1) + rubocop (~> 1.48.1) + rubocop-rspec (~> 2.19.0) BUNDLED WITH 2.3.5 From 2d9b85376b360b0fdddb5ce8be580b480561cdc8 Mon Sep 17 00:00:00 2001 From: Pere Joan Martorell Calaf Date: Thu, 16 Mar 2023 12:15:22 +0100 Subject: [PATCH 8/9] Fix more rubocop offenses --- app_rail-steps.gemspec | 1 + spec/app_rail/steps/core/stack_spec.rb | 2 +- spec/app_rail/steps/core_forms/form_spec.rb | 20 +++++++++---------- .../steps/core_forms/question_spec.rb | 4 ++-- spec/app_rail/steps_spec.rb | 2 +- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/app_rail-steps.gemspec b/app_rail-steps.gemspec index 6144993..4c57a27 100644 --- a/app_rail-steps.gemspec +++ b/app_rail-steps.gemspec @@ -24,4 +24,5 @@ Gem::Specification.new do |spec| spec.bindir = "exe" spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] + spec.metadata["rubygems_mfa_required"] = "true" end diff --git a/spec/app_rail/steps/core/stack_spec.rb b/spec/app_rail/steps/core/stack_spec.rb index 83b113e..882125b 100644 --- a/spec/app_rail/steps/core/stack_spec.rb +++ b/spec/app_rail/steps/core/stack_spec.rb @@ -23,7 +23,7 @@ it { expect(result[:text]).to eq "London" } it { expect(result[:sfSymbolName]).to eq "map" } it { expect(result[:materialIconName]).to eq "map" } - it { expect(result[:label]).to eq nil } + it { expect(result[:label]).to be_nil } end end diff --git a/spec/app_rail/steps/core_forms/form_spec.rb b/spec/app_rail/steps/core_forms/form_spec.rb index 87cca32..6b2f236 100644 --- a/spec/app_rail/steps/core_forms/form_spec.rb +++ b/spec/app_rail/steps/core_forms/form_spec.rb @@ -29,8 +29,8 @@ it { expect(result[:label]).to eq "Challenge Type" } it { expect(result[:multiple_selection_options]).to eq multiple_section_options } it { expect(result[:selection_type]).to eq :single } - it { expect(result[:optional]).to eq false } - it { expect(result[:show_other_option]).to eq false } + it { expect(result[:optional]).to be false } + it { expect(result[:show_other_option]).to be false } end describe "#ar_core_forms_form_multiple_selection_options" do @@ -41,7 +41,7 @@ it { expect(result[:text]).to eq "Open for all" } it { expect(result[:hint]).to eq "Every user will be able to join" } - it { expect(result[:isPreSelected]).to eq false } + it { expect(result[:isPreSelected]).to be false } end describe "#ar_core_forms_form_number" do @@ -54,7 +54,7 @@ it { expect(result[:number_type]).to eq :number } it { expect(result[:label]).to eq "Target Amount" } it { expect(result[:placeholder]).to eq "100 Eur" } - it { expect(result[:optional]).to eq false } + it { expect(result[:optional]).to be false } it { expect(result[:default_text_answer]).to eq 50 } end @@ -68,8 +68,8 @@ it { expect(result[:item_type]).to eq :text } it { expect(result[:label]).to eq "Your Location" } it { expect(result[:placeholder]).to eq "London" } - it { expect(result[:optional]).to eq false } - it { expect(result[:multiline]).to eq false } + it { expect(result[:optional]).to be false } + it { expect(result[:multiline]).to be false } it { expect(result[:hint]).to eq "Maximum 20 characters" } end @@ -80,7 +80,7 @@ it { expect(result[:item_type]).to eq :date } it { expect(result[:date_type]).to eq :calendar } it { expect(result[:label]).to eq "Start Date" } - it { expect(result[:optional]).to eq true } + it { expect(result[:optional]).to be true } end describe "#ar_core_forms_form_time" do @@ -89,7 +89,7 @@ it { expect(result[:id]).to eq 1 } it { expect(result[:item_type]).to eq :time } it { expect(result[:label]).to eq "Start Time" } - it { expect(result[:optional]).to eq true } + it { expect(result[:optional]).to be true } end describe "#ar_core_forms_form_email" do @@ -102,7 +102,7 @@ it { expect(result[:item_type]).to eq :email } it { expect(result[:label]).to eq "Your Email" } it { expect(result[:placeholder]).to eq "example@email.com" } - it { expect(result[:optional]).to eq false } + it { expect(result[:optional]).to be false } it { expect(result[:default_text_answer]).to eq "montse@futureworkshops.com" } end @@ -116,7 +116,7 @@ it { expect(result[:item_type]).to eq :secure } it { expect(result[:label]).to eq "Your Password" } it { expect(result[:placeholder]).to eq "Secret123" } - it { expect(result[:optional]).to eq false } + it { expect(result[:optional]).to be false } it { expect(result[:hint]).to eq "Must be at least 8 characters long" } end end diff --git a/spec/app_rail/steps/core_forms/question_spec.rb b/spec/app_rail/steps/core_forms/question_spec.rb index 92a1e3b..afbf7ce 100644 --- a/spec/app_rail/steps/core_forms/question_spec.rb +++ b/spec/app_rail/steps/core_forms/question_spec.rb @@ -22,7 +22,7 @@ it { expect(result[:label]).to eq "Challenge Type" } it { expect(result[:multiple_selection_options]).to eq multiple_section_options } it { expect(result[:selection_type]).to eq :single } - it { expect(result[:optional]).to eq false } - it { expect(result[:show_other_option]).to eq false } + it { expect(result[:optional]).to be false } + it { expect(result[:show_other_option]).to be false } end end diff --git a/spec/app_rail/steps_spec.rb b/spec/app_rail/steps_spec.rb index de9dc15..52661a6 100644 --- a/spec/app_rail/steps_spec.rb +++ b/spec/app_rail/steps_spec.rb @@ -2,6 +2,6 @@ RSpec.describe AppRail::Steps do it "has a version number" do - expect(AppRail::Steps::VERSION).not_to be nil + expect(AppRail::Steps::VERSION).not_to be_nil end end From 2fa04e25ee11aabcb42b2c09611897eba2b9e463 Mon Sep 17 00:00:00 2001 From: Pere Joan Martorell Calaf Date: Thu, 16 Mar 2023 12:18:00 +0100 Subject: [PATCH 9/9] Disable some rubocop rules --- .rubocop.yml | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 69fa8b2..886d056 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -3,14 +3,31 @@ require: AllCops: TargetRubyVersion: 2.7 - + NewCops: enable +Layout/LineLength: + Enabled: false +Metrics/AbcSize: + Enabled: false +Metrics/BlockLength: + Enabled: false +Metrics/ClassLength: + Enabled: false +Metrics/MethodLength: + Enabled: false +Metrics/ModuleLength: + Enabled: false +Metrics/ParameterLists: + Max: 10 +RSpec/ContextWording: + Enabled: false +RSpec/ExampleLength: + Enabled: false +Style/Documentation: + Enabled: false Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes - Style/StringLiteralsInInterpolation: Enabled: true EnforcedStyle: double_quotes -Layout/LineLength: - Max: 120