Module: Turnip::RSpec

Defined in:
lib/turnip/rspec.rb

Defined Under Namespace

Modules: Execute, Loader

Class Method Summary collapse

Class Method Details

.run(feature_file) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/turnip/rspec.rb', line 55

def run(feature_file)
  Turnip::Builder.build(feature_file).features.each do |feature|
    describe feature.name, feature. do
      before do
        # This is kind of a hack, but it will make RSpec throw way nicer exceptions
        example.[:file_path] = feature_file

        feature.backgrounds.map(&:steps).flatten.each do |step|
          run_step(feature_file, step)
        end
      end
      feature.scenarios.each do |scenario|
        describe scenario.name, scenario. do
          it scenario.steps.map(&:description).join(' -> ') do
            scenario.steps.each do |step|
              run_step(feature_file, step)
            end
          end
        end
      end
    end
  end
end