Skip to content

Commit

Permalink
Merge pull request DavyJonesLocker#41 from twalpole/loosen_capybara_req
Browse files Browse the repository at this point in the history
Loosen capybara req and change to rspec expect syntax
  • Loading branch information
bcardarella committed Jun 5, 2014
2 parents 86e0b7d + a3c88d6 commit 19fae33
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 52 deletions.
18 changes: 9 additions & 9 deletions README.md
Expand Up @@ -47,19 +47,19 @@ feature 'Emailer' do

scenario 'following a link' do
current_email.click_link 'your profile'
page.should have_content 'Profile page'
expect(page).to have_content 'Profile page'
end

scenario 'testing for content' do
current_email.should have_content 'Hello Joe!'
expect(current_email).to have_content 'Hello Joe!'
end

scenario 'testing for a custom header' do
current_email.headers.should include 'header-key'
expect(current_email.headers).to include 'header-key'
end

scenario 'testing for a custom header value' do
current_email.header('header-key').should eq 'header_value'
expect(current_email.header('header-key')).to eq 'header_value'
end

scenario 'view the email body in your browser' do
Expand Down Expand Up @@ -96,7 +96,7 @@ Scenario: Email is sent to winning user

Then /^"([^"]*)" receives an email with "([^"]*)" as the subject$/ do |email_address, subject|
open_email(email_address)
current_email.subject.should eq subject
expect(current_email.subject).to eq subject
end
```

Expand Down Expand Up @@ -132,19 +132,19 @@ class EmailTriggerControllerTest < ActionController::IntegrationTest

test 'following a link' do
current_email.click_link 'your profile'
page.should have_content 'Profile page'
expect(page).to have_content 'Profile page'
end

test 'testing for content' do
current_email.should have_content 'Hello Joe!'
expect(current_email).to have_content 'Hello Joe!'
end

test 'testing for a custom header' do
current_email.headers.should include 'header-key'
expect(current_email.headers).to include 'header-key'
end

test 'testing for a custom header value' do
current_email.header('header-key').should eq 'header_value'
expect(current_email.header('header-key')).to eq 'header_value'
end

test 'view the email body in your browser' do
Expand Down
2 changes: 1 addition & 1 deletion capybara-email.gemspec
Expand Up @@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
gem.version = Capybara::Email::VERSION

gem.add_dependency 'mail'
gem.add_dependency 'capybara', '~> 2.2.0'
gem.add_dependency 'capybara', '~> 2.2'
gem.add_development_dependency 'actionmailer', '> 3.0'
gem.add_development_dependency 'bourne'
gem.add_development_dependency 'rspec'
Expand Down
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 19fae33

Please sign in to comment.