Class: MiniTest::Spec
- Inherits:
-
Object
- Object
- MiniTest::Spec
- Includes:
- Capybara, HelperMethods
- Defined in:
- lib/generators/testing_machine/templates/helper.rb,
lib/tm.rb
Class Method Summary collapse
- .background(type = :each, opts = {}, &block) ⇒ Object (also: Background)
- .scenario(desc, opts = {}, &block) ⇒ Object (also: Scenario)
Class Method Details
.background(type = :each, opts = {}, &block) ⇒ Object Also known as: Background
63 64 65 66 67 68 69 |
# File 'lib/tm.rb', line 63 def background type = :each, opts = {}, &block return unless TM.should_run?(opts[:tag]) before type do self.instance_exec(&block) end end |
.scenario(desc, opts = {}, &block) ⇒ Object Also known as: Scenario
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/tm.rb', line 36 def scenario desc, opts = {}, &block return unless TM.should_run?(opts[:tag], desc) TM::Configuration.(opts[:tag]) test_file = File.(caller[0].sub(/:.*$/,'')) it desc do if TM::Configuration.data data_table = eval("TM::Table[test_file, desc][#{TM::Configuration.data}].to_a") else data_table = TM::Table[test_file, desc] end if !data_table.empty? data_table.map do |example| instance_variable_set("@_headers", example.headers) example.headers.map do |header| instance_variable_set("@#{header}", example.send(header.to_sym)) end self.instance_exec(&block) end else self.instance_exec(&block) end end end |