Skip to content

Commit

Permalink
update to rspec expect syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
twalpole committed Jun 5, 2014
1 parent da3a27e commit 217ab35
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 42 deletions.
64 changes: 32 additions & 32 deletions spec/email/driver_spec.rb
Expand Up @@ -17,41 +17,41 @@ def self.call(env)

open_email('test@example.com')
current_email.click_link 'example'
page.should have_content 'Hello world!'
current_email.should have_content 'This is only a html test'
expect(page).to have_content 'Hello world!'
expect(current_email).to have_content 'This is only a html test'

all_emails.first.should eq email
expect(all_emails.first).to eq email

clear_emails
all_emails.should be_empty
expect(all_emails).to be_empty
end

scenario 'html email follows links' do
email = deliver(html_email)
open_email('test@example.com')

current_email.click_link 'example'
page.current_url.should eq('http://example.com/')
expect(page.current_url).to eq('http://example.com/')

current_email.click_link 'another example'
page.current_url.should eq('http://example.com:1234/')
expect(page.current_url).to eq('http://example.com:1234/')

current_email.click_link 'yet another example'
page.current_url.should eq('http://example.com:1234/some/path?foo=bar')
expect(page.current_url).to eq('http://example.com:1234/some/path?foo=bar')
end

scenario 'plain text email' do
email = deliver(plain_email)

open_email('test@example.com')
current_email.click_link 'http://example.com'
page.should have_content 'Hello world!'
current_email.should have_content 'This is only a plain test.'
expect(page).to have_content 'Hello world!'
expect(current_email).to have_content 'This is only a plain test.'

all_emails.first.should eq email
expect(all_emails.first).to eq email

clear_emails
all_emails.should be_empty
expect(all_emails).to be_empty
end

# should read html_part
Expand All @@ -60,19 +60,19 @@ def self.call(env)

open_email('test@example.com')
current_email.click_link 'example'
page.should have_content 'Hello world!'
current_email.should have_content 'This is only a html test'
expect(page).to have_content 'Hello world!'
expect(current_email).to have_content 'This is only a html test'

all_emails.first.should eq email
expect(all_emails.first).to eq email

clear_emails
all_emails.should be_empty
expect(all_emails).to be_empty
end

it 'delegates to base' do
email = deliver(plain_email)
open_email('test@example.com')
current_email.subject.should eq 'Test Email'
expect(current_email.subject).to eq 'Test Email'
end

# should read html_part
Expand All @@ -81,13 +81,13 @@ def self.call(env)

open_email('test@example.com')
current_email.click_link 'example'
page.should have_content 'Hello world!'
current_email.should have_content 'This is only a html test'
expect(page).to have_content 'Hello world!'
expect(current_email).to have_content 'This is only a html test'

all_emails.first.should eq email
expect(all_emails.first).to eq email

clear_emails
all_emails.should be_empty
expect(all_emails).to be_empty
end

# should read html_part
Expand All @@ -96,56 +96,56 @@ def self.call(env)

open_email('test@example.com')
current_email.click_link 'example'
page.should have_content 'Hello world!'
current_email.should have_content 'This is only a html test'
expect(page).to have_content 'Hello world!'
expect(current_email).to have_content 'This is only a html test'

all_emails.first.should eq email
expect(all_emails.first).to eq email

clear_emails
all_emails.should be_empty
expect(all_emails).to be_empty
end

scenario 'email content matchers' do
email = deliver(multipart_email)
open_email('test@example.com')
current_email.should have_link('another example', :href => 'http://example.com:1234')
expect(current_email).to have_link('another example', :href => 'http://example.com:1234')
end

scenario 'via ActionMailer' do
email = deliver(plain_email)

all_emails.first.should eq email
expect(all_emails.first).to eq email

clear_emails
all_emails.should be_empty
expect(all_emails).to be_empty
end

scenario 'via Mail' do
email = plain_email.deliver!

all_emails.first.should eq email
expect(all_emails.first).to eq email

clear_emails
all_emails.should be_empty
expect(all_emails).to be_empty
end

scenario 'multiple emails' do
deliver(plain_email)
deliver(Mail::Message.new(:to => 'test@example.com', :body => 'New Message', :context => 'text/plain'))
open_email('test@example.com')
current_email.body.should eq 'New Message'
expect(current_email.body).to eq 'New Message'
end

scenario "cc'd" do
deliver(Mail::Message.new(:cc => 'test@example.com', :body => 'New Message', :context => 'text/plain'))
open_email('test@example.com')
current_email.body.should eq 'New Message'
expect(current_email.body).to eq 'New Message'
end

scenario "bcc'd" do
deliver(Mail::Message.new(:bcc => 'test@example.com', :body => 'New Message', :context => 'text/plain'))
open_email('test@example.com')
current_email.body.should eq 'New Message'
expect(current_email.body).to eq 'New Message'
end
end

Expand Down
20 changes: 10 additions & 10 deletions spec/node/email_spec.rb
Expand Up @@ -12,7 +12,7 @@
end

it 'delegates to the base' do
email.body.should eq '<a href="http://example.com">example</a>'
expect(email.body).to eq '<a href="http://example.com">example</a>'
end
end

Expand All @@ -23,7 +23,7 @@
end

it 'delegates to the base' do
email.body.should eq 'http://example.com'
expect(email.body).to eq 'http://example.com'
end
end
end
Expand All @@ -34,7 +34,7 @@
end

it 'delegates to the base' do
email.subject.should eq 'Test subject'
expect(email.subject).to eq 'Test subject'
end
end

Expand All @@ -44,7 +44,7 @@
end

it 'delegates to the base' do
email.to.should include 'test@example.com'
expect(email.to).to include 'test@example.com'
end
end

Expand All @@ -54,7 +54,7 @@
end

it 'delegates to the base' do
email.reply_to.should include 'test@example.com'
expect(email.reply_to).to include 'test@example.com'
end
end

Expand All @@ -64,7 +64,7 @@
end

it 'delegates to the base' do
email.from.should include 'test@example.com'
expect(email.from).to include 'test@example.com'
end
end

Expand All @@ -74,7 +74,7 @@
end

it 'delegates to the base' do
email.header('header-key').should eq 'header_value'
expect(email.header('header-key')).to eq 'header_value'
end
end

Expand All @@ -85,14 +85,14 @@
end

it 'delegates to the base' do
email.headers.should include 'first-key'
email.headers.should include 'second-key'
expect(email.headers).to include 'first-key'
expect(email.headers).to include 'second-key'
end
end

describe '#inspect' do
it 'corrects class name' do
email.inspect.should eq '<Capybara::Node::Email>'
expect(email.inspect).to eq '<Capybara::Node::Email>'
end
end
end

0 comments on commit 217ab35

Please sign in to comment.