Module: Thoreau::DSL

Includes:
Context::Clan, Logging
Defined in:
lib/thoreau/dsl.rb,
lib/thoreau/dsl/expanded.rb,
lib/thoreau/dsl/context/clan.rb,
lib/thoreau/dsl/context/suite.rb,
lib/thoreau/dsl/test_suite_data.rb,
lib/thoreau/dsl/context/appendix.rb,
lib/thoreau/dsl/context/test_cases.rb

Defined Under Namespace

Modules: Context Classes: Expanded, TestSuiteData

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Context::Clan

#action, def_family_methods_for, #expanded

Methods included from Logging

included, logger, #logger

Instance Attribute Details

#suite_dataObject (readonly)

Returns the value of attribute suite_data.



20
21
22
# File 'lib/thoreau/dsl.rb', line 20

def suite_data
  @suite_data
end

Instance Method Details

#test_suite(name = nil, focus: false, &block) ⇒ Object Also known as: suite



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/thoreau/dsl.rb', line 22

def test_suite name = nil, focus: false, &block
  logger.debug("# Processing keyword `test_suite`")

  appendix        = Model::Appendix.new
  top_level_clan_model = Thoreau::Model::TestClan.new name, appendix: appendix
  @suite_data     = Thoreau::DSL::TestSuiteData.new name, test_clan: top_level_clan_model, appendix: appendix

  # Evaluate all the top-level keywords: test_cases, appendix
  @suite_context = Thoreau::DSL::Context::Suite.new suite_data:      @suite_data,
                                                  test_clan_model: top_level_clan_model
  logger.debug("## Evaluating suite")
  @suite_context.instance_eval(&block)

  logger.debug("## Evaluating appendix block")
  appendix_block = @suite_data.appendix_block
  Thoreau::DSL::Context::Appendix.new(@suite_data, &appendix_block) unless appendix_block.nil?

  logger.debug("## Evaluating test_cases blocks")
  @suite_data.test_cases_blocks.each do |name, cases_block|

    raise TestCasesAtMultipleLevelsError unless @suite_data.test_clans.first.empty?

    test_clan_model = Thoreau::Model::TestClan.new name,
                                                    appendix: appendix,
                                                    action_block: top_level_clan_model.action_block
    Thoreau::DSL::Context::TestCases.new(test_clan_model, &cases_block)
    @suite_data.test_clans << test_clan_model
  end

  Model::TestSuite.new(data: @suite_data, focus: focus)
end

#test_suite!(name = nil, &block) ⇒ Object Also known as: suite!



60
61
62
# File 'lib/thoreau/dsl.rb', line 60

def test_suite! name = nil, &block
  test_suite name, focus: true, &block
end

#xtest_suite(name = nil, &block) ⇒ Object Also known as: xsuite



54
55
# File 'lib/thoreau/dsl.rb', line 54

def xtest_suite name = nil, &block
end