Sha256: cdb98c38c7ae9a61137326acf1ca8c0ddd925c5da404f9cf48b59d51318fc31e

Contents?: true

Size: 1.25 KB

Versions: 6

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'

describe "RamenRails::Config" do

  before :each do
    @user = Hashie::Mash.new(name: 'Ryan', email: 'ryan@ramen.is', id: '1234')
    @company = Hashie::Mash.new(name: 'Scrubber', url: 'http://scrubber.social', id: 'comp-1234')
    @organization_id = rand(1_000_000)
    @organization_secret = rand(1_000_000)
  end

  it "should set things" do
    RamenRails.config do |config|
      config.organization_id = @organization_id
      config.organization_secret = @organization_secret
      config.current_user = Proc.new { @user }
      config.current_company = Proc.new { @company }
    end

    expect(instance_eval(&RamenRails.config.current_user).id).to eq('1234')
    expect(instance_eval(&RamenRails.config.current_company).id).to eq('comp-1234')
    
    expect(RamenRails.config.current_user.call.id).to eq('1234')
    expect(RamenRails.config.current_company.call.id).to eq('comp-1234')
    expect(RamenRails.config.organization_id).to eq(@organization_id)
    expect(RamenRails.config.organization_secret).to eq(@organization_secret)
  end

  it "should error if passed a lambda" do
    expect do
      RamenRails.config do |c|
        c.current_user = -> { @user }
      end
    end.to raise_error(RamenRails::Config::NoLambdasPlease)
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ramen-rails-0.0.7 spec/lib/config_spec.rb
ramen-rails-0.0.6 spec/lib/config_spec.rb
ramen-rails-0.0.5 spec/lib/config_spec.rb
ramen-rails-0.0.4 spec/lib/config_spec.rb
ramen-rails-0.0.3 spec/lib/config_spec.rb
ramen-rails-0.0.1 spec/lib/config_spec.rb