lib/you_track/client/mock.rb in you_track-0.4.0 vs lib/you_track/client/mock.rb in you_track-0.4.1

- old
+ new

@@ -33,19 +33,28 @@ end end.to_s end def initialize(options={}) - @url = URI.parse(options[:url]) + @url = URI.parse(options[:url]) @username = options[:username] - self.data[:users][@username] = { - :email => @username, - :full_name => Faker::Name.name, - :last_created_project => SecureRandom.hex(2), + + set_current_user + end + + def set_current_user + self.data[:users][username] ||= { + "email" => "#{username}@example.org", + "full_name" => Faker::Name.name, + "last_created_project" => SecureRandom.hex(2), } end + def current_user + @current_user ||= users.current + end + def response(options={}) body = options[:response_body] || options[:body] method = options[:method] || :get params = options[:params] self.last_request = options[:request_body] @@ -76,11 +85,7 @@ :status => status, ) Faraday::Response::RaiseError.new.on_complete(env) || Faraday::Response.new(env) - end - - def current_user - @current_user ||= users.current end end