<commit_before># -*- coding: utf-8 -*-

# Import Salt Testing libs
from salttesting import skipIf, TestCase
from salttesting.helpers import ensure_in_syspath
from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch
ensure_in_syspath('../../')

# Import salt libs
import salt.modules.gem as gem

gem.__salt__ = {}


@skipIf(NO_MOCK, NO_MOCK_REASON)
class TestGemModule(TestCase):

    def test__gem(self):
        mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
        with patch.dict(gem.__salt__,
                        {'rvm.is_installed': MagicMock(return_value=False),
                         'rbenv.is_installed': MagicMock(return_value=False),
                         'cmd.run_all': mock}):
            gem._gem('install rails')
            mock.assert_called_once_with('gem install rails', runas=None)

        mock = MagicMock(return_value=None)
        with patch.dict(gem.__salt__,
                        {'rvm.is_installed': MagicMock(return_value=True),
                         'rbenv.is_installed': MagicMock(return_value=False),
                         'rvm.do': mock}):
            gem._gem('install rails', ruby='1.9.3')
            mock.assert_called_once_with(
                '1.9.3', 'gem install rails', runas=None
            )

        mock = MagicMock(return_value=None)
        with patch.dict(gem.__salt__,
                        {'rvm.is_installed': MagicMock(return_value=False),<commit_msg>Fix gem failure<commit_after># -*- coding: utf-8 -*-

# Import Salt Testing libs
from salttesting import skipIf, TestCase
from salttesting.helpers import ensure_in_syspath
from salttesting.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch
ensure_in_syspath('../../')

# Import salt libs
import salt.modules.gem as gem

gem.__salt__ = {}


@skipIf(NO_MOCK, NO_MOCK_REASON)
class TestGemModule(TestCase):

    def test__gem(self):
        mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
        with patch.dict(gem.__salt__,
                        {'rvm.is_installed': MagicMock(return_value=False),
                         'rbenv.is_installed': MagicMock(return_value=False),
                         'cmd.run_all': mock}):
            gem._gem('install rails')
            mock.assert_called_once_with('gem install rails', runas=None, python_shell=False)

        mock = MagicMock(return_value=None)
        with patch.dict(gem.__salt__,
                        {'rvm.is_installed': MagicMock(return_value=True),
                         'rbenv.is_installed': MagicMock(return_value=False),
                         'rvm.do': mock}):
            gem._gem('install rails', ruby='1.9.3')
            mock.assert_called_once_with(
                '1.9.3', 'gem install rails', runas=None
            )

        mock = MagicMock(return_value=None)
        with patch.dict(gem.__salt__,
                        {'rvm.is_installed': MagicMock(return_value=False),
{'fraction_non_alphanumeric': 0.11885245901639344, 'fraction_numerical': 0.00546448087431694, 'mean_word_length': 2.343607305936073, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2338674', 'n_tokens_mistral': 925, 'n_tokens_neox': 866, 'n_words': 164}