Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated README.md testing example #84

Merged
merged 1 commit into from
May 5, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 5 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -481,11 +481,9 @@ context.

```ruby
describe AuthenticateUser do
describe "#call" do

let(:interactor) { AuthenticateUser.new(email: "john@example.com", password: "secret") }
let(:context) { interactor.context }
subject(:context) { AuthenticateUser.call(email: "john@example.com", password: "secret") }

describe ".call" do
context "when given valid credentials" do
let(:user) { double(:user, secret_token: "token") }

Expand All @@ -494,25 +492,15 @@ describe AuthenticateUser do
end

it "succeeds" do
interactor.call

expect(context).to be_a_success
end

it "provides the user" do
expect {
interactor.call
}.to change {
context.user
}.from(nil).to(user)
expect(context.user).to eq(user)
end

it "provides the user's secret token" do
expect {
interactor.call
}.to change {
context.token
}.from(nil).to("token")
expect(context.token).to eq("token")
end
end

Expand All @@ -522,17 +510,11 @@ describe AuthenticateUser do
end

it "fails" do
interactor.call

expect(context).to be_a_failure
end

it "provides a failure message" do
expect {
interactor.call
}.to change {
context.message
}.from(nil).to be_present
expect(context.message).to be_present
end
end
end
Expand Down