Skip to content

Instantly share code, notes, and snippets.

@mustmodify
Created August 22, 2014 15:16
Show Gist options
  • Save mustmodify/71016edc80dffe3264f2 to your computer and use it in GitHub Desktop.
Save mustmodify/71016edc80dffe3264f2 to your computer and use it in GitHub Desktop.
something wacky this way comes
it 'searches by zipcode' do
puts "Before this bruhaha, zipcode count is #{Zipcode.count}: #{Zipcode.all.map(&:code)}"
needle = Zipcode.where(:code => '90333').first || FactoryGirl.create(:zipcode, code: '90333')
puts "in the middle, zipcode count is #{Zipcode.count}: #{Zipcode.all.map(&:code)}"
get :search, :format => :json, :code => 90333
assigns(:zipcodes).should have(1).entry
assigns(:zipcodes).should include(needle)
puts "Afterwards, zipcode count is #{Zipcode.count}: #{Zipcode.all.map(&:code)}"
needle.delete
end
end
Before this bruhaha, zipcode count is 1: ["90210"]
in the middle, zipcode count is 2: ["90210", "90333"]
Afterwards, zipcode count is 2: ["90210", "90333"]
F
Failures:
1) ZipcodesController search searches by zipcode
Failure/Error: assigns(:zipcodes).should include(needle)
expected [#<Zipcode id: 62, code: "90333", city: "Los Angeles", state: "CA", latitude: nil, longitude: nil, kml: nil, created_at: "2014-08-22 15:02:36", updated_at: "2014-08-22 15:02:36", time_zone: "--- :null\n">] to include #<Zipcode id: 104, code: "90333", city: "Somewhere", state: "WA", latitude: nil, longitude: nil, kml: nil, created_at: "2014-08-22 15:15:59", updated_at: "2014-08-22 15:15:59", time_zone: "--- :null\n">
Diff:
@@ -1,2 +1,2 @@
-[#<Zipcode id: 104, code: "90333", city: "Somewhere", state: "WA", latitude: nil, longitude: nil, kml: nil, created_at: "2014-08-22 15:15:59", updated_at: "2014-08-22 15:15:59", time_zone: "--- :null\n">]
+[#<Zipcode id: 62, code: "90333", city: "Los Angeles", state: "CA", latitude: nil, longitude: nil, kml: nil, created_at: "2014-08-22 15:02:36", updated_at: "2014-08-22 15:02:36", time_zone: "--- :null\n">]
# ./spec/controllers/zipcodes_controller_spec.rb:23:in `block (3 levels) in <top (required)>'
Finished in 0.64956 seconds
1 example, 1 failure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment