Sha256: e915ed43be95c5ef959df76a92d695a9c4fe185897f0099d8929f91e6b76205f

Contents?: true

Size: 1.36 KB

Versions: 26

Compression:

Stored size: 1.36 KB

Contents

PROJECT_ROOT     = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')).freeze
APP_NAME         = 'testapp'.freeze
BUNDLE_ENV_VARS = %w(RUBYOPT BUNDLE_PATH BUNDLE_BIN_PATH BUNDLE_GEMFILE)
ORIGINAL_BUNDLE_VARS = Hash[ENV.select{ |key,value| BUNDLE_ENV_VARS.include?(key) }]

ENV['RAILS_ENV'] = 'test'

Before do
  gemfile = ENV['BUNDLE_GEMFILE'].to_s
  ENV['BUNDLE_GEMFILE'] = File.join(Dir.pwd, gemfile) unless gemfile.start_with?(Dir.pwd)
  @framework_version = nil
end

After do
  ORIGINAL_BUNDLE_VARS.each_pair do |key, value|
    ENV[key] = value
  end
end

When /^I reset Bundler environment variable$/ do
  BUNDLE_ENV_VARS.each do |key|
    ENV[key] = nil
  end
end

module RailsCommandHelpers
  def framework_version?(version_string)
    framework_version =~ /^#{version_string}/
  end

  def framework_version
    @framework_version ||= `rails -v`[/^Rails (.+)$/, 1]
  end

  def framework_major_version
    framework_version.split(".").first.to_i
  end

  def using_protected_attributes?
    framework_major_version < 4
  end

  def new_application_command
    "rails new"
  end

  def generator_command
    if framework_major_version >= 4
      "rails generate"
    else
      "script/rails generate"
    end
  end

  def runner_command
    if framework_major_version >= 4
      "rails runner"
    else
      "script/rails runner"
    end
  end
end
World(RailsCommandHelpers)

Version data entries

26 entries across 24 versions & 6 rubygems

Version Path
kt-paperclip-4.4.0 features/support/rails.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/paperclip-5.1.0/features/support/rails.rb
paperclip-5.1.0 features/support/rails.rb
paperclip-5.0.0 features/support/rails.rb
paperclip-4.3.7 features/support/rails.rb
paperclip_jk-5.0.0.beta2 features/support/rails.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/paperclip-4.3.6/features/support/rails.rb
paperclip-5.0.0.beta2 features/support/rails.rb
paperclip-5.0.0.beta1 features/support/rails.rb
paperclip-4.3.6 features/support/rails.rb
paperclip-4.3.5 features/support/rails.rb
paperclip-4.3.4 features/support/rails.rb
paperclip-4.3.3 features/support/rails.rb
paperclip-4.3.2 features/support/rails.rb
paperclip-4.3.1 features/support/rails.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/paperclip-4.2.4/features/support/rails.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/paperclip-4.2.4/features/support/rails.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/paperclip-4.2.3/features/support/rails.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/paperclip-4.2.2/features/support/rails.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/paperclip-4.2.4/features/support/rails.rb