Created
March 4, 2015 09:56
-
-
Save anonymous/797e5c79acdc33f510ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rails_helper" | |
RSpec.describe "Lessons", type: :request do | |
before { create_user } | |
it "renders index" do | |
get api_lessons_path | |
end | |
it "returns all lessons" do | |
FactoryGirl.create(:lesson) | |
FactoryGirl.create(:lesson) | |
get api_lessons_path | |
expect(response.status).to eq 200 | |
body = JSON.parse(response.body) | |
lesson_titles = body.map {|l| l["title"] } | |
expect(lesson_titles).to match_array(["foo1", "foo2"]) | |
end | |
it "returns a lesson" do | |
lesson = FactoryGirl.create(:lesson) | |
get api_lesson_path(lesson) | |
body = JSON.parse(response.body) | |
expect(body["title"]).to eq "foo3" | |
end | |
it "creates a lesson" do | |
post "/api/lessons", title: "this is a test" | |
expect(response.status).to eq 201 | |
expect(Lesson.first.title).to eq "this is a test" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment