File: file_steps.rb

package info (click to toggle)
ruby-carrierwave 1.3.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,692 kB
  • sloc: ruby: 9,881; sh: 26; makefile: 5
file content (51 lines) | stat: -rw-r--r-- 1,816 bytes parent folder | download | duplicates (2)
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
###
# EXISTENCE

Then /^there should be a file at '(.*?)'$/ do |file|
  File.exist?(file_path(file)).should be_truthy
end

Then /^there should not be a file at '(.*?)'$/ do |file|
  File.exist?(file_path(file)).should be_falsey
end

Then /^there should be a file called '(.*?)' somewhere in a subdirectory of '(.*?)'$/ do |file, directory|
  Dir.glob(File.join(file_path(directory), '**', file)).any?.should be_truthy
end

###
# IDENTICAL

Then /^the file at '(.*?)' should be identical to the file at '(.*?)'$/ do |one, two|
  File.read(file_path(one)).should == File.read(file_path(two))
end

Then /^the file at '(.*?)' should not be identical to the file at '(.*?)'$/ do |one, two|
  File.read(file_path(one)).should_not == File.read(file_path(two))
end

Then /^the file called '(.*?)' in a subdirectory of '(.*?)' should be identical to the file at '(.*?)'$/ do |file, directory, other|
  File.read(Dir.glob(File.join(file_path(directory), '**', file)).first).should == File.read(file_path(other))
end

Then /^the file called '(.*?)' in a subdirectory of '(.*?)' should not be identical to the file at '(.*?)'$/ do |file, directory, other|
  File.read(Dir.glob(File.join(file_path(directory), '**', file)).first).should_not == File.read(file_path(other))
end

###
# CONTENT

Then /^the file called '([^']+)' in a subdirectory of '([^']+)' should contain '([^']+)'$/ do |file, directory, content|
  File.read(Dir.glob(File.join(file_path(directory), '**', file)).first).should include(content)
end

Then /^the file at '([^']+)' should contain '([^']+)'$/ do |path, content|
  File.read(file_path(path)).should include(content)
end

###
# REVERSING

Then /^the file at '(.*?)' should be the reverse of the file at '(.*?)'$/ do |one, two|
  File.read(file_path(one)).should == File.read(file_path(two)).reverse
end