Skip to content

Instantly share code, notes, and snippets.

@dblessing
Last active August 29, 2015 14:17
Show Gist options
  • Save dblessing/9f711d11dfe8743c17e9 to your computer and use it in GitHub Desktop.
Save dblessing/9f711d11dfe8743c17e9 to your computer and use it in GitHub Desktop.
Stub IO.read
require 'spec_helper'
describe KnifeCookbookDoc::AttributesModel do
describe '#load_descriptions' do
before do
allow(IO).to receive(:read).with('attributes/default.rb').and_return(attributes)
end
let(:attributes) {
<<EOS
#<> Single line comment
default['knife_cookbook_doc']['attr1'] = 'attr1'
#<
# Multiline comment with single line of text
#>
=begin
#<
Multiline begin/end with single line of text
#>
EOS
}
end
subject { IO.read('attributes/default.rb') }
it { is_expected.to match /thing/ }
end
---- ERROR: No such file or directory @ rb_sysopen - attributes/default.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment