Sha256: a5ac201966fd346ccba31bd69bb366d0b90b114831749d460f43e1ffc250af70

Contents?: true

Size: 1.21 KB

Versions: 6

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'

describe Sheet::Open do

  it "should show a message when the app doesn't exist" do
    message = "A cheat named rails doesn't exist.\nYou can create one with sheet new rails"
    Sheet.should_receive(:write).with(message)

    Sheet::Open.new('rails').open
  end

  it "should output the sheet content" do
    message = "My sheet about git"
    Sheet.should_receive(:write).with(message)

    s = Sheet::Open.new('git')
    Sheet.stub(:sheet_exists?).with('git') { true }
    s.stub(:sheet_content) { message }
    s.open
  end

  it "should open a url" do
    Sheet.stub(:open_command) { 'open' }
    message = "url: http://example.com"
    Sheet.should_receive(:exec).with('open http://example.com')

    s = Sheet::Open.new('git')
    Sheet.stub(:sheet_exists?).with('git') { true }
    s.stub(:sheet_content) { message }
    s.open
  end

  it "should fallback to showing the content if an open command is not present" do
    Sheet.stub(:open_command) { nil}
    message = "url: http://example.com"
    Sheet.should_receive(:puts).with('url: http://example.com')

    s = Sheet::Open.new('git')
    Sheet.stub(:sheet_exists?).with('git') { true }
    s.stub(:sheet_content) { message }
    s.open
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sheet-0.1.5 spec/sheet/open_spec.rb
sheet-0.1.4 spec/sheet/open_spec.rb
sheet-0.1.3 spec/sheet/open_spec.rb
sheet-0.1.2 spec/sheet/open_spec.rb
sheet-0.1.1 spec/sheet/open_spec.rb
sheet-0.1.0 spec/sheet/open_spec.rb