<commit_before>require File.expand_path('./rspec_helper', File.dirname(__FILE__))
require 'view_assets/action_view'

describe ActionViewHelpers do
  class Dummy
    include ActionViewHelpers
  end
  AVH_TEST_ROOT = File.expand_path('./fixtures/action_view', File.dirname(__FILE__))

  describe "#retrieve_assets" do
    context "Production Mode" do
      let(:va) { Dummy.new }
      before(:each) do
        Rails.stub(:public_path).and_return(AVH_TEST_ROOT)
        Rails.stub_chain('env.production?').and_return(:true)
      end

      it "retrieve specific controller and action" do
        va.should_receive(:raw).with(
          ViewAssets.tag(:css, '/assets/stylesheets/controller1_action1-d41d8cd98f00b204e9800998ecf8427e.css')
        ).ordered
        va.should_receive(:raw).with(
          ViewAssets.tag(:js, '/assets/javascripts/controller1_action1-d41d8cd98f00b204e9800998ecf8427e.js')
        ).ordered

        va.retrieve_assets('controller1', 'action1')
      end

      it "retrieve controller assets when action assets is nonexistent" do
        va.should_receive(:raw).with(
          ViewAssets.tag(:css, '/assets/stylesheets/controller3-d41d8cd98f00b204e9800998ecf8427e.css')
        ).ordered
        va.should_receive(:raw).with(
          ViewAssets.tag(:js, '/assets/javascripts/controller3-d41d8cd98f00b204e9800998ecf8427e.js')
        ).ordered

        va.retrieve_assets('controller3', 'action3')
      end

      it "retrieve application assets when controller and action assets are both nonexistent" do
        va.should_receive(:raw).with(
          ViewAssets.tag(:css, '/assets/stylesheets/application-d41d8cd98f00b204e9800998ecf8427e.css')
        ).ordered
        va.should_receive(:raw).with(
          ViewAssets.tag(:js, '/assets/javascripts/application-d41d8cd98f00b204e9800998ecf8427e.js')
        ).ordered

        va.retrieve_assets('controller2', 'action1')
      end
    end
  end
end<commit_msg>fix action_view_helpers rspec examples<commit_after>require File.expand_path('./rspec_helper', File.dirname(__FILE__))
require 'view_assets/action_view'

describe ActionViewHelpers do
  class Dummy
    include ActionViewHelpers
  end
  AVH_TEST_ROOT = File.expand_path('./fixtures/action_view', File.dirname(__FILE__))

  describe "#retrieve_assets" do
    context "Production Mode" do
      let(:va) { Dummy.new }
      before(:each) do
        Rails.stub(:public_path).and_return(AVH_TEST_ROOT)
        Rails.stub_chain('env.production?').and_return(:true)
      end

      it "retrieve specific controller and action" do
        css_assets = ViewAssets.tag(:css, '/assets/stylesheets/controller1_action1-d41d8cd98f00b204e9800998ecf8427e.css')
        js_assets = ViewAssets.tag(:js, '/assets/javascripts/controller1_action1-d41d8cd98f00b204e9800998ecf8427e.js')
        va.should_receive(:raw).with("#{css_assets}\n #{js_assets}")

        va.retrieve_assets('controller1', 'action1')
      end

      it "retrieve controller assets when action assets is nonexistent" do
        css_assets = ViewAssets.tag(:css, '/assets/stylesheets/controller3-d41d8cd98f00b204e9800998ecf8427e.css')
        js_assets = ViewAssets.tag(:js, '/assets/javascripts/controller3-d41d8cd98f00b204e9800998ecf8427e.js')
        va.should_receive(:raw).with("#{css_assets}\n #{js_assets}")

        va.retrieve_assets('controller3', 'action3')
      end

      it "retrieve application assets when controller and action assets are both nonexistent" do
        css_assets = ViewAssets.tag(:css, '/assets/stylesheets/application-d41d8cd98f00b204e9800998ecf8427e.css')
        js_assets = ViewAssets.tag(:js, '/assets/javascripts/application-d41d8cd98f00b204e9800998ecf8427e.js')
        va.should_receive(:raw).with("#{css_assets}\n #{js_assets}")

        va.retrieve_assets('controller2', 'action1')
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.1116593092703194, 'fraction_numerical': 0.07166969618280966, 'mean_word_length': 3.7032967032967035, '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': '779961', 'n_tokens_mistral': 1431, 'n_tokens_neox': 1273, 'n_words': 194}