test/test_command.rb in boom-0.2.0 vs test/test_command.rb in boom-0.2.1

- old
+ new

@@ -31,11 +31,12 @@ def command(cmd) cmd = cmd.split(' ') if cmd Boom::Command.capture_output Boom::Command.execute(*cmd) - Boom::Command.captured_output + output = Boom::Command.captured_output + output.gsub(/\e\[\d\d?m/, '') end def test_overview_for_empty storage = Boom::Storage storage.stubs(:lists).returns([]) @@ -56,13 +57,17 @@ assert_match /urls/, cmd assert_match /github/, cmd end def test_list_creation - assert_match /a new list called "newlist"/, command('newlist') + assert_match /a new list called newlist/, command('newlist') end + def test_list_creation_with_item + assert_match /a new list called newlist.* item in newlist/, command('newlist item blah') + end + def test_item_access assert_match /copied https:\/\/github\.com to your clipboard/, command('github') end @@ -70,28 +75,26 @@ assert_match /copied https:\/\/github\.com to your clipboard/, command('urls github') end def test_item_open_url - Boom::Platform.stubs(:open_command).returns("echo") - assert_match /opened https:\/\/github\.com for you/, - command('open github') + Boom::Platform.stubs(:system).returns('') + assert_match /opened https:\/\/github\.com for you/, command('open github') end def test_item_open_lists - Boom::Platform.stubs(:open_command).returns("echo") - assert_match /opened all of \"urls\" for you/, - command('open urls') + Boom::Platform.stubs(:system).returns('') + assert_match /opened all of urls for you/, command('open urls') end def test_item_creation - assert_match /"twitter" in "urls"/, + assert_match /twitter in urls/, command('urls twitter http://twitter.com/holman') end def test_item_creation_long_value - assert_match /is "tanqueray hendricks bombay"/, + assert_match /is tanqueray hendricks bombay/, command('urls gins tanqueray hendricks bombay') end def test_list_deletion_no STDIN.stubs(:gets).returns('n') @@ -102,15 +105,15 @@ STDIN.stubs(:gets).returns('y') assert_match /Deleted all your urls/, command('urls delete') end def test_item_deletion - assert_match /"github" is gone forever/, command('urls github delete') + assert_match /github is gone forever/, command('urls github delete') end def test_edit - Boom::Command.stubs(:system).returns('') + Boom::Platform.stubs(:system).returns('') assert_match 'Make your edits', command('edit') end def test_help assert_match 'boom help', command('help') @@ -122,11 +125,11 @@ assert_match 'boom help', command('--anything') assert_match 'boom help', command('-d') end def test_nonexistent_item_access_scoped_by_list - assert_match /"twitter" not found in "urls"/, command('urls twitter') + assert_match /twitter not found in urls/, command('urls twitter') end def test_echo_item assert_match /https:\/\/github\.com/, command('echo github') end @@ -134,22 +137,23 @@ def test_echo_item_shorthand assert_match /https:\/\/github\.com/, command('e github') end def test_echo_item_does_not_exist - assert_match /"wrong" not found/, command('echo wrong') + assert_match /wrong not found/, command('echo wrong') end def test_echo_list_item assert_match /https:\/\/github\.com/, command('echo urls github') end def test_echo_list_item_does_not_exist - assert_match /"wrong" not found in "urls"/, command('echo urls wrong') + assert_match /wrong not found in urls/, command('echo urls wrong') end def test_show_storage + Boom::Config.any_instance.stubs(:attributes).returns('backend' => 'json') assert_match /You're currently using json/, command('storage') end def test_nonexistant_storage_switch Boom::Config.any_instance.stubs(:save).returns(true) @@ -165,7 +169,15 @@ assert_match /#{Boom::VERSION}/, command('-v') end def test_version_long assert_match /#{Boom::VERSION}/, command('--version') + end + + def test_stdin_pipes + stub = Object.new + stub.stubs(:stat).returns([1,2]) + stub.stubs(:read).returns("http://twitter.com") + Boom::Command.stubs(:stdin).returns(stub) + assert_match /twitter in urls/, command('urls twitter') end end