File: foo_by_env.rb

package info (click to toggle)
ruby-rspec-stubbed-env 1.0.4-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,004 kB
  • sloc: ruby: 932; javascript: 529; sh: 4; makefile: 4
file content (21 lines) | stat: -rw-r--r-- 528 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true

# Class to help with testing
class FooByEnv
  attr_reader :array, :size, :env

  def initialize
    @env = Rails.env.to_s
    @array = case @env
    when "test" then ["localhost:123", "localhost:124"]
    when "development" then [ENV.fetch("MEDIUM_1", nil), ENV.fetch("MEDIUM_2", nil)]
    when "production" then [
      ENV.fetch("BIG_1", nil),
      ENV.fetch("BIG_2", nil),
      ENV.fetch("BIG_3", nil),
      ENV.fetch("BIG_4", nil),
    ]
    end.compact
    @size = @array.length
  end
end