Class: Crab::RallyToCucumberAdapter

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

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(language) ⇒ RallyToCucumberAdapter

Returns a new instance of RallyToCucumberAdapter.



5
6
7
# File 'lib/crab/rally_to_cucumber_adapter.rb', line 5

def initialize(language)
  @language = language
end

Instance Method Details

#feature_from(story) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/crab/rally_to_cucumber_adapter.rb', line 9

def feature_from(story)
  comments = [
    "# language: #{@language.iso_code}",
    "# state: #{story.state}",
    "# fetched: #{DateTime.now}",
    "# revision: #{story.revision}",
  ].map {|c| Gherkin::Formatter::Model::Comment.new(c, 0) }
  tags = []
  keyword = @language.keywords('feature').last
  name = "[#{story.formatted_id}] #{story.name}"
  description = story.description
  line = 0

  Gherkin::Formatter::Model::Feature.new(comments, tags, keyword, name, description, line)
end

#scenario_from(test_case) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/crab/rally_to_cucumber_adapter.rb', line 25

def scenario_from(test_case)
  comments = [
    "# revision: #{test_case.revision}",
  ].map {|c| Gherkin::Formatter::Model::Comment.new(c, 0) }
  tags = test_case.tags.map {|tag| Gherkin::Formatter::Model::Tag.new("@#{tag}", 0) }
  keyword = @language.keywords('scenario').last
  name = "[#{test_case.formatted_id}] #{test_case.name}"
  description = test_case.description
  line = 0

  Gherkin::Formatter::Model::Scenario.new(comments, tags, keyword, name, description, line)
end

#steps_from(test_case) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/crab/rally_to_cucumber_adapter.rb', line 38

def steps_from(test_case)
  test_case.steps.tap {|steps| logger.info "#{test_case.formatted_id}: #{steps.size} step(s) found"}.map do |step|
    step_words = step.split(' ')
    comments = []
    keyword = step_words.shift
    name = " " + step_words.join(' ')
    line = 0

    Gherkin::Formatter::Model::Step.new(comments, keyword, name, line)
  end
end