update rspec matchers to use expect()

This commit is contained in:
Emil Tin 2014-06-30 20:43:51 +02:00
parent 1c75ce5911
commit dba9998118
3 changed files with 25 additions and 25 deletions

View File

@ -15,35 +15,35 @@ When(/^I run "osrm\-prepare\s?(.*?)"$/) do |options|
end end
Then /^it should exit with code (\d+)$/ do |code| Then /^it should exit with code (\d+)$/ do |code|
@exit_code.should == code.to_i expect(@exit_code).to eq( code.to_i )
end end
Then /^stdout should contain "(.*?)"$/ do |str| Then /^stdout should contain "(.*?)"$/ do |str|
@stdout.should include(str) expect(@stdout).to include(str)
end end
Then /^stderr should contain "(.*?)"$/ do |str| Then /^stderr should contain "(.*?)"$/ do |str|
@stderr.should include(str) expect(@stderr).to include(str)
end end
Then(/^stdout should contain \/(.*)\/$/) do |regex_str| Then(/^stdout should contain \/(.*)\/$/) do |regex_str|
regex = Regexp.new regex_str regex = Regexp.new regex_str
@stdout.should =~ regex expect(@stdout).to match( regex )
end end
Then(/^stderr should contain \/(.*)\/$/) do |regex_str| Then(/^stderr should contain \/(.*)\/$/) do |regex_str|
regex = Regexp.new regex_str regex = Regexp.new regex_str
@stderr.should =~ regex expect(@stderr).to match( regex )
end end
Then /^stdout should be empty$/ do Then /^stdout should be empty$/ do
@stdout.should == "" expect(@stdout).to eq("")
end end
Then /^stderr should be empty$/ do Then /^stderr should be empty$/ do
@stderr.should == "" expect(@stderr).to eq("")
end end
Then /^stdout should contain (\d+) lines?$/ do |lines| Then /^stdout should contain (\d+) lines?$/ do |lines|
@stdout.lines.count.should == lines.to_i expect(@stdout.lines.count).to eq( lines.to_i )
end end

View File

@ -6,9 +6,9 @@ When /^I request \/(.*)$/ do |path|
end end
Then /^I should get a response/ do Then /^I should get a response/ do
@response.code.should == "200" expect(@response.code).to eq("200")
@response.body.should_not == nil expect(@response.body).not_to eq(nil)
@response.body.should_not == '' expect(@response.body).not_to eq('')
end end
Then /^response should be valid JSON$/ do Then /^response should be valid JSON$/ do
@ -16,31 +16,31 @@ Then /^response should be valid JSON$/ do
end end
Then /^response should be well-formed$/ do Then /^response should be well-formed$/ do
@json['status'].class.should == Fixnum expect(@json['status'].class).to eq(Fixnum)
end end
Then /^status code should be (\d+)$/ do |code| Then /^status code should be (\d+)$/ do |code|
@json = JSON.parse @response.body @json = JSON.parse @response.body
@json['status'].should == code.to_i expect(@json['status']).to eq(code.to_i)
end end
Then /^status message should be "(.*?)"$/ do |message| Then /^status message should be "(.*?)"$/ do |message|
@json = JSON.parse @response.body @json = JSON.parse @response.body
@json['status_message'].should == message expect(@json['status_message']).to eq(message)
end end
Then /^response should be a well-formed route$/ do Then /^response should be a well-formed route$/ do
step "response should be well-formed" step "response should be well-formed"
@json['status_message'].class.should == String expect(@json['status_message'].class).to eq(String)
@json['route_summary'].class.should == Hash expect(@json['route_summary'].class).to eq(Hash)
@json['route_geometry'].class.should == String expect(@json['route_geometry'].class).to eq(String)
@json['route_instructions'].class.should == Array expect(@json['route_instructions'].class).to eq(Array)
@json['via_points'].class.should == Array expect(@json['via_points'].class).to eq(Array)
@json['via_indices'].class.should == Array expect(@json['via_indices'].class).to eq(Array)
end end
Then /^"([^"]*)" should return code (\d+)$/ do |binary, code| Then /^"([^"]*)" should return code (\d+)$/ do |binary, code|
@process_error.is_a?(OSRMError).should == true expect(@process_error.is_a?(OSRMError)).to eq(true)
@process_error.process.should == binary expect(@process_error.process).to eq(binary)
@process_error.code.to_i.should == code.to_i expect(@process_error.code.to_i).to eq(code.to_i)
end end

View File

@ -2,6 +2,6 @@ Then /^I should get a valid timestamp/ do
step "I should get a response" step "I should get a response"
step "response should be valid JSON" step "response should be valid JSON"
step "response should be well-formed" step "response should be well-formed"
@json['timestamp'].class.should == String expect(@json['timestamp'].class).to eq(String)
@json['timestamp'].should == OSM_TIMESTAMP expect(@json['timestamp']).to eq(OSM_TIMESTAMP)
end end