Sha256: 9db40f9cb7c838f1e662e80213d103358eb5aee84554b8d69c9ad6a74ac7098d

Contents?: true

Size: 1.27 KB

Versions: 8

Compression:

Stored size: 1.27 KB

Contents

describe SharingTags::Configuration do
  before do
    SharingTags.configure do
      page_url { root_url }

      twitter do
        title  { awesome_title }
      end

      context :copyright do
        twitter do
          title  { |band| "#{awesome_title} (c) #{band}" }
        end
      end
    end
  end

  let(:running_context) do
    Class.new do
      def root_url
        "context url"
      end

      def awesome_title
        "All you need is love"
      end
    end
  end

  let(:params) { SharingTags.config.within_context_params(running_context.new) }

  describe "default context" do
    it "expect get twitter title from calling in running_context" do
      expect(params.twitter.page_url).to eql("context url")
    end

    it "expect get page_url from calling in running_context" do
      expect(params.twitter.title).to eql("All you need is love")
    end
  end

  describe "copyright context" do
    before do
      SharingTags.config.switch_context(:copyright, "Beatles")
    end

    it "expect get page_url from calling in running_context" do
      expect(params.twitter.title).to eql("All you need is love (c) Beatles")
    end

    it "expect get twitter title from calling in running_context" do
      expect(params.twitter.page_url).to eql("context url")
    end
  end


end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sharing_tags-0.0.9 spec/models/running_in_context_spec.rb
sharing_tags-0.0.8 spec/models/running_in_context_spec.rb
sharing_tags-0.0.7 spec/models/running_in_context_spec.rb
sharing_tags-0.0.6 spec/models/running_in_context_spec.rb
sharing_tags-0.0.5 spec/models/running_in_context_spec.rb
sharing_tags-0.0.4 spec/models/running_in_context_spec.rb
sharing_tags-0.0.3 spec/models/running_in_context_spec.rb
sharing_tags-0.0.2 spec/models/running_in_context_spec.rb