Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ruby

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
Avatar for Daichi Hirata Daichi Hirata
September 25, 2013
120

 Ruby

Avatar for Daichi Hirata

Daichi Hirata

September 25, 2013
Tweet

Transcript

  1. describe Stack do context '৽ن࡞੒ͷ৔߹' do before { @stack =

    Stack.new } subject { @stack } its(:empty?) { should be_true } end context 'ۭͷ৔߹' do before { @stack = Stack.new } describe '#size' do subject { @stack.size } it { should == 0 } end describe '#pop' do subject { lambda { @stack.pop } } it { should raise_error(Stack::EmptyError) } end describe '#push' do subject { lambda { @stack.push(Object.new) } } it { should change(@stack, :size).by(1) } end end end
  2. pry(main)> cd FileUtils pry(FileUtils):1> show-method rm From: /opt/ruby/lib/ruby/1.9.1/fileutils.rb @ line

    556: Number of lines: 10 Owner: FileUtils def rm(list, options = {}) fu_check_options options, OPT_TABLE['rm'] list = fu_list(list) fu_output_message "rm#{options[:force] ? ' -f' : ''} #{list.join ' '}" if options[:verbose] return if options[:noop] list.each do |path| remove_file path, options[:force] end end pry(FileUtils):2>
  3. require 'pry' class Hello attr_reader :message def initialize @message =

    "Hello Variable!" end def say_hello puts @message end end describe Hello do it "has a say_hello method" do binding.pry subject.respond_to?(:say_hello) end end