<commit_before>
require 'spec_helper'

describe Restfulness::Router do

  class RouterResource < Restfulness::Resource
  end

  class SecondRouterResource < Restfulness::Resource
  end

  let :klass do
    Restfulness::Router
  end

  let :resource do
    RouterResource
  end

  describe "#initialize" do

    it "should prepare routes" do
      obj = klass.new
      obj.routes.should eql([])
    end

    it "should prepare routes with instance eval block" do
      obj = klass.new do
        @foo = 'bar'
      end
      obj.instance_variable_get(:@foo).should eql('bar')
    end

  end

  describe "#add" do
    it "should add route to object" do
      obj = klass.new
      obj.add 'projects', resource
      obj.routes.length.should eql(1)
      route = obj.routes.first
      route.should be_a(Restfulness::Route)
      route.path.should eql(['projects'])
    end
    it "should accept block as scope" do
      obj = klass.new
      obj.add 'project', RouterResource do
        add 'examples', SecondRouterResource
      end
      route = obj.routes.first
      route.resource.should eql(RouterResource)
      route.path.should eql(['project', 'examples'])
      route = obj.routes.last
      route.resource.should eql(SecondRouterResource)
      route.path.should eql(['project'])
    end
  end

  describe "#scope" do
    it "should append to the current_scope attribute in block and reset" do
      obj = klass.new
      subscope = nil # Can't use rspec inside instance eval!
      obj.scope 'api' do
        subscope = current_scope
      end
      subscope.should eql(['api'])
      obj.current_scope.should eql([])
    end <commit_msg>Fixing spec, nothing important enough to warrent new release<commit_after>
require 'spec_helper'

describe Restfulness::Router do

  class RouterResource < Restfulness::Resource
  end

  class SecondRouterResource < Restfulness::Resource
  end

  let :klass do
    Restfulness::Router
  end

  let :resource do
    RouterResource
  end

  describe "#initialize" do

    it "should prepare routes" do
      obj = klass.new
      obj.routes.should eql([])
    end

    it "should prepare routes with instance eval block" do
      obj = klass.new do
        @foo = 'bar'
      end
      obj.instance_variable_get(:@foo).should eql('bar')
    end

  end

  describe "#add" do
    it "should add route to object" do
      obj = klass.new
      obj.add 'projects', resource
      obj.routes.length.should eql(1)
      route = obj.routes.first
      route.should be_a(Restfulness::Route)
      route.path.should eql(['projects'])
    end
    it "should accept block as scope" do
      obj = klass.new
      obj.add 'project', RouterResource do
        add 'examples', SecondRouterResource
      end
      route = obj.routes.first
      route.resource.should eql(SecondRouterResource)
      route.path.should eql(['project', 'examples'])
      route = obj.routes.last
      route.resource.should eql(RouterResource)
      route.path.should eql(['project'])
    end
  end

  describe "#scope" do
    it "should append to the current_scope attribute in block and reset" do
      obj = klass.new
      subscope = nil # Can't use rspec inside instance eval!
      obj.scope 'api' do
        subscope = current_scope
      end
      subscope.should eql(['api'])
      obj.current_scope.should eql([])
    end 
{'fraction_non_alphanumeric': 0.09118086696562033, 'fraction_numerical': 0.0005979073243647235, 'mean_word_length': 2.5862808145766345, 'pattern_counts': {'":': 0, '<': 7, '<?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': '1648383', 'n_tokens_mistral': 991, 'n_tokens_neox': 982, 'n_words': 304}