Class: Crab::TestCase

Inherits:
Object
  • Object
show all
Includes:
Utilities
Defined in:
lib/crab/testcase.rb

Constant Summary collapse

PRIORITIES =
%w{useful important critical}
RISKS =
%w{low medium high}
METHODS =
%w{automated manual}
TYPES =
%w{acceptance functional non-functional performance regression usability}

Instance Method Summary collapse

Methods included from Utilities

#add_or_update_options, #credentials_file, #current_project_name, #dotcrab_file, #sanitize, #sanitize_options, #state_after, #state_before, #state_from, #valid_credentials_file, #valid_project_name

Methods included from Logging

#logger

Constructor Details

#initialize(rally_test_case, dry_run) ⇒ TestCase

Returns a new instance of TestCase.



12
13
14
15
# File 'lib/crab/testcase.rb', line 12

def initialize(rally_test_case, dry_run)
  @rally_test_case = rally_test_case
  @dry_run
end

Instance Method Details

#deleteObject



60
61
62
63
64
65
66
# File 'lib/crab/testcase.rb', line 60

def delete
  if @dry_run
    puts "Would delete test case #{formatted_id}"
  else
    @rally_test_case.delete
  end
end

#descriptionObject



25
26
27
# File 'lib/crab/testcase.rb', line 25

def description
  sanitize(@rally_test_case.description || '')
end

#formatted_idObject



17
18
19
# File 'lib/crab/testcase.rb', line 17

def formatted_id
  @rally_test_case.formatted_i_d
end

#nameObject



21
22
23
# File 'lib/crab/testcase.rb', line 21

def name
  @rally_test_case.name
end

#priorityObject



40
41
42
# File 'lib/crab/testcase.rb', line 40

def priority
  @rally_test_case.priority
end

#revisionObject



35
36
37
38
# File 'lib/crab/testcase.rb', line 35

def revision
  rev = @rally_test_case.revision_history.revisions.first
  "#{rev.revision_number}, by #{rev.user}"
end

#riskObject



44
45
46
# File 'lib/crab/testcase.rb', line 44

def risk
  @rally_test_case.risk
end

#stepsObject



76
77
78
# File 'lib/crab/testcase.rb', line 76

def steps
  Array(@rally_test_case.steps).map {|step| step.input }
end

#storyObject



56
57
58
# File 'lib/crab/testcase.rb', line 56

def story
  Crab::Story.new(@rally_test_case.work_product, @dry_run)
end

#tagsObject



29
30
31
32
33
# File 'lib/crab/testcase.rb', line 29

def tags
  [priority, risk, test_method, test_type].map(&:parameterize).reject do |tag|
    %w{important medium manual functional}.include? tag
  end
end

#test_methodObject



48
49
50
# File 'lib/crab/testcase.rb', line 48

def test_method
  @rally_test_case.elements[:method]
end

#test_typeObject



52
53
54
# File 'lib/crab/testcase.rb', line 52

def test_type
  @rally_test_case.elements[:type]
end

#update(options) ⇒ Object



68
69
70
71
72
73
74
# File 'lib/crab/testcase.rb', line 68

def update(options)
  if @dry_run
    puts "Would update test case #{formatted_id} with #{options.inspect}"
  else
    @rally_test_case.update options
  end
end