Skip to content

Commit

Permalink
fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lashd committed Aug 12, 2012
1 parent 5ae76e9 commit 11212d5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion bin/mirage
Expand Up @@ -7,7 +7,7 @@ require 'mirage/client'

begin
Mirage::Runner.start
rescue RuntimeError => e
rescue Mirage::ClientError => e
puts e.message
exit 1
end
Expand Down
2 changes: 1 addition & 1 deletion features/client/command_line_interface.feature
Expand Up @@ -77,7 +77,7 @@ Feature: The Mirage client provides a programmatic interface equivalent to the c
begin
Mirage.stop
raise "should have errored"
rescue
rescue Mirage::ClientError => ce
end
"""
Then mirage should be running on 'http://localhost:7001/mirage'
Expand Down
17 changes: 11 additions & 6 deletions lib/mirage/client.rb
Expand Up @@ -52,13 +52,12 @@ def start

desc "stop", "stops mirage"
method_option :port, :aliases => "-p", :type => :array, :banner => "[port_1 port_2|all]", :desc => "port(s) of mirage instance(s). ALL stops all running instances"

def stop

ports = options[:port]
if ports.nil?
mirage_process_ids = mirage_process_ids([:all])
raise "Mirage is running on ports #{mirage_process_ids.keys.join(", ")}. Please run mirage stop -p [PORT(s)] instead" if mirage_process_ids.size > 1
raise ClientError.new("Mirage is running on ports #{mirage_process_ids.keys.join(", ")}. Please run mirage stop -p [PORT(s)] instead") if mirage_process_ids.size > 1
ports = [:all]
end

Expand All @@ -73,8 +72,8 @@ def stop
end

private
def mirage_process_ids ports

def mirage_process_ids *ports
ports.flatten!
mirage_instances = {}
if ports.first.to_s.downcase == "all"
if ChildProcess.windows?
Expand Down Expand Up @@ -118,8 +117,8 @@ def stop options={}
end
puts "Stopping Mirage"
Runner.new.invoke(:stop, [], options)
rescue RuntimeError => e
raise "Mirage is running on more than one port, please specify the port(s) you wish to stop it on"
rescue ClientError => e
raise ClientError.new("Mirage is running multiple ports, please specify the port(s) see api/tests for details")
end

private
Expand Down Expand Up @@ -170,6 +169,12 @@ class InternalServerException < MirageError;
class ResponseNotFound < MirageError;
end

class ClientError < ::Exception
def initialize message
super message
end
end

class Client
include ::Mirage::Web
attr_reader :url
Expand Down
5 changes: 1 addition & 4 deletions test.rb
Expand Up @@ -2,7 +2,4 @@
require 'rubygems'
require 'mirage/client'

Dir.chdir "/home/team/Projects/mirage/scratch" do
Mirage.stop :port => 9001
Mirage.start :port => 9001, :defaults => './custom_responses_location'
end
Mirage.stop :port => 7001

0 comments on commit 11212d5

Please sign in to comment.