Skip to content

Instantly share code, notes, and snippets.

@colby-swandale
Last active February 20, 2016 05:24
Show Gist options
  • Save colby-swandale/f7d71ca03e12b82ec64b to your computer and use it in GitHub Desktop.
Save colby-swandale/f7d71ca03e12b82ec64b to your computer and use it in GitHub Desktop.
class CPU
attr_reader :f
def initialize
@f = 0x00
end
def instruction
if @f & 0x10 == 0x10
# do something
else
# do something else
end
end
end
### RSPEC
describe CPU
let(:cpu) { CPU.new }
describe '#instruction' do
context 'when register state is 0x10' do
before { CPU.instance_variable_set "@#{f}", 0x10 } # <-- can this be improved?
it 'does something'
end
it 'does something else'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment