<commit_before>require 'spec_helper'
require 'mobvious/rails/helper'

module Mobvious
module Rails
class HelperSpec < MiniTest::Spec
  describe Helper do
    before do
      @helper = Object.new
      @request = mock 'request'
      @env = mock 'env'
      @env.stubs('[]').with('mobvious.device_type').returns(:mobile)
      @request.stubs(:env).returns(@env)

      mock_request = @request
      @helper.extend Helper
      @helper.define_singleton_method(:request) do
        mock_request
      end
    end

    it "runs the provided block only for corresponding device type" do
      mobile_block_executed = false
      desktop_block_executed = false

      @helper.device :mobile do
        mobile_block_executed = true
      end
      @helper.device :desktop do
        desktop_block_executed = true
      end
<commit_msg>spec preparation refactoring to be more readable<commit_after>require 'spec_helper'
require 'mobvious/rails/helper'

module Mobvious
module Rails
class HelperSpec < MiniTest::Spec
  describe Helper do
    before do
      @env = mock 'env'
      @env.stubs('[]').with('mobvious.device_type').returns(:mobile)

      @request = mock 'request'
      @request.stubs(:env).returns(@env)
      mock_request = @request

      @helper = Object.new
      @helper.extend Helper
      @helper.define_singleton_method(:request) do
        mock_request
      end
    end

    it "runs the provided block only for corresponding device type" do
      mobile_block_executed = false
      desktop_block_executed = false

      @helper.device :mobile do
        mobile_block_executed = true
      end
      @helper.device :desktop do
        desktop_block_executed = true
      end

{'fraction_non_alphanumeric': 0.08392434988179669, 'fraction_numerical': 0.0, 'mean_word_length': 2.8477272727272727, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2118135', 'n_tokens_mistral': 501, 'n_tokens_neox': 484, 'n_words': 130}