Sha256: 6431bb4715303062619072c98eeb7b94fafec43794dd3c897dc165d7142aa93b

Contents?: true

Size: 1.15 KB

Versions: 17

Compression:

Stored size: 1.15 KB

Contents

require "spec_helper"
require "shamu/entities"

describe Shamu::Entities::ListScope::Dates do
  let( :klass ) do
    Class.new( Shamu::Entities::ListScope ) do
      include Shamu::Entities::ListScope::Dates
    end
  end

  it "has a :since attribute" do
    expect( klass.attributes ).to have_key :since
  end

  it "has an :until attribute" do
    expect( klass.attributes ).to have_key :until
  end

  it "coerces with #to_time if available" do
    expect( Time ).to receive( :instance_method ).and_return( true )
    value = double
    expect( value ).to receive( :to_time )

    klass.new( since: value )
  end

  it "includes paging values in to_param" do
    time = Time.now
    expect( klass.new( since: time, until: time ).params ).to eq since: time, until: time
  end

  it "should not be dated when using defaults" do
    scope = klass.new
    expect( scope.dated? ).to be_falsy
  end

  it "should not be dated when since is provided" do
    scope = klass.new since: Time.now
    expect( scope.dated? ).to be_truthy
  end

  it "should not be dated when until is provided" do
    scope = klass.new until: Time.now
    expect( scope.dated? ).to be_truthy
  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
shamu-0.0.24 spec/lib/shamu/entities/list_scope/dates_spec.rb
shamu-0.0.21 spec/lib/shamu/entities/list_scope/dates_spec.rb
shamu-0.0.20 spec/lib/shamu/entities/list_scope/dates_spec.rb
shamu-0.0.19 spec/lib/shamu/entities/list_scope/dates_spec.rb
shamu-0.0.18 spec/lib/shamu/entities/list_scope/dates_spec.rb
shamu-0.0.17 spec/lib/shamu/entities/list_scope/dates_spec.rb
shamu-0.0.15 spec/lib/shamu/entities/list_scope/dates_spec.rb
shamu-0.0.14 spec/lib/shamu/entities/list_scope/dates_spec.rb
shamu-0.0.13 spec/lib/shamu/entities/list_scope/dates_spec.rb
shamu-0.0.11 spec/lib/shamu/entities/list_scope/dates_spec.rb
shamu-0.0.9 spec/lib/shamu/entities/list_scope/dates_spec.rb
shamu-0.0.8 spec/lib/shamu/entities/list_scope/dates_spec.rb
shamu-0.0.7 spec/lib/shamu/entities/list_scope/dates_spec.rb
shamu-0.0.5 spec/lib/shamu/entities/list_scope/dates_spec.rb
shamu-0.0.4 spec/lib/shamu/entities/list_scope/dates_spec.rb
shamu-0.0.3 spec/lib/shamu/entities/list_scope/dates_spec.rb
shamu-0.0.2 spec/lib/shamu/entities/list_scope/dates_spec.rb