summaryrefslogtreecommitdiff
path: root/spec/controllers/api/v1/tutorials_controller_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/controllers/api/v1/tutorials_controller_spec.rb')
-rw-r--r--spec/controllers/api/v1/tutorials_controller_spec.rb17
1 files changed, 8 insertions, 9 deletions
diff --git a/spec/controllers/api/v1/tutorials_controller_spec.rb b/spec/controllers/api/v1/tutorials_controller_spec.rb
index 7d7ef5c6..d1e9a749 100644
--- a/spec/controllers/api/v1/tutorials_controller_spec.rb
+++ b/spec/controllers/api/v1/tutorials_controller_spec.rb
@@ -1,20 +1,20 @@
require "rails_helper"
describe Api::V1::TutorialsController do
+ render_views
let(:user) { create(:user) }
before :each do
- request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Token.encode_credentials(user.authentication_token)
+ api_login(user)
end
describe "#index" do
- let(:my_tutorial) { create(:tutorial, user: user) }
- let(:other_tutorial) { create(:tutorial) }
+ let!(:my_tutorial) { create(:tutorial, user: user) }
+ let!(:other_tutorial) { create(:tutorial) }
it "returns the users tutorials" do
xhr :get, :index
- expect(assigns(:tutorials)).to include(my_tutorial)
- expect(assigns(:tutorials)).to_not include(other_tutorial)
+ expect(assigns(:tutorials)).to match_array([my_tutorial])
end
end
@@ -22,9 +22,9 @@ describe Api::V1::TutorialsController do
it "creates a new tutorial" do
attributes = {
url: "https://twitter.com/",
- image_url: "https://abs.twimg.com/a/1405611403/img/t1/front_page/exp_wc2014_gen_laurenlemon.jpg",
+ image_url: "https://abs.twimg.com/a/img/t1/lemon.jpg",
heading: "Twitter",
- description: "Connect with your friends - and other fascinating people. Get in-the-moment updates on the things that interest you. And watch events unfold, in real time, from every angle.",
+ description: "Connect with your friends - and other fascinating people",
tags: "cake,cookie",
}
xhr :post, :create, tutorial: attributes
@@ -34,8 +34,7 @@ describe Api::V1::TutorialsController do
expect(assigns(:tutorial).description).to eql(attributes[:description])
expect(assigns(:tutorial).heading).to eql(attributes[:heading])
expect(assigns(:tutorial).tags.count).to eql(2)
- expect(assigns(:tutorial).tags.first.name).to eql('cake')
- expect(assigns(:tutorial).tags.last.name).to eql('cookie')
+ expect(assigns(:tutorial).tags.pluck(:name)).to match_array(["cake", "cookie"])
end
end
end