Skip to content

Commit

Permalink
Fix syntax and logic in fixture scenarios
Browse files Browse the repository at this point in the history
- Create a file picked up by rspec in each scenario
- Fix before :each syntax to work on Ruby < 2.4
- Create correct fixture file in each scenario
  • Loading branch information
mvz committed May 19, 2019
1 parent 10e9595 commit 32486af
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions features/04_aruba_api/filesystem/use_fixtures.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Feature: Use fixtures in your tests
RSpec.describe 'My Feature', :type => :aruba do
describe 'Copy file' do
context 'when the file exists' do
before :each { copy '%/song.mp3', 'file.mp3' }
before(:each) { copy '%/song.mp3', 'file.mp3' }
it { expect('file.mp3').to be_an_existing_file }
end
Expand All @@ -35,8 +35,8 @@ Feature: Use fixtures in your tests
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' }
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
Expand All @@ -56,61 +56,61 @@ Feature: Use fixtures in your tests
Then the specs should all pass

Scenario: Use a fixture for your tests in test/
Given a file named "features/fixtures.feature" with:
Given a file named "spec/fixture_spec.rb" with:
"""
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' }
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"
And an empty file named "test/fixtures/song.mp3"
When I run `rspec`
Then the specs should all pass

Scenario: Use a fixture for your tests in spec/
Given a file named "features/fixtures.feature" with:
Given a file named "spec/fixture_spec.rb" with:
"""
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' }
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"
And an empty file named "spec/fixtures/song.mp3"
When I run `rspec`
Then the specs should all pass

Scenario: Use a fixture for your tests in features/
Given a file named "features/fixtures.feature" with:
Given a file named "spec/fixture_spec.rb" with:
"""
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' }
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"
And an empty file named "features/fixtures/song.mp3"
When I run `rspec`
Then the specs should all pass

0 comments on commit 32486af

Please sign in to comment.