spec/indentation_spec.rb in tailor-0.1.3 vs spec/indentation_spec.rb in tailor-0.1.4
- old
+ new
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/spec_helper.rb'
+require_relative 'spec_helper'
require 'tailor/file_line'
require 'pathname'
include Tailor
@@ -23,11 +23,11 @@
end
end
describe Tailor::Indentation do
include Tailor::Indentation
-
+
context "should return the number of leading spaces in a line" do
it "when the line is not indented" do
line = create_file_line "def do_something", __LINE__
line.indented_spaces.should == 0
end
@@ -43,11 +43,11 @@
end
end
context "should know what level of indentation a line is at" do
context "for indent expressions" do
- INDENT_EXPRESSIONS.each do |regexp|
+ Tailor::Indentation::INDENT_EXPRESSIONS.each do |regexp|
expression = strip_regex(regexp)
it "when the '#{expression }' line is not indented" do
line = create_file_line "#{expression}", __LINE__
line.is_at_level.should == 0.0
@@ -64,11 +64,11 @@
end
end
end
context "for outdent expressions" do
- OUTDENT_EXPRESSIONS.each do |regexp|
+ Tailor::Indentation::OUTDENT_EXPRESSIONS.each do |regexp|
expression = strip_regex(regexp)
it "when the '#{expression }' line is not indented" do
line = create_file_line "#{expression}", __LINE__
line.is_at_level.should == 0.0
@@ -85,11 +85,11 @@
end
end
end
context "for end expressions" do
- END_EXPRESSIONS.each do |regexp|
+ Tailor::Indentation::END_EXPRESSIONS.each do |regexp|
expression = strip_regex(regexp)
it "when the '#{expression }' line is not indented" do
line = create_file_line "#{expression}", __LINE__
line.is_at_level.should == 0.0
@@ -107,42 +107,42 @@
end
end
end
context "#indent?" do
- INDENT_EXPRESSIONS.each do |regexp|
+ Tailor::Indentation::INDENT_EXPRESSIONS.each do |regexp|
expression = strip_regex(regexp)
it "should return true if the line contains #{expression}" do
line = create_file_line "#{expression}", __LINE__
line.indent?.should be_true
end
end
end
context "#outdent?" do
- OUTDENT_EXPRESSIONS.each do |regexp|
+ Tailor::Indentation::OUTDENT_EXPRESSIONS.each do |regexp|
expression = strip_regex(regexp)
it "should return true if the line contains #{expression}" do
line = create_file_line "#{expression}", __LINE__
line.outdent?.should be_true
end
end
end
context "#contains_end?" do
- END_EXPRESSIONS.each do |regexp|
+ Tailor::Indentation::END_EXPRESSIONS.each do |regexp|
expression = strip_regex(regexp)
it "should return true if the line contains #{expression}" do
line = create_file_line "#{expression}", __LINE__
line.contains_end?.should be_true
end
end
end
-
+
context "#at_improper_level?" do
it "should return true if the line is at the wrong level" do
proper_level = 1.0
line = create_file_line "class SomeClass", __LINE__
line.at_improper_level?(proper_level).should be_true
@@ -254,6 +254,6 @@
it "should return false if it has a ( and a )" do
line = create_file_line " def some_method(thing)", __LINE__
line.unclosed_parenthesis?.should be_false
end
end
-end
\ No newline at end of file
+end