diff --git a/.gitignore b/.gitignore index 2e679cf..56dd36c 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,5 @@ tmp *.swp .rspec vendor/bundle +.rspec_status +.idea diff --git a/.rspec b/.rspec index b83d9b7..6c6110e 100644 --- a/.rspec +++ b/.rspec @@ -1,3 +1,4 @@ ---color --format documentation +--color --require spec_helper +--order random diff --git a/.standard.yml b/.standard.yml new file mode 100644 index 0000000..72b2693 --- /dev/null +++ b/.standard.yml @@ -0,0 +1 @@ +ruby_version: 3.1 diff --git a/Gemfile.lock b/Gemfile.lock index 65fdbf6..687435e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -26,6 +26,7 @@ GEM base64 (0.2.0) benchmark (0.4.0) bigdecimal (3.1.9) + bigdecimal (3.1.9-java) concurrent-ruby (1.3.5) connection_pool (2.5.0) diff-lcs (1.6.1) @@ -41,6 +42,7 @@ GEM i18n (1.14.7) concurrent-ruby (~> 1.0) json (2.10.2) + json (2.10.2-java) language_server-protocol (3.17.0.4) lint_roller (1.1.0) logger (1.7.0) @@ -57,6 +59,7 @@ GEM prism (1.4.0) public_suffix (6.0.1) racc (1.8.1) + racc (1.8.1-java) rainbow (3.1.1) rake (13.2.1) regexp_parser (2.10.0) @@ -127,6 +130,7 @@ PLATFORMS arm-linux-gnu arm-linux-musl arm64-darwin + java ruby x86-linux-gnu x86-linux-musl diff --git a/README.md b/README.md index 750e4d0..3b9463c 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# Errbit Github Plugin +# Errbit GitHub Plugin [![RSpec](https://github.com/errbit/errbit_github_plugin/actions/workflows/rspec.yml/badge.svg)](https://github.com/errbit/errbit_github_plugin/actions/workflows/rspec.yml) [![RSpec on JRuby](https://github.com/errbit/errbit_github_plugin/actions/workflows/jruby.yml/badge.svg)](https://github.com/errbit/errbit_github_plugin/actions/workflows/jruby.yml) [![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/standardrb/standard) -This plugin provides GitHub issue tracker integration for Errbit and it is the +This plugin provides GitHub issue tracker integration for Errbit, and it is the only plugin included by default in Errbit. diff --git a/lib/errbit_github_plugin/issue_tracker.rb b/lib/errbit_github_plugin/issue_tracker.rb index e4c31c1..fbfe57c 100644 --- a/lib/errbit_github_plugin/issue_tracker.rb +++ b/lib/errbit_github_plugin/issue_tracker.rb @@ -6,9 +6,9 @@ module ErrbitGithubPlugin class IssueTracker < ErrbitPlugin::IssueTracker LABEL = "github" - NOTE = "Please configure your github repository in the GITHUB " \ - "REPO field above.
Instead of providing your " \ - "username & password, you can link your Github account to your " \ + NOTE = "Please configure your GitHub repository in the GITHUB " \ + "REPO field above.
Instead of providing your " \ + "username & password, you can link your GitHub account to your " \ "user profile, and allow Errbit to create issues using your " \ "OAuth token." diff --git a/spec/issue_tracker_spec.rb b/spec/errbit_github_plugin/issue_tracker_spec.rb similarity index 89% rename from spec/issue_tracker_spec.rb rename to spec/errbit_github_plugin/issue_tracker_spec.rb index deca783..921fb7d 100644 --- a/spec/issue_tracker_spec.rb +++ b/spec/errbit_github_plugin/issue_tracker_spec.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true -describe ErrbitGithubPlugin::IssueTracker do +require "spec_helper" + +RSpec.describe ErrbitGithubPlugin::IssueTracker do describe ".label" do it "return LABEL" do expect(described_class.label).to eq described_class::LABEL @@ -108,12 +110,12 @@ end let(:fake_github_client) do double("Fake GitHub Client").tap do |github_client| - github_client.stub(:create_issue).and_return(fake_issue) + expect(github_client).to receive(:create_issue).and_return(fake_issue) end end let(:fake_issue) do double("Fake Issue").tap do |issue| - issue.stub(:html_url).and_return("http://github.com/user/repos/issues/878") + expect(issue).to receive(:html_url).and_return("http://github.com/user/repos/issues/878").twice end end @@ -125,7 +127,7 @@ } end it "return issue url" do - Octokit::Client.stub(:new).with( + expect(Octokit::Client).to receive(:new).with( login: user["github_login"], access_token: user["github_oauth_token"] ).and_return(fake_github_client) expect(subject).to eq fake_issue.html_url @@ -135,7 +137,7 @@ context "signed in with password" do let(:user) { {} } it "return issue url" do - Octokit::Client.stub(:new).with( + expect(Octokit::Client).to receive(:new).with( login: options["username"], password: options["password"] ).and_return(fake_github_client) expect(subject).to eq fake_issue.html_url @@ -147,10 +149,10 @@ {"github_login" => "alice", "github_oauth_token" => "invalid_token"} end it "raise AuthenticationError" do - Octokit::Client.stub(:new).with( + expect(Octokit::Client).to receive(:new).with( login: user["github_login"], access_token: user["github_oauth_token"] ).and_raise(Octokit::Unauthorized) - expect { subject }.to raise_error + expect { subject }.to raise_error(ErrbitGithubPlugin::AuthenticationError) end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8bd2cca..05f63c8 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,19 +2,24 @@ require "simplecov" -SimpleCov.start +SimpleCov.start do + enable_coverage :branch + + primary_coverage :branch +end require "errbit_plugin" require "errbit_github_plugin" require "active_support/all" RSpec.configure do |config| - config.run_all_when_everything_filtered = true - config.filter_run :focus + # Enable flags like --only-failures and --next-failure + config.example_status_persistence_file_path = ".rspec_status" + + # Disable RSpec exposing methods globally on `Module` and `main` + config.disable_monkey_patching! - # Run specs in random order to surface order dependencies. If you find an - # order dependency and want to debug it, you can fix the order by providing - # the seed, which is printed after each run. - # --seed 1234 - config.order = "random" + config.expect_with :rspec do |c| + c.syntax = :expect + end end