Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
ruby-version:
- head
- '3.2'
- '3.1'
- '3.0'
- '2.7'
- '2.6'
- '2.5'
- jruby
- jruby-9.3
- jruby-9.2
steps:
- uses: actions/checkout@v3
- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # 'bundle install' and cache
- name: Run tests
run: bundle exec rake
9 changes: 0 additions & 9 deletions .travis.yml

This file was deleted.

42 changes: 21 additions & 21 deletions spec/column_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,87 +6,87 @@
let(:c) {Column.new(:data => ["Once upon a time", "there was a dark and stormy night"], :name => :tagline)}

it "remembers its name as a string" do
c.name.should == "tagline"
expect(c.name).to eq "tagline"
end

it "exposes the array of data representing the column" do
c.data.should == ["Once upon a time", "there was a dark and stormy night"]
expect(c.data).to eq ["Once upon a time", "there was a dark and stormy night"]
end

describe "#add_formatter" do
it "stores the formatter" do
f = {}
c.add_formatter(f)
c.formatters.should == [f]
expect(c.formatters).to eq [f]
end
end

describe "#formatter=" do
it "adds the formatters individually" do
c.should_receive(:add_formatter).twice
expect(c).to receive(:add_formatter).twice
c.formatters = [{}, {}]
end
end

describe "#display_method" do
it "returns the column's display method as a string" do
c = Column.new(:display_method => :boofar)
c.display_method.should == "boofar"
expect(c.display_method).to eq "boofar"
end

it "doesn't turn a lambda display method into a string" do
lam = lambda{}
c = Column.new(:display_method => lam)
c.display_method.should == lam
expect(c.display_method).to eq lam
end

it "defaults to the column name" do
c = Column.new(:name => :boofar)
c.display_method.should == "boofar"
expect(c.display_method).to eq "boofar"
end
end

describe "#data_width" do
it "reflects the width of the data set" do
c.data_width.should == 33
expect(c.data_width).to eq 33
end

it "includes the title in the calculation" do
c.name = "a horse is a horse of course of course"
c.data_width.should == 38
expect(c.data_width).to eq 38
end
end

describe "#width" do
context "when default width is specified" do
it "uses the default width" do
c.default_width = 10
c.stub(:data_width => 15)
c.stub(:max_width => 20)
c.width.should == 10
allow(c).to receive(:data_width).and_return(15)
allow(c).to receive(:max_width).and_return(20)
expect(c.width).to eq 10
end

it "isn't limited by the config width" do
c.default_width = 40
c.stub(:data_width => 50)
c.stub(:max_width => 20)
c.width.should == 40
allow(c).to receive(:data_width).and_return(50)
allow(c).to receive(:max_width).and_return(20)
expect(c.width).to eq 40
end
end

context "When default width is not specified" do
it "uses the data width" do
c.default_width = nil
c.stub(:data_width => 10)
c.stub(:max_width => 20)
c.width.should == 10
allow(c).to receive(:data_width).and_return(10)
allow(c).to receive(:max_width).and_return(20)
expect(c.width).to eq 10
end

it "is limited by the config width" do
c.default_width = nil
c.stub(:data_width => 30)
c.stub(:max_width => 20)
c.width.should == 20
allow(c).to receive(:data_width).and_return(30)
allow(c).to receive(:max_width).and_return(20)
expect(c.width).to eq 20
end
end
end
Expand Down
Loading