-
Notifications
You must be signed in to change notification settings - Fork 0
Test PE Feat/styling spec #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
52c64a5
e0eefa7
b680c6c
87a677a
cf64428
6f3ef4b
e417c40
fe4e7aa
b80411a
fb32fe9
4942fc1
8358c62
f33d6c4
98933f8
3d8571a
c7b3fd3
3a98cc0
6b466f6
8c93ed9
5069a11
b095597
5230884
49d6ffa
fed30f1
8c2ab9e
8114666
215f891
4a77fde
a804658
b972242
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| path = File.expand_path("../../../../bin/guard", __FILE__) | ||
| # frozen_string_literal: true | ||
|
|
||
| path = File.expand_path("../../../bin/guard", __dir__) | ||
| load path | ||
|
|
||
| RSpec.describe GuardReloader do | ||
|
|
@@ -11,13 +13,13 @@ | |
| before do | ||
| allow(described_class::Config).to receive(:new).and_return(config) | ||
|
|
||
| allow(config).to receive(:current_bundler_gemfile). | ||
| and_return(bundle_gemfile_env) | ||
| allow(config).to receive(:current_bundler_gemfile) | ||
| .and_return(bundle_gemfile_env) | ||
|
|
||
| allow(config).to receive(:using_bundler?).and_return(bundle_gemfile_env) | ||
| allow(config).to receive(:guard_core_path).and_return(guard_core_path) | ||
|
|
||
| allow(config).to receive(:program_arguments).and_return(%w(foo bar baz)) | ||
| allow(config).to receive(:program_arguments).and_return(%w[foo bar baz]) | ||
| allow(config).to receive(:using_rubygems?).and_return(rubygems_deps_env) | ||
| allow(config).to receive(:program_path).and_return(program_path) | ||
| end | ||
|
|
@@ -54,8 +56,8 @@ | |
|
|
||
| context "when the relative Gemfile exists" do | ||
| before do | ||
| allow(config).to receive(:exist?). | ||
| with(Pathname("/my/project/Gemfile")).and_return(true) | ||
| allow(config).to receive(:exist?) | ||
| .with(Pathname("/my/project/Gemfile")).and_return(true) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. |
||
|
|
||
| allow(config).to receive(:setup_bundler) | ||
| allow(config).to receive(:setup_bundler_env) | ||
|
|
@@ -67,19 +69,19 @@ | |
| end | ||
|
|
||
| it "sets the Gemfile" do | ||
| expect(config).to receive(:setup_bundler_env). | ||
| with("/my/project/Gemfile") | ||
| expect(config).to receive(:setup_bundler_env) | ||
| .with("/my/project/Gemfile") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. |
||
| subject.setup | ||
| end | ||
| end | ||
|
|
||
| context "when the relative Gemfile does not exist" do | ||
| before do | ||
| allow(config).to receive(:exist?). | ||
| with(Pathname("/my/project/Gemfile")).and_return(false) | ||
| allow(config).to receive(:exist?) | ||
| .with(Pathname("/my/project/Gemfile")).and_return(false) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. |
||
|
|
||
| allow(config).to receive(:exist?).with(Pathname("Gemfile")). | ||
| and_return(false) | ||
| allow(config).to receive(:exist?).with(Pathname("Gemfile")) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. |
||
| .and_return(false) | ||
| end | ||
|
|
||
| it "does not setup bundler" do | ||
|
|
@@ -110,8 +112,8 @@ | |
|
|
||
| context "when Gemfile exists" do | ||
| before do | ||
| allow(config).to receive(:exist?).with(Pathname("Gemfile")). | ||
| and_return(true) | ||
| allow(config).to receive(:exist?).with(Pathname("Gemfile")) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. |
||
| .and_return(true) | ||
| end | ||
|
|
||
| it "shows a warning" do | ||
|
|
@@ -122,8 +124,8 @@ | |
|
|
||
| context "when no Gemfile exists" do | ||
| before do | ||
| allow(config).to receive(:exist?).with(Pathname("Gemfile")). | ||
| and_return(false) | ||
| allow(config).to receive(:exist?).with(Pathname("Gemfile")) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. |
||
| .and_return(false) | ||
| end | ||
|
|
||
| it "shows no warning" do | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require "guard/cli/environments/bundler" | ||
|
|
||
| # TODO: instead of shared examples, use have_received if possible | ||
|
|
@@ -22,8 +24,8 @@ | |
| allow(ENV).to receive(:[]).with("BUNDLE_GEMFILE").and_return(gemfile) | ||
| allow(ENV).to receive(:[]).with("RUBYGEMS_GEMDEPS").and_return(gemdeps) | ||
|
|
||
| allow(File).to receive(:exist?).with("Gemfile"). | ||
| and_return(gemfile_present) | ||
| allow(File).to receive(:exist?).with("Gemfile") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. |
||
| .and_return(gemfile_present) | ||
|
|
||
| subject.verify | ||
| end | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require "guard/cli/environments/valid" | ||
| require "guard/cli/environments/bundler" | ||
|
|
||
|
|
@@ -14,8 +16,8 @@ | |
| let(:bundler) { instance_double("Guard::Cli::Environments::Bundler") } | ||
|
|
||
| before do | ||
| allow(Guard::Cli::Environments::Bundler).to receive(:new). | ||
| and_return(bundler) | ||
| allow(Guard::Cli::Environments::Bundler).to receive(:new) | ||
| .and_return(bundler) | ||
|
|
||
| allow(bundler).to receive(:verify) | ||
| end | ||
|
|
@@ -24,8 +26,8 @@ | |
| before do | ||
| allow(bundler).to receive(:verify) | ||
|
|
||
| allow(options).to receive(:[]).with(:no_bundler_warning). | ||
| and_return(false) | ||
| allow(options).to receive(:[]).with(:no_bundler_warning) | ||
| .and_return(false) | ||
| end | ||
|
|
||
| it "starts guard" do | ||
|
|
@@ -52,8 +54,8 @@ | |
| ].each do |error_class| | ||
| context "when a #{error_class} error occurs" do | ||
| before do | ||
| allow(Guard).to receive(:start). | ||
| and_raise(error_class, "#{error_class} error!") | ||
| allow(Guard).to receive(:start) | ||
| .and_raise(error_class, "#{error_class} error!") | ||
| end | ||
|
|
||
| it "aborts" do | ||
|
|
@@ -150,8 +152,8 @@ | |
| end | ||
|
|
||
| it "Only creates the Guardfile without initializing any Guard template" do | ||
| allow(evaluator).to receive(:evaluate). | ||
| and_raise(Guard::Guardfile::Evaluator::NoGuardfileError) | ||
| allow(evaluator).to receive(:evaluate) | ||
| .and_raise(Guard::Guardfile::Evaluator::NoGuardfileError) | ||
|
|
||
| allow(File).to receive(:exist?).with("Gemfile").and_return(false) | ||
| expect(generator).to receive(:create_guardfile) | ||
|
|
@@ -178,12 +180,12 @@ | |
| end | ||
|
|
||
| it "creates a Guardfile" do | ||
| expect(evaluator).to receive(:evaluate). | ||
| and_raise(Guard::Guardfile::Evaluator::NoGuardfileError).once | ||
| expect(evaluator).to receive(:evaluate) | ||
| .and_raise(Guard::Guardfile::Evaluator::NoGuardfileError).once | ||
| expect(evaluator).to receive(:evaluate) | ||
|
|
||
| expect(Guard::Guardfile::Generator).to receive(:new). | ||
| and_return(generator) | ||
| expect(Guard::Guardfile::Generator).to receive(:new) | ||
| .and_return(generator) | ||
| expect(generator).to receive(:create_guardfile) | ||
|
|
||
| subject.initialize_guardfile | ||
|
|
@@ -203,30 +205,30 @@ | |
| expect(generator).to receive(:initialize_template).with("rspec") | ||
| expect(generator).to receive(:initialize_template).with("pow") | ||
|
|
||
| subject.initialize_guardfile(%w(rspec pow)) | ||
| subject.initialize_guardfile(%w[rspec pow]) | ||
| end | ||
|
|
||
| context "when passed a guard name" do | ||
| context "when the Guardfile is empty" do | ||
| before do | ||
| allow(evaluator).to receive(:evaluate). | ||
| and_raise Guard::Guardfile::Evaluator::NoPluginsError | ||
| allow(evaluator).to receive(:evaluate) | ||
| .and_raise Guard::Guardfile::Evaluator::NoPluginsError | ||
| allow(generator).to receive(:initialize_template) | ||
| end | ||
|
|
||
| it "works without without errors" do | ||
| expect(subject.initialize_guardfile(%w(rspec))).to be_zero | ||
| expect(subject.initialize_guardfile(%w[rspec])).to be_zero | ||
| end | ||
|
|
||
| it "adds the template" do | ||
| expect(generator).to receive(:initialize_template).with("rspec") | ||
| subject.initialize_guardfile(%w(rspec)) | ||
| subject.initialize_guardfile(%w[rspec]) | ||
| end | ||
| end | ||
|
|
||
| it "initializes the template of the passed Guard" do | ||
| expect(generator).to receive(:initialize_template).with("rspec") | ||
| subject.initialize_guardfile(%w(rspec)) | ||
| subject.initialize_guardfile(%w[rspec]) | ||
| end | ||
| end | ||
|
|
||
|
|
@@ -236,16 +238,16 @@ | |
|
|
||
| context "when passed an unknown guard name" do | ||
| before do | ||
| expect(generator).to receive(:initialize_template).with("foo"). | ||
| and_raise(Guard::Guardfile::Generator::NoSuchPlugin, "foo") | ||
| expect(generator).to receive(:initialize_template).with("foo") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. |
||
| .and_raise(Guard::Guardfile::Generator::NoSuchPlugin, "foo") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. |
||
| end | ||
|
|
||
| it "returns an exit code" do | ||
| expect(::Guard::UI).to receive(:error).with( | ||
| "Could not load 'guard/foo' or '~/.guard/templates/foo'"\ | ||
| " or find class Guard::Foo\n" | ||
| ) | ||
| expect(subject.initialize_guardfile(%w(foo))).to be(1) | ||
| expect(subject.initialize_guardfile(%w[foo])).to be(1) | ||
| end | ||
| end | ||
| end | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.