Module: Yari::DSL::Rspec

Defined in:
lib/yari/yari_dsl.rb

Instance Method Summary collapse

Instance Method Details

#background(&block) ⇒ Object



50
51
52
# File 'lib/yari/yari_dsl.rb', line 50

def background(&block)
  before(:each, &block)
end

#scenario(name = nil, new_metadata = {}, &block) ⇒ Object

Raises:

  • (ArgumentError)


54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/yari/yari_dsl.rb', line 54

def scenario(name = nil,  = {}, &block)
  raise ArgumentError.new("requires a name") if name.nil?

  matching_scenario = find_scenario(self.[:current_feature], name)
  [:scenario_name]= name

  if matching_scenario
    if matching_scenario.tags.include?('@updated')
      pending_scenario(name, , block.source_location,
                       "Scenario has been marked as updated\n \t# Update specs for this scenario and remove the @updated tag\n \t# Feature file: '#{feature_path(block.source_location)}'"
      )
    # elsif matching_scenario.arguments
    #   specify "Scenario: #{name}", new_metadata do
    #     instance_exec(*matching_scenario.arguments, &block)
    #   end
    else
      specify("Scenario: #{name}", , &block)
    end
  else
    pending_scenario(name, , block.source_location, "No such scenario in '#{feature_path(block.source_location)}'")
  end
end

#scenario_with_test_cases(name = nil, new_metadata = {}, &block) ⇒ Object

Raises:

  • (ArgumentError)


78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/yari/yari_dsl.rb', line 78

def scenario_with_test_cases(name = nil,  = {}, &block)
  raise ArgumentError.new("requires a name") if name.nil?

  matching_scenario = find_scenario(self.[:current_feature], name)

  if matching_scenario
    if matching_scenario.tags.include?('@updated')
      pending_scenario(name, , block.source_location,
                       "Scenario has been marked as updated\n \t# Update specs for this scenario and remove the @updated tag\n \t# Feature file: '#{feature_path(block.source_location)}'"
      )
    else
      describe("Scenario: #{name}", .merge(:scenario_name => name), &block)
    end
  else
    pending_scenario(name, , block.source_location, "No such scenario in '#{feature_path(block.source_location)}'")
  end
end

#test_case(name = nil, new_metadata = {}, &block) ⇒ Object

Raises:

  • (ArgumentError)


96
97
98
99
100
# File 'lib/yari/yari_dsl.rb', line 96

def test_case(name = nil,  = {}, &block)
  raise ArgumentError.new("requires a name") if name.nil?
  [:test_case_name]= name
  specify("Test_Case: #{name}", , &block)
end