spec/lib/prosperity/metric_spec.rb in prosperity-0.0.9 vs spec/lib/prosperity/metric_spec.rb in prosperity-0.0.10

- old
+ new

@@ -8,23 +8,23 @@ scope { User } end.new end it "groups by created_at by default" do - subject.group_by.should == :created_at + expect(subject.group_by).to eq(:created_at) end it "gets the scope" do - subject.scope.should == User + expect(subject.scope).to eq(User) end it "should not be sql" do - subject.should_not be_sql + expect(subject).not_to be_sql end it "should have the default aggregate" do - subject.aggregate.should be_an(Aggregate::Count) + expect(subject.aggregate).to be_an(Aggregate::Count) end end context "A raw sql metric" do context "From a string" do @@ -33,15 +33,15 @@ sql "SELECT name, created_at FROM users" end.new end it "groups by created_at by default" do - subject.group_by.should == :created_at + expect(subject.group_by).to eq(:created_at) end it "gets the scope" do - subject.sql.should == "SELECT name, created_at FROM users" + expect(subject.sql).to eq("SELECT name, created_at FROM users") end it "raises an exception when adding an option" do expect { subject.class.option "active" do |scope| @@ -49,11 +49,11 @@ end }.to raise_exception(SqlMetricCannotHaveOption) end it "should be sql" do - subject.should be_sql + expect(subject).to be_sql end end context "From a block" do subject do @@ -61,15 +61,15 @@ sql { "SELECT name, created_at FROM users" } end.new end it "groups by created_at by default" do - subject.group_by.should == :created_at + expect(subject.group_by).to eq(:created_at) end it "gets the scope" do - subject.sql.should == "SELECT name, created_at FROM users" + expect(subject.sql).to eq("SELECT name, created_at FROM users") end it "raises an exception when adding an option" do expect { subject.class.option "active" do |scope| @@ -77,11 +77,11 @@ end }.to raise_exception(SqlMetricCannotHaveOption) end it "should be sql" do - subject.should be_sql + expect(subject).to be_sql end end end context "a metric missing the scope" do @@ -115,13 +115,13 @@ end end.new end it "should have multiple options" do - subject.options.size.should == 2 - subject.options['default'].should be_present - subject.options['active'].should be_present + expect(subject.options.size).to eq(2) + expect(subject.options['default']).to be_present + expect(subject.options['active']).to be_present end end context "A metric with a custom group by" do subject do @@ -129,11 +129,14 @@ scope { User } group_by "users.created_at" end.new end - its(:group_by) { should == 'users.created_at' } + describe '#group_by' do + subject { super().group_by } + it { is_expected.to eq('users.created_at') } + end end context "A metric with a a sum aggregate" do subject do Class.new(Metric) do @@ -143,12 +146,12 @@ end let(:aggregate) { subject.aggregate } it "has the correct aggregate info" do - aggregate.should be_an(Aggregate::Sum) - aggregate.column.should == :some_column + expect(aggregate).to be_an(Aggregate::Sum) + expect(aggregate.column).to eq(:some_column) end end context "a ruby code metric" do subject do @@ -158,16 +161,16 @@ end end.new end it "has the correct value_at info" do - subject.value_at.call.should == :expected + expect(subject.value_at.call).to eq(:expected) end describe ".ruby?" do it "should be true" do - subject.class.ruby?.should == true - subject.ruby?.should == true + expect(subject.class.ruby?).to eq(true) + expect(subject.ruby?).to eq(true) end end end end end