Skip to content

Commit

Permalink
Bring the test suite up-to-date
Browse files Browse the repository at this point in the history
…with the latest, non-EOL:
- Ruby versions
- Rails versions
- Aruba version
  • Loading branch information
laserlemon committed May 10, 2020
1 parent 0695557 commit e932bbe
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 124 deletions.
20 changes: 2 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,13 @@ branches:
only:
- master
gemfile:
- gemfiles/rails30.gemfile
- gemfiles/rails31.gemfile
- gemfiles/rails32.gemfile
- gemfiles/rails40.gemfile
- gemfiles/rails41.gemfile
- gemfiles/rails42.gemfile
- gemfiles/rails52.gemfile
- gemfiles/rails60.gemfile
language: ruby
matrix:
allow_failures:
- rvm: 1.9.3
- rvm: "2.0"
- rvm: "2.1"
- rvm: "2.2"
- rvm: "2.3"
- rvm: "2.4"
- rvm: ruby-head
rvm:
- 1.9.3
- "2.0"
- "2.1"
- "2.2"
- "2.3"
- "2.4"
- "2.5"
- "2.6"
- "2.7"
Expand Down
8 changes: 4 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ source "https://rubygems.org"

gemspec

gem "rails", ">= 3.0.3", "< 4.3"
gem "rails", ">= 5.2.0", "< 6.1"

group :test do
gem "aruba", "~> 0.6.2"
gem "rspec", "~> 3.1"
gem "sqlite3", "~> 1.3"
gem "aruba", "~> 1.0"
gem "rspec", "~> 3.9"
gem "sqlite3"
end
6 changes: 3 additions & 3 deletions figaro.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ Gem::Specification.new do |gem|
gem.homepage = "https://github.com/laserlemon/figaro"
gem.license = "MIT"

gem.add_dependency "thor", "~> 0.14"
gem.add_dependency "thor", ">= 0.14.0", "< 2"

gem.add_development_dependency "bundler", "~> 1.7"
gem.add_development_dependency "rake", "~> 10.4"
gem.add_development_dependency "bundler", ">= 1.7.0", "< 3"
gem.add_development_dependency "rake", ">= 10.4.0", "< 14"

gem.files = `git ls-files`.split($\)
gem.test_files = gem.files.grep(/^spec/)
Expand Down
11 changes: 0 additions & 11 deletions gemfiles/rails30.gemfile

This file was deleted.

11 changes: 0 additions & 11 deletions gemfiles/rails31.gemfile

This file was deleted.

11 changes: 0 additions & 11 deletions gemfiles/rails32.gemfile

This file was deleted.

11 changes: 0 additions & 11 deletions gemfiles/rails40.gemfile

This file was deleted.

11 changes: 0 additions & 11 deletions gemfiles/rails41.gemfile

This file was deleted.

11 changes: 0 additions & 11 deletions gemfiles/rails42.gemfile

This file was deleted.

11 changes: 11 additions & 0 deletions gemfiles/rails52.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
source "https://rubygems.org"

gemspec path: ".."

gem "rails", "~> 5.2.0"

group :test do
gem "aruba", "~> 1.0"
gem "rspec", "~> 3.9"
gem "sqlite3"
end
11 changes: 11 additions & 0 deletions gemfiles/rails60.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
source "https://rubygems.org"

gemspec path: ".."

gem "rails", "~> 6.0.0"

group :test do
gem "aruba", "~> 1.0"
gem "rspec", "~> 3.9"
gem "sqlite3"
end
14 changes: 7 additions & 7 deletions spec/figaro/cli/heroku_set_spec.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
describe "figaro heroku:set" do
before do
create_dir("example")
create_directory("example")
cd("example")
write_file("config/application.yml", "foo: bar")
end

it "sends Figaro configuration to Heroku" do
run_simple("figaro heroku:set")
run_command_and_stop("figaro heroku:set")

command = commands.last
expect(command.name).to eq("heroku")
Expand All @@ -16,7 +16,7 @@
it "respects path" do
write_file("env.yml", "foo: bar")

run_simple("figaro heroku:set -p env.yml")
run_command_and_stop("figaro heroku:set -p env.yml")

command = commands.last
expect(command.name).to eq("heroku")
Expand All @@ -30,15 +30,15 @@
foo: baz
EOF

run_simple("figaro heroku:set -e test")
run_command_and_stop("figaro heroku:set -e test")

command = commands.last
expect(command.name).to eq("heroku")
expect(command.args).to eq(["config:set", "foo=baz"])
end

it "targets a specific Heroku app" do
run_simple("figaro heroku:set -a foo-bar-app")
run_command_and_stop("figaro heroku:set -a foo-bar-app")

command = commands.last
expect(command.name).to eq("heroku")
Expand All @@ -47,7 +47,7 @@
end

it "targets a specific Heroku git remote" do
run_simple("figaro heroku:set -r production")
run_command_and_stop("figaro heroku:set -r production")

command = commands.last
expect(command.name).to eq("heroku")
Expand All @@ -58,7 +58,7 @@
it "handles values with special characters" do
overwrite_file("config/application.yml", "foo: bar baz")

run_simple("figaro heroku:set")
run_command_and_stop("figaro heroku:set")

command = commands.last
expect(command.name).to eq("heroku")
Expand Down
26 changes: 13 additions & 13 deletions spec/figaro/cli/install_spec.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
describe "figaro install" do
before do
create_dir("example")
create_directory("example")
cd("example")
end

it "creates a configuration file" do
run_simple("figaro install")
run_command_and_stop("figaro install")

check_file_presence(["config/application.yml"], true)
expect("config/application.yml").to be_an_existing_file
end

it "respects path" do
run_simple("figaro install -p env.yml")
run_command_and_stop("figaro install -p env.yml")

check_file_presence(["env.yml"], true)
expect("env.yml").to be_an_existing_file
end

context "with a .gitignore file" do
Expand All @@ -25,25 +25,25 @@
end

it "Git-ignores the configuration file if applicable" do
run_simple("figaro install")
run_command_and_stop("figaro install")

check_file_content(".gitignore", %r(^/foo$), true)
check_file_content(".gitignore", %r(^/bar$), true)
check_file_content(".gitignore", %r(^/config/application\.yml$), true)
expect(".gitignore").to have_file_content(%r(^/foo$))
expect(".gitignore").to have_file_content(%r(^/bar$))
expect(".gitignore").to have_file_content(%r(^/config/application\.yml$))
end

it "respects path" do
run_simple("figaro install -p env.yml")
run_command_and_stop("figaro install -p env.yml")

check_file_content(".gitignore", %r(^/env\.yml$), true)
expect(".gitignore").to have_file_content(%r(^/env\.yml$))
end
end

context "without a .gitignore file" do
it "doesn't generate a new .gitignore file" do
run_simple("figaro install")
run_command_and_stop("figaro install")

check_file_presence([".gitignore"], false)
expect(".gitignore").not_to be_an_existing_file
end
end
end
25 changes: 15 additions & 10 deletions spec/rails_spec.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
describe Figaro::Rails do
before do
run_simple(<<-CMD)
run_command_and_stop(<<-CMD)
rails new example \
--skip-gemfile \
--skip-bundle \
--skip-git \
--skip-keeps \
--skip-sprockets \
--skip-spring \
--skip-listen \
--skip-javascript \
--skip-test-unit \
--skip-turbolinks \
--skip-test \
--skip-bootsnap \
--no-rc \
--quiet
--skip-bundle \
--skip-webpack-install
CMD
cd("example")
end
Expand All @@ -20,9 +25,9 @@
end

it "loads application.yml" do
run_simple("rails runner 'puts Figaro.env.foo'")
run_command_and_stop("rails runner 'puts Figaro.env.foo'")

assert_partial_output("bar", all_stdout)
expect(all_stdout).to include("bar")
end

it "happens before database initialization" do
Expand All @@ -32,19 +37,19 @@
database: db/<%= ENV["foo"] %>.sqlite3
EOF

run_simple("rake db:migrate")
run_command_and_stop("rake db:migrate")

check_file_presence(["db/bar.sqlite3"], true)
expect("db/bar.sqlite3").to be_an_existing_file
end

it "happens before application configuration" do
insert_into_file_after("config/application.rb", /< Rails::Application$/, <<-EOL)
config.foo = ENV["foo"]
EOL

run_simple("rails runner 'puts Rails.application.config.foo'")
run_command_and_stop("rails runner 'puts Rails.application.config.foo'")

assert_partial_output("bar", all_stdout)
expect(all_stdout).to include("bar")
end
end
end
5 changes: 2 additions & 3 deletions spec/support/aruba.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module ArubaHelpers
def insert_into_file_after(file, pattern, addition)
content = prep_for_fs_check { IO.read(file) }
content = cd(".") { IO.read(file) }
content.sub!(pattern, "\\0\n#{addition}")
overwrite_file(file, content)
end
Expand All @@ -13,7 +13,6 @@ def insert_into_file_after(file, pattern, addition)
config.include(ArubaHelpers)

config.before do
@aruba_timeout_seconds = 60
FileUtils.rm_rf(current_dir)
setup_aruba
end
end

0 comments on commit e932bbe

Please sign in to comment.