This file contains hidden or 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 "Error Handling" do | |
describe "Active Record Not Found" do | |
controller do | |
def index | |
raise ActiveRecord::RecordNotFound | |
end | |
end | |
This file contains hidden or 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 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 |
This file contains hidden or 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
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, |
This file contains hidden or 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
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 |
This file contains hidden or 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
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 |
This file contains hidden or 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
[email protected]_by(&:category).each do |category, items| | |
%ul | |
-items.each do |item| | |
%li=item.name |
This file contains hidden or 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 '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 |
This file contains hidden or 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
default: | |
plugins: | |
- textcolor | |
- link | |
- fullscreen | |
- preview | |
- code | |
- contextmenu | |
- paste |
This file contains hidden or 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
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 |
This file contains hidden or 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
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" |