File: foobar_spec.rb

package info (click to toggle)
ruby-test-construct 2.0.2-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 188 kB
  • sloc: ruby: 762; makefile: 4
file content (34 lines) | stat: -rw-r--r-- 806 bytes parent folder | download | duplicates (3)
1
2
3
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
# Run with:
# rspec -Ilib examples/foobar_spec.rb

require 'rspec'
require 'test_construct/rspec_integration'

describe "Foobar", test_construct: true do

  it "creates file" do
    example.metadata[:construct].directory "alice/rabbithole" do |d|
      d.file "white_rabbit.txt", "I'm late!"
      File.read("white_rabbit.txt").should == "I'm late!"
    end
  end

  it "leaves file on error" do
    example.metadata[:construct].directory "alice/rabbithole" do |d|
      d.file "white_rabbit.txt", "I'm late!"
      raise "Whoops"
    end
  end

end

describe "Foobar", test_construct: { keep_on_error: false} do

  it "doesn't leave file on error" do
    example.metadata[:construct].directory "alice/rabbithole" do |d|
      d.file "white_rabbit.txt", "I'm late!"
      raise "Whoops"
    end
  end

end