Skip to content
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

Make forgetting setup_aruba a hard failure #510

Merged
merged 3 commits into from
Nov 12, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Feature: Getting started with RSpec and aruba

Running `setup_aruba` removes `tmp/aruba`, creates a new one `tmp/aruba`
and make it the working directory. Running it within a `before(:all)`-hook,
run some `aruba`-method and then run `setup_arub` again within a
run some `aruba`-method and then run `setup_aruba` again within a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we change this text to drop the hyphens, so that

`aruba`-method

becomes

`aruba` method

`before(:each)`-hook, will remove the files/directories created within the
`before(:all)`-hook.

Expand All @@ -115,64 +115,3 @@ Feature: Getting started with RSpec and aruba
"""
When I run `rspec`
Then the specs should all pass

Scenario: Setup aruba before use any of it's methods

From 1.0.0 it will be required, that you setup aruba before you use it.

Given a file named "spec/spec_helper.rb" with:
"""
require 'aruba/api'

RSpec.configure do |config|
config.include Aruba::Api
end
"""
And a file named "spec/getting_started_spec.rb" with:
"""
require 'spec_helper'

RSpec.describe 'Custom Integration of aruba' do
let(:file) { 'file.txt' }

before(:each) { setup_aruba }

it { expect(true).to be true }
end
"""
And an empty file named "tmp/aruba/garbage.txt"
When I run `rspec`
Then the specs should all pass
And the file "tmp/aruba/garbage.txt" should not exist anymore

Scenario: Fail-safe use if "setup_aruba" is not used

If you forgot to run `setup_aruba` before the first method of aruba is
used, you might see an error. Although we did our best to prevent this.

Make sure that you run `setup_aruba` before any method of aruba is used. At
best before each and every test.

This will be not supported anymore from 1.0.0 on.

Given a file named "spec/spec_helper.rb" with:
"""
require 'aruba/api'

RSpec.configure do |config|
config.include Aruba::Api
end
"""
And a file named "spec/getting_started_spec.rb" with:
"""
require 'spec_helper'

RSpec.describe 'Custom Integration of aruba' do
let(:file) { 'file.txt' }

it { expect { write_file file, 'Hello World' }.not_to raise_error }
it { expect(aruba.current_directory.directory?).to be true }
end
"""
When I run `rspec`
Then the specs should all pass
2 changes: 1 addition & 1 deletion lib/aruba/api/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def expand_path(file_name, dir_string = nil)
fail ArgumentError, message unless file_name.is_a?(String) && !file_name.empty?

# rubocop:disable Metrics/LineLength
aruba.logger.warn %(`aruba`'s working directory does not exist. Maybe you forgot to run `setup_aruba` before using it's API. This warning will be an error from 1.0.0) unless Aruba.platform.directory? File.join(aruba.config.root_directory, aruba.config.working_directory)
fail %(Aruba's working directory does not exist. Maybe you forgot to run `setup_aruba` before using it's API.) unless Aruba.platform.directory? File.join(aruba.config.root_directory, aruba.config.working_directory)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar note: it's => its

# rubocop:enable Metrics/LineLength

prefix = file_name[0]
Expand Down