Module: Sapphire::Testing::RSpecRunner

Included in:
DSL::Scenarios::Scenario
Defined in:
lib/sapphire/Testing/RSpecRunner.rb

Instance Method Summary collapse

Instance Method Details

#execute(id) ⇒ Object



4
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/sapphire/Testing/RSpecRunner.rb', line 4

def execute(id)
  @block.call
  s = self
  x = @givens
  y = @backgrounds
  background_pending = false

  y.each do |background|
    if(background.value.instance_of? Pending)
      background_pending = true
    end
  end

  x.each do |g|
  describe g.text do

    before :all do
      y.each do |b|
        if(!b.value.instance_of? Pending and !s.value.instance_of? Pending)
          b.block.call()
        end
      end
    end

    before :each do
      if(!g.value.instance_of? Pending and !s.value.instance_of? Pending and !background_pending)
        g.block.call()
        g.and.each do |a|
          a.block.call()
        end
      end
    end

    g.when.each do |w|
      describe w.text do
        before do
          if(!w.value.instance_of? Pending and !s.value.instance_of? Pending and !background_pending)
            w.block.call()

            if (w.and.count > 0)
              w.and.each do |a|
                a.block.call()
              end
            end
          end
        end

        if (w.then.count > 0)
          w.then.each do |t|
            if(!t.value.instance_of? Pending and !w.value.instance_of? Pending and !g.value.instance_of? Pending and !s.value.instance_of? Pending and !background_pending)
              it t.text do
                t.block.call()
                t.and.each do |a|
                  if(!a.value.instance_of? Pending)
                    a.block.call()
                  end
                end
              end
            else
              pending t.text
            end
          end
        end
      end
    end

    after :all do
      if(g.finally and !g.finally.value.instance_of? Pending and !s.value.instance_of? Pending and !background_pending)
        g.finally.block.call()

        g.finally.and.each do |a|
          a.block.call()
        end
      end
    end
    end
  end
end