My first post on SO... so wanted to start off with a quick thank you for everything I've been able to learn from here!
I'm working on my first RoR application... and it's coming together nicely. I believe I have a decent handle on controller, feature, and view specs... not so much request specs, and especially not model specs. With some research, I've been able to get something going with request specs (not sure if this is enough though), but I haven't really been able to find any useful guides on what should be in the model specs...
I have read through a ton of links from the Goog... but haven't been able to find a good guide (expect for one that is pretty out of date). If someone could steer me to a good guide, or make some reco's, it would be very appreciated.
Ex: Request Spec so Far:
require 'rails_helper'
RSpec.describe "Datasets", type: :request do
let (:user) {create(:user)}
let (:dataset) {create(:dataset, created_by: user.to_param)}
before(:each) do
sign_in_as_a_valid_user
end
describe "GET /admin/dataset/datasets" do
it "displays dataset index" do
get admin_datasets_path
expect(response).to have_http_status(200)
end
end
describe "GET /admin/dataset/datasets/1" do
it "displays dataset show" do
get admin_dataset_path(dataset, tab: "items")
expect(response).to have_http_status(200)
end
end
describe "EDIT /admin/dataset/datasets/1" do
it "displays dataset edit" do
get edit_admin_dataset_path(dataset)
expect(response).to have_http_status(200)
end
end
describe "NEW /admin/dataset/datasets/" do
it "displays dataset new" do
get admin_dashboard_path
expect(response).to have_http_status(200)
end
end
end
Ex: Model Spec so far...
require 'rails_helper'
describe Dataset do
let (:user) {create(:user)}
it "has a valid factory" do
expect(create(:dataset, created_by: user.to_param)).to be_valid
end
describe 'validations' do
it {should validate_presence_of(:title)}
it {should validate_presence_of(:created_by)}
end
end
Aucun commentaire:
Enregistrer un commentaire