Created
June 2, 2015 07:55
-
-
Save lorenzosinisi/c79f2b9e43bbfb9b6029 to your computer and use it in GitHub Desktop.
Test model Agent that makes http requests with rspec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe Agent do | |
describe "1. calling #request" do | |
it "serves the action POST if the request is in POST" do | |
variable = Agent.request("http://google.com", "params", "post") | |
variable.should be_truthy | |
end | |
it "serves the action GET if the request is in GET" do | |
variable = Agent.request("http://google.com", "params", "get") | |
variable.should be_truthy | |
end | |
it "returns FALSE if the request is not yet available" do | |
variable = Agent.request("http://google.com", "params", "patch") | |
variable.should be_falsey | |
end | |
end | |
describe "2. Afer calling requests is serves the action that can be:" do | |
describe "#get" do | |
it "should return true or the HTTP error code" do | |
url = "http://it.comp.macintosh.narkive.com/dcmPCviU/vim-e-caratteri-speciali" | |
params = {:ciao => "hello", :prova => "coem"} | |
variable = Agent.get(url, params) | |
variable.should be_truthy | |
end | |
end | |
describe "#post" do | |
it "should return true or the HTTP error code" do | |
url = "http://it.comp.macintosh.narkive.com/dcmPCviU/vim-e-caratteri-speciali" | |
params = {:ciao => "hello", :prova => "coem"} | |
variable = Agent.get(url, params) | |
variable.should be_truthy | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment