summaryrefslogtreecommitdiff
path: root/spec/mspec/spec/helpers/argv_spec.rb
blob: c3b21c7639aee11645fb7d5eea772864df78e256 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
require 'spec_helper'
require 'mspec/guards'
require 'mspec/helpers'

describe Object, "#argv" do
  before :each do
    ScratchPad.clear

    @saved_argv = ARGV.dup
    @argv = ["a", "b"]
  end

  it "replaces and restores the value of ARGV" do
    argv @argv
    ARGV.should == @argv
    argv :restore
    ARGV.should == @saved_argv
  end

  it "yields to the block after setting ARGV" do
    argv @argv do
      ScratchPad.record ARGV.dup
    end
    ScratchPad.recorded.should == @argv
    ARGV.should == @saved_argv
  end
end