File: rspec_steps.rb

package info (click to toggle)
ruby-bogus 0.1.6-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, stretch
  • size: 856 kB
  • ctags: 640
  • sloc: ruby: 4,219; makefile: 7; sh: 2
file content (85 lines) | stat: -rw-r--r-- 1,652 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
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
82
83
84
85
Given /^a spec file named "([^"]*)" with:$/ do |file_name, string|
  @spec_file_names ||= []
  @spec_file_names << file_name

  steps %Q{
    Given a file named "#{file_name}" with:
    """ruby
    require 'bogus/rspec'

    #{string}
    """
  }
end

Then /^the specs should fail$/ do
  steps %Q{
    Then the exit status should be 1
  }
end

Then /^the specs should pass$/ do
  steps %Q{
    Then the exit status should be 0
  }
end

When /^I run spec with the following content:$/ do |string|
  file_name = "foo_#{rand(1000000)}_spec.rb"

  steps %Q{
    Given a spec file named "#{file_name}" with:
    """ruby
    #{string}
    """
  }

  steps %Q{
    When I run `rspec #{@spec_file_names.join(' ')}`
  }
end

Then /^spec file with following content should pass:$/ do |string|
  steps %Q{
    When I run spec with the following content:
    """ruby
    #{string}
    """
    Then the specs should pass
  }
end

Then /^spec file with following content should fail:$/ do |string|
  steps %Q{
    When I run spec with the following content:
    """ruby
    #{string}
    """
    Then the specs should fail
  }
end

Then /^the following test should pass:$/ do |string|
  steps %Q{
    When I run spec with the following content:
    """ruby
    describe Bogus do
      specify do
        #{string}
      end
    end
    """
    Then the specs should pass
  }
end

Then /^minitest file "([^"]*)" with the following content should (pass|fail):$/ do |file_name, pass_fail, string|
  steps %Q{
    Given a file named "#{file_name}" with:
    """ruby
    #{string}
    """
    When I run `ruby #{file_name}`
    Then the specs should #{pass_fail}
  }
end