Sha256: d92cd4b9a2468821433cc20cd637055a1dca2a70b16130fbf903255740be5880

Contents?: true

Size: 1.81 KB

Versions: 17

Compression:

Stored size: 1.81 KB

Contents

require "stringio"

When /^I execute the following code in a new thread$/ do |code|
  Thread.new do
    eval code
  end
end

When /^I execute the code$/ do |code|
  @result = eval code
end

Then /^I see an anmo server on port (\d+)$/ do |port|
  response = nil

  timeout 5 do
    while response.nil?
      response = HTTParty.get("http://localhost:#{port}") rescue nil
    end
  end

  response.body.should include "Not Found"
end

Given /^an anmo server$/ do
  Thread.new do
    Anmo.launch_server
  end

  timeout 5 do
    response = nil
    while response.nil?
      response = HTTParty.get("http://localhost:8787") rescue nil
    end
    sleep 0.1
  end
end

Then /^I issue a get request to the uri "([^"]*)"$/ do |uri|
  @response = HTTParty.get(uri)
end

When /^I issue a put request to the uri "([^"]*)"$/ do |uri|
  @response = HTTParty.put(uri)
end

When /^I request the uri "([^"]*)"$/ do |uri|
  @requested_uri = uri
  @response = HTTParty.get(uri)
end

When /^I request the uri "([^"]*)" with the headers$/ do |uri, headers|
  headers = JSON.parse(headers)
  @response = HTTParty.get(uri, :headers => headers)
end

Then /^I see the response body "([^"]*)"$/ do |body|
  @response.body.should == body
end

Then /^I see the response code (\d+)$/ do |code|
  @response.code.should == code.to_i
end

Then /^that request should be stored$/ do
  Anmo.requests.last["PATH_INFO"].should == @requested_uri.gsub("http://localhost:8787", "")
end

Then /^there should be no stored requests$/ do
  Anmo.requests.size.should == 0
end

Then /^I should see the value$/ do |code|
  @result.should == eval(code)
end

Then /^I see that the anmo server is not running$/ do
  @result.should == false
end

Then /^I see that the anmo server is running$/ do
  @result.should == true
end

Then /^I see the anmo version$/ do
  @result.should == Anmo::VERSION
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
anmo2-0.0.32 features/step_definitions/api_steps.rb
anmo2-0.0.31 features/step_definitions/api_steps.rb
anmo-0.0.30 features/step_definitions/api_steps.rb
anmo-0.0.29 features/step_definitions/api_steps.rb
anmo-0.0.28 features/step_definitions/api_steps.rb
anmo-0.0.27 features/step_definitions/api_steps.rb
anmo-0.0.26 features/step_definitions/api_steps.rb
anmo-0.0.25 features/step_definitions/api_steps.rb
anmo-0.0.24 features/step_definitions/api_steps.rb
anmo-0.0.23 features/step_definitions/api_steps.rb
anmo-0.0.22 features/step_definitions/api_steps.rb
anmo-0.0.21 features/step_definitions/api_steps.rb
anmo-0.0.20 features/step_definitions/api_steps.rb
anmo-0.0.19 features/step_definitions/api_steps.rb
anmo-0.0.18 features/step_definitions/api_steps.rb
anmo-0.0.17 features/step_definitions/api_steps.rb
anmo-0.0.16 features/step_definitions/api_steps.rb