Created
March 4, 2015 10:18
-
-
Save anonymous/0bba2a2cb5af598bbad1 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 } | |
def json_response | |
JSON.parse(response.body) | |
end | |
def force(*); end | |
def fetch(key) | |
->(r){ r[key] } | |
end | |
context "GET /some/path" do | |
context "when there are no lessons" do | |
it "returns an empty set" do | |
get api_lesson_path | |
expect(json_response).to be_empty | |
end | |
end | |
context "when there are lessons" do | |
let(:lessons){ FactoryGirl.create_list(:lesson,2) } | |
before{ force(lessons) } | |
it "returns all lessons" do | |
get api_lesson_path | |
expect(json_response.map(&fetch('title'))).to match_arry(lessons.map(&fetch('title'))) | |
end | |
end | |
end | |
context "GET /some/path/id" do | |
context "when there exists a lesson with that id" | |
context "when there exists no lesson with that id" | |
end | |
# etc ... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment