Sha256: 916d8ce529ea173ebdd75dd4eb12bc51f513dc85f8b92e1bf2fe50a9f6644ff1
Contents?: true
Size: 1.34 KB
Versions: 8
Compression:
Stored size: 1.34 KB
Contents
require 'spec_helper' include Neutral::VotingBuilder::Elements describe Span, type: :feature do [Span::Positive, Span::Negative].each do |span| describe span do describe "#to_s" do let(:total) { rand(100) + 1 } let(:klass) { span.to_s.demodulize.downcase } subject { Capybara.string span.new(total).to_s } it { should have_selector("span.#{klass}") } it "has value of given total" do subject.find("span").text.should == total.to_s end it "nullifies total of zero" do Capybara.string(span.new(0).to_s).text.should == "" end end end end describe Span::Difference do def difference_element(total) Capybara.string(Span::Difference.new(total).to_s).find("span") end describe "#to_s" do let(:positive) { rand(100) + 1 } let(:negative) { -(rand(100) + 1) } it "has absolute value of total" do difference_element(negative).text.to_i.should > 0 end it "has 'positive' class when positive value of total is passed" do difference_element(positive)[:class].should include("positive") end it "has 'negative' class when negative value of total is passed" do difference_element(negative)[:class].should include("negative") end end end end
Version data entries
8 entries across 8 versions & 1 rubygems