Skip to content

Instantly share code, notes, and snippets.

@umate
Last active August 29, 2015 14:25
Show Gist options
  • Save umate/73bde682b4bb9f8fe535 to your computer and use it in GitHub Desktop.
Save umate/73bde682b4bb9f8fe535 to your computer and use it in GitHub Desktop.
class Service
def self.instance
@instance ||= self.new
end
def initialize
end
def perform_action
puts 'aciton performing'
end
end
10.times do |variable|
puts Service.instance.to_s
end
require 'test_helper'
class PostsControllerTest < ActionController::TestCase
# called before every single test
def setup
@post = posts(:one)
end
# called after every single test
def teardown
# as we are re-initializing @post before every test
# setting it to nil here is not essential but I hope
# you understand how you can use the teardown method
@post = nil
end
test "should show post" do
get :show, :id => @post.id
assert_response :success
end
test "should destroy post" do
assert_difference('Post.count', -1) do
delete :destroy, :id => @post.id
end
assert_redirected_to posts_path
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment