juncture 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/juncture/version.rb +1 -1
- data/lib/juncture.rb +6 -6
- data/spec/juncture_spec.rb +80 -80
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 1f28a15579970e84b17cd602610f67d1aa1fb0fe
         | 
| 4 | 
            +
              data.tar.gz: ced8f397144e95be239664b175790d463aa96dc1
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 6bb89d966c61a680c1ee2510b921d4961f430a813b9a19f50420c6df11088c05c20d9c3334951089209c06e03eb37a4ea11818c3efd11fff14ed66d12f78e526
         | 
| 7 | 
            +
              data.tar.gz: 1da2fb3916a43f6799c87dbaa1d6b3ae29f77bdb944d14589f85cba60ec4814d47019efabc0c99dfc7abe90afdf0bae1953945e082b04a001c4fb5a99d2ec54d
         | 
    
        data/lib/juncture/version.rb
    CHANGED
    
    
    
        data/lib/juncture.rb
    CHANGED
    
    | @@ -44,24 +44,24 @@ class Juncture | |
| 44 44 | 
             
              end
         | 
| 45 45 |  | 
| 46 46 | 
             
              def <(value)
         | 
| 47 | 
            -
                 | 
| 47 | 
            +
                index < index(value)
         | 
| 48 48 | 
             
              end
         | 
| 49 49 |  | 
| 50 50 | 
             
              def <=(value)
         | 
| 51 | 
            -
                 | 
| 51 | 
            +
                index <= index(value)
         | 
| 52 52 | 
             
              end
         | 
| 53 53 |  | 
| 54 54 | 
             
              def >(value)
         | 
| 55 | 
            -
                 | 
| 55 | 
            +
                index > index(value)
         | 
| 56 56 | 
             
              end
         | 
| 57 57 |  | 
| 58 58 | 
             
              def >=(value)
         | 
| 59 | 
            -
                 | 
| 59 | 
            +
                index >= index(value)
         | 
| 60 60 | 
             
              end
         | 
| 61 61 |  | 
| 62 62 | 
             
              private
         | 
| 63 63 |  | 
| 64 | 
            -
              def index
         | 
| 65 | 
            -
                @states.index(@ | 
| 64 | 
            +
              def index value = @current_state
         | 
| 65 | 
            +
                @states.index(value) || @states[0]
         | 
| 66 66 | 
             
              end
         | 
| 67 67 | 
             
            end
         | 
    
        data/spec/juncture_spec.rb
    CHANGED
    
    | @@ -6,177 +6,177 @@ describe Juncture do | |
| 6 6 | 
             
              end
         | 
| 7 7 |  | 
| 8 8 | 
             
              describe '::new' do
         | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 9 | 
            +
                it 'creates a new instance of Juncture' do
         | 
| 10 | 
            +
                  expect(Juncture.new []).to be_an_instance_of Juncture
         | 
| 11 | 
            +
                end
         | 
| 12 12 | 
             
              end
         | 
| 13 13 |  | 
| 14 14 | 
             
              describe '#inspect' do
         | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 15 | 
            +
                it 'returns the Juncture object' do
         | 
| 16 | 
            +
                  expect(Juncture.new([]).inspect).to match(/<Juncture:\S+ State:\S*>/)
         | 
| 17 | 
            +
                end
         | 
| 18 18 | 
             
              end
         | 
| 19 19 |  | 
| 20 20 | 
             
              describe '#state' do
         | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 21 | 
            +
                it 'returns the current state' do
         | 
| 22 | 
            +
                  temp = Juncture.new :first, :second, :third
         | 
| 23 | 
            +
                  expect(temp.state).to be_nil
         | 
| 24 | 
            +
                end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                it 'returns the default state' do
         | 
| 27 | 
            +
                  temp = Juncture.new :first, :second, :third, default: :first
         | 
| 28 | 
            +
                  expect(temp.state).to eq :first
         | 
| 29 | 
            +
                end
         | 
| 30 30 | 
             
              end
         | 
| 31 31 |  | 
| 32 32 | 
             
              describe '#set' do
         | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
| 39 | 
            -
             | 
| 40 | 
            -
             | 
| 41 | 
            -
             | 
| 42 | 
            -
             | 
| 33 | 
            +
                it 'sets the current state' do
         | 
| 34 | 
            +
                  temp = Juncture.new :first, :second, :third
         | 
| 35 | 
            +
                  temp.set :first
         | 
| 36 | 
            +
                  expect(temp.state).to eq :first
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                it 'raises an error if the state is not present' do
         | 
| 40 | 
            +
                  temp = Juncture.new :first, :second, :third
         | 
| 41 | 
            +
                  expect{ temp.set :fourth }.to raise_error
         | 
| 42 | 
            +
                end
         | 
| 43 43 | 
             
              end
         | 
| 44 44 |  | 
| 45 45 | 
             
              describe '#next' do
         | 
| 46 46 | 
             
                it 'moves the state forward one step' do
         | 
| 47 | 
            -
                  temp = Juncture.new  | 
| 48 | 
            -
                  expect(temp.next).to eq  | 
| 49 | 
            -
                  expect(temp.state).to eq  | 
| 50 | 
            -
                  expect(temp.next).to eq  | 
| 51 | 
            -
                  expect(temp.state).to eq  | 
| 47 | 
            +
                  temp = Juncture.new :first, :second, :third, default: :first
         | 
| 48 | 
            +
                  expect(temp.next).to eq :second
         | 
| 49 | 
            +
                  expect(temp.state).to eq :second
         | 
| 50 | 
            +
                  expect(temp.next).to eq :third
         | 
| 51 | 
            +
                  expect(temp.state).to eq :third
         | 
| 52 52 | 
             
                end
         | 
| 53 53 |  | 
| 54 54 | 
             
                it 'resets if on final state' do
         | 
| 55 | 
            -
                  temp = Juncture.new  | 
| 56 | 
            -
                  expect(temp.next).to eq  | 
| 57 | 
            -
                  expect(temp.state).to eq  | 
| 58 | 
            -
                  expect(temp.next).to eq  | 
| 59 | 
            -
                  expect(temp.state).to eq  | 
| 55 | 
            +
                  temp = Juncture.new :first, :second, :third, default: :second
         | 
| 56 | 
            +
                  expect(temp.next).to eq :third
         | 
| 57 | 
            +
                  expect(temp.state).to eq :third
         | 
| 58 | 
            +
                  expect(temp.next).to eq :first
         | 
| 59 | 
            +
                  expect(temp.state).to eq :first
         | 
| 60 60 | 
             
                end
         | 
| 61 61 |  | 
| 62 62 | 
             
                it 'resets if default is nil' do
         | 
| 63 | 
            -
                  temp = Juncture.new  | 
| 64 | 
            -
                  expect(temp.next).to eq  | 
| 65 | 
            -
                  expect(temp.state).to eq  | 
| 66 | 
            -
                  expect(temp.next).to eq  | 
| 67 | 
            -
                  expect(temp.state).to eq  | 
| 63 | 
            +
                  temp = Juncture.new :first, :second, :third
         | 
| 64 | 
            +
                  expect(temp.next).to eq :first
         | 
| 65 | 
            +
                  expect(temp.state).to eq :first
         | 
| 66 | 
            +
                  expect(temp.next).to eq :second
         | 
| 67 | 
            +
                  expect(temp.state).to eq :second
         | 
| 68 68 | 
             
                end
         | 
| 69 69 |  | 
| 70 70 | 
             
                it 'resets if default is not a state' do
         | 
| 71 | 
            -
                  temp = Juncture.new  | 
| 72 | 
            -
                  expect(temp.next).to eq  | 
| 73 | 
            -
                  expect(temp.state).to eq  | 
| 74 | 
            -
                  expect(temp.next).to eq  | 
| 75 | 
            -
                  expect(temp.state).to eq  | 
| 71 | 
            +
                  temp = Juncture.new :first, :second, :third, default: 4
         | 
| 72 | 
            +
                  expect(temp.next).to eq :first
         | 
| 73 | 
            +
                  expect(temp.state).to eq :first
         | 
| 74 | 
            +
                  expect(temp.next).to eq :second
         | 
| 75 | 
            +
                  expect(temp.state).to eq :second
         | 
| 76 76 | 
             
                end
         | 
| 77 77 | 
             
              end
         | 
| 78 78 |  | 
| 79 79 | 
             
              describe '#==' do
         | 
| 80 80 | 
             
                it 'returns true if matching' do
         | 
| 81 | 
            -
                  temp = Juncture.new  | 
| 82 | 
            -
                  expect(temp ==  | 
| 81 | 
            +
                  temp = Juncture.new :first, :second, :third, default: :second
         | 
| 82 | 
            +
                  expect(temp == :second).to be_true
         | 
| 83 83 | 
             
                end
         | 
| 84 84 |  | 
| 85 85 | 
             
                it 'returns false if not matching' do
         | 
| 86 | 
            -
                  temp = Juncture.new  | 
| 87 | 
            -
                  expect(temp ==  | 
| 86 | 
            +
                  temp = Juncture.new :first, :second, :third, default: :second
         | 
| 87 | 
            +
                  expect(temp == :first).to be_false
         | 
| 88 88 | 
             
                end
         | 
| 89 89 | 
             
              end
         | 
| 90 90 |  | 
| 91 91 | 
             
              describe '#===' do
         | 
| 92 92 | 
             
                it 'returns true if matching' do
         | 
| 93 | 
            -
                  temp = Juncture.new  | 
| 94 | 
            -
                  expect(temp ===  | 
| 93 | 
            +
                  temp = Juncture.new :first, :second, :third, default: :second
         | 
| 94 | 
            +
                  expect(temp === :second).to be_true
         | 
| 95 95 | 
             
                end
         | 
| 96 96 |  | 
| 97 97 | 
             
                it 'returns false if not matching' do
         | 
| 98 | 
            -
                  temp = Juncture.new  | 
| 99 | 
            -
                  expect(temp ===  | 
| 98 | 
            +
                  temp = Juncture.new :first, :second, :third, default: :second
         | 
| 99 | 
            +
                  expect(temp === :first).to be_false
         | 
| 100 100 | 
             
                end
         | 
| 101 101 | 
             
              end
         | 
| 102 102 |  | 
| 103 103 | 
             
              describe '#<' do
         | 
| 104 104 | 
             
                it 'returns true if matching' do
         | 
| 105 | 
            -
                  temp = Juncture.new  | 
| 106 | 
            -
                  expect(temp <  | 
| 105 | 
            +
                  temp = Juncture.new :first, :second, :third, default: :second
         | 
| 106 | 
            +
                  expect(temp < :third).to be_true
         | 
| 107 107 | 
             
                end
         | 
| 108 108 |  | 
| 109 109 | 
             
                it 'returns false if not matching' do
         | 
| 110 | 
            -
                  temp = Juncture.new  | 
| 111 | 
            -
                  expect(temp <  | 
| 110 | 
            +
                  temp = Juncture.new :first, :second, :third, default: :second
         | 
| 111 | 
            +
                  expect(temp < :second).to be_false
         | 
| 112 112 | 
             
                end
         | 
| 113 113 |  | 
| 114 114 | 
             
                it 'returns false if not matching' do
         | 
| 115 | 
            -
                  temp = Juncture.new  | 
| 116 | 
            -
                  expect(temp <  | 
| 115 | 
            +
                  temp = Juncture.new :first, :second, :third, default: :second
         | 
| 116 | 
            +
                  expect(temp < :first).to be_false
         | 
| 117 117 | 
             
                end
         | 
| 118 118 | 
             
              end
         | 
| 119 119 |  | 
| 120 120 | 
             
              describe '#<=' do
         | 
| 121 121 | 
             
                it 'returns true if matching' do
         | 
| 122 | 
            -
                  temp = Juncture.new  | 
| 123 | 
            -
                  expect(temp <=  | 
| 122 | 
            +
                  temp = Juncture.new :first, :second, :third, default: :second
         | 
| 123 | 
            +
                  expect(temp <= :third).to be_true
         | 
| 124 124 | 
             
                end
         | 
| 125 125 |  | 
| 126 126 | 
             
                it 'returns true if matching' do
         | 
| 127 | 
            -
                  temp = Juncture.new  | 
| 128 | 
            -
                  expect(temp <=  | 
| 127 | 
            +
                  temp = Juncture.new :first, :second, :third, default: :second
         | 
| 128 | 
            +
                  expect(temp <= :second).to be_true
         | 
| 129 129 | 
             
                end
         | 
| 130 130 |  | 
| 131 131 | 
             
                it 'returns false if not matching' do
         | 
| 132 | 
            -
                  temp = Juncture.new  | 
| 133 | 
            -
                  expect(temp <=  | 
| 132 | 
            +
                  temp = Juncture.new :first, :second, :third, default: :second
         | 
| 133 | 
            +
                  expect(temp <= :first).to be_false
         | 
| 134 134 | 
             
                end
         | 
| 135 135 | 
             
              end
         | 
| 136 136 |  | 
| 137 137 | 
             
              describe '#>' do
         | 
| 138 138 | 
             
                it 'returns true if matching' do
         | 
| 139 | 
            -
                  temp = Juncture.new  | 
| 140 | 
            -
                  expect(temp >  | 
| 139 | 
            +
                  temp = Juncture.new :first, :second, :third, default: :second
         | 
| 140 | 
            +
                  expect(temp > :first).to be_true
         | 
| 141 141 | 
             
                end
         | 
| 142 142 |  | 
| 143 143 | 
             
                it 'returns false if not matching' do
         | 
| 144 | 
            -
                  temp = Juncture.new  | 
| 145 | 
            -
                  expect(temp >  | 
| 144 | 
            +
                  temp = Juncture.new :first, :second, :third, default: :second
         | 
| 145 | 
            +
                  expect(temp > :second).to be_false
         | 
| 146 146 | 
             
                end
         | 
| 147 147 |  | 
| 148 148 | 
             
                it 'returns false if not matching' do
         | 
| 149 | 
            -
                  temp = Juncture.new  | 
| 150 | 
            -
                  expect(temp >  | 
| 149 | 
            +
                  temp = Juncture.new :first, :second, :third, default: :second
         | 
| 150 | 
            +
                  expect(temp > :third).to be_false
         | 
| 151 151 | 
             
                end
         | 
| 152 152 | 
             
              end
         | 
| 153 153 |  | 
| 154 154 | 
             
              describe '#>=' do
         | 
| 155 155 | 
             
                it 'returns true if matching' do
         | 
| 156 | 
            -
                  temp = Juncture.new  | 
| 157 | 
            -
                  expect(temp >=  | 
| 156 | 
            +
                  temp = Juncture.new :first, :second, :third, default: :second
         | 
| 157 | 
            +
                  expect(temp >= :first).to be_true
         | 
| 158 158 | 
             
                end
         | 
| 159 159 |  | 
| 160 160 | 
             
                it 'returns true if matching' do
         | 
| 161 | 
            -
                  temp = Juncture.new  | 
| 162 | 
            -
                  expect(temp >=  | 
| 161 | 
            +
                  temp = Juncture.new :first, :second, :third, default: :second
         | 
| 162 | 
            +
                  expect(temp >= :second).to be_true
         | 
| 163 163 | 
             
                end
         | 
| 164 164 |  | 
| 165 165 | 
             
                it 'returns false if not matching' do
         | 
| 166 | 
            -
                  temp = Juncture.new  | 
| 167 | 
            -
                  expect(temp >=  | 
| 166 | 
            +
                  temp = Juncture.new :first, :second, :third, default: :second
         | 
| 167 | 
            +
                  expect(temp >= :third).to be_false
         | 
| 168 168 | 
             
                end
         | 
| 169 169 | 
             
              end
         | 
| 170 170 |  | 
| 171 171 | 
             
              describe '#method_missing' do
         | 
| 172 172 | 
             
                it 'forards to the state array' do
         | 
| 173 | 
            -
                  temp = Juncture.new  | 
| 174 | 
            -
                  expect(temp[1]).to eq  | 
| 173 | 
            +
                  temp = Juncture.new :first, :second, :third, default: :second
         | 
| 174 | 
            +
                  expect(temp[1]).to eq :second
         | 
| 175 175 | 
             
                  expect(temp.length).to eq 3
         | 
| 176 176 | 
             
                end
         | 
| 177 177 |  | 
| 178 178 | 
             
                it 'raises an error to super' do
         | 
| 179 | 
            -
                  temp = Juncture.new  | 
| 179 | 
            +
                  temp = Juncture.new :first, :second, :third, default: :second
         | 
| 180 180 | 
             
                  expect{ temp.no_response }.to raise_error
         | 
| 181 181 | 
             
                end
         | 
| 182 182 | 
             
              end
         |