/
cucumber.rb
132 lines (101 loc) · 3.29 KB
/
cucumber.rb
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
require 'aruba/api'
World(Aruba::Api)
Before do
FileUtils.rm_rf(current_dir)
end
Before('@announce-cmd') do
@announce_cmd = true
end
Before('@announce-stdout') do
@announce_stdout = true
end
Before('@announce') do
@announce_stdout = true
@announce_cmd = true
end
Given /^I am using rvm "([^\"]*)"$/ do |rvm_ruby_version|
use_rvm(rvm_ruby_version)
end
Given /^I am using rvm gemset "([^\"]*)"$/ do |rvm_gemset|
use_rvm_gemset(rvm_gemset)
end
Given /^a directory named "([^\"]*)"$/ do |dir_name|
create_dir(dir_name)
end
Given /^a file named "([^\"]*)" with:$/ do |file_name, file_content|
create_file(file_name, file_content)
end
Given /^an empty file named "([^\"]*)"$/ do |file_name|
create_file(file_name, "")
end
When /^I append to "([^\"]*)" with:$/ do |file_name, file_content|
append_to_file(file_name, file_content)
end
When /^I cd to "([^\"]*)"$/ do |dir|
cd(dir)
end
When /^I run "(.*)"$/ do |cmd|
run(unescape(cmd))
end
When /^I successfully run "(.*)"$/ do |cmd|
run(unescape(cmd))
if(@last_exit_status != 0)
fail("Exit status was #{@last_exit_status}. Output:\n#{combined_output}")
end
end
Then /^I should see "([^\"]*)"$/ do |partial_output|
combined_output.should =~ compile_and_escape(partial_output)
end
Then /^I should not see "([^\"]*)"$/ do |partial_output|
combined_output.should_not =~ compile_and_escape(partial_output)
end
Then /^I should see:$/ do |partial_output|
combined_output.should =~ compile_and_escape(partial_output)
end
Then /^I should not see:$/ do |partial_output|
combined_output.should_not =~ compile_and_escape(partial_output)
end
Then /^I should see exactly "([^\"]*)"$/ do |exact_output|
combined_output.should == unescape(exact_output)
end
Then /^I should see exactly:$/ do |exact_output|
combined_output.should == exact_output
end
Then /^the exit status should be (\d+)$/ do |exit_status|
@last_exit_status.should == exit_status.to_i
end
Then /^the exit status should not be (\d+)$/ do |exit_status|
@last_exit_status.should_not == exit_status.to_i
end
Then /^it should (pass|fail) with:$/ do |pass_fail, partial_output|
Then "I should see:", partial_output
if pass_fail == 'pass'
@last_exit_status.should == 0
else
@last_exit_status.should_not == 0
end
end
Then /^the stderr should contain "([^\"]*)"$/ do |partial_output|
@last_stderr.should =~ compile_and_escape(partial_output)
end
Then /^the stdout should contain "([^\"]*)"$/ do |partial_output|
@last_stdout.should =~ compile_and_escape(partial_output)
end
Then /^the stderr should not contain "([^\"]*)"$/ do |partial_output|
@last_stderr.should_not =~ compile_and_escape(partial_output)
end
Then /^the stdout should not contain "([^\"]*)"$/ do |partial_output|
@last_stdout.should_not =~ compile_and_escape(partial_output)
end
Then /^the following files should exist:$/ do |files|
check_file_presence(files.raw.map{|file_row| file_row[0]}, true)
end
Then /^the following files should not exist:$/ do |files|
check_file_presence(files.raw.map{|file_row| file_row[0]}, false)
end
Then /^the file "([^\"]*)" should contain "([^\"]*)"$/ do |file, partial_content|
check_file_content(file, partial_content, true)
end
Then /^the file "([^\"]*)" should not contain "([^\"]*)"$/ do |file, partial_content|
check_file_content(file, partial_content, false)
end