Permalink
Browse files

Polish up ui

  • Loading branch information...
1 parent bdaad9b commit a45e38bb1b81d54bcde385c8242bb8d0b984fa81 Ryan Burrows committed Apr 8, 2010
@@ -32,21 +32,3 @@ Feature: Reviewr gets user information
Given I enter "asdfasdf" for my email password
When I run a reviewr command that requires email
Then the email password should be set to "asdfasdf"
-
- Scenario: Reviewr asks for email server but sets a default
- Given my git email is "name@wrongsite.com"
- And I enter "me@site.com" for my email
- When I run a reviewr command that requires email
- Then I should see "Email server (default site.com): "
-
- Scenario: Reviewr defaults the email server if I don't set one
- Given my git email is "name@site.com"
- And I use the default email server
- When I run a reviewr command that requires email
- Then the email server should be set to "site.com"
-
- Scenario: Reviewr accepts the email server that I enter
- Given my git email is "name@wrongsite.com"
- And I enter "site.com" for my email server
- When I run a reviewr command that requires email
- Then the email server should be set to "site.com"
@@ -30,7 +30,7 @@ def messages
@messages ||= []
end
- def puts(message)
+ def print(message)
messages << message
end
end
@@ -24,18 +24,14 @@ def run
end
def prompt_for_user(input = STDIN, output = STDOUT)
- output.puts("Email (default #{project.user_email}): ")
+ output.print("Email (default #{project.user_email}): ")
email = input.gets.chomp
project.user_email = email unless email.empty?
- output.puts("Email password: ")
+ output.print("Email password: ")
no_echo(input) do
project.email_password = input.gets.chomp
end
-
- output.puts("Email server (default #{project.email_server}): ")
- server = input.gets.chomp
- project.email_server = server unless server.empty?
end
private
@@ -10,6 +10,7 @@ def send(body)
Pony.mail(:from => @project.user_email,
:to => @project.to,
:body => body,
+ :subject => "Code review request from #{@project.user_email}",
:via => :smtp,
:smtp => {
:host => 'smtp.gmail.com',
@@ -4,8 +4,8 @@ module Reviewr
class Project
extend Forwardable
- attr_reader :to, :git
- attr_accessor :user_email, :email_password, :email_server
+ attr_reader :to, :git, :email_server
+ attr_accessor :user_email, :email_password
def_delegators :git, :push_branch, :origin_location
@@ -68,7 +68,7 @@ def new_main(args)
it "Asks for the user's email with the default user email from git" do
Reviewr::Git.instance.stub(:user_email).and_return('e@s.com')
- output.should_receive(:puts).with("Email (default e@s.com): ")
+ output.should_receive(:print).with("Email (default e@s.com): ")
main.prompt_for_user(input, output)
end
@@ -85,7 +85,7 @@ def new_main(args)
end
it "Asks for the user's email password" do
- output.should_receive(:puts).with("Email password: ")
+ output.should_receive(:print).with("Email password: ")
main.prompt_for_user(input, output)
end
@@ -94,24 +94,6 @@ def new_main(args)
input.stub(:gets).and_return("email@s.com", "asdf")
main.prompt_for_user(input, output)
end
-
- it "Asks for the user's email server with the default based on email" do
- main.project.stub(:email_server).and_return("site.com")
- output.should_receive(:puts).with("Email server (default site.com): ")
- main.prompt_for_user(input, output)
- end
-
- it "Sets the entered email server into the project" do
- main.project.should_receive(:email_server=).with("site.com")
- input.stub(:gets).and_return("site.com")
- main.prompt_for_user(input, output)
- end
-
- it "Uses the default email if an empty string is entered" do
- main.project.should_not_receive(:email_server=)
- input.stub(:gets).and_return("\n")
- main.prompt_for_user(input, output)
- end
end
end
end
@@ -9,20 +9,21 @@ module Reviewr
:to => 'to',
:email_server => 'host',
:email_password => 'p')
- Pony.should_receive(:mail).with(hash_including(:from => 'from',
- :to => 'to',
- :body => 'body',
- :via => :smtp,
- :smtp => {
- :host =>
- 'smtp.gmail.com',
- :port => '587',
- :user => 'from',
- :tls => true,
- :password => 'p',
- :auth => :plain,
- :domain => 'host'
- }))
+ Pony.should_receive(:mail).with(
+ hash_including(:from => 'from',
+ :to => 'to',
+ :body => 'body',
+ :subject => 'Code review request from from',
+ :via => :smtp,
+ :smtp => {
+ :host => 'smtp.gmail.com',
+ :port => '587',
+ :user => 'from',
+ :tls => true,
+ :password => 'p',
+ :auth => :plain,
+ :domain => 'host'
+ }))
Mailer.new(project).send('body')
end
end

0 comments on commit a45e38b

Please sign in to comment.