Skip to content

Commit

Permalink
Fix features for API copy to use a fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmeyer authored and mvz committed May 19, 2019
1 parent 3b8b9df commit 10e9595
Showing 1 changed file with 70 additions and 58 deletions.
128 changes: 70 additions & 58 deletions features/04_aruba_api/filesystem/use_fixtures.feature
Original file line number Diff line number Diff line change
@@ -1,56 +1,74 @@
Feature: Use fixtures in your tests

Sometimes your tests need existing files to work - e.g binary data files you
cannot create programmatically. Since `aruba` >= 0.6.3 includes some basic
support for fixtures. All you need to do is the following:

cannot create programmatically. All you need to do is the following:

1. Create a `fixtures`-directory
2. Create fixture files in this directory


Background:
Given I use a fixture named "cli-app"

Scenario: Use a fixture for your tests
Given a file named "features/fixtures.feature" with:
Given a file named "spec/fixture_spec.rb" with:
"""
Feature: Fixture
Scenario: Fixture
Given a file named "fixtures_spec.rb" with:
\"\"\"
RSpec.describe 'My Feature' do
describe '#read_music_file' do
context 'when the file exists' do
before :each { copy '%/song.mp3', 'file.mp3' }
it { expect('file.mp3').to be_an_existing_file }
end
end
require 'spec_helper'
RSpec.describe 'My Feature', :type => :aruba do
describe 'Copy file' do
context 'when the file exists' do
before :each { copy '%/song.mp3', 'file.mp3' }
it { expect('file.mp3').to be_an_existing_file }
end
\"\"\"
end
end
"""
And a directory named "fixtures"
And an empty file named "fixtures/fixtures-app/test.txt"
And an empty file named "fixtures/song.mp3"
When I run `rspec`
Then the specs should all pass

Scenario: Pass file from fixtures to your command
Given a file named "spec/fixture_spec.rb" with:
"""
require 'spec_helper'
RSpec.describe 'My Feature', :type => :aruba do
before :each { copy '%/my_file.txt', 'new_file.txt' }
before :each { run_command 'aruba-test-cli new_file.txt' }
it { expect(last_command_started).to have_output 'Hello Aruba!' }
end
"""
And a directory named "fixtures"
And a file named "fixtures/my_file.txt" with:
"""
Hello Aruba!
"""
And a file named "bin/aruba-test-cli" with:
"""
#!/usr/bin/env ruby
puts File.read(ARGV[0]).chomp
"""
When I run `rspec`
Then the specs should all pass

Scenario: Use a fixture for your tests in test/
Given a file named "features/fixtures.feature" with:
"""
Feature: Fixture
Scenario: Fixture
Given a file named "fixtures_spec.rb" with:
\"\"\"
RSpec.describe 'My Feature' do
describe '#read_music_file' do
context 'when the file exists' do
before :each { copy '%/song.mp3', 'file.mp3' }
it { expect('file.mp3').to be_an_existing_file }
end
end
require 'spec_helper'
RSpec.describe 'My Feature', :type => :aruba do
describe 'Copy file' do
context 'when the file exists' do
before :each { copy '%/song.mp3', 'file.mp3' }
it { expect('file.mp3').to be_an_existing_file }
end
\"\"\"
end
end
"""
And a directory named "test/fixtures"
And an empty file named "test/fixtures/fixtures-app/test.txt"
Expand All @@ -60,20 +78,17 @@ Feature: Use fixtures in your tests
Scenario: Use a fixture for your tests in spec/
Given a file named "features/fixtures.feature" with:
"""
Feature: Fixture
Scenario: Fixture
Given a file named "fixtures_spec.rb" with:
\"\"\"
RSpec.describe 'My Feature' do
describe '#read_music_file' do
context 'when the file exists' do
before :each { copy '%/song.mp3', 'file.mp3' }
it { expect('file.mp3').to be_an_existing_file }
end
end
require 'spec_helper'
RSpec.describe 'My Feature', :type => :aruba do
describe 'Copy file' do
context 'when the file exists' do
before :each { copy '%/song.mp3', 'file.mp3' }
it { expect('file.mp3').to be_an_existing_file }
end
\"\"\"
end
end
"""
And a directory named "spec/fixtures"
And an empty file named "spec/fixtures/fixtures-app/test.txt"
Expand All @@ -83,20 +98,17 @@ Feature: Use fixtures in your tests
Scenario: Use a fixture for your tests in features/
Given a file named "features/fixtures.feature" with:
"""
Feature: Fixture
Scenario: Fixture
Given a file named "fixtures_spec.rb" with:
\"\"\"
RSpec.describe 'My Feature' do
describe '#read_music_file' do
context 'when the file exists' do
before :each { copy '%/song.mp3', 'file.mp3' }
it { expect('file.mp3').to be_an_existing_file }
end
end
require 'spec_helper'
RSpec.describe 'My Feature', :type => :aruba do
describe 'Copy file' do
context 'when the file exists' do
before :each { copy '%/song.mp3', 'file.mp3' }
it { expect('file.mp3').to be_an_existing_file }
end
\"\"\"
end
end
"""
And a directory named "features/fixtures"
And an empty file named "features/fixtures/fixtures-app/test.txt"
Expand Down

0 comments on commit 10e9595

Please sign in to comment.