Updated

spec/helpers / signature_helper_spec.rb

F
77 lines of codes
0 methods
N/A complexity/method
5 churn
141.3 complexity
167 duplications
require 'rails_helper' RSpec.describe SignatureHelper, type: :helper do describe "#signature_count" do describe "for normal petition lists" do
  1. Similar code found in 4 nodes Locations: 0 1 2 3
it "returns a HTML-safe string" do expect(helper.signature_count(:default, 1)).to be_an(ActiveSupport::SafeBuffer) end context "when the signature count is 1" do it "returns a correctly formatted signature count" do expect(helper.signature_count(:default, 1)).to eq("<span class=\"count\" data-count=\"1\">1</span> <span class=\"text\">signature</span>") end end context "when the signature count is 100" do it "returns a correctly formatted signature count" do expect(helper.signature_count(:default, 100)).to eq("<span class=\"count\" data-count=\"100\">100</span> <span class=\"text\">signatures</span>") end end context "when the signature count is 1000" do it "returns a correctly formatted signature count" do expect(helper.signature_count(:default, 1000)).to eq("<span class=\"count\" data-count=\"1000\">1,000</span> <span class=\"text\">signatures</span>") end end end describe "for trending petition lists" do
  1. Similar code found in 4 nodes Locations: 0 1 2 3
it "returns a HTML-safe string" do expect(helper.signature_count(:trending, 1)).to be_an(ActiveSupport::SafeBuffer) end context "when the signature count is 1" do it "returns a correctly formatted signature count" do expect(helper.signature_count(:trending, 1)).to eq("<span class=\"count\">1</span> signature in the last hour") end end context "when the signature count is 100" do it "returns a correctly formatted signature count" do expect(helper.signature_count(:trending, 100)).to eq("<span class=\"count\">100</span> signatures in the last hour") end end context "when the signature count is 1000" do it "returns a correctly formatted signature count" do expect(helper.signature_count(:trending, 1000)).to eq("<span class=\"count\">1,000</span> signatures in the last hour") end end end describe "for petitions in your constituency" do it "returns a HTML-safe string" do expect(helper.signature_count(:in_your_constituency, 1, constituency: 'North Votingshire')).to be_an(ActiveSupport::SafeBuffer) end context "when the signature count is 1" do
  1. Similar code found in 3 nodes Locations: 0 1 2
it "returns a correctly formatted signature count" do expect(helper.signature_count(:in_your_constituency, 1, constituency: 'North Votingshire')).to eq("1 signature from North Votingshire") end end context "when the signature count is 100" do
  1. Similar code found in 3 nodes Locations: 0 1 2
it "returns a correctly formatted signature count" do expect(helper.signature_count(:in_your_constituency, 100, constituency: 'North Votingshire')).to eq("100 signatures from North Votingshire") end end context "when the signature count is 1000" do
  1. Similar code found in 3 nodes Locations: 0 1 2
it "returns a correctly formatted signature count" do expect(helper.signature_count(:in_your_constituency, 1000, constituency: 'North Votingshire')).to eq("1,000 signatures from North Votingshire") end end end end end