ianwhite-pickle 0.1.1 → 0.1.2
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.
- data/History.txt +12 -0
- data/README.textile +70 -39
- data/Todo.txt +0 -5
- data/lib/pickle.rb +17 -45
- data/lib/pickle/adapter.rb +86 -0
- data/lib/pickle/config.rb +51 -0
- data/lib/pickle/injector.rb +11 -11
- data/lib/pickle/parser.rb +31 -44
- data/lib/pickle/parser/matchers.rb +75 -0
- data/lib/pickle/parser/with_session.rb +24 -0
- data/lib/pickle/session.rb +26 -25
- data/lib/pickle/version.rb +9 -0
- data/rails_generators/pickle/pickle_generator.rb +19 -0
- data/rails_generators/pickle/templates/env.rb +9 -0
- data/rails_generators/pickle/templates/pickle_steps.rb +23 -0
- data/spec/lib/pickle_adapter_spec.rb +128 -0
- data/spec/lib/pickle_config_spec.rb +82 -28
- data/spec/lib/pickle_injector_spec.rb +3 -3
- data/spec/lib/pickle_parser_matchers_spec.rb +54 -0
- data/spec/lib/pickle_parser_spec.rb +56 -77
- data/spec/lib/pickle_session_spec.rb +38 -36
- metadata +14 -3
- data/lib/pickle/steps.rb +0 -27
| @@ -3,9 +3,9 @@ require File.expand_path(File.join(File.dirname(__FILE__), '../spec_helper')) | |
| 3 3 | 
             
            describe Pickle::Injector do
         | 
| 4 4 | 
             
              describe ".inject Pickle::Session, :into => <a class>" do
         | 
| 5 5 | 
             
                before do
         | 
| 6 | 
            -
                   | 
| 7 | 
            -
                  Pickle::Injector.inject Pickle::Session, :into =>  | 
| 8 | 
            -
                  @object =  | 
| 6 | 
            +
                  klass = Class.new
         | 
| 7 | 
            +
                  Pickle::Injector.inject Pickle::Session, :into => klass
         | 
| 8 | 
            +
                  @object = klass.new
         | 
| 9 9 | 
             
                end
         | 
| 10 10 |  | 
| 11 11 | 
             
                it "object should respond_to Pickle:Session methods" do
         | 
| @@ -0,0 +1,54 @@ | |
| 1 | 
            +
            require File.expand_path(File.join(File.dirname(__FILE__), '../spec_helper'))
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe Pickle::Parser::Matchers, "with config defining factories: user, car, fast_car" do
         | 
| 4 | 
            +
              include Pickle::Parser::Matchers
         | 
| 5 | 
            +
              
         | 
| 6 | 
            +
              def config
         | 
| 7 | 
            +
                @config ||= Pickle::Config.new do |c|
         | 
| 8 | 
            +
                  c.factories = {
         | 
| 9 | 
            +
                    'user'      => mock('factory'),
         | 
| 10 | 
            +
                    'car'       => mock('factory'),
         | 
| 11 | 
            +
                    'fast_car'  => mock('factory')
         | 
| 12 | 
            +
                  }
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
              
         | 
| 16 | 
            +
              describe "Match atoms" do
         | 
| 17 | 
            +
                def self.atom_should_match(atom, strings)
         | 
| 18 | 
            +
                  Array(strings).each do |string|
         | 
| 19 | 
            +
                    it "#{atom} should match '#{string}'" do
         | 
| 20 | 
            +
                      string.should match(/^#{send atom}$/)
         | 
| 21 | 
            +
                    end
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                def self.atom_should_not_match(atom, strings)
         | 
| 26 | 
            +
                  Array(strings).each do |string|
         | 
| 27 | 
            +
                    it "#{atom} should NOT match '#{string}'" do
         | 
| 28 | 
            +
                      string.should_not match(/^#{send atom}$/)
         | 
| 29 | 
            +
                    end
         | 
| 30 | 
            +
                  end
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
              
         | 
| 33 | 
            +
                atom_should_match     :match_ordinal, ['1st', '2nd', '23rd', '104th']
         | 
| 34 | 
            +
                atom_should_not_match :match_ordinal, ['1', '2']
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                atom_should_match     :match_index, ['first', 'last', '23rd', '104th']
         | 
| 37 | 
            +
                atom_should_not_match :match_index, ['1', '2', 'foo']
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                atom_should_match     :match_label, [': "gday"', ': "gday mate"']
         | 
| 40 | 
            +
                atom_should_not_match :match_label, [': "gday""', ': gday']
         | 
| 41 | 
            +
              
         | 
| 42 | 
            +
                atom_should_match     :match_field, ['foo: "this is the life"', 'bar_man: "and so is this"']
         | 
| 43 | 
            +
                atom_should_not_match :match_field, ['foo bar: "this aint workin"']
         | 
| 44 | 
            +
              
         | 
| 45 | 
            +
                atom_should_match     :match_fields, ['foo: "bar"', 'foo: "bar", baz: "bah"']
         | 
| 46 | 
            +
                atom_should_not_match :match_fields, ['foo bar: "baz"', 'email: "a", password: "b", and password_confirmation: "c"']
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                atom_should_match     :match_model, ['a user', '1st fast car', 'the 23rd fast_car', 'the user: "fred flinstone"']
         | 
| 49 | 
            +
                atom_should_not_match :match_model, ['a giraffe', 'a 1st faster car: "jim"', 'an event created']
         | 
| 50 | 
            +
              
         | 
| 51 | 
            +
                atom_should_match     :match_factory, ['user', 'fast car', 'fast_car', 'car']
         | 
| 52 | 
            +
                atom_should_not_match :match_factory, ['users', 'faster car', 'event created']
         | 
| 53 | 
            +
              end
         | 
| 54 | 
            +
            end
         | 
| @@ -1,51 +1,23 @@ | |
| 1 1 | 
             
            require File.expand_path(File.join(File.dirname(__FILE__), '../spec_helper'))
         | 
| 2 2 |  | 
| 3 3 | 
             
            describe Pickle::Parser do
         | 
| 4 | 
            -
               | 
| 5 | 
            -
             | 
| 6 | 
            -
               | 
| 7 | 
            -
                def self.atom_should_match(atom, strings)
         | 
| 8 | 
            -
                  Array(strings).each do |string|
         | 
| 9 | 
            -
                    it "#{atom} should match '#{string}'" do
         | 
| 10 | 
            -
                      string.should match(/^#{eval "Pickle::Parser::#{atom}"}$/)
         | 
| 11 | 
            -
                    end
         | 
| 12 | 
            -
                  end
         | 
| 13 | 
            -
                end
         | 
| 14 | 
            -
             | 
| 15 | 
            -
                def self.atom_should_not_match(atom, strings)
         | 
| 16 | 
            -
                  Array(strings).each do |string|
         | 
| 17 | 
            -
                    it "#{atom} should NOT match '#{string}'" do
         | 
| 18 | 
            -
                      string.should_not match(/^#{eval "Pickle::Parser::#{atom}"}$/)
         | 
| 19 | 
            -
                    end
         | 
| 20 | 
            -
                  end
         | 
| 21 | 
            -
                end
         | 
| 22 | 
            -
                
         | 
| 23 | 
            -
                atom_should_match     'Match::Ordinal', ['1st', '2nd', '23rd', '104th']
         | 
| 24 | 
            -
                atom_should_not_match 'Match::Ordinal', ['1', '2']
         | 
| 25 | 
            -
             | 
| 26 | 
            -
                atom_should_match     'Match::Index', ['first', 'last', '23rd', '104th']
         | 
| 27 | 
            -
                atom_should_not_match 'Match::Index', ['1', '2', 'foo']
         | 
| 28 | 
            -
             | 
| 29 | 
            -
                atom_should_match     'Match::Name', [': "gday"', ': "gday mate"']
         | 
| 30 | 
            -
                atom_should_not_match 'Match::Name', [': "gday""', ': gday']
         | 
| 31 | 
            -
                
         | 
| 32 | 
            -
                atom_should_match     'Match::Field', ['foo: "this is the life"', 'bar_man: "and so is this"']
         | 
| 33 | 
            -
                atom_should_not_match 'Match::Field', ['foo bar: "this aint workin"']
         | 
| 34 | 
            -
                
         | 
| 35 | 
            -
                atom_should_match     'Match::Fields', ['foo: "bar"', 'foo: "bar", baz: "bah"']
         | 
| 36 | 
            -
                atom_should_not_match 'Match::Fields', ['foo bar: "baz"', 'email: "a", password: "b", and password_confirmation: "c"']
         | 
| 4 | 
            +
              before do
         | 
| 5 | 
            +
                @parser = Pickle::Parser.new
         | 
| 6 | 
            +
              end
         | 
| 37 7 |  | 
| 38 | 
            -
             | 
| 39 | 
            -
                 | 
| 40 | 
            -
             | 
| 41 | 
            -
             | 
| 42 | 
            -
             | 
| 8 | 
            +
              it "should use the default config when created with no args" do
         | 
| 9 | 
            +
                @parser.config.should == Pickle.config
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
              
         | 
| 12 | 
            +
              it "should use the passed config when created with :config option" do
         | 
| 13 | 
            +
                parser = Pickle::Parser.new :config => (cfg = mock('config'))
         | 
| 14 | 
            +
                parser.config.should == cfg
         | 
| 43 15 | 
             
              end
         | 
| 44 16 |  | 
| 45 17 | 
             
              describe 'misc regexps' do
         | 
| 46 | 
            -
                describe ' | 
| 18 | 
            +
                describe '/^#{capture_model} exists/' do
         | 
| 47 19 | 
             
                  before do
         | 
| 48 | 
            -
                    @regexp = /^(#{ | 
| 20 | 
            +
                    @regexp = /^(#{@parser.capture_model}) exists$/
         | 
| 49 21 | 
             
                  end
         | 
| 50 22 |  | 
| 51 23 | 
             
                  it "should match 'a user exists'" do
         | 
| @@ -60,104 +32,111 @@ describe Pickle::Parser do | |
| 60 32 |  | 
| 61 33 | 
             
              describe '#parse_field' do
         | 
| 62 34 | 
             
                it "should return {'a' => 'b'} for 'a: \"b\"'" do
         | 
| 63 | 
            -
                  parse_field('a: "b"').should == {'a' => 'b'}
         | 
| 35 | 
            +
                  @parser.parse_field('a: "b"').should == {'a' => 'b'}
         | 
| 64 36 | 
             
                end
         | 
| 65 37 |  | 
| 66 38 | 
             
                it "should raise error for invalid field 'a : b'" do
         | 
| 67 | 
            -
                  lambda { parse_field('a : b') }.should raise_error(ArgumentError)
         | 
| 39 | 
            +
                  lambda { @parser.parse_field('a : b') }.should raise_error(ArgumentError)
         | 
| 68 40 | 
             
                end
         | 
| 69 41 | 
             
              end
         | 
| 70 42 |  | 
| 71 43 | 
             
              describe '#parse_fields' do
         | 
| 72 44 | 
             
                it 'should return {} for blank argument' do
         | 
| 73 | 
            -
                  parse_fields(nil).should == {}
         | 
| 74 | 
            -
                  parse_fields('').should == {}
         | 
| 45 | 
            +
                  @parser.parse_fields(nil).should == {}
         | 
| 46 | 
            +
                  @parser.parse_fields('').should == {}
         | 
| 75 47 | 
             
                end
         | 
| 76 48 |  | 
| 77 49 | 
             
                it 'should raise error for invalid argument' do
         | 
| 78 | 
            -
                  lambda { parse_fields('foo foo') }.should raise_error(ArgumentError)
         | 
| 50 | 
            +
                  lambda { @parser.parse_fields('foo foo') }.should raise_error(ArgumentError)
         | 
| 79 51 | 
             
                end
         | 
| 80 52 |  | 
| 81 53 | 
             
                it '(\'foo: "bar"\') should == { "foo" => "bar"}' do
         | 
| 82 | 
            -
                  parse_fields('foo: "bar"').should == { "foo" => "bar"}
         | 
| 54 | 
            +
                  @parser.parse_fields('foo: "bar"').should == { "foo" => "bar"}
         | 
| 83 55 | 
             
                end
         | 
| 84 56 |  | 
| 85 57 | 
             
                it '(\'foo: "bar", bar_man: "wonga wonga", gump: "123"\') should == {"foo" => "bar", "bar_man" => "wonga wonga", "gump" => "123"}' do
         | 
| 86 | 
            -
                  parse_fields('foo: "bar", bar_man: "wonga wonga", gump: "123"').should == {"foo" => "bar", "bar_man" => "wonga wonga", "gump" => "123"}
         | 
| 58 | 
            +
                  @parser.parse_fields('foo: "bar", bar_man: "wonga wonga", gump: "123"').should == {"foo" => "bar", "bar_man" => "wonga wonga", "gump" => "123"}
         | 
| 87 59 | 
             
                end
         | 
| 88 60 | 
             
              end
         | 
| 89 61 |  | 
| 90 62 | 
             
              describe '#parse_model' do
         | 
| 91 63 | 
             
                it '("a user") should == ["user", ""]' do
         | 
| 92 | 
            -
                  parse_model("a user").should == ["user", ""]
         | 
| 64 | 
            +
                  @parser.parse_model("a user").should == ["user", ""]
         | 
| 93 65 | 
             
                end
         | 
| 94 | 
            -
             | 
| 66 | 
            +
              
         | 
| 95 67 | 
             
                it '("the user") should == ["user", ""]' do
         | 
| 96 | 
            -
                  parse_model("the user").should == ["user", ""]
         | 
| 68 | 
            +
                  @parser.parse_model("the user").should == ["user", ""]
         | 
| 97 69 | 
             
                end
         | 
| 98 | 
            -
             | 
| 70 | 
            +
              
         | 
| 99 71 | 
             
                it '("1 fast car") should == ["fast_car", ""]' do
         | 
| 100 | 
            -
                  parse_model("1 fast car").should == ["fast_car", ""]
         | 
| 72 | 
            +
                  @parser.parse_model("1 fast car").should == ["fast_car", ""]
         | 
| 101 73 | 
             
                end
         | 
| 102 74 |  | 
| 103 75 | 
             
                it '(\'an user: "jim jones"\') should == ["user", "jim_jones"]' do
         | 
| 104 | 
            -
                  parse_model('an user: "jim jones"').should == ["user", "jim_jones"]
         | 
| 76 | 
            +
                  @parser.parse_model('an user: "jim jones"').should == ["user", "jim_jones"]
         | 
| 105 77 | 
             
                end
         | 
| 106 78 |  | 
| 107 79 | 
             
                it '(\'that fast car: "herbie"\') should == ["fast_car", "herbie"]' do
         | 
| 108 | 
            -
                  parse_model('that fast car: "herbie"').should == ["fast_car", "herbie"]
         | 
| 80 | 
            +
                  @parser.parse_model('that fast car: "herbie"').should == ["fast_car", "herbie"]
         | 
| 109 81 | 
             
                end
         | 
| 110 82 |  | 
| 111 83 | 
             
                it '(\'the 12th user\') should == ["user", 11]' do
         | 
| 112 | 
            -
                  parse_model('the 12th user').should == ["user", 11]
         | 
| 84 | 
            +
                  @parser.parse_model('the 12th user').should == ["user", 11]
         | 
| 113 85 | 
             
                end
         | 
| 114 | 
            -
             | 
| 86 | 
            +
              
         | 
| 115 87 | 
             
                it '(\'the last user\') should == ["user", -1]' do
         | 
| 116 | 
            -
                  parse_model('the last user').should == ["user", -1]
         | 
| 88 | 
            +
                  @parser.parse_model('the last user').should == ["user", -1]
         | 
| 117 89 | 
             
                end
         | 
| 118 90 |  | 
| 119 91 | 
             
                it '("the first user") should == ["user", 0]' do
         | 
| 120 | 
            -
                  parse_model('the first user').should == ["user", 0]
         | 
| 92 | 
            +
                  @parser.parse_model('the first user').should == ["user", 0]
         | 
| 121 93 | 
             
                end
         | 
| 122 | 
            -
             | 
| 94 | 
            +
              
         | 
| 123 95 | 
             
                it '("the 1st user") should == ["user", 0]' do
         | 
| 124 | 
            -
                  parse_model('the 1st user').should == ["user", 0]
         | 
| 96 | 
            +
                  @parser.parse_model('the 1st user').should == ["user", 0]
         | 
| 125 97 | 
             
                end
         | 
| 126 98 | 
             
              end
         | 
| 127 99 |  | 
| 128 100 | 
             
              describe "#parse_index" do
         | 
| 129 101 | 
             
                it '("1st") should == 0' do
         | 
| 130 | 
            -
                  parse_index("1st").should == 0
         | 
| 102 | 
            +
                  @parser.parse_index("1st").should == 0
         | 
| 131 103 | 
             
                end
         | 
| 132 | 
            -
             | 
| 104 | 
            +
              
         | 
| 133 105 | 
             
                it '("24th") should == 23' do
         | 
| 134 | 
            -
                  parse_index("24th").should == 23
         | 
| 106 | 
            +
                  @parser.parse_index("24th").should == 23
         | 
| 135 107 | 
             
                end
         | 
| 136 108 | 
             
                it '("first") should == 0' do
         | 
| 137 | 
            -
                  parse_index("first").should == 0
         | 
| 109 | 
            +
                  @parser.parse_index("first").should == 0
         | 
| 138 110 | 
             
                end
         | 
| 139 111 |  | 
| 140 112 | 
             
                it '("last") should == -1' do
         | 
| 141 | 
            -
                  parse_index("last").should == -1
         | 
| 113 | 
            +
                  @parser.parse_index("last").should == -1
         | 
| 142 114 | 
             
                end
         | 
| 143 115 | 
             
              end
         | 
| 144 116 |  | 
| 145 117 | 
             
              describe "customised mappings" do
         | 
| 146 | 
            -
                describe ' | 
| 147 | 
            -
                   | 
| 148 | 
            -
                     | 
| 118 | 
            +
                describe "config maps 'I|myself' to 'user: \"me\"'" do
         | 
| 119 | 
            +
                  before do
         | 
| 120 | 
            +
                    @config = Pickle::Config.new do |c|
         | 
| 121 | 
            +
                      c.map 'I', 'myself', :to => 'user: "me"'
         | 
| 122 | 
            +
                    end
         | 
| 123 | 
            +
                    @parser = Pickle::Parser.new(:config => @config)
         | 
| 149 124 | 
             
                  end
         | 
| 150 | 
            -
             | 
| 151 | 
            -
                  it "' | 
| 152 | 
            -
                    ' | 
| 125 | 
            +
             | 
| 126 | 
            +
                  it "'I' should match /\#{match_model}/" do
         | 
| 127 | 
            +
                    'I'.should match(/#{@parser.match_model}/)
         | 
| 153 128 | 
             
                  end
         | 
| 154 | 
            -
             | 
| 155 | 
            -
                  it " | 
| 156 | 
            -
                     | 
| 129 | 
            +
                
         | 
| 130 | 
            +
                  it "'myself' should match /\#{match_model}/" do
         | 
| 131 | 
            +
                    'myself'.should match(/#{@parser.match_model}/)
         | 
| 157 132 | 
             
                  end
         | 
| 158 | 
            -
             | 
| 159 | 
            -
                  it " | 
| 160 | 
            -
                    parse_model('I').should == ["user", "me"]
         | 
| 133 | 
            +
                
         | 
| 134 | 
            +
                  it "parse_model('I') should == ['user', 'me']" do
         | 
| 135 | 
            +
                    @parser.parse_model('I').should == ["user", "me"]
         | 
| 136 | 
            +
                  end
         | 
| 137 | 
            +
             | 
| 138 | 
            +
                  it "parse_model('myself') should == ['user', 'me']" do
         | 
| 139 | 
            +
                    @parser.parse_model('myself').should == ["user", "me"]
         | 
| 161 140 | 
             
                  end
         | 
| 162 141 | 
             
                end
         | 
| 163 142 | 
             
              end
         | 
| @@ -6,21 +6,21 @@ describe Pickle::Session do | |
| 6 6 | 
             
              end
         | 
| 7 7 |  | 
| 8 8 | 
             
              describe "after storing a single user", :shared => true do
         | 
| 9 | 
            -
                it " | 
| 10 | 
            -
                  @session. | 
| 9 | 
            +
                it "created_models('user') should be array containing the original user" do
         | 
| 10 | 
            +
                  @session.created_models('user').should == [@user]
         | 
| 11 11 | 
             
                end
         | 
| 12 12 |  | 
| 13 13 | 
             
                describe "the original user should be retrievable with" do
         | 
| 14 | 
            -
                  it " | 
| 15 | 
            -
                    @session. | 
| 14 | 
            +
                  it "created_model('the user')" do
         | 
| 15 | 
            +
                    @session.created_model('the user').should == @user
         | 
| 16 16 | 
             
                  end
         | 
| 17 17 |  | 
| 18 | 
            -
                  it " | 
| 19 | 
            -
                    @session. | 
| 18 | 
            +
                  it "created_model('1st user')" do
         | 
| 19 | 
            +
                    @session.created_model('1st user').should == @user
         | 
| 20 20 | 
             
                  end
         | 
| 21 21 |  | 
| 22 | 
            -
                  it " | 
| 23 | 
            -
                    @session. | 
| 22 | 
            +
                  it "created_model('last user')" do
         | 
| 23 | 
            +
                    @session.created_model('last user').should == @user
         | 
| 24 24 | 
             
                  end
         | 
| 25 25 | 
             
                end
         | 
| 26 26 |  | 
| @@ -105,12 +105,12 @@ describe Pickle::Session do | |
| 105 105 |  | 
| 106 106 | 
             
                    it_should_behave_like "after storing a single user"
         | 
| 107 107 |  | 
| 108 | 
            -
                    it " | 
| 109 | 
            -
                      @session. | 
| 108 | 
            +
                    it "created_model('the user: \"fred\"') should retrieve the user" do
         | 
| 109 | 
            +
                      @session.created_model('the user: "fred"').should == @user
         | 
| 110 110 | 
             
                    end
         | 
| 111 111 |  | 
| 112 | 
            -
                    it " | 
| 113 | 
            -
                      @session. | 
| 112 | 
            +
                    it "created_model?('the user: \"shirl\"') should be false" do
         | 
| 113 | 
            +
                      @session.created_model?('the user: "shirl"').should == false
         | 
| 114 114 | 
             
                    end
         | 
| 115 115 |  | 
| 116 116 | 
             
                    it "model?('the user: \"shirl\"') should be false" do
         | 
| @@ -172,55 +172,57 @@ describe Pickle::Session do | |
| 172 172 | 
             
                    do_create_users
         | 
| 173 173 | 
             
                  end
         | 
| 174 174 |  | 
| 175 | 
            -
                  it " | 
| 176 | 
            -
                    @session. | 
| 175 | 
            +
                  it "created_models('user') should == [@fred, @shirl, @noname]" do
         | 
| 176 | 
            +
                    @session.created_models('user').should == [@fred, @shirl, @noname]
         | 
| 177 177 | 
             
                  end
         | 
| 178 178 |  | 
| 179 | 
            -
                  it " | 
| 180 | 
            -
                    @session. | 
| 179 | 
            +
                  it "created_models('super_admin') should == [@fred, @noname]" do
         | 
| 180 | 
            +
                    @session.created_models('super_admin').should == [@fred, @noname]
         | 
| 181 181 | 
             
                  end
         | 
| 182 182 |  | 
| 183 | 
            -
                  describe "# | 
| 183 | 
            +
                  describe "#created_model" do
         | 
| 184 184 | 
             
                    it "'that user' should be @noname (the last user created - as super_admins are users)" do
         | 
| 185 | 
            -
                      @session. | 
| 185 | 
            +
                      @session.created_model('that user').should == @noname
         | 
| 186 186 | 
             
                    end
         | 
| 187 187 |  | 
| 188 188 | 
             
                    it "'the super admin' should be @noname (the last super admin created)" do
         | 
| 189 | 
            -
                      @session. | 
| 189 | 
            +
                      @session.created_model('that super admin').should == @noname
         | 
| 190 190 | 
             
                    end
         | 
| 191 191 |  | 
| 192 192 | 
             
                    it "'the 1st super admin' should be @fred" do
         | 
| 193 | 
            -
                      @session. | 
| 193 | 
            +
                      @session.created_model('the 1st super admin').should == @fred
         | 
| 194 194 | 
             
                    end
         | 
| 195 195 |  | 
| 196 196 | 
             
                    it "'the first user' should be @fred" do
         | 
| 197 | 
            -
                      @session. | 
| 197 | 
            +
                      @session.created_model('the first user').should == @fred
         | 
| 198 198 | 
             
                    end
         | 
| 199 199 |  | 
| 200 200 | 
             
                    it "'the 2nd user' should be @shirl" do
         | 
| 201 | 
            -
                      @session. | 
| 201 | 
            +
                      @session.created_model('the 2nd user').should == @shirl
         | 
| 202 202 | 
             
                    end
         | 
| 203 203 |  | 
| 204 204 | 
             
                    it "'the last user' should be @noname" do
         | 
| 205 | 
            -
                      @session. | 
| 205 | 
            +
                      @session.created_model('the last user').should == @noname
         | 
| 206 206 | 
             
                    end
         | 
| 207 207 |  | 
| 208 208 | 
             
                    it "'the user: \"fred\" should be @fred" do
         | 
| 209 | 
            -
                      @session. | 
| 209 | 
            +
                      @session.created_model('the user: "fred"').should == @fred
         | 
| 210 210 | 
             
                    end
         | 
| 211 211 |  | 
| 212 212 | 
             
                    it "'the user: \"shirl\" should be @shirl" do
         | 
| 213 | 
            -
                      @session. | 
| 213 | 
            +
                      @session.created_model('the user: "shirl"').should == @shirl
         | 
| 214 214 | 
             
                    end
         | 
| 215 215 | 
             
                  end
         | 
| 216 216 | 
             
                end
         | 
| 217 217 | 
             
              end
         | 
| 218 218 |  | 
| 219 | 
            -
              describe "when 'the user: \"me\"' exists  | 
| 219 | 
            +
              describe "when 'the user: \"me\"' exists and there is a mapping from 'I', 'myself' => 'user: \"me\"" do
         | 
| 220 220 | 
             
                before do
         | 
| 221 221 | 
             
                  @user = mock_model(User)
         | 
| 222 222 | 
             
                  User.stub!(:find).and_return(@user)
         | 
| 223 223 | 
             
                  Factory.stub!(:create).and_return(@user)
         | 
| 224 | 
            +
                  parser = Pickle::Parser.new(:config => Pickle::Config.new {|c| c.map 'I', 'myself', :to => 'user: "me"'})
         | 
| 225 | 
            +
                  @session = Pickle::Session.new(:parser => parser)
         | 
| 224 226 | 
             
                  @session.create_model('the user: "me"')
         | 
| 225 227 | 
             
                end
         | 
| 226 228 |  | 
| @@ -232,24 +234,24 @@ describe Pickle::Session do | |
| 232 234 | 
             
                  @session.model('myself').should == @user
         | 
| 233 235 | 
             
                end
         | 
| 234 236 |  | 
| 235 | 
            -
                it "#parse_fields 'author: user \"JIM\"' should raise Error, as model deos not refer" do
         | 
| 236 | 
            -
                  lambda { @session.parse_fields('author: user "JIM"') }.should raise_error
         | 
| 237 | 
            +
                it "#parser.parse_fields 'author: user \"JIM\"' should raise Error, as model deos not refer" do
         | 
| 238 | 
            +
                  lambda { @session.send(:parser).parse_fields('author: user "JIM"') }.should raise_error
         | 
| 237 239 | 
             
                end
         | 
| 238 240 |  | 
| 239 | 
            -
                it "#parse_fields 'author: the user' should return {\"author\" => <user>}" do
         | 
| 240 | 
            -
                  @session.parse_fields('author: the user').should == {"author" => @user}
         | 
| 241 | 
            +
                it "#parser.parse_fields 'author: the user' should return {\"author\" => <user>}" do
         | 
| 242 | 
            +
                  @session.send(:parser).parse_fields('author: the user').should == {"author" => @user}
         | 
| 241 243 | 
             
                end
         | 
| 242 244 |  | 
| 243 | 
            -
                it "#parse_fields 'author: myself' should return {\"author\" => <user>}" do
         | 
| 244 | 
            -
                  @session.parse_fields('author: myself').should == {"author" => @user}
         | 
| 245 | 
            +
                it "#parser.parse_fields 'author: myself' should return {\"author\" => <user>}" do
         | 
| 246 | 
            +
                  @session.send(:parser).parse_fields('author: myself').should == {"author" => @user}
         | 
| 245 247 | 
             
                end
         | 
| 246 248 |  | 
| 247 | 
            -
                it "#parse_fields 'author: the user, approver: I, rating: \"5\"' should return {'author' => <user>, 'approver' => <user>, 'rating' => '5'}" do
         | 
| 248 | 
            -
                  @session.parse_fields('author: the user, approver: I, rating: "5"').should == {'author' => @user, 'approver' => @user, 'rating' => '5'}
         | 
| 249 | 
            +
                it "#parser.parse_fields 'author: the user, approver: I, rating: \"5\"' should return {'author' => <user>, 'approver' => <user>, 'rating' => '5'}" do
         | 
| 250 | 
            +
                  @session.send(:parser).parse_fields('author: the user, approver: I, rating: "5"').should == {'author' => @user, 'approver' => @user, 'rating' => '5'}
         | 
| 249 251 | 
             
                end
         | 
| 250 252 |  | 
| 251 | 
            -
                it "#parse_fields 'author: user: \"me\", approver: \"\"' should return {'author' => <user>, 'approver' => \"\"}" do
         | 
| 252 | 
            -
                  @session.parse_fields('author: user: "me", approver: ""').should == {'author' => @user, 'approver' => ""}
         | 
| 253 | 
            +
                it "#parser.parse_fields 'author: user: \"me\", approver: \"\"' should return {'author' => <user>, 'approver' => \"\"}" do
         | 
| 254 | 
            +
                  @session.send(:parser).parse_fields('author: user: "me", approver: ""').should == {'author' => @user, 'approver' => ""}
         | 
| 253 255 | 
             
                end
         | 
| 254 256 | 
             
              end
         | 
| 255 257 |  | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: ianwhite-pickle
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              version: 0.1. | 
| 4 | 
            +
              version: 0.1.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors: 
         | 
| 7 7 | 
             
            - Ian White
         | 
| @@ -9,7 +9,7 @@ autorequire: | |
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 11 |  | 
| 12 | 
            -
            date: 2008-12- | 
| 12 | 
            +
            date: 2008-12-31 00:00:00 -08:00
         | 
| 13 13 | 
             
            default_executable: 
         | 
| 14 14 | 
             
            dependencies: []
         | 
| 15 15 |  | 
| @@ -22,17 +22,26 @@ extensions: [] | |
| 22 22 | 
             
            extra_rdoc_files: []
         | 
| 23 23 |  | 
| 24 24 | 
             
            files: 
         | 
| 25 | 
            +
            - lib/pickle/adapter.rb
         | 
| 26 | 
            +
            - lib/pickle/config.rb
         | 
| 25 27 | 
             
            - lib/pickle/injector.rb
         | 
| 28 | 
            +
            - lib/pickle/parser/matchers.rb
         | 
| 29 | 
            +
            - lib/pickle/parser/with_session.rb
         | 
| 26 30 | 
             
            - lib/pickle/parser.rb
         | 
| 27 31 | 
             
            - lib/pickle/session.rb
         | 
| 28 | 
            -
            - lib/pickle/ | 
| 32 | 
            +
            - lib/pickle/version.rb
         | 
| 29 33 | 
             
            - lib/pickle.rb
         | 
| 34 | 
            +
            - rails_generators/pickle/pickle_generator.rb
         | 
| 35 | 
            +
            - rails_generators/pickle/templates/env.rb
         | 
| 36 | 
            +
            - rails_generators/pickle/templates/pickle_steps.rb
         | 
| 30 37 | 
             
            - License.txt
         | 
| 31 38 | 
             
            - README.textile
         | 
| 32 39 | 
             
            - Todo.txt
         | 
| 33 40 | 
             
            - History.txt
         | 
| 41 | 
            +
            - spec/lib/pickle_adapter_spec.rb
         | 
| 34 42 | 
             
            - spec/lib/pickle_config_spec.rb
         | 
| 35 43 | 
             
            - spec/lib/pickle_injector_spec.rb
         | 
| 44 | 
            +
            - spec/lib/pickle_parser_matchers_spec.rb
         | 
| 36 45 | 
             
            - spec/lib/pickle_parser_spec.rb
         | 
| 37 46 | 
             
            - spec/lib/pickle_session_spec.rb
         | 
| 38 47 | 
             
            has_rdoc: true
         | 
| @@ -64,7 +73,9 @@ signing_key: | |
| 64 73 | 
             
            specification_version: 2
         | 
| 65 74 | 
             
            summary: Easy model creation and reference in your cucumber features
         | 
| 66 75 | 
             
            test_files: 
         | 
| 76 | 
            +
            - spec/lib/pickle_adapter_spec.rb
         | 
| 67 77 | 
             
            - spec/lib/pickle_config_spec.rb
         | 
| 68 78 | 
             
            - spec/lib/pickle_injector_spec.rb
         | 
| 79 | 
            +
            - spec/lib/pickle_parser_matchers_spec.rb
         | 
| 69 80 | 
             
            - spec/lib/pickle_parser_spec.rb
         | 
| 70 81 | 
             
            - spec/lib/pickle_session_spec.rb
         |