Skip to content

Instantly share code, notes, and snippets.

@kwstannard
Created August 30, 2012 16:31
Show Gist options
  • Save kwstannard/3532475 to your computer and use it in GitHub Desktop.
Save kwstannard/3532475 to your computer and use it in GitHub Desktop.
Testing modules
module Foo
def bar
"A cow"
end
end
describe Foo
let :subject_class { Class.new }
let :subject { subject_class.new }
before :each do
subject_class.class_eval { include Foo }
end
it "returns a cow" do
subject.bar.should eq "A cow"
end
end
@LogaJ
Copy link

LogaJ commented Mar 18, 2014

You can also use:

  before :each do
    subject.extend(Foo)
  end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment