Last active
December 14, 2015 13:28
-
-
Save bengm/5093104 to your computer and use it in GitHub Desktop.
This is how I got my first set of fast tests running. There are probably a dozen ways to do it better, but this worked for me. I wanted to test some rails helper methods that had simple interfaces and no dependency on rails. Here's how I finally got it working.
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
# spec/helpers/my_helper_spec.rb | |
# note: must replace references to my_helper/MyHelper to appropriate name | |
# require any dependencies - I needed date/time so just included all of active support | |
require 'active_support/all' | |
# require the specific helper module | |
require_relative "../../app/helpers/my_helper.rb" | |
class DummyClass | |
end | |
describe MyHelper do | |
before(:each) do | |
@helper = DummyClass.new | |
@helper.extend(MyHelper) | |
end | |
it "should return something" do | |
@helper.some_method.should eq "something" | |
end | |
# ... more tests | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment