Class: GovukAbTesting::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/govuk_ab_testing/configuration.rb

Constant Summary collapse

VALID_FRAMEWORKS =
%i[capybara active_support].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



6
7
8
# File 'lib/govuk_ab_testing/configuration.rb', line 6

def initialize
  @config = {}
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



4
5
6
# File 'lib/govuk_ab_testing/configuration.rb', line 4

def config
  @config
end

Instance Method Details

#acceptance_test_frameworkObject



10
11
12
# File 'lib/govuk_ab_testing/configuration.rb', line 10

def acceptance_test_framework
  config[:acceptance_test_framework]
end

#acceptance_test_framework=(framework) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/govuk_ab_testing/configuration.rb', line 14

def acceptance_test_framework=(framework)
  unless VALID_FRAMEWORKS.include?(framework)
    raise "Invalid acceptance test framework '#{framework}'"
  end

  config[:acceptance_test_framework] = framework
  @framework_class = nil
end

#framework_classObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/govuk_ab_testing/configuration.rb', line 23

def framework_class
  @framework_class ||= case config[:acceptance_test_framework]
                       when :capybara
                         GovukAbTesting::AcceptanceTests::Capybara
                       when :active_support
                         GovukAbTesting::AcceptanceTests::ActiveSupport
                       else
                         raise "Invalid framework #{acceptance_test_framework}"
                       end
end