Improve features / tests code #1493

Merged
merged 4 commits into from Oct 24, 2013

Projects

None yet

4 participants

@maul-esel
Contributor

Improves the cucumber step definitions by reducing code duplication and using assert_match for better error messages.

@parkr parkr and 2 others commented on an outdated diff Sep 4, 2013
features/step_definitions/jekyll_steps.rb
@@ -142,11 +142,11 @@
end
Then /^I should see "(.*)" in "(.*)"$/ do |text, file|
- assert Regexp.new(text).match(File.open(file).readlines.join)
+ assert Regexp.new(text).match(File.read(file))
@parkr
parkr Sep 4, 2013 Member

This makes testing on systems that use \r\n inconsistent :/

@mattr-
mattr- Sep 4, 2013 Member

hmm. wasn't aware of that.

On Wed, Sep 4, 2013 at 9:45 AM, Parker Moore notifications@github.comwrote:

In features/step_definitions/jekyll_steps.rb:

@@ -142,11 +142,11 @@
end

Then /^I should see "(.)" in "(.)"$/ do |text, file|

  • assert Regexp.new(text).match(File.open(file).readlines.join)
  • assert Regexp.new(text).match(File.read(file))

This makes testing on systems that use \r\n inconsistent :/


Reply to this email directly or view it on GitHubhttps://github.com/mojombo/jekyll/pull/1493/files#r6155478
.

@parkr
parkr Sep 4, 2013 Member

The structure is different, anyhow. If we don't care then I guess we don't care.

@maul-esel
maul-esel Sep 5, 2013 Contributor

I didn't know that. Maybe I could just introduce a new function in features/support/env.rb that encapsulates this construct?

@mattr-
mattr- Sep 5, 2013 Member

I'm almost never going to turn down having a new function for something, so
I'm cool if you want to go ahead and do that. 😃

@parkr
parkr Sep 7, 2013 Member

Once we have the new method for this, I'm 👍.

@maul-esel maul-esel Revert to #readlines#join, but enclose it in a function
This is necessary to preserve the handling
of \r\n and \n line endings.
89f0d69
@maul-esel
Contributor

@parkr, @mattr-: now using a read_file function.

@parkr parkr and 1 other commented on an outdated diff Sep 9, 2013
features/support/env.rb
@@ -35,5 +35,11 @@ def location(folder, direction)
[before || '.', after || '.']
end
+def read_file(path)
@parkr
parkr Sep 9, 2013 Member

maybe file_contents?

@maul-esel
maul-esel Sep 10, 2013 Contributor

Done 😀

@maul-esel
Contributor

I'd consider this ready-to-merge. Anything holding it back?

@troyswanson
Member

Nicely done!

@parkr
Member
parkr commented Oct 7, 2013

👍 from me! @mattr-?

@mattr- mattr- merged commit fb6f8c1 into jekyll:master Oct 24, 2013

1 check passed

default The Travis CI build passed
Details
@mattr- mattr- added a commit that referenced this pull request Oct 24, 2013
@mattr- mattr- Update history to reflect merge of #1493 2397a16
@maul-esel maul-esel deleted the maul-esel:feature-improvements branch Oct 24, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment