Class: XcodeTestCase

Inherits:
Object
  • Object
show all
Defined in:
lib/second_curtain/xcode_test_case.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ XcodeTestCase

Returns a new instance of XcodeTestCase.



33
34
35
36
# File 'lib/second_curtain/xcode_test_case.rb', line 33

def initialize (name)
  @commands = []
  @name = name
end

Instance Attribute Details

#commandsObject

Returns the value of attribute commands.



2
3
4
# File 'lib/second_curtain/xcode_test_case.rb', line 2

def commands
  @commands
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/second_curtain/xcode_test_case.rb', line 3

def name
  @name
end

Class Method Details

.test_case_from_line(line) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/second_curtain/xcode_test_case.rb', line 5

def self.test_case_from_line(line)
  components = line.split("Test Case '-[")

  if components.count == 2 && line.include?("]' started.")
    # Let's make it readable
    name = components.last.split("'").first
    name = name.split(" ").last
    name = name.split("]").first
    name = name.gsub("_", " ")

    # We avoid hitting ends of words by addng the space, but that potentially misses the first one
    name += " "

    name.gsub!(" hasnt ", " hasn't")
    name.gsub!(" isn t", " isn't")
    name.gsub!(" won t", " won't")
    name.gsub!(" don t", " don't")
    name.gsub!(" doesn t", " doesn't")
    name.gsub!(" shouldn t", " shouldn't")
    name.gsub!(" can t", " can't")

    first_char_upper = name[0].upcase
    name[0] = first_char_upper
    name.strip!
    XcodeTestCase.new(name)
  end
end

Instance Method Details

#add_command(command) ⇒ Object



38
39
40
# File 'lib/second_curtain/xcode_test_case.rb', line 38

def add_command(command)
  @commands.push(command)
end

#latest_commandObject



42
43
44
# File 'lib/second_curtain/xcode_test_case.rb', line 42

def latest_command
  @commands.last
end