Skip to content

Instantly share code, notes, and snippets.

View tpendragon's full-sized avatar

Trey Pendragon tpendragon

  • Princeton University Library
  • Salem, OR
View GitHub Profile
require 'rails_helper'
RSpec.describe StartersController do
describe "#index" do
fake(:starter_pet_finder, :all => [])
before do
stub(Tressonia::Pets::StarterPetFinder).new { starter_pet_finder }
get :index
end
it "finds the pets" do
15:55 smathy: terrellt, is the tl;dr that you're replacing capybara tests with controller and/or model tests?
15:57 smathy: Assuming so, capybara should be used only when it's impossible to test other ways.
15:57 pipework: I use feature tests for important workflows.
15:58 pipework: But I keep them pretty minimal and sometimes run them on-demand and just in CI, not in the default test suite rake task.
15:58 terrellt: smathy: Controller/model/view tests - effectively the tipping point for me is I'm deciding that there being an interface that I have to touch my tests for should I change it is a -good- thing.
15:59 terrellt: Whereas before I used feature specs to give me complete flexibility independent of architecture.
16:00 terrellt: pipework: I think where I'm landing now says that I'd avoid them ESPECIALLY for important workflows, because if I add that crutch I'm less likely to think critically about the architecture.
16:00 pipework: During development, I'll often write feature specs to drive implementation,
13:53 terrellt: I'm starting to flex my opinions about how specs should be written and I'd like some input from anybody out there writing Capybara specs.
13:53 terrellt: If somebody has time and an interest in the conversation, could you look at https://github.com/OregonDigital/oregondigital/pull/705 ?
13:55 jcoyne: terrellt: view specs are much better than feature specs for particular cases like this. Feature specs are great to make sure all the layers are connected together correctly
13:56 terrellt: If this were two years ago I'd scoff at view specs at all. If it were a year ago I'd agree and write a Capybara test to make sure what I'm testing here holds true.
13:57 terrellt: I'm starting to think enforcing the interface in my test does the last part.
13:57 jcoyne: terrellt: I like to think of feature specs like the features you describe to your users.
13:58 jcoyne: Like "You can upload a file, supply some metadata and then it shows up in the search"
13:58 jcoyne: But not the particular edge cases of that
module DynamicNetworkGraph
class NetworkFlow
def self.fields
%w{srcAddr dstAddr srcPort dstPort protocol start end packets transferred status}
end
fields.each do |field|
attr_accessor field
end
-@list.group_by(&:category).each do |category, items|
%ul
-items.each do |item|
%li=item.name
require 'spec_helper'
describe Project do
let!(:user) { FactoryGirl.create(:user) }
let!(:plan) { FactoryGirl.create(:plan_with_subscription, user: user) }
it "has a valid factory" do
FactoryGirl.create(:project, user: user). should be_valid
end
default:
plugins:
- textcolor
- link
- fullscreen
- preview
- code
- contextmenu
- paste
Run options: include {:locations=>{"./spec/controllers/shelters_controller_spec.rb"=>[61]}}
SheltersController
Fails to PATCH update when submitting invalid data
"#<ActiveModel::Errors:0x00000005446ad8 @base=#<Shelter id: 1, name: nil, phone_number: \"606-555-1212\",
contact_person: \"Shelter Contact\", rescue_group_id: nil, created_at: \"2013-12-27 20:33:10\",
updated_at: \"2013-12-27 20:33:10\">, @messages={:name=>[\"can't be blank\"]}>"
"#<ActionDispatch::Flash::FlashHash:0x000000068fdd28 @discard=#<Set: {}>,
@flashes={:notice=>\"Successfully updated Shelter!\"}, @now=nil>"
fails to update a shelter with bad info
describe "relationships" do
before(:each) do
@new_object = DummyAsset.new
@new_object.title = "subbla"
@new_object.save
subject.title = "bla"
subject.descMetadata.creator = @new_object
end
it "should have accessible relationship attributes" do
expect(subject.descMetadata.license.title).to eq "subbla"
@tpendragon
tpendragon / search.rb
Last active December 26, 2015 03:39 — forked from Viswanathantv/search
class MainsController < ApplicationController
def index
[City, State, Country].each do |klass|
@search = klass.search(params[:q])
@result = @search.result
break unless @result.blank?
end
end