features/steps/pacto_steps.rb in pacto-0.3.1 vs features/steps/pacto_steps.rb in pacto-0.4.0.rc1
- old
+ new
@@ -1,25 +1,26 @@
+# -*- encoding : utf-8 -*-
Given(/^Pacto is configured with:$/) do |string|
- steps %Q{
+ steps %(
Given a file named "pacto_config.rb" with:
"""ruby
#{string}
"""
- }
+ )
end
Given(/^I have a Rakefile$/) do
- steps %Q{
+ steps %(
Given a file named "Rakefile" with:
"""ruby
require 'pacto/rake_task'
"""
- }
+ )
end
When(/^I request "(.*?)"$/) do |url|
- steps %Q{
+ steps %{
Given a file named "request.rb" with:
"""ruby
require 'pacto'
require_relative 'pacto_config'
require 'faraday'
@@ -32,14 +33,14 @@
When I run `bundle exec ruby request.rb`
}
end
Given(/^an existing set of services$/) do
- WebMock.stub_request(:get, 'www.example.com/service1').to_return(:body => {'thoughtworks' => 'pacto' }.to_json)
- WebMock.stub_request(:post, 'www.example.com/service1').with(:body => 'thoughtworks').to_return(:body => 'pacto')
- WebMock.stub_request(:get, 'www.example.com/service2').to_return(:body => {'service2' => %w{'thoughtworks', 'pacto'} }.to_json)
- WebMock.stub_request(:post, 'www.example.com/service2').with(:body => 'thoughtworks').to_return(:body => 'pacto')
+ WebMock.stub_request(:get, 'www.example.com/service1').to_return(body: { 'thoughtworks' => 'pacto' }.to_json)
+ WebMock.stub_request(:post, 'www.example.com/service1').with(body: 'thoughtworks').to_return(body: 'pacto')
+ WebMock.stub_request(:get, 'www.example.com/service2').to_return(body: { 'service2' => %w(thoughtworks pacto) }.to_json)
+ WebMock.stub_request(:post, 'www.example.com/service2').with(body: 'thoughtworks').to_return(body: 'pacto')
end
When(/^I execute:$/) do |script|
FileUtils.mkdir_p 'tmp/aruba'
Dir.chdir 'tmp/aruba' do
@@ -52,15 +53,14 @@
ensure
$stdout = STDOUT
end
eof
eval(script) # rubocop:disable Eval
- # It's just for testing...
+ # It's just for testing...
rescue SyntaxError => e
- puts e
- puts e.backtrace
+ raise e
end
end
end
When(/^I make replacements in "([^"]*)":$/) do |file_name, replacements|
@@ -70,6 +70,11 @@
content.gsub! Regexp.new(pattern), replacement
end
File.open(file_name, 'w') { |file| file.write content }
end
+end
+
+Then(/^the stdout should match this contract:$/) do |expected_contract|
+ actual_contract = all_stdout
+ expect(actual_contract).to be_json_eql(expected_contract).excluding('description')
end