Class: Crab::Story

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

Constant Summary collapse

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

Instance Method Summary collapse

Constructor Details

#initialize(rally_story, dry_run) ⇒ Story

Returns a new instance of Story.



7
8
9
10
# File 'lib/crab/story.rb', line 7

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

Instance Method Details

#deleteObject



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

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

#descriptionObject



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

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_story.description || '').gsub(/  +/, "\n").gsub(/\n\n/, "\n").gsub(/\n/, "\n  ")
end

#file_nameObject



16
17
18
# File 'lib/crab/story.rb', line 16

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

#formatted_idObject



24
25
26
# File 'lib/crab/story.rb', line 24

def formatted_id
  @rally_story.formatted_i_d
end

#full_file_nameObject



20
21
22
# File 'lib/crab/story.rb', line 20

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

#nameObject



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

def name
  @rally_story.name
end

#rally_objectObject



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

def rally_object
  @rally_story
end

#scenariosObject



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

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

#stateObject



28
29
30
# File 'lib/crab/story.rb', line 28

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

#update(opts) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/crab/story.rb', line 44

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