<commit_before>require 'spec_helper'
require 'maptastic/view_helpers/action_view'

describe Maptastic::ViewHelpers::ActionView do
  
  context "#maptastic_provider_tag" do
    it "should exist" do
      helper.should respond_to :maptastic_provider_tag
    end

    it "should return a script tag" do
      helper.maptastic_provider_tag.should have_selector("script[type='text/javascript']")
    end

    it "should include the API key in the Url" do
      Maptastic.stub(:api_key => "SOME_RANDOM_API_KEY")
      helper.maptastic_provider_tag.should match /key=SOME_RANDOM_API_KEY/
    end
    
    it "should include the sensor param when set to true" do
      Maptastic.stub(:sensor => true)
      helper.maptastic_provider_tag.should match /sensor=true/
    end
    
    it "should include the sensor param when set to false" do
      Maptastic.stub(:sensor => false)
      helper.maptastic_provider_tag.should match /sensor=false/
    end
    
    it "should not include the sensor param when not set" do
      Maptastic.stub(:sensor => nil)
      helper.maptastic_provider_tag.should_not match /sensor=(false|true)/
    end
    
    it "should use the current I18n.locale" do
      I18n.stub(:locale => :de)
      helper.maptastic_provider_tag.should match /hl=de/
    end
    
    it "should use the locale defined in the config when available" do
      I18n.stub(:locale => :en)
      Maptastic.stub(:locale => :de)
      helper.maptastic_provider_tag.should match /hl=de/
    end
  end
  
  context "#maptastic" do
    
    it "should have a data-map=true attribute" do
      helper.maptastic.should have_selector("div[data-map=true]")
    end
    
    it "should have a data-map-zoom attribute set to the default defined in the config" do
      Maptastic.stub(:default_zoom_level => 5)<commit_msg>Use describe instead of context for methods<commit_after>require 'spec_helper'
require 'maptastic/view_helpers/action_view'

describe Maptastic::ViewHelpers::ActionView do
  
  describe "#maptastic_provider_tag" do
    
    it "should exist" do
      helper.should respond_to :maptastic_provider_tag
    end

    it "should return a script tag" do
      helper.maptastic_provider_tag.should have_selector("script[type='text/javascript']")
    end

    it "should include the API key in the Url" do
      Maptastic.stub(:api_key => "SOME_RANDOM_API_KEY")
      helper.maptastic_provider_tag.should match /key=SOME_RANDOM_API_KEY/
    end
    
    it "should include the sensor param when set to true" do
      Maptastic.stub(:sensor => true)
      helper.maptastic_provider_tag.should match /sensor=true/
    end
    
    it "should include the sensor param when set to false" do
      Maptastic.stub(:sensor => false)
      helper.maptastic_provider_tag.should match /sensor=false/
    end
    
    it "should not include the sensor param when not set" do
      Maptastic.stub(:sensor => nil)
      helper.maptastic_provider_tag.should_not match /sensor=(false|true)/
    end
    
    it "should use the current I18n.locale" do
      I18n.stub(:locale => :de)
      helper.maptastic_provider_tag.should match /hl=de/
    end
    
    it "should use the locale defined in the config when available" do
      I18n.stub(:locale => :en)
      Maptastic.stub(:locale => :de)
      helper.maptastic_provider_tag.should match /hl=de/
    end
  end
  
  describe "#maptastic" do
    
    it "should have a data-map=true attribute" do
      helper.maptastic.should have_selector("div[data-map=true]")
    end
    
    it "should have a data-map-zoom attribute set to the default defined in the config" do
      Maptastic.stub(:default_zoom_level => 5)
{'fraction_non_alphanumeric': 0.08445297504798464, 'fraction_numerical': 0.003838771593090211, 'mean_word_length': 3.098876404494382, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '4870334', 'n_tokens_mistral': 1151, 'n_tokens_neox': 1159, 'n_words': 323}