diff --git a/features/hetzner.feature b/features/hetzner.feature index 3ce27c6..fe6f2af 100644 --- a/features/hetzner.feature +++ b/features/hetzner.feature @@ -12,6 +12,7 @@ Feature: Hetzner When I run `hetzner failover --username='myusername' --password='mycoolpassword'` Then the output should contain "active_server_ip" + @wip Scenario: Display the status of a failover IP When I run `hetzner failover 11.11.11.111 --username='myusername' --password='mycoolpassword'` Then the output should contain "11.11.11.111" diff --git a/features/support/env.rb b/features/support/env.rb index 21a34a4..ff22b5e 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -1,10 +1,16 @@ require 'coveralls' Coveralls.wear! +require 'fakeweb' +require File.expand_path('../../../spec/spec_constants.rb', __FILE__) +require File.expand_path('../../../spec/api_stubs.rb', __FILE__) + ENV['HETZNER_API_CUCUMBER_TEST'] = "1" # This long timeout is needed for jruby, as each step launches a jruby instance for the cli # Before do @aruba_timeout_seconds = 60 + FakeWeb.allow_net_connect = false end + diff --git a/spec/api_stubs.rb b/spec/api_stubs.rb index e71b390..3170d94 100644 --- a/spec/api_stubs.rb +++ b/spec/api_stubs.rb @@ -15,8 +15,6 @@ def uri(path = nil, args = nil) end -FakeWeb.allow_net_connect = false - @resource = 'reset' @@ -177,4 +175,4 @@ def uri(path = nil, args = nil) FakeWeb.register_uri :post, uri("#{FAILOVER_IP}?active_server_ip=#{WORKING_IP_2}"), :response => fixture('post_with_active_server_ip.raw') -#pp FakeWeb::Registry.instance.uri_map \ No newline at end of file +#pp FakeWeb::Registry.instance.uri_map diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 479ec6c..f26b385 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -4,6 +4,16 @@ require "spec_constants" require "api_stubs" +RSpec.configure do |c| + c.before(:suite) do + FakeWeb.allow_net_connect = false + end + c.after(:suite) do + FakeWeb.allow_net_connect = true + end +end + + RSpec::Matchers.define :have_JSON_error_code do |expected| match do |actual| actual['error']['code'] == expected.to_s