Last active
August 29, 2015 14:25
-
-
Save umate/73bde682b4bb9f8fe535 to your computer and use it in GitHub Desktop.
This file contains 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
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 |
This file contains 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 '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