pagemodels 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,4 +4,6 @@
4
4
  require File.expand_path('../config/application', __FILE__)
5
5
  require 'rake'
6
6
 
7
- RailsAndCucumber::Application.load_tasks
7
+ task :default => [:cucumber]
8
+
9
+ RailsAndCucumber::Application.load_tasks
@@ -9,5 +9,7 @@ module PageModels
9
9
  args = args.scan(/"([^"]+)"/).map(&:first)
10
10
  page_model_class_name = page.gsub(/(?:^|[^\w])([a-z])/) { $1.upcase }
11
11
  Kernel.const_get(page_model_class_name).new(*args)
12
+ rescue NameError
13
+ raise MissingPageModelError.new(page_model_class_name)
12
14
  end
13
15
  end
@@ -7,4 +7,10 @@ module PageModels
7
7
  super("#{page_model.class} must implement ##{method}.")
8
8
  end
9
9
  end
10
+
11
+ class MissingPageModelError < StandardError
12
+ def initialize(klass)
13
+ super("The page model class for #{klass} has not yet been written. You will need to create 'class #{klass} < PageModels:: Base'")
14
+ end
15
+ end
10
16
  end
@@ -1,3 +1,3 @@
1
1
  module PageModels
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -0,0 +1,26 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "../../spec_helper")
2
+
3
+ class MyTestPage < PageModels::Base
4
+ attr_accessor :args
5
+ def initialize(*args)
6
+ @args = args
7
+ end
8
+ end
9
+
10
+ describe PageModels do
11
+ describe "creating instances from cucumber (or similar) text" do
12
+ it "should create an instance with no args" do
13
+ page_model = PageModels.create("my test page", "")
14
+ page_model.args.should == []
15
+ end
16
+
17
+ it "should create an instance with 1..n args" do
18
+ page_model = PageModels.create("my test page", 'with "some" additional "arguments" denoted by "quotes"')
19
+ page_model.args.should == ["some", "arguments", "quotes"]
20
+ end
21
+
22
+ it "should raise a helpful error when the class does not exist" do
23
+ lambda { page_model = PageModels.create("not real page", "") }.should raise_error(PageModels::MissingPageModelError)
24
+ end
25
+ end
26
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: pagemodels
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.1.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Rick Grundy
@@ -83,6 +83,7 @@ files:
83
83
  - pagemodels.gemspec
84
84
  - spec/page_models/base_spec.rb
85
85
  - spec/page_models/configuration_spec.rb
86
+ - spec/page_models/core_spec.rb
86
87
  - spec/spec_helper.rb
87
88
  has_rdoc: true
88
89
  homepage: http://www.github.com/rickgrundy/pagemodels
@@ -115,4 +116,5 @@ summary: Page models for your browser driving acceptance tests with optional int
115
116
  test_files:
116
117
  - spec/page_models/base_spec.rb
117
118
  - spec/page_models/configuration_spec.rb
119
+ - spec/page_models/core_spec.rb
118
120
  - spec/spec_helper.rb