Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

New step definition for appending to a file

  • Loading branch information...
commit 2afd02b7d44102119f20179763c85340e919f71d 1 parent a147289
Aslak Hellesøy aslakhellesoy authored
3  History.txt
... ... @@ -1,3 +1,6 @@
  1 +== 0.1.4
  2 +* New step definition for appending to a file (Aslak Hellesøy)
  3 +
1 4 == 0.1.3
2 5 * New step definition for cd (change directory) (Aslak Hellesøy)
3 6
2  Rakefile
@@ -4,7 +4,7 @@ require 'rake'
4 4 begin
5 5 require 'jeweler'
6 6 Jeweler::Tasks.new do |gem|
7   - gem.version = "0.1.3"
  7 + gem.version = "0.1.4"
8 8 gem.name = "aruba"
9 9 gem.summary = %Q{CLI Steps for Cucumber}
10 10 gem.description = %Q{CLI Steps for Cucumber, hand-crafted for you in Aruba}
15 features/file_system_commands.feature
@@ -9,7 +9,7 @@ Feature: file system commands
9 9 When I run "ruby -e \"puts test ?d, 'foo'\""
10 10 Then the stdout should contain "true"
11 11
12   - Scenario: cat a file
  12 + Scenario: create a file
13 13 Given a file named "foo/bar/example.rb" with:
14 14 """
15 15 puts "hello world"
@@ -17,6 +17,19 @@ Feature: file system commands
17 17 When I run "ruby foo/bar/example.rb"
18 18 Then I should see "hello world"
19 19
  20 + Scenario: append to a file
  21 + Given a file named "foo/bar/example.rb" with:
  22 + """
  23 + puts "hello world"
  24 + """
  25 + When I append to "foo/bar/example.rb" with:
  26 + """
  27 + puts "this was appended"
  28 + """
  29 + When I run "ruby foo/bar/example.rb"
  30 + Then I should see "hello world"
  31 + And I should see "this was appended"
  32 +
20 33 Scenario: clean up files generated in previous scenario
21 34 When I run "ruby foo/bar/example.rb"
22 35 Then the exit status should be 1
6 lib/aruba/api.rb
@@ -27,6 +27,12 @@ def create_file(file_name, file_content)
27 27 end
28 28 end
29 29
  30 + def append_to_file(file_name, file_content)
  31 + in_current_dir do
  32 + File.open(file_name, 'a') { |f| f << file_content }
  33 + end
  34 + end
  35 +
30 36 def create_dir(dir_name)
31 37 in_current_dir do
32 38 _mkdir(dir_name)
4 lib/aruba/cucumber.rb
@@ -14,6 +14,10 @@
14 14 create_file(file_name, file_content)
15 15 end
16 16
  17 +When /^I append to "([^\"]*)" with:$/ do |file_name, file_content|
  18 + append_to_file(file_name, file_content)
  19 +end
  20 +
17 21 When /^I cd to "([^\"]*)"$/ do |dir|
18 22 cd(dir)
19 23 end

0 comments on commit 2afd02b

Please sign in to comment.
Something went wrong with that request. Please try again.