Class: Crab::Story

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

Constant Summary collapse

VALID_STATES =
%w{Grooming Defined In-Progress Completed Accepted Released}

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_story, dry_run) ⇒ Story

Returns a new instance of Story.



9
10
11
12
# File 'lib/crab/story.rb', line 9

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

Instance Method Details

#deleteObject



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

def delete
  if @dry_run
    puts "Would delete story #{formatted_id}"
  else
    @rally_story.delete
  end
end

#descriptionObject



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

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

#file_nameObject



18
19
20
# File 'lib/crab/story.rb', line 18

def file_name
  "#{formatted_id}-#{name.parameterize.dasherize}.feature"
end

#formatted_idObject



26
27
28
# File 'lib/crab/story.rb', line 26

def formatted_id
  @rally_story.formatted_i_d
end

#full_file_nameObject



22
23
24
# File 'lib/crab/story.rb', line 22

def full_file_name
  "features/#{state}/#{file_name}"
end

#nameObject



14
15
16
# File 'lib/crab/story.rb', line 14

def name
  @rally_story.name
end

#rally_objectObject



67
68
69
# File 'lib/crab/story.rb', line 67

def rally_object
  @rally_story
end

#revisionObject



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

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

#scenariosObject



43
44
45
# File 'lib/crab/story.rb', line 43

def scenarios
  Array(@rally_story.test_cases).map {|tc| Crab::TestCase.new(tc, @dry_run) }
end

#stateObject



30
31
32
# File 'lib/crab/story.rb', line 30

def state
  (@rally_story.schedule_state || "unknown").parameterize.underscore
end

#test_casesObject



47
48
49
# File 'lib/crab/story.rb', line 47

def test_cases
  scenarios
end

#update(opts) ⇒ Object



51
52
53
54
55
56
57
# File 'lib/crab/story.rb', line 51

def update(opts)
  if @dry_run
    puts "Would update story #{formatted_id} with #{opts.inspect}"
  else
    @rally_story.update opts
  end
end