Skip to content

Instantly share code, notes, and snippets.

@heronmedeiros
Created August 27, 2012 13:25
Show Gist options
  • Save heronmedeiros/3488389 to your computer and use it in GitHub Desktop.
Save heronmedeiros/3488389 to your computer and use it in GitHub Desktop.
class Klass
def self.foo
File.open "filename", "w" do |file|
file.write("text")
end
end
end
describe "foo" do
it "should create 'filename' and put 'text' in it" do
file = mock('file')
File.should_receive(:open).with("filename", "w").and_yield(file)
file.should_receive(:write).with("text")
foo
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment