|
7 | 7 |
|
8 | 8 | let(:score) { 3 } |
9 | 9 | let(:highlight_stars) { nil } |
| 10 | + let(:half_stars) { false } |
10 | 11 |
|
11 | 12 | before do |
12 | | - render_inline described_class.new(highlight_stars: highlight_stars.presence, score: score.presence) |
| 13 | + render_inline described_class.new(highlight_stars: highlight_stars.presence, score: score.presence, half_stars: half_stars) |
13 | 14 | end |
14 | 15 |
|
15 | 16 | it { is_expected.to have_css ".star--full", count: 3 } |
|
19 | 20 | context "when the stars are highlighted" do |
20 | 21 | let(:highlight_stars) { true } |
21 | 22 |
|
22 | | - context "when the score is decimal" do |
23 | | - let(:score) { 2.8 } |
| 23 | + context "when half stars is set to true" do |
| 24 | + let(:half_stars) { true } |
24 | 25 |
|
25 | | - it { is_expected.to have_css ".stars--highlight" } |
26 | | - it { is_expected.to have_css ".star--full", count: 2 } |
27 | | - it { is_expected.to have_css ".star--empty", count: 2 } |
28 | | - it { is_expected.to have_css ".star--half", count: 1 } |
| 26 | + context "when the score is decimal" do |
| 27 | + let(:score) { 2.8 } |
| 28 | + |
| 29 | + it { is_expected.to have_css ".stars--highlight" } |
| 30 | + it { is_expected.to have_css ".star--full", count: 2 } |
| 31 | + it { is_expected.to have_css ".star--empty", count: 2 } |
| 32 | + it { is_expected.to have_css ".star--half", count: 1 } |
| 33 | + end |
| 34 | + |
| 35 | + context "when the score is a decimal, but less than .5 of the whole number" do |
| 36 | + let(:score) { 2.3 } |
| 37 | + |
| 38 | + it { is_expected.to have_css ".stars--highlight" } |
| 39 | + it { is_expected.to have_css ".star--full", count: 2 } |
| 40 | + it { is_expected.to have_css ".star--empty", count: 3 } |
| 41 | + it { is_expected.to have_no_css ".star--half" } |
| 42 | + end |
| 43 | + end |
| 44 | + |
| 45 | + context "when half stars is set to false" do |
| 46 | + let(:half_stars) { false } |
| 47 | + |
| 48 | + context "when the score is decimal" do |
| 49 | + let(:score) { 2.8 } |
| 50 | + |
| 51 | + it { is_expected.to have_css ".stars--highlight" } |
| 52 | + it { is_expected.to have_css ".star--full", count: 2 } |
| 53 | + it { is_expected.to have_css ".star--empty", count: 3 } |
| 54 | + it { is_expected.to have_css ".star--half", count: 0 } |
| 55 | + end |
| 56 | + |
| 57 | + context "when the score is a decimal, but less than .5 of the whole number" do |
| 58 | + let(:score) { 2.3 } |
| 59 | + |
| 60 | + it { is_expected.to have_css ".stars--highlight" } |
| 61 | + it { is_expected.to have_css ".star--full", count: 2 } |
| 62 | + it { is_expected.to have_css ".star--empty", count: 3 } |
| 63 | + it { is_expected.to have_no_css ".star--half" } |
| 64 | + end |
| 65 | + end |
| 66 | + end |
| 67 | + |
| 68 | + context "when the stars are not highlighted" do |
| 69 | + let(:highlight_stars) { false } |
| 70 | + |
| 71 | + context "when half stars is set to true" do |
| 72 | + let(:half_stars) { true } |
| 73 | + |
| 74 | + context "when the score is decimal" do |
| 75 | + let(:score) { 2.8 } |
| 76 | + |
| 77 | + it { is_expected.to have_no_css ".stars--highlight" } |
| 78 | + it { is_expected.to have_css ".star--full", count: 2 } |
| 79 | + it { is_expected.to have_css ".star--empty", count: 2 } |
| 80 | + it { is_expected.to have_css ".star--half", count: 1 } |
| 81 | + end |
| 82 | + |
| 83 | + context "when the score is a decimal, but less than .5 of the whole number" do |
| 84 | + let(:score) { 2.3 } |
| 85 | + |
| 86 | + it { is_expected.to have_no_css ".stars--highlight" } |
| 87 | + it { is_expected.to have_css ".star--full", count: 2 } |
| 88 | + it { is_expected.to have_css ".star--empty", count: 3 } |
| 89 | + it { is_expected.to have_no_css ".star--half" } |
| 90 | + end |
29 | 91 | end |
30 | 92 |
|
31 | | - context "when the score is not decimal" do |
32 | | - let(:score) { 2 } |
| 93 | + context "when half stars is set to false" do |
| 94 | + let(:half_stars) { false } |
| 95 | + |
| 96 | + context "when the score is decimal" do |
| 97 | + let(:score) { 2.8 } |
| 98 | + |
| 99 | + it { is_expected.to have_no_css ".stars--highlight" } |
| 100 | + it { is_expected.to have_css ".star--full", count: 2 } |
| 101 | + it { is_expected.to have_css ".star--empty", count: 3 } |
| 102 | + it { is_expected.to have_css ".star--half", count: 0 } |
| 103 | + end |
| 104 | + |
| 105 | + context "when the score is a decimal, but less than .5 of the whole number" do |
| 106 | + let(:score) { 2.3 } |
33 | 107 |
|
34 | | - it { is_expected.to have_css ".stars--highlight" } |
35 | | - it { is_expected.to have_css ".star--full", count: 2 } |
36 | | - it { is_expected.to have_css ".star--empty", count: 3 } |
37 | | - it { is_expected.to have_no_css ".star--half" } |
| 108 | + it { is_expected.to have_no_css ".stars--highlight" } |
| 109 | + it { is_expected.to have_css ".star--full", count: 2 } |
| 110 | + it { is_expected.to have_css ".star--empty", count: 3 } |
| 111 | + it { is_expected.to have_no_css ".star--half" } |
| 112 | + end |
38 | 113 | end |
39 | 114 | end |
40 | 115 | end |
0 commit comments