Given(/^I have a CSV with the following content:$/) do |string|
  @csv = string
end

Given(/^it is stored at the url "(.*?)"$/) do |url|
  @url = url
  charset = @encoding || "UTF-8"
  stub_request(:get, url).to_return(:status => 200, :body => @csv, :headers => {"Content-Type" => "text/csv; charset=#{charset}"})
end

When(/^I ask if the CSV is valid$/) do
  @validator = Csvlint::Validator.new( @url ) 
  @valid = @validator.valid?
end

Then(/^I should get the value of true$/) do
  expect( @valid ).to be(true)
end

Then(/^I should get the value of false$/) do
  expect( @valid ).to be(false)
end

Given(/^I have a CSV with the following content:$/) do |string|
  @csv = string
end

Given(/^it is stored at the url "(.*?)"$/) do |url|
  @url = url
  content_type = @content_type || "text/csv"
  charset = @encoding || "UTF-8"
  stub_request(:get, url).to_return(:status => 200, :body => @csv, :headers => {"Content-Type" => "#{content_type}; charset=#{charset}"})
end

When(/^I ask if the CSV is valid$/) do
  @validator = Csvlint::Validator.new( @url ) 
  @valid = @validator.valid?
end

Then(/^I should get the value of true$/) do
  expect( @valid ).to be(true)
end

Then(/^I should get the value of false$/) do
  expect( @valid ).to be(false)
end

Allow content type to be explicitly set in tests
Allow content type to be explicitly set in tests
