Sha256: 84f95d129e9070bcad0b9b8f8255a09c3d1e50227f8d06937ce1f8e245f38c04
Contents?: true
Size: 1.17 KB
Versions: 2
Compression:
Stored size: 1.17 KB
Contents
require 'spec_helper' describe 'coverage', :coverage do class CoverageSpec < Sample::Model identity :id attribute :used, type: :string attribute :unused, type: :string end let!(:obj) { CoverageSpec.new(used: 'foo', unused: 'bar') } before(:each) do CoverageSpec.attributes[:used][:coverage_hits] = 0 expect(obj.used).to eq('foo') # once expect(obj.used).to eq('foo') # twice end it 'should store the file path where the attribute was defined' do expect(CoverageSpec.attributes[:used][:coverage_file]).to eq(__FILE__) expect(CoverageSpec.attributes[:unused][:coverage_file]).to eq(__FILE__) end it 'should store the line number where the attribute was defined' do src_lines = File.read(__FILE__).lines expect(src_lines[CoverageSpec.attributes[:used][:coverage_line] - 1]).to match(/attribute :used/) expect(src_lines[CoverageSpec.attributes[:unused][:coverage_line] - 1]).to match(/attribute :unused/) end it "should store how many times an attribute's reader is called" do expect(CoverageSpec.attributes[:used][:coverage_hits]).to eq(2) expect(CoverageSpec.attributes[:unused][:coverage_hits]).to eq(3) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cistern-2.4.1 | spec/coverage_spec.rb |
cistern-2.4.0 | spec/coverage_spec.rb |