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, #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



64
65
66
67
68
69
70
# File 'lib/crab/testcase.rb', line 64

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

#descriptionObject



25
26
27
28
29
30
31
# File 'lib/crab/testcase.rb', line 25

def description
  # this could use a lot of rethinking :(
  # biggest problem is that Cucumber breaks if text in description looks like something
  # it might know how to parse, but doesn't
  # our feature descriptions are quite like that, so I was being ultra-conservative
  sanitize(@rally_test_case.description || '').gsub(/  +/, "\n").gsub(/\n\n/, "\n").gsub(/\n/, "\n  ")
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



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

def priority
  @rally_test_case.priority
end

#revisionObject



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

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

#riskObject



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

def risk
  @rally_test_case.risk
end

#stepsObject



80
81
82
# File 'lib/crab/testcase.rb', line 80

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

#storyObject



60
61
62
# File 'lib/crab/testcase.rb', line 60

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

#tagsObject



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

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

#test_methodObject



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

def test_method
  @rally_test_case.elements[:method]
end

#test_typeObject



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

def test_type
  @rally_test_case.elements[:type]
end

#update(options) ⇒ Object



72
73
74
75
76
77
78
# File 'lib/crab/testcase.rb', line 72

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